# Untitled Document

The packages `topoly` and `to_poly_solve` are experimental; the specifications of the functions in these packages might change or the some of the functions in these packages might be merged into other Maxima functions.

Barton Willis (Professor of Mathematics, University of Nebraska at Kearney) wrote the `topoly` and `to_poly_solve` packages and the English language user documentation for these packages.

Operator: %and

  The operator `%and` is a simplifying nonshort-circuited logical conjunction. Maxima simplifies an `%and` expression to either true, false, or a logically equivalent, but simplified, expression. The operator `%and` is associative, commutative, and idempotent. Thus when `%and` returns a noun form, the arguments of `%and` form a non-redundant sorted list; for example

       (%i1) a %and (a %and b);
       (%o1) a %and b

  If one argument to a conjunction is the explicit the negation of another argument, `%and` returns false:

       (%i2) a %and (not a);
       (%o2) false

  If any member of the conjunction is false, the conjunction simplifies to false even if other members are manifestly non-boolean; for example

       (%i1) 42 %and false;
       (%o1) false

  Any argument of an `%and` expression that is an inequation (that is, an inequality or equation), is simplified using the Fourier elimination package. The Fourier elimination simplifier has a pre-processor that converts some, but not all, nonlinear inequations into linear inequations; for example the Fourier elimination code simplifies `abs(x) + 1 > 0` to true, so

       (%i1) (x < 1) %and (abs(x) + 1 > 0);
       (%o1) x<1

  Notes

  - The option variable `prederror` does not alter the simplification `%and` expressions.
  - To avoid operator precedence errors, compound expressions involving the operators `%and, %or`, and `not` should be fully parenthesized.
  - The Maxima operators and and or are both short-circuited. Thus and isn't associative or commutative.

  Limitations The conjunction `%and` simplifies inequations locally, not globally. This means that conjunctions such as

       (%i1) (x < 1) %and (x > 1);
       (%o1) (x > 1) %and (x < 1)

  do not simplify to false. Also, the Fourier elimination code ignores the fact database;

       (%i1) assume(x > 5);
       (%o1) [x>5]
       (%i2) (x > 1) %and (x > 2);
       (%o2) (x > 1) %and (x > 2)

  Finally, nonlinear inequations that aren't easily converted into an equivalent linear inequation aren't simplified.

  There is no support for distributing %and over %or; neither is there support for distributing a logical negation over %and.

  To use ``load(to_poly_solver)'`

  Related functions %or, %if, and, or, not

  Status The operator `%and` is experimental; the specifications of this function might change and its functionality might be merged into other Maxima functions.

Operator: %if ( bool, a, b)

  The operator `%if` is a simplifying conditional. The conditional bool should be boolean-valued. When the conditional is true, return the second argument; when the conditional is false, return the third; in all other cases, return a noun form.

  Maxima inequations (either an inequality or an equality) are not boolean-valued; for example, Maxima does not simplify 5 < 6 to true, and it does not simplify 5 = 6 to false; however, in the context of a conditional to an %if statement, Maxima automatically attempts to determine the truth value of an inequation. Examples:

       (%i1) f : %if(x # 1, 2, 8);
       (%o1) %if(x-1#0,2,8)

       (%i2) [subst(x = -1,f), subst(x=1,f)];
       (%o2) [2,8]

  If the conditional involves an inequation, Maxima simplifies it using the Fourier elimination package.

  Notes

  - If the conditional is manifestly non-boolean, Maxima returns a noun form:

         (%i1) %if(42,1,2);
         (%o1) %if(42,1,2)

  - The Maxima operator `if` is nary, the operator `%if` isn't nary.

  Limitations The Fourier elimination code only simplifies nonlinear inequations that are readily convertible to an equivalent linear inequation.

  To use: ``load(to_poly_solver)'`

  Status: The operator `%if` is experimental; its specifications might change and its functionality might be merged into other Maxima functions.

Operator: %or

  The operator `%or` is a simplifying nonshort-circuited logical disjunction. Maxima simplifies an `%or` expression to either true, false, or a logically equivalent, but simplified, expression. The operator `%or` is associative, commutative, and idempotent. Thus when `%or` returns a noun form, the arguments of `%or` form a non-redundant sorted list; for example

       (%i1) a %or (a %or b);
       (%o1) a %or b

  If one member of the disjunction is the explicit the negation of another member, `%or` returns true:

       (%i2) a %or (not a);
       (%o2) true

  If any member of the disjunction is true, the disjunction simplifies to true even if other members of the disjunction are manifestly non-boolean; for example

       (%i1) 42 %or true;
       (%o1) true

  Any argument of an `%or` expression that is an inequation (that is, an inequality or equation), is simplified using the Fourier elimination package. The Fourier elimination code simplifies `abs(x) + 1 > 0` to true, so we have

       (%i3) (x < 1) %or (abs(x) + 1 > 0);
       (%o3) true

  Notes

  - The option variable `prederror` does not alter the simplification of `%or` expressions.
  - You should parenthesize compound expressions involving the operators `%and, %or`, and `not`; the binding powers of these operators might not match your expectations.
  - The Maxima operators and and or are both short-circuited. Thus or isn't associative or commutative.

  Limitations The conjunction `%or` simplifies inequations locally, not globally. This means that conjunctions such as

       (%i1) (x < 1) %or (x >= 1);
       (%o1) (x > 1) %or (x >= 1)

  do not simplify to true. Further, the Fourier elimination code ignores the fact database;

       (%i1) assume(x > 5);
       (%o1) [x>5]
       (%i2) (x > 1) %and (x > 2);
       (%o2) (x > 1) %and (x > 2)

  Finally, nonlinear inequations that aren't easily converted into an equivalent linear inequation aren't simplified.

  The algorithm that looks for terms that cannot both be false is weak; also there is no support for distributing %or over %and; neither is there support for distributing a logical negation over %or.

  To use ``load(to_poly_solver)'`

  Related functions %or, %if, and, or, not

  Status The operator `%or` is experimental; the specifications of this function might change and its functionality might be merged into other Maxima functions.

Function: complex_number_p (x)

  The predicate `complex_number_p` returns true if its argument is either a + %i * b, a, %i b, or %i, where `a` and `b` are either rational or floating point numbers (including big floating point); for all other inputs, `complex_number_p` returns false; for example

       (%i2) map('complex_number_p,[2/3, 2 + 1.5 * %i, %i]);
       (%o2) [true,true,true]

       (%i3) complex_number_p((2+%i)/(5-%i));
       (%o3) false

       (%i4) complex_number_p(cos(5 - 2 * %i));
       (%o4) false

  Related functions `isreal_p`

  To use ``load(to_poly_solver)'`

  Status The operator `complex_number_p` is experimental; its specifications might change and its functionality might be merged into other Maxima functions.

Function: compose_functions (l)

  The function call `compose_functions(l)` returns a lambda form that is the composition of the functions in the list l. The functions are applied from right to left; for example

       (%i1) compose_functions([cos, exp]);
       (%o1) lambda([%g0],cos(%e^%g0))

       (%i2) %(x);
       (%o2) cos(%e^x)

  When the function list is empty, return the identity function:

       (%i3) compose_functions([]);
       (%o3) lambda([%g1],%g1)

       (%i4) %(x);
       (%o4) x

  Notes

  - When Maxima determines that a list member isn't a symbol or a lambda form, `funmake` (not `compose_functions`) signals an error:

         (%i5) compose_functions([a < b]);
         Bad first argument to `funmake': a<b

  - To avoid name conflicts, the independent variable is determined by the function `new_variable`.

         (%i1) compose_functions([%g0]);
         (%o1) lambda([%g4],%g0(%g4))

         (%i2) compose_functions([%g0]);
         (%o2) lambda([%g5],%g0(%g5))

    Although the independent variables are different, Maxima is able to to deduce that these lambda forms are semantically equal:

         (%i3) is(equal(%o1,%o2));
         (%o3) true

  To use ``load(to_poly_solver)'`

  Status The function `compose_functions` is experimental; its specifications might change and its functionality might be merged into other Maxima functions.

Function: dfloat (x)

  The function `dfloat` is a similar to `float`, but the function `dfloat` applies `rectform` when `float` fails to evaluate to an IEEE double floating point number; thus

       (%i1) float(4.5^(1 + %i));
       (%o1) 4.5^(%i+1)

       (%i2) dfloat(4.5^(1 + %i));
       (%o2) 4.48998802962884*%i+0.30001248938957

  Notes

  - The rectangular form of an expression might be poorly suited for numerical evaluation--for example, the rectangular form might needlessly involve the difference of floating point numbers (subtractive cancellation).
  - The identifier `float` is both an option variable (default value false) and a function name.

  Related functions `float, bfloat`

  To use ``load(to_poly_solver)'`

  Status The function `dfloat` is experimental; its specifications might change and its functionality might be merged into other Maxima functions.

Function: elim (l, x)

  The function `elim` eliminates the variables in the set or list `x` from the equations in the set or list `l`. Each member of `x` must be a symbol; the members of `l` can either be equations, or expressions that are assumed to equal zero.

  The function `elim` returns a list of two lists; the first is the list of expressions with the variables eliminated; the second is the list of pivots; thus, the second list is a list of expressions that `elim` used to eliminate the variables.

  Here is a example of eliminating between linear equations:

       (%i1) elim(set(x + y + z = 1, x - y  - z = 8, x - z = 1),set(x,y));
       (%o1) [[2*z-7],[y+7,z-x+1]]

  Eliminating `x` and `y` yields the single equation `2 z - 7 = 0`; the equations `y + 7 = 0` and `z - z + 1 = 1` were used as pivots. Eliminating all three variables from these equations, triangularizes the linear system:

       (%i2) elim(set(x + y + z = 1, x - y  - z = 8, x - z = 1),set(x,y,z));
       (%o2) [[],[2*z-7,y+7,z-x+1]]

  Of course, the equations needn't be linear:

       (%i6) elim(set(x^2 - 2 * y^3 = 1,  x - y = 5), [x,y]);
       (%o6) [[],[2*y^3-y^2-10*y-24,y-x+5]]

  The user doesn't control the order the variables are eliminated. Instead, the algorithm uses a heuristic to attempt to choose the best pivot and the best elimination order.

  Notes

  - Unlike the related function `eliminate`, the function `elim` does not invoke `solve` when the number of equations equals the number of variables.
  - The function `elim` works by applying resultants; the option variable `resultant` determines which algorithm Maxima uses. Using `sqfr`, Maxima factors each resultant and suppresses multiple zeros.
  - The `elim` will triangularize a nonlinear set of polynomial equations; the solution set of the triangularized set can be larger than that solution set of the untriangularized set. Thus, the triangularized equations can have spurious solutions.

  Related functions elim_allbut, eliminate_using, eliminate

  Option variables resultant

  To use ``load(to_poly)'`

  Status The function `elim` is experimental; its specifications might change and its functionality might be merged into other Maxima functions.

Function: elim_allbut (l, x)

  This function is similar to `elim`, except that it eliminates all the variables in the list of equations `l` except for those variables that in in the list `x`

       (%i1) elim_allbut([x+y = 1, x - 5*y = 1],[]);
       (%o1) [[],[y,y+x-1]]

       (%i2) elim_allbut([x+y = 1, x - 5*y = 1],[x]);
       (%o2) [[x-1],[y+x-1]]

  To use ``load(to_poly)'`

  Option variables resultant

  Related functions elim, eliminate_using, eliminate

  Status The function `elim_allbut` is experimental; its specifications might change and its functionality might be merged into other Maxima functions.

Function: eliminate_using (l, e, x)

  Using `e` as the pivot, eliminate the symbol `x` from the list or set of equations in `l`. The function `eliminate_using` returns a set.

      (%i1) eq : [x^2 - y^2 - z^3 , x*y - z^2 - 5, x - y + z];
      (%o1) [-z^3-y^2+x^2,-z^2+x*y-5,z-y+x]

      (%i2) eliminate_using(eq,first(eq),z);
      (%o2) {y^3+(1-3*x)*y^2+3*x^2*y-x^3-x^2,y^4-x^3*y^3+13*x^2*y^2-75*x*y+x^4+125}

      (%i3) eliminate_using(eq,second(eq),z);
      (%o3) {y^2-3*x*y+x^2+5,y^4-x^3*y^3+13*x^2*y^2-75*x*y+x^4+125}

      (%i4) eliminate_using(eq, third(eq),z);
      (%o4) {y^2-3*x*y+x^2+5,y^3+(1-3*x)*y^2+3*x^2*y-x^3-x^2}

  Option variables resultant

  Related functions elim, eliminate, elim_allbut

  To use ``load(topoly)'`

  Status The function `eliminate_using` is experimental; its specifications might change and its functionality might be merged into other Maxima functions.

Function: fourier_elim ([eq1, eq2, ...], [var1, var, ...])

  Fourier elimination is the analog of Gauss elimination for linear inequations (equations or inequalities). The function call `fourier_elim([eq1,eq2,...], [var1,var2,...]` does Fourier elimination on a list of linear inequations `[eq1,eq2,...]` with respect to the variables `[var1,var2,...]`; for example

       (%i7) fourier_elim([y-x < 5, x - y < 7, 10 < y],[x,y]);
       (%o7) [y-5<x,x<y+7,10<y]

       (%i8) fourier_elim([y-x < 5, x - y < 7, 10 < y],[y,x]);
       (%o8) [max(10,x-7)<y,y<x+5,5<x]

  Eliminating first with respect to x and second with respect to y yields lower and upper bounds for x that depend on y, and lower and upper bounds for y that are numbers. Eliminating in the other order gives x dependent lower and upper bounds for y, and numerical lower and upper bounds for x.

  When necessary, `fourier_elim` returns a disjunction of lists of inequations:

       (%i1) fourier_elim([x # 6],[x]);
       (%o1) [x<6] or [6<x]

  When the solution set is empty, `fourier_elim` returns `emptyset`, and when the solution set is all reals, `fourier_elim` returns `universalset`; for example

       (%i1) fourier_elim([x < 1, x > 1],[x]);
       (%o1) emptyset

       (%i2) fourier_elim([minf < x, x < inf],[x]);
       (%o2) universalset

  For nonlinear inequations, `fourier_elim` returns a (somewhat) simplified list of inequations:

       (%i1) fourier_elim([x^3 - 1 > 0],[x]);
       (%o1) [1<x,x^2+x+1>0] or [x<1,-(x^2+x+1)>0]

       (%i2) fourier_elim([cos(x) < 1/2],[x]);
       (%o2) [1-2*cos(x)>0]

  Instead of a list of inequations, the first argument to `fourier_elim` may be a logical disjunction or conjunction:

       (%i1) fourier_elim((x + y < 5) and (x - y >8),[x,y]);
       (%o1) [y+8<x,x<5-y,y<-3/2]

       (%i2) fourier_elim(((x + y < 5) and x < 1) or  (x - y >8),[x,y]);
       (%o2) [y+8<x] or [x<min(1,5-y)]

  The function `fourier_elim` supports the inequation operators <, <=, >, >=, #, and =.

  The Fourier elimination code has a preprocessor that converts some nonlinear inequations that involve the absolute value, minimum, and maximum functions into linear in equations. Additionally, the preprocessor handles some expressions that are the product or quotient of linear terms:

       (%i9) fourier_elim([max(x,y) > 6, x # 8, abs(y-1) > 12],[x,y]);
       (%o9) [6<x,x<8,y<-11] or [8<x,y<-11] or [x<8,13<y] or [x=y,13<y] or [8<x,x<y,13<y] or [y<x,13<y]

       (%i10) fourier_elim([(x+6)/(x-9) <= 6],[x]);
       (%o10) [x=12] or [12<x] or [x<9]

       (%i11) fourier_elim([x^2 - 1 # 0],[x]);
       (%o11) [-1<x,x<1] or [1<x] or [x<-1]

  To use ``load(fourier_elim)'`

Function: isreal_p (e)

  The predicate `isreal_p` returns true when Maxima is able to determine that `e` is real-valued on the entire real line; it returns false when Maxima is able to determine that `e` isn't real-valued on some nonempty subset of the real line; and it returns a noun form for all other cases.

       (%i1) map('isreal_p, [-1, 0, %i, %pi]);
       (%o1) [true,true,false,true]

  Maxima variables are assumed to be real; thus

       (%i2) isreal_p(x);
       (%o2) true

  The function `isreal_p` examines the fact database:

       (%i3) declare(z,complex)$

       (%i4) isreal_p(z);
       (%o4) isreal_p(z)

  Limitations Too often, `isreal_p` returns a noun form when it should be able to return false; a simple example: the logarithm function isn't real-valued on the entire real line, so `isreal_p(log(x))` should return false; however

       (%i5) isreal_p(log(x));
       (%o5) isreal_p(log(x))

  To use ``load(to_poly_solver)'`

  Related functions complex_number_p

  Status The function `real_p` is experimental; its specifications might change and its functionality might be merged into other Maxima functions.

Function: new_variable (type)

  Return a unique symbol of the form %[z,n,r,c,g]k, where k is an integer. The allowed values for type are integer, natural_number, real, natural_number, and general. (By natural number, we mean the nonnegative integers; thus zero is a natural number. Some, but not all,definitions of natural number exclude zero.)

  When type isn't one of the allowed values, type defaults to general. For integers, natural numbers, and complex numbers, Maxima automatically appends this information to the fact database.

       (%i1) map('new_variable, ['integer, 'natural_number, 'real, 'complex, 'general]);
       (%o1) [%z17,%n18,%r19,%c20,%g21]

       (%i2) featurep(%z0, 'integer);
       (%o2) true

       (%i3) featurep(%n1, 'integer);
       (%o3) true

       (%i4) is(%n1 >= 0);
       (%o4) true

       (%i5) featurep(%c20, 'complex);
       (%o5) true

  Note Generally, the argument to `new_variable` should be quoted. The quote will protect against errors similar to

       (%i1) integer : 12$

       (%i2) new_variable(integer);
       (%o2) %g4

       (%i3) new_variable('integer);
       (%o3) %z5

  Related functions nicedummies

  To use ``load(to_poly_solver)'`

  Status The function `new_variable` is experimental; its specifications might change and its functionality might be merged into other Maxima functions.

Function: nicedummies

  Starting with zero, the function `nicedummies` re-indexes the variables in an expression that were introduced by `new_variable`;

       (%i1) new_variable('integer) + 52 * new_variable('integer);
       (%o1) 52*%z1+%z0

       (%i2) new_variable('integer) - new_variable('integer);
       (%o2) %z2-%z3

       (%i3) nicedummies(%);
       (%o3) %z0-%z1

  Related functions new_variable

  To use ``load(to_poly_solver)'`

  Status The function `nicedummies` is experimental; its specifications might change and its functionality might be merged into other Maxima functions.

Function: parg (x)

  The function `parg` is a simplifying version of the complex argument function `carg`; thus

       (%i1) map('parg,[1,1+%i,%i, -1 + %i, -1]);
       (%o1) [0,%pi/4,%pi/2,(3*%pi)/4,%pi]

  Generally, for a non-constant input, `parg` returns a noun form; thus

       (%i1) parg(x + %i * sqrt(x));
       (%o1) parg(x+%i*sqrt(x))

  When `sign` can determine that the input is a positive or negative real number, `parg` will return a non-noun form for a non-constant input. Here are two examples:

       (%i1) parg(abs(x));
       (%o1) 0

       (%i2) parg(-x^2-1);
       (%o2) %pi

  Note The `sign` function mostly ignores the variables that are declared to be complex (`declare(x,complex)`); for variables that are declared to be complex, the `parg` can return incorrect values; for example

      (%i1) declare(x,complex)$

      (%i2) parg(x^2 + 1);
      (%o2) 0

  Related function carg, isreal_p

  To use ``load(to_poly_solver)'`

  Status The function `parg` is experimental; its specifications might change and its functionality might be merged into other Maxima functions.

Function: real_imagpart_to_conjugate (e)

  The function `real_imagpart_to_conjugate` replaces all occurrences of `realpart` and `imagpart` to algebraically equivalent expressions involving the `conjugate`.

      (%i1) declare(x,complex)$
      (%i3) real_imagpart_to_conjugate(realpart(x) +  imagpart(x) = 3);
      (%o3) (conjugate(x)+x)/2-(%i*(x-conjugate(x)))/2=3

  To use ``load(to_poly_solver)'`

  Status The function `real_imagpart_to_conjugate` is experimental; its specifications might change and its functionality might be merged into other Maxima functions.

Function: rectform_log_if_constant (e)

  The function `rectform_if_constant` converts all terms of the form `log(c)` to `rectform(log(c))`, where `c` is either a declared constant expression or explicitly declared constant

       (%i2) rectform_log_if_constant(log(1-%i) - log(x - %i));
       (%o2) -log(x-%i)+log(2)/2-(%i*%pi)/4

       (%i3) declare(a,constant, b,constant)$

       (%i4) rectform_log_if_constant(log(a + %i*b));
       (%o4) log(b^2+a^2)/2+%i*atan2(b,a)

  To use ``load(to_poly_solver)'`

  Status The function `rectform_log_if_constant` is experimental; the specifications of this function might change might change and its functionality might be merged into other Maxima functions.

Function: simp_inequality (e)

  The function `simp_inequality` applies some simplifications to conjunctions and disjunctions of inequations.

  Limitations The function `simp_inequality` is limited in at least two ways; first, the simplifications are local; thus

      (%i1) simp_inequality((x > minf) %and (x < 0));
      (%o2) (x>1) %and (x<1)

  And second, `simp_inequality` doesn't consult the fact database:

       (%i1) assume(x > 0)$

       (%i2) simp_inequality(x > 0);
       (%o2) x>0

  To use ``load(fourier_elim)'`

  Status The function `simp_inequality` is experimental; its specifications might change and its functionality might be merged into other Maxima functions.

Function: standardize_inverse_trig (e)

  This function applies the identities `cot(x) = atan(1/x), acsc(x) = asin(1/x),` and similarly for `asec, acoth, acsch` and `asech` to an expression. See Abramowitz and Stegun, Eqs. 4.4.6 through 4.4.8 and 4.6.4 through 4.6.6.

  To use ``load(to_poly_solver)'`

  Status The function `standardize_inverse_trig` is experimental; its specifications might change and its functionality might be merged into other Maxima functions.

Function: subst_parallel (l, e)

  When `l` is a single equation or a list of equations, substitute the right hand side of each equation for the left hand side. The substitutions are made in parallel; for example

       (%i2) subst_parallel([x=y,y=x], [x,y]);
       (%o2) [y,x]

  Compare this to substitutions made serially:

       (%i3) subst([x=y,y=x],[x,y]);
       (%o3) [x,x]

  The function `subst_parallel` is similar to `sublis` except that `subst_parallel` allows for substitution of nonatoms; for example

       (%i6) subst_parallel([x^2 = a, y = b], x^2 * y);
       (%o6) a*b

       (%i7) sublis([x^2 = a, y = b], x^2 * y);
        `sublis': Bad 1st arg

  The substitutions made by `subst_parallel` are literal, not semantic; thus `subst_parallel` does not recognize that x * y is a subexpression of x^2 * y

       (%i9) subst_parallel([x * y = a], x^2 * y);
       (%o9) x^2*y

  The function `subst_parallel` completes all substitutions before simplifications. This allows for substitutions into conditional expressions where errors might occur if the simplifications were made earlier:

       (%i12) subst_parallel([x = 0], %if(x < 1, 5, log(x)));
       (%o12) 5

       (%i13) subst([x = 0], %if(x < 1, 5, log(x)));
        log(0) has been generated.

  Related functions subst, sublis, ratsubst

  To use ``load(to_poly_solve_extra.lisp)'`

  Status The function `subst_parallel` is experimental; the specifications of this function might change might change and its functionality might be merged into other Maxima functions.

Function: to_poly (e, l)

  The function `to_poly` attempts to convert the equation `e` into a polynomial system along with inequality constraints; the solutions to the polynomial system that satisfy the constraints are solutions to the equation `e`. Informally, `to_poly` attempts to polynomialize the equation e; an example might clarify:

       (%i2) to_poly(sqrt(x) = 3, [x]);
       (%o2) [[%g6-3,x=%g6^2],[-%pi/2<parg(%g6),parg(%g6)<=%pi/2],[]]

  The conditions -%pi/2<parg(%g6),parg(%g6)<=%pi/2 tell us that %g6 is in the range of the square root function. When this is true, the solution set to sqrt(x) = 3 is the same as the solution set to %g6-3,x=%g6^2.

  To polynomialize trigonometric expressions, it is necessary to introduce a nonalgebraic substitution; these nonalgebraic substitutions are returned in the third list returned by `to_poly`; for example

      (%i3) to_poly(cos(x),[x]);
      (%o3) [[%g7^2+1],[2*%g7#0],[%g7=%e^(%i*x)]]

  Constant terms aren't polynomializied unless the number one is a member of the variable list; for example

       (%i1) to_poly(x = sqrt(5),[x]);
       (%o1) [[x-sqrt(5)],[],[]]

       (%i2) to_poly(x = sqrt(5),[1,x]);
       (%o2) [[x-%g31,5=%g31^2],[-%pi/2<parg(%g31),parg(%g31)<=%pi/2],[]]

  To generate a polynomial with sqrt(5) + sqrt(7) as one of its roots, use the commands

       (%i3) first(elim_allbut(first(to_poly(x = sqrt(5) + sqrt(7),[1,x])), [x]));
       (%o3) [x^4-24*x^2+4]

  Related functions to_poly_solve

  To use ``load(to_poly)'`

  Status: The function `to_poly` is experimental; its specifications might change and its functionality might be merged into other Maxima functions.

Function: to_poly_solve (e, l, [options])

  The function `to_poly_solve` tries to solve the equations e for the variables l. The equation(s) e can either be a single expression or a set or list of expressions; similarly, l can either be a single symbol or a list of set of symbols.

  The basic strategy of `to_poly_solve` is use `to_poly` to convert the input into a polynomial form and call `algsys` on the polynomial system. Thus user options that affect `algsys`, especially `algexact`, also affect `to_poly_solve`. The default for `algexact` is false, but for `to_poly_solve`, generally `algexact` should be true. The function `to_poly_solve` does not locally set `algexact` to true because this would make it impossible to find approximate solutions when the `algsys` is unable to determine an exact solution.

  The function `to_poly_solve` is a simplifying function. An alias for `to_poly_solve` is `%solve`. When `to_poly_solve` is unable to find a solution set, it returns a `%solve` noun form.

  The function `to_poly_solve` is able to solve some, but not all, equations involving rational powers, some nonrational powers, absolute values, trigonometric functions, and minimum and maximum. Also, some it can solve some equations that are solvable in in terms of the Lambert W function; some examples:

       (%i1) to_poly_solve(set(max(x,y) = 5, x+y = 2), set(x,y));
       (%o1) %union([x=-3,y=5],[x=5,y=-3])

       (%i2) to_poly_solve(abs(1-abs(1-x)) = 10,x);
       (%o2) %union([x=-10],[x=12])

       (%i3) to_poly_solve(set(sqrt(x) + sqrt(y) = 5, x + y = 10), set(x,y));
       (%o3) %union([x=-(5*sqrt(5)*%i-10)/2,y=(5*sqrt(5)*%i+10)/2],[x=(5*sqrt(5)*%i+10)/2,y=-(5*sqrt(5)*%i-10)/2])

       (%i4) to_poly_solve(cos(x) * sin(x) = 1/2,x, 'simpfuncs = ['expand, 'nicedummies]);
       (%o4) %union([x=%pi*%z0+%pi/4])

       (%i5) to_poly_solve(x^(2*a) + x^a + 1,x);

       (%o5) %union([x = (-sqrt(3)*%i-1)^(1/a)*%e^(2*%i*%pi*%z10/a)/2^(1/a)],
                    [x = (sqrt(3)*%i-1)^(1/a)*%e^(2*%i*%pi*%z9/a)/2^(1/a)])

       (%i6) to_poly_solve(x * exp(x) = a, x);
       (%o6) %union([x = lambert_w(a)])

  For linear inequalities, `to_poly_solve` does Fourier elimination:

       (%i1) to_poly_solve([x + y < 1, x - y >= 8],[x,y]);
       (%o1) %union([x = y+8,y < -7/2],[y+8 < x,x < 1-y,y < -7/2])

  When to_poly_solve is able to find the solution set, it returns a %union object; each argument to the %union object is a solution to the equation; for example

       (%i1) to_poly_solve(sqrt(x) - x = 1/4,x);
       (%o1) %union([x=1/4])

       (%i2) to_poly_solve(sqrt(x) - x = 42,x);
       (%o2) %union([x=(sqrt(167)*%i-83)/2],[x=-(sqrt(167)*%i+83)/2])

  When to_poly_solve is unable to find the solution set, it returns a noun form; for example,

      (%i6) to_poly_solve(a*x^9 + x^2 - 1,x);
      (%o6) %solve([a*x^9+x^2-1],[x])

      (%i7) subst(a=0,%);
      (%o7) %union([x = -1],[x = 1])

  Each optional argument to to_poly_solve must be an equation; generally, the order of these options does not matter.

  - simpfuncs = l, where l is a list of functions. Apply the composition of the members of l to each solution.

         (%i1) to_poly_solve(x^2=%i,x);
         (%o1) %union([x=-(-1)^(1/4)],[x=(-1)^(1/4)])

         (%i2) to_poly_solve(x^2= %i,x, 'simpfuncs = ['rectform]);
         (%o2) %union([x=-%i/sqrt(2)-1/sqrt(2)],[x=%i/sqrt(2)+1/sqrt(2)])

    Sometimes additional simplification can revert a simplification; for example

         (%i1) to_poly_solve(x^2=1,x);
         (%o1) %union([x=-1],[x=1])

         (%i2) to_poly_solve(x^2= 1,x, 'simpfuncs = [polarform]);
         (%o2) %union([x=1],[x=%e^(%i*%pi)])

    Maxima doesn't try to check that each member of the function list l is purely a simplification; thus

        (%i3) to_poly_solve(x^2 = %i,x, 'simpfuncs = [lambda([s],s^2)]);
        (%o3) %union([x=%i])

    To convert each solution to a double float, use simpfunc = ['dfloat]:

        (%i4) to_poly_solve(x^3 +x + 1 = 0,x, 'simpfuncs = ['dfloat]), algexact : true;
        (%o4) %union([x=-0.68232780382802],[x=0.34116390191401-1.161541399997252*%i],
                      [x=1.161541399997252*%i+0.34116390191401])

  - use_grobner = true With this option, the function poly_reduced_grobner is applied to the equations before attempting their solution. Primarily, this option provides a workaround for weakness in the function algsys. Here is an example of such a workaround:

        (%i1) to_poly_solve([x^2+y^2=2^2,(x-1)^2+(y-1)^2=2^2],[x,y], 'use_grobner = true);
        (%o1) %union([x=-(sqrt(7)-1)/2,y=(sqrt(7)+1)/2],[x=(sqrt(7)+1)/2,y=-(sqrt(7)-1)/2])

        (%i2) to_poly_solve([x^2+y^2=2^2,(x-1)^2+(y-1)^2=2^2],[x,y]);
        (%o2) %union()

  - maxdepth = k, where k is a positive integer. This function controls the maximum recursion depth for the solver. The default value for maxdepth is five. When the recursions depth is exceeded, the solver signals an error:

         (%i1) to_poly_solve(cos(x) = x,x, 'maxdepth = 2);
        Maximum recursion depth exceeded; unable to solve

  - parameters = l, where l is a list of symbols. The solver attempts to return a solution that is valid for all members of the list l; for example:

        (%i1) to_poly_solve(a * x = x, x);
        (%o1) %union([x=0])

        (%i2) to_poly_solve(a * x = x, x, 'parameters = [a]);
        (%o2) %union(%if(a-1=0,[x=%c123],%union()),%if(a-1#0,[x=0],%union()))

    In (%o2), the solver introduced a dummy variable; to re-index the these dummy variables, use the function nicedummies:

         (%i3) nicedummies(%);
         (%o3) %union(%if(a-1=0,[x=%c0],%union()),%if(a-1#0,[x=0],%union()))

  The `to_poly_solver` uses data stored in the hashed array `one_to_one_reduce` to solve equations of the form f(a) = f(b). The assignment `one_to_one_reduce['f,'f] : lambda([a,b], a=b)` tells `to_poly_solver` that the solution set of f(a) = f(b) equals the solution set of a=b; for example

       (%i2) one_to_one_reduce['f,'f] : lambda([a,b], a=b)$
       (%i3) to_poly_solve(f(x^2-1) = f(0),x);
       (%o3) %union([x = - 1], [x = 1])

  More generally, the assignment `one_to_one_reduce['f,'g] : lambda([a,b], w(a,b)=0` tells `to_poly_solver` that the solution set of f(a) = f(b) equals the solution set of w(a,b) = 0; for example

       (%i4) one_to_one_reduce['f,'g] : lambda([a,b], a = 1 + b/2)$
       (%i5) to_poly_solve(f(x) - g(x),x);
       (%o5) %union([x = 2])

  Additionally, `to_poly_solver` uses data stored in the hashed array `function_inverse` to solve equations of the form f(a) = b. The assignment `function_inverse['f] : lambda([s], g(s))` informs `to_poly_solver` that solution set to `f(x) = b` equals the solution set to `x = g(b)`; two examples:

       (%i6) function_inverse['Q] : lambda([s], P(s))$

       (%i7) to_poly_solve(Q(x-1) = 2009,x);
       (%o7) %union([x = P(2009) + 1])

       (%i8) function_inverse['G] : lambda([s], s + new_variable(integer));
       (%o8) lambda([s], s + new_variable(integer))

       (%i9) to_poly_solve(G(x - a) = b,x);
       (%o9) %union([x = b + a + %z1289])

  Notes

  - The solve variables needn't be symbols; when fullratsubst is able to appropriately make substitutions, the solve variables can be nonsymbols:

        (%i1) to_poly_solve([x^2 + y^2 + x * y = 5, x * y = 8], [x^2 + y^2, x * y]);
        (%o1) %union([x*y=8,y^2+x^2=-3])

  - For equations that involve complex conjugates, the solver automatically appends the conjugate equations; for example

        (%i1) declare(x,complex)$
        (%i2) to_poly_solve(x + (5 + %i) * conjugate(x) = 1, x);
        (%o2) %union([x=(%i+4)/25])

        (%i3) declare(y,complex)$
        (%i4) to_poly_solve(set(conjugate(x) - y = 42 + %i, x + conjugate(y) = 0), set(x,y));
        (%o4) %union([x=-(%i-42)/2,y=-(%i+42)/2])

  - For an equation that involves the absolute value function, the to_poly_solver consults the fact database to decide if the argument to the absolute value is complex valued. When

        (%i1) to_poly_solve(abs(x) = 6,x);
        (%o1) %union([x=-6],[x=6])

        (%i2) declare(z,complex)$
        (%i3) to_poly_solve(abs(z) = 6,z);
        (%o3) %union([z=%r38-%i*sqrt(36-%r38^2)],[z=%i*sqrt(36-%r39^2)+%r39])

    This is the only situation that the solver consults the fact database. If a solve variable is declared to be an integer, for example, to_poly_solve ignores this declaration.

  Relevant option variables algexact, resultant, algebraic

  Related functions to_poly

  To use ``load(to_poly_solve)'`

  Status: The function `to_poly_solve` is experimental; its specifications might change and its functionality might be merged into other Maxima functions.

This document was generated on 2 November 2009 using texi2html 1.56k.