comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » solve cubic polynomial for dummies?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: solve cubic polynomial for dummies? [message #88425 is a reply to message #88423] Wed, 23 April 2014 16:39 Go to previous messageGo to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
You could use the exact formula for a cubic ( e.g. http://idlastro.gsfc.nasa.gov/ftp/contrib/freudenreich/cuber oot.pro ) but it is probably easier to use the general root finder FZ_ROOTS in a little program like cube solve.pro below

coeff = [-1.94410 , 2.87770 , -2.02300 , 1.00000 ]
Y = [0.556076778, 0.459954297, 0.404784134, 0.540789788, 0.7493244, 0.814803237, 1, 0.296016879, 0.434675619, 0.612691897]

pro cubesolve,coeff,y
foreach val,y do begin
c = coeff
c[0] = coeff[0]-val
roots = fz_roots(c,/double)
print,roots
endforeach
return
end

There are 3 roots to a cubic but likely you are only interested in the real root.

On Wednesday, April 23, 2014 5:26:50 PM UTC-4, mg...@students.waikato.ac.nz wrote:
> Hi all
>
>
>
> I have a cubic polynomial:
>
>
>
> '-1.9441*x^3+2.8777*x^2-2.2023*x+1'
>
>
>
> and a series of y values:
>
>
>
> Y = [0.556076778, 0.459954297, 0.404784134, 0.540789788, 0.7493244, 0.814803237, 1, 0.296016879, 0.434675619, 0.612691897]
>
>
>
> How would I solve this for x in each case?
>
>
>
> Cheers,
>
>
>
> Mat
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Upload a file on a website
Next Topic: H5D_Read on compound type (GDL)

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 14:13:39 PDT 2025

Total time taken to generate the page: 0.00733 seconds