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 :

In[1]:=
Click for copyable input
Out[1]=

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:

In[2]:=
Click for copyable input
Out[2]=

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

In[3]:=
Click for copyable input
Out[3]=
    

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

In[1]:=
Click for copyable input
Out[1]=

This uses the second solution:

In[2]:=
Click for copyable input
Out[2]=
    

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:

In[1]:=
Click for copyable input
Out[1]=

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

In[2]:=
Click for copyable input
Out[2]=

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:

In[3]:=
Click for copyable input
Out[3]=

This uses the solution set:

In[4]:=
Click for copyable input
Out[4]=

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:

In[5]:=
Click for copyable input
Out[5]=

Substitute for it:

In[6]:=
Click for copyable input
Out[6]=

Similarly, this substitutes for the second and third variables:

In[7]:=
Click for copyable input
Out[7]=
    

These equations have two solution sets:

In[1]:=
Click for copyable input
Out[1]=

This substitutes both of the solution sets:

In[2]:=
Click for copyable input
Out[2]=
    

This shows how to verify solutions to an equation.

First, solve a quadratic equation depending on a parameter:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=

Verify the results by substitution:

In[3]:=
Click for copyable input
Out[3]=

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:

In[4]:=
Click for copyable input
Out[4]=

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

In[5]:=
Click for copyable input
Out[5]=

Similarly, plot just the first solution in :

In[6]:=
Click for copyable input
Out[6]=