roots of polynomial on a 2d grid [message #5408] |
Fri, 22 December 1995 00:00 |
brooker
Messages: 12 Registered: March 1994
|
Junior Member |
|
|
folks,
I have a polynomial function of the form
f(u) = c_o + c_1*u + c_2*u^2 + c_3*u^3
and I want to find all the roots of the polynomial. By the roots of the
polynomial I mean the values of u such that f(u)=0. To do this one usually
makes an array coefs=[c_o,c_1,c_2,c_3] and the call
roots=nr_zroots(coefs)
All the roots are then stored in the array roots.
This is all fine but ...
Suppose that instead of just one set of coefficients you have an array of sets
of coefficients. For example consider
c_o=[0,1,3,4]
c_1=[2,2,2,2]
c_2=[4,3,2,1]
c_3=[3,3,4,4]
In order to find the roots must you use a FOR loop like
roots=fltarr(3,4)
for i=0,3 do begin
coefs=[c_o(i),c_1(i),c_2(i),c_3(i)]
roots(*,i)=nr_zroots(coefs)
endfor
Is there any way to find the roots without having to use the for loop??
sorry for the long winded question,
peter brooker
|
|
|