SOLVE IT!

If you live long enough (and well enough!), then eventually you are going to have to solve for x. It's unavoidable. Get used to it. Below are a variety of examples involving both symbolic and numerical solutions of equations and systems of equations. Enjoy!

Here are the functions and expressions.

> restart;

> y1:=2*x+5;

y1 := 2*x+5

> y2:=-x+10;

y2 := -x+10

> y3:=x^3-x^2+x-2;

y3 := x^3-x^2+x-2

> f:=x->x^2-x-1;

f := proc (x) options operator, arrow; x^2-x-1 end ...

> g:=x^2+y^2;

g := x^2+y^2

Here are the solutions.

> solve(y1=0, x);

-5/2

> solve({y=y1,y=y2},{x,y});

{y = 25/3, x = 5/3}

> p:=solve(y3=0, x);

p := 1/6*(188+12*sqrt(249))^(1/3)-4/3*1/((188+12*sq...
p := 1/6*(188+12*sqrt(249))^(1/3)-4/3*1/((188+12*sq...
p := 1/6*(188+12*sqrt(249))^(1/3)-4/3*1/((188+12*sq...

> p[1];

1/6*(188+12*sqrt(249))^(1/3)-4/3*1/((188+12*sqrt(24...

> evalf(p[1]);

1.353209965

> solve(f(x)=0, x);

1/2+1/2*sqrt(5), 1/2-1/2*sqrt(5)

> solve(g=1, y);

sqrt(-x^2+1), -sqrt(-x^2+1)

And now, here are the floating point solutions (more or less).

> fsolve(y1=0, x);

-2.500000000

> fsolve({y=y1,y=y2},{x,y});

{x = 5/3, y = 25/3}

> fsolve(y3=0, x);

1.353209964

> fsolve(y3=0, x, complex);

-.1766049821-1.202820819*I, -.1766049821+1.20282081...

> fsolve(y3=0, x, 0..2);

1.353209964

> fsolve(f(x)=0, x);

-.6180339887, 1.618033989

>