How to | Use Rule Solutions

Since many functions in

*Mathematica* give solutions in the form of rules, you need to be able to use these rules to explore and interpret your results. Although many of the methods for using such solutions are specific to the type of problem being solved, you will consistently perform two basic steps: getting rule solutions from lists and then applying them to an expression.

Solve the simple equation

for

:

Out[62]= | |

The solution to this equation is contained in a nested list, which is a list of lists. Lists in

*Mathematica* are represented by

. Items in lists are called elements and can be referred to by their position.

To use the solution, you must first get it out of the nested list. Use

(the short form for

Part), with the position of the solution in the nested list. The solution here is the first (and only) element in the nested list:

Out[63]= | |

You can now use the solution with

(the short form of

ReplaceAll) to substitute the solution into the expression

:

Out[73]= | |

Two solutions are returned for a quadratic equation. There are two sublists, one per solution:

Out[77]= | |

This uses the second solution:

Out[78]= | |

A solution set is returned in one sublist when you solve a system of linear equations.

Set up a list of a simple system of linear equations to solve:

Out[78]= | |

Solve the equations. A nested list containing the one unique solution set is returned:

Out[79]= | |

The inner list containing the solution set is the first (and only) element in the nested list. Thus, using

with the nested list will return the list of solutions:

Out[80]= | |

This uses the solution set:

Out[81]= | |

You can get the parts of the solution set by extending the syntax to include the position of the solution within the inner list.

Get the solution for the first variable:

Out[83]= | |

Out[84]= | |

Similarly, this substitutes for the second and third variables:

Out[91]= | |

These equations have two solution sets:

Out[2]= | |

This substitutes both of the solution sets:

Out[3]= | |

This shows how to verify solutions to an equation.

First, solve a quadratic equation depending on a parameter:

Out[97]= | |

Verify the results by substitution:

Out[98]= | |

Note that the result of the substitution is in the form of an equation, instead of

True or

False.

Use

Simplify to determine if the substitution satisfies the equation. Each substitution evaluates to

True, indicating that the solutions satisfy the equation:

Out[99]= | |

Here is how to plot the solutions as a function of the parameter

by substituting:

Out[70]= | |

Similarly, plot just the first solution in

:

Out[72]= | |