Advice: Real values for a RootOf

Maple often returns solutions to various types of equations in terms of RootOf a polynomial. The allvalues function can be used to replace the RootOf with the roots of the polynomial. By default this will use symbolic solutions if that is possible (e.g. if the polynomial is of degree 4 or less). In many cases that may be inconvenient because the symbolic solutions are very complicated. In previous releases, numerical values were used when symbolic solutions were not available, but in Maple 6 these are replaced by indexed roots. You can use evalf to evaluate these. Note that this includes complex solutions. An alternative, which always returns floating-point results for real solutions, is to use fsolve as follows.

Examples:

> solve({ y^2+2*y+x=0, y = x^2 - 1 });

{y = RootOf(-_Z+_Z^4+4*_Z^3+4*_Z^2-1,label = _L1), ...
{y = RootOf(-_Z+_Z^4+4*_Z^3+4*_Z^2-1,label = _L1), ...
{y = RootOf(-_Z+_Z^4+4*_Z^3+4*_Z^2-1,label = _L1), ...

Save this in a variable:

> q:= %:

Isolate the RootOf :

> ro:= op(indets(q,RootOf));

ro := RootOf(-_Z+_Z^4+4*_Z^3+4*_Z^2-1,label = _L1)

Find a list of the real roots:

> rts:= [ fsolve(op(1,ro)) ];

rts := [-.4751114013, .4902161201]

Substitute into the solutions:

> map(t -> subs(ro=t,q), rts);

[{y = -.4751114013, x = .7244919591}, {y = .4902161...

You could obtain complex solutions in the same way, using fsolve with the complex option:

> rts:= [ fsolve(op(1,ro), _Z, complex) ];

rts := [-2.007552359-.5131157956*I, -2.007552359+.5...
rts := [-2.007552359-.5131157956*I, -2.007552359+.5...

> map(t -> subs(ro=t,q), rts);

[{y = -2.007552359-.5131157956*I, x = .2481260636-1...
[{y = -2.007552359-.5131157956*I, x = .2481260636-1...
[{y = -2.007552359-.5131157956*I, x = .2481260636-1...

Here is the same calculation, done using allvalues . The implicit option prevents the use of the very complicated explicit solution of the quartic polynomial.

> allvalues(q,implicit);

{y = RootOf(-_Z+_Z^4+4*_Z^3+4*_Z^2-1,index = 1), x ...
{y = RootOf(-_Z+_Z^4+4*_Z^3+4*_Z^2-1,index = 1), x ...
{y = RootOf(-_Z+_Z^4+4*_Z^3+4*_Z^2-1,index = 1), x ...
{y = RootOf(-_Z+_Z^4+4*_Z^3+4*_Z^2-1,index = 1), x ...
{y = RootOf(-_Z+_Z^4+4*_Z^3+4*_Z^2-1,index = 1), x ...
{y = RootOf(-_Z+_Z^4+4*_Z^3+4*_Z^2-1,index = 1), x ...
{y = RootOf(-_Z+_Z^4+4*_Z^3+4*_Z^2-1,index = 1), x ...
{y = RootOf(-_Z+_Z^4+4*_Z^3+4*_Z^2-1,index = 1), x ...
{y = RootOf(-_Z+_Z^4+4*_Z^3+4*_Z^2-1,index = 1), x ...
{y = RootOf(-_Z+_Z^4+4*_Z^3+4*_Z^2-1,index = 1), x ...
{y = RootOf(-_Z+_Z^4+4*_Z^3+4*_Z^2-1,index = 1), x ...
{y = RootOf(-_Z+_Z^4+4*_Z^3+4*_Z^2-1,index = 1), x ...

> evalf([%]);

[[{y = .4902161201, x = -1.220744085}, {y = -2.0075...
[[{y = .4902161201, x = -1.220744085}, {y = -2.0075...
[[{y = .4902161201, x = -1.220744085}, {y = -2.0075...
[[{y = .4902161201, x = -1.220744085}, {y = -2.0075...

See also: fsolve , RootOf , allvalues , allsolve

Maple Advisor Database R. Israel, 1997