Using SOLVE in a Program

You can use the SOLVE operation as part of a program.

If appropriate, include or prompt for initial guesses (into the unknown variable and into the X–register) before executing the SOLVE variable instruction. The two instructions for solving an equation for an unknown variable appear in programs as:

/ label

#variable

The programmed SOLVE instruction does not produce a labeled display (variable

=value) since this might not be the significant output for your program (that is, you might want to do further calculations with this number before displaying it). If you do want this result displayed, add a VIEW variable instruction after the SOLVE instruction.

If no solution is found for the unknown variable, then the next program line is skipped (in accordance with the "Do if True" rule, explained in chapter 13). The program should then handle the case of not finding a root, such as by choosing new initial estimates or changing an input value.

Example: SOLVE in a Program.

The following excerpt is from a program that allows you to solve for x or y by pressing XX or Y.

14–6Solving and Integrating Programs