LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-25-2013, 07:56 PM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Blog Entries: 1

Rep: Reputation: 90
python - two math requirements


Hi!

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?

Thanks in advance.
 
Old 05-25-2013, 08:20 PM   #2
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Have you considered using a language designed for audio signal processing (e.g., faust, etc.), or functional evaluation (e.g., pure, etc.)?

For your specific question, look here for a generic solution.
 
Old 05-26-2013, 10:34 AM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
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.
  1. 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.)
  2. 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.

Kevin Barry

Last edited by ta0kira; 05-27-2013 at 09:00 AM.
 
Old 05-26-2013, 10:49 PM   #4
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.1
Posts: 722
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
To work with matrixes in python you will need something like NumPy
 
  


Reply

Tags
algebra, curves, functions, math, python



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Symbolic Math with Python LXer Syndicated Linux News 0 12-20-2012 03:31 AM
C (math.h)not doing right math? exp() issue. knockout_artist Programming 7 11-25-2011 02:13 PM
[SOLVED] python math calculation gary_in_springhill Programming 10 02-25-2010 11:42 PM
math program that I can enter math functions ... Four General 5 04-19-2006 08:02 PM
graph problems - python is the language but math is the question cs-cam Programming 3 09-03-2005 10:33 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration