 RootOf - Maple Help

verify/RootOf

verify equality of expressions involving RootOf Calling Sequence verify(expr1, expr2, RootOf) verify(expr1, expr2, 'RootOf'(ver)) Parameters

 expr1 - anything expr2 - anything ver - verification after normalizing RootOf subexpressions Description

 • The verify(expr1, expr2, RootOf) calling sequence performs the following steps. It finds all subexpressions of expr1 and expr2 that are of the form RootOf(...), and replaces each such subexpression ro by the result of calling convert(ro, RootOf, form = index). It then compares the expressions resulting from doing this conversion on expr1 and expr2, and returns true if these results are the same, and false if they are different.
 • If ver is specified, then that verification is used to compare the resulting expressions, rather than simple equality testing.
 • This verification is symmetric if ver is not specified, or if ver is specified and it is symmetric.
 • Since RootOf is a Maple function, it must be enclosed in single quotes to prevent evaluation. Examples

Suppose you want to compare two expressions involving RootOf calls that are specified with intervals. They do not compare as equal if the intervals are not specified in the same way--even if they refer to the same root. Consider the example below: this polynomial has three roots, all real and between -2 and 2.

 > $\mathrm{plot}\left({x}^{3}-3x+1,x=-2..2\right)$ The root between 0 and 1 is the same as the root between 0.34 and 0.35. However, plain equality testing does not see that.

 > $\mathrm{verify}\left(2+\mathrm{RootOf}\left({\mathrm{_Z}}^{3}-3\mathrm{_Z}+1,0..1\right),2+\mathrm{RootOf}\left({\mathrm{_Z}}^{3}-3\mathrm{_Z}+1,0.34..0.35\right)\right)$
 ${\mathrm{false}}$ (1)

The RootOf verification solves this problem.

 > $\mathrm{verify}\left(2+\mathrm{RootOf}\left({\mathrm{_Z}}^{3}-3\mathrm{_Z}+1,0..1\right),2+\mathrm{RootOf}\left({\mathrm{_Z}}^{3}-3\mathrm{_Z}+1,0.34..0.35\right),\mathrm{RootOf}\right)$
 ${\mathrm{true}}$ (2)

We can still distinguish the two positive roots.

 > $\mathrm{verify}\left(2+\mathrm{RootOf}\left({\mathrm{_Z}}^{3}-3\mathrm{_Z}+1,0..1\right),2+\mathrm{RootOf}\left({\mathrm{_Z}}^{3}-3\mathrm{_Z}+1,1..2\right),\mathrm{RootOf}\right)$
 ${\mathrm{false}}$ (3)

If you want to test a different verification than simple equality after normalizing the RootOf subexpressions, you can use the second calling sequence. For example, suppose we want to see whether a given expression is equivalent to either of the following RootOf calls. We can do that by using the second calling sequence and specifying member verification for ver.

 > $\mathrm{accepted_answers}≔\left\{\mathrm{RootOf}\left({\mathrm{_Z}}^{3}-3\mathrm{_Z}+1,0..1\right),\mathrm{RootOf}\left({\mathrm{_Z}}^{3}+\mathrm{_Z}-3,1..2\right)\right\}$
 ${\mathrm{accepted_answers}}{≔}\left\{{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{-}{3}{}{\mathrm{_Z}}{+}{1}{,}{0}{..}{1}\right){,}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{+}{\mathrm{_Z}}{-}{3}{,}{1}{..}{2}\right)\right\}$ (4)
 > $\mathrm{to_test}≔\mathrm{RootOf}\left({\mathrm{_Z}}^{3}-3\mathrm{_Z}+1,0.3\right)$
 ${\mathrm{to_test}}{≔}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{3}}{-}{3}{}{\mathrm{_Z}}{+}{1}{,}{0.3}\right)$ (5)
 > $\mathrm{verify}\left(\mathrm{to_test},\mathrm{accepted_answers},'\mathrm{RootOf}'\left('\mathrm{member}'\right)\right)$
 ${\mathrm{true}}$ (6)

Coincidentally, we can specify an equivalent verification by specifying RootOf verification as the parameter to member verification, instead of the other way around. This calling sequence is explained on the verify/member help page.

 > $\mathrm{verify}\left(\mathrm{to_test},\mathrm{accepted_answers},'\mathrm{member}'\left('\mathrm{RootOf}'\right)\right)$
 ${\mathrm{true}}$ (7)