How to get the largest positive root of a polynomial
Subject: How to get the largest positive root of a polynomial
From: Glenn Ramsey
Date: Sat, 19 Nov 2005 15:12:50 +1300
Hi,
If I have found the roots of a polynomial using allroots() are the roots
given in any particular order?
If not how can I sort the list to get the largest positive root?
Here's what I want to do:
I have a cubic which has been fitted to some experimental material test
data, but the fit is poor at low values of x so I'm trying to define a
piecewise function which is linear for low values and cubic otherwise.
I've chosen to make the linear part tangent to the cubic.
The fitted cubic is:
(%i1) f(x):=4970*x^3 + 6320*x^2 - 425*x + 26;
3 2
(%o1) f(x) := 4970 x + 6320 x + (- 425) x + 26
I can find the tangent of a line through 0,0 andthe cubic:
(%i2) a:allroots(f(x)-diff(f(x),x)*x);
(%o2) [x = .06125686127110409, x = - .06786377328650396,
x = -
.6292079773206162]
Now I can define the piecewise function, but this assumes that the roots
list is sorted in descending order.
(%i3) g(x):=block(u:rhs(a[1]), if(x 07 8627077
http://www.componic.co.nz