# How to solve for x give the equation of a circle and the equation of a line?

38 views (last 30 days)

Show older comments

##### 0 Comments

### Accepted Answer

### More Answers (2)

DGM
on 3 Dec 2021

Consider the example of finding the intersection of a parabola and a circle. Note that this can all be done with the equations in implicit form.

syms x y real

eq1 = (x-3)^2 + (y+3)^2 == 4^2;

eq2 = 2*x + (y+1)^2 == 5;

S = solve([eq1 eq2],[x y]);

S.x

S.y

double(S.x)

double(S.y)

% plot curves

fimplicit(eq1,[-5 10 -10 5]); hold on

fimplicit(eq2,[-5 10 -10 5])

% plot solution points

plot(double(S.x),double(S.y),'ko')

##### 0 Comments

Jon
on 3 Dec 2021

You can use MATLAB's fsolve to solve the original system of two equations and two unknowns. To do this you have to rearrange the equation so that the right hand side is equal to zero, and then solve for the value of x and y that satisfy this using fsolve.

Alternatively, once you have substituted for y, as you show in your lower equation you can expand that as a second order polynomial , once again rearranging to make the right hand side equal to zero and solve for the roots (values of x that make the function equal to zero) using MATLAB's roots function.

##### 1 Comment

Jon
on 3 Dec 2021

To find out more about either of these functions, type doc followed by the function name on the command line, so

doc fsolve

doc roots

Also, if you have the symbolic math toolbox, there are further options. I don't have this so I can't offer any other specifics

### See Also

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!