How to | Use Rule Solutions

Since many functions in the Wolfram Language 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 :

The solution to this equation is contained in a nested list, which is a list of lists. Lists in the Wolfram Language 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:

You can now use the solution with /. (the short form of ReplaceAll) to substitute the solution into the expression :

    

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

This uses the second solution:

    

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:

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

The inner list containing the solution set is the first (and only) element in the nested list. Thus, using [[1]] with the nested list will return the list of solutions:

This uses the solution set:

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:

Substitute for it:

Similarly, this substitutes for the second and third variables:

    

These equations have two solution sets:

This substitutes both of the solution sets:

    

This shows how to verify solutions to an equation.

First, solve a quadratic equation depending on a parameter:

Verify the results by substitution:

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:

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

Similarly, plot just the first solution in sol: