Solving equations

The basic command

"Solve" is the basic command to solve equations. Note that you have to type 2 equal signs!

Solve[x^2+4x-6==0]

You can tell Mathematica which variable to solve for:

Solve[a x^2+4x -5==0, x]

Solve[a x^2+4x -5==0, a]

Mathematica can also solve systems of equations:

Solve[{x^2+2y^2==5,x-3y==0}]

Solve[{a x^2+b y^2==5,x-3y==0},{x,y}]

Solve[{a x^2+b y^2==5,x-3y==0},{a,x}]

Nsolve works the same way, but gives numerical answers:

NSolve[x^2+4x-6==0]

How to extract solutions

Mathematica does not make assignements to variables. That’s why solutions are presented the way they are. Here is a first way to extract the values:

sol=Solve[x^2+4x-5==0]

sol[[1]]

sol[[1,1]]

sol[[1,1,2]]

sol[[2,1,2]]

Here is another way:

sol=Solve[x^2+4x-5==0]

x/.sol

Try It Yourself !

1. Solve the cubic equation (x^3)-4(x^2)+2x-5=0. Find the answers in exact and numerical form!

2. Find the points of intersection of the two circles (x^2)+(y^2)=9 and (((x-1))^2)+(((y+2))^2)=7.

3. For which value(s) of a do the two circles (x^2)+(y^2)=(a^2) and (((x-a))^2)+(((y+2))^2)=7 intersect in exactly one point?