ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm working on pythogoras, a personal music research project. I'm working on adding sampling synthesis. At the moment I need to solve two problems and would like to know the simplest way to work around them on python. I know I could sit down to solve them by hand but perhaps there are already standard libraries that can take care of both things:
- Given 4 pairs (x, y) that define a function (think of 3rd degree function), what is the root (x where y = 0)? There will one and only one root in my case.
- Given 4 pairs (x, y) (again, 3rd degree function), what is the value of y for a given x?
So it all revolves around 3rd degree functions. What libraries are available out there for this?
You have the problem, so now you need a model to solve the problem before you can get into the code. You should formalize the steps of the process first, e.g.
Fit a 3rd-degree polynomial to 4 points. You should be able to do this with least-squares, which can be done with matrices. You need to find a in Xa=y, where X is a matrix of each x value raised to the powers 0-3 (one row per x) and y is a vector of the corresponding y values. There are various levels of sophistication for solving this. (Note that there should be an exact solution for this.)
Given a 3rd-degree polynomial, find its real roots. There is a closed-form solution for this.
The next step would be to decide if you want to hand-code something or if you want to try to offload some of the math onto a package or library.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.