Next: , Previous: Solving Equations, Up: Solving Equations

#### 10.6.1 Multiple Solutions

Some equations have more than one solution. The Hyperbolic flag (`H a S`) [`fsolve`] tells the solver to report the fully general family of solutions. It will invent variables `n1`, `n2`, ..., which represent independent arbitrary integers, and `s1`, `s2`, ..., which represent independent arbitrary signs (either +1 or -1). If you don't use the Hyperbolic flag, Calc will use zero in place of all arbitrary integers, and plus one in place of all arbitrary signs. Note that variables like `n1` and `s1` are not given any special interpretation in Calc except by the equation solver itself. As usual, you can use the s l (`calc-let`) command to obtain solutions for various actual values of these variables.

For example, ' x^2 = y <RET> H a S x <RET> solves to get ‘x = s1 sqrt(y)’, indicating that the two solutions to the equation are ‘sqrt(y)’ and ‘-sqrt(y)’. Another way to think about it is that the square-root operation is really a two-valued function; since every Calc function must return a single result, `sqrt` chooses to return the positive result. Then H a S doctors this result using `s1` to indicate the full set of possible values of the mathematical square-root.

There is a similar phenomenon going the other direction: Suppose we solve ‘sqrt(y) = x’ for `y`. Calc squares both sides to get ‘y = x^2’. This is correct, except that it introduces some dubious solutions. Consider solving ‘sqrt(y) = -3’: Calc will report ‘y = 9’ as a valid solution, which is true in the mathematical sense of square-root, but false (there is no solution) for the actual Calc positive-valued `sqrt`. This happens for both a S and H a S.

If you store a positive integer in the Calc variable `GenCount`, then Calc will generate formulas of the form ‘as(n)’ for arbitrary signs, and ‘an(n)’ for arbitrary integers, where n represents successive values taken by incrementing `GenCount` by one. While the normal arbitrary sign and integer symbols start over at `s1` and `n1` with each new Calc command, the `GenCount` approach will give each arbitrary value a name that is unique throughout the entire Calc session. Also, the arbitrary values are function calls instead of variables, which is advantageous in some cases. For example, you can make a rewrite rule that recognizes all arbitrary signs using a pattern like ‘as(n)’. The s l command only works on variables, but you can use the a b (`calc-substitute`) command to substitute actual values for function calls like ‘as(3)’.

The s G (`calc-edit-GenCount`) command is a convenient way to create or edit this variable. Press C-c C-c to finish.

If you have not stored a value in `GenCount`, or if the value in that variable is not a positive integer, the regular `s1`/`n1` notation is used.

With the Inverse flag, I a S [`finv`] treats the expression on top of the stack as a function of the specified variable and solves to find the inverse function, written in terms of the same variable. For example, I a S x inverts ‘2x + 6’ to ‘x/2 - 3’. You can use both Inverse and Hyperbolic [`ffinv`] to obtain a fully general inverse, as described above.

Some equations, specifically polynomials, have a known, finite number of solutions. The a P (`calc-poly-roots`) [`roots`] command uses H a S to solve an equation in general form, then, for all arbitrary-sign variables like `s1`, and all arbitrary-integer variables like `n1` for which `n1` only usefully varies over a finite range, it expands these variables out to all their possible values. The results are collected into a vector, which is returned. For example, ‘roots(x^4 = 1, x)’ returns the four solutions ‘[1, -1, (0, 1), (0, -1)]’. Generally an nth degree polynomial will always have n roots on the complex plane. (If you have given a `real` declaration for the solution variable, then only the real-valued solutions, if any, will be reported; see Declarations.)

Note that because a P uses H a S, it is able to deliver symbolic solutions if the polynomial has symbolic coefficients. Also note that Calc's solver is not able to get exact symbolic solutions to all polynomials. Polynomials containing powers up to ‘x^4’ can always be solved exactly; polynomials of higher degree sometimes can be: ‘x^6 + x^3 + 1’ is converted to ‘(x^3)^2 + (x^3) + 1’, which can be solved for ‘x^3’ using the quadratic equation, and then for ‘x’ by taking cube roots. But in many cases, like ‘x^6 + x + 1’, Calc does not know how to rewrite the polynomial into a form it can solve. The a P command can still deliver a list of numerical roots, however, provided that Symbolic mode (m s) is not turned on. (If you work with Symbolic mode on, recall that the N (`calc-eval-num`) key is a handy way to reevaluate the formula on the stack with Symbolic mode temporarily off.) Naturally, a P can only provide numerical roots if the polynomial coefficients are all numbers (real or complex).