MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

# Intersection of Two Implicit Curves over a domain

Asked by Rodrigo on 8 May 2013

I have two implicit equations, one circle and one ellipse. I would like to know if there is a function or a way to find an intersection belonging to a given domain. Consider, for example:

circ = @(x,y) x^2+y^2-4 elp = @(x,y) ((x-2))^2+((y+2)/4)^2-1

There are two points of intersection (approximately):

P1 ~ (1.00 , -1.73) P2 ~ (1.46 , 1.37)

So I would like to know how to find P1, knowing it lies somewhere between: X: (0.8 , 1.2) Y: (-2 , -1)

OBS: I have no problems with numeric approximations, especially if it is not computationally intensive.

Thanks

## Products

No products are associated with this question.

Answer by Teja Muppirala on 9 May 2013

This sort of problem can be solved easily using FSOLVE

```circ = @(x,y) x^2+y^2-4
elp = @(x,y) ((x-2))^2+((y+2)/4)^2-1
```
```fsolve(@(X)[circ(X(1),X(2)); elp(X(1),X(2))],[1 -1.5])
```

This returns

```ans =
1.0023   -1.7307
```