Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Polynomial equation algorithm

by Anonymous Monk
on Nov 07, 2003 at 07:33 UTC ( [id://305243]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Polynomial equation algorithm
by Corion (Patriarch) on Nov 07, 2003 at 08:26 UTC

    This question sounds much like homework to me, thus I will only give you hints at what to look for:

    1. Define what polynomial division is.
    2. Every Polynom can be written in two standard forms (at least if you also allow imaginary numbers, which won't be necessary for our case). Identify those two forms.
    3. Are those two forms of a given polynomial unique? Why? Why not?
    4. You are looking for a f(X) which satisfies f(Xi) = Yi for all i between 1 and the length of your data column.
    5. Start with the easy cases of i=0, i=1 and i=2.
    6. Can you extend a solution for i=1 to i=2?
    7. Can you extend a solution for i=n to i=n+1?
    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
Re: Polynomial equation algorithm
by castaway (Parson) on Nov 07, 2003 at 08:16 UTC
    Heres a vague answer to your vague question:

    Polynomial

    ("Searching CPAN" is usually a good algorithm)

    C.

      The question is not vague. The man has a set of n (x,y) coordinates that he wants to plot a polynomial of the nth order through.

      Let's say our polynomial looks like this:
      y = a0 + a1 x + a2 x2 + a3 x3 + ... + an xn

      If we fill in the (x,y) pairs in this equation, we get n equations and since we have n unknowns (a0 .. an) we can solve the equations. This is usually done in matrix form.
Re: Polynomial equation algorithm
by PERLscienceman (Curate) on Nov 07, 2003 at 11:29 UTC
Re: Polynomial equation algorithm
by RandomWalk (Beadle) on Nov 07, 2003 at 14:27 UTC
    You want Y=f(X) where f is polynomial, right? Lagrange interpolation will give you algebraic equality, but watch out for numerical problems if you want to use f. Your interpolant will have one less degree than the length of your list. If you are happy with approximate equality using a lower degree, you need a regression routine. If you look at PDL::Fit::Polynomial, you can do it either way (because the degree of the approximating polynomial is input by the user). PDL also provides a gateway to standard numerical routines written in C.
      If it's non-linear, it would also be worth considering PDL::Opt::NonLinear, though that's for optimisation, not fitting.
OT: Snark
by BorgCopyeditor (Friar) on Nov 12, 2003 at 21:42 UTC
    do { my $homework; } while ( $i->sleep() );
    
    :-)

    BCE
    --Your punctuation skills are insufficient!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://305243]
Approved by castaway
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-24 06:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found