f

#### suppose I have an equation x^2+x+y^2+3*y=5*y^2+3*y+3*x*y+5 and I want to find the set of (x,y) that satisfy the equation.

```Question
How can i do that?
I've been trying, solve, explot and subs.
I can get the graph, but i cannot get the (x,y) pairs that I want.

When I use function solve to solve the equation in term of x or y and then substitute the numeric value for one of them to find the other, I got the problem about complex numer. This might be because that numeric value that I substitute is not the number that satisfy the equation, so the program give me the result in complex number.

Background.
I need to use the pairs to find the optimal value of my objective function.
I tried to use the fmincon, but it gave me the optimal value that is not reliable, so i try to do it manually.
Note that my equality constraint is in the form of the equation in the subject.
I also have a couple of inequality constraints.

``` 0  Kittithad
8/12/2010 1:02:06 PM comp.soft-sys.matlab  211265 articles. 25 followers. 11 Replies 2665 Views Similar Articles

[PageSpeed] 40

```> Question
> How can i do that?
> I've been trying, solve, explot and subs.
> I can get the graph, but i cannot get the (x,y) pairs
> that I want.
>
> When I use function solve to solve the equation in
> term of x or y and then substitute the numeric value
> for one of them to find the other, I got the problem
> about complex numer. This might be because that
> numeric value that I substitute is not the number
> that satisfy the equation, so the program give me the
> result in complex number.
>
> Background.
> I need to use the pairs to find the optimal value of
> my objective function.
> I tried to use the fmincon, but it gave me the
> optimal value that is not reliable, so i try to do it
> manually.
> Note that my equality constraint is in the form of
> the equation in the subject.
> I also have a couple of inequality constraints.
>

x^2+x+y^2+3y = 5y^2+3y+3xy+5
x^2+x(1-3y)+(-4y^2-5)=0
x^2-2x*(1.5y-0.5)-(4y^2+5)=0
x = 1.5y-0.5 +/- sqrt((2.25y^2-1.5y+0.25)+(4y^2+5))
x = 1.5y-0.5 +/- 0.5*sqrt(25y^2-6y+21)

So all points of the form
(1.5y-0.5 + 0.5*sqrt(25y^2-6y+21),y) or
(1.5y-0.5 - 0.5*sqrt(25y^2-6y+21),y)
for y in IR satisfy our equation.

Best wishes
Torsten.
``` 0  Torsten
8/12/2010 10:37:36 AM
```Could somebody help me on this, please?
It may sound absurd, but i've been trying to do this for, like, many hours.
``` 0  Kittithad
8/12/2010 2:16:25 PM
```"Kittithad Wangveerathananon" <kittithad@startfromyou.com> wrote in message <i40vno\$9fm\$1@fred.mathworks.com>...
> Could somebody help me on this, please?
> It may sound absurd, but i've been trying to do this for, like, many hours.

Your question didn't get answered in an hour and 14 minutes.  I think that's a very low  response time for a bunch of people volunteering their time to help you.

What's wrong with this?
>>solve('x^2+x+y^2+3*y=5*y^2+3*y+3*x*y+5','x')
``` 0  Sean
8/12/2010 2:30:28 PM
```
news:i40rce\$qur\$1@fred.mathworks.com...
> Question
> How can i do that?
> I've been trying, solve, explot and subs.
> I can get the graph, but i cannot get the (x,y) pairs that I want.

What, specifically, do you want to obtain?  There are an infinite number of
(x, y) points that satisfy this equation.  One such pair is approximately
(3, -2.8615).

> When I use function solve to solve the equation in term of x or y and then
> substitute the numeric value for one of them to find the other, I got the
> problem about complex numer. This might be because that numeric value that
> I substitute is not the number that satisfy the equation, so the program
> give me the result in complex number.
>
> Background.
> I need to use the pairs to find the optimal value of my objective
> function.
> I tried to use the fmincon, but it gave me the optimal value that is not
> reliable, so i try to do it manually.
> Note that my equality constraint is in the form of the equation in the
> subject.

for easy quoting.

> I also have a couple of inequality constraints.

If you were just looking to identify the points that satisfy your equation
graphically, I would use CONTOUR.  Write your equation as z = f(x, y) and
look at the contour for z = 0.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
http://www.mathworks.com

``` 0 8/12/2010 2:46:14 PM
```> What's wrong with this?
> >>solve('x^2+x+y^2+3*y=5*y^2+3*y+3*x*y+5','x')

Dear sean, it very nice of you for your respoonse.

Sorry for the messing in the title. I'll keep that in mind.

What I want is the set of (x*,y*) that solve the equation.
Obviously, this problem is in the form of 2 variables and 1equation, so i should get an answer in form of set of (X,Y).

1)
solve('x^2+x+y^2+3*y=5*y^2+3*y+3*x*y+5','x') gives me x in term of y. Then I need to create a vector yi to sub into x. I think the value of vector of y I created is not related to (x*,y*) that solve the equation. That's why xi=subs(x,y,yi) return a complex number.

2)
solve('x^2+x+y^2+3*y=5*y^2+3*y+3*x*y+5','x','y') will, obviously, yield error message.

Actually this is what i'm trying to do, the variable GBC is in the form of the equation in the title.

%exo parameters
tax=0.2;
gamma=1;
N0H=0.25;
aH=1;
nL=1;
nH=3;
d0=1;
%endo parameters
N0L=1-N0H;
dH=d0*aH*nH;
dL=2*dH;
EzH=dH/2;
EzL=dL/2;
g=(nH-nL)/gamma;
D=(1/dH)+(1/dL);
disposible=1-tax;
C=disposible*D;
N1H=N0H;
N1L=1-N1H;

%Compute endo vars
syms phi mew
w=(1/(2*C))*(C*aH*nH-D*mew-(N1L/dL)*phi);
e=(1/dH)*((1-tax)*w-mew);
j=(1/dL)*((1-tax)*w-mew+phi);
%number workers
NLJ=j*N1L;
NLU=(1-j)*N1L;
NHE=e*N1H;
NHU=(1-e)*N1H;
%spending per workers
SLJ=phi+g;
SLU=mew;
SHE=0;
SHU=mew;
%rev per workers
RLJ=tax*w;
RLU=0;
RHE=tax*w;
RHU=0;
%firm's profitax from low
FLJ=(aH*nH-w);
FLU=0;
FHE=(aH*nH-w);
FHU=0;
omega=NLJ*FLJ+NLU*FLU+NHE*FHE+NHU*FHU;
%payoff of low
PLJ=omega+w-EzL+phi;
PLU=omega+mew;
PHE=omega+w-EzH;
PHU=omega+mew;
%TS,TR and SWF
TS=NLJ*SLJ+NLU*SLU+NHE*SHE+NHU*SHU;
TR=NLJ*RLJ+NLU*RLU+NHE*RHE+NHU*RHU;
GBC=TS-TR;
swf=NLJ*PLJ+NLU*PLU+NHE*PHE+NHU*PHU;

A=solve(GBC,mew);
phii=0:0.02:2;
mewi=subs(A,phi,phii);
``` 0 8/12/2010 2:53:08 PM
```Yeah basically, that what I want. But I need to obtain the value of those pairs, because I want to use it to sub into my objective function to find that which pair max my objective.

I used fmincon before, but feel that the answer is not quite right, since I'm not familiar with the function. So I decided to go manually.

"Steven_Lord" <slord@mathworks.com> wrote in message <i411fm\$4e0\$1@fred.mathworks.com>...
>
>
> news:i40rce\$qur\$1@fred.mathworks.com...
> > Question
> > How can i do that?
> > I've been trying, solve, explot and subs.
> > I can get the graph, but i cannot get the (x,y) pairs that I want.
>
> What, specifically, do you want to obtain?  There are an infinite number of
> (x, y) points that satisfy this equation.  One such pair is approximately
> (3, -2.8615).
>
> > When I use function solve to solve the equation in term of x or y and then
> > substitute the numeric value for one of them to find the other, I got the
> > problem about complex numer. This might be because that numeric value that
> > I substitute is not the number that satisfy the equation, so the program
> > give me the result in complex number.
> >
> > Background.
> > I need to use the pairs to find the optimal value of my objective
> > function.
> > I tried to use the fmincon, but it gave me the optimal value that is not
> > reliable, so i try to do it manually.
> > Note that my equality constraint is in the form of the equation in the
> > subject.
>
> for easy quoting.
>
> > I also have a couple of inequality constraints.
>
> If you were just looking to identify the points that satisfy your equation
> graphically, I would use CONTOUR.  Write your equation as z = f(x, y) and
> look at the contour for z = 0.
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> http://www.mathworks.com
``` 0 8/12/2010 3:06:05 PM
``` all points of the form
(1.5y-0.5 + 0.5*sqrt(25y^2-6y+21),y) or
(1.5y-0.5 - 0.5*sqrt(25y^2-6y+21),y)

If I sub the value of y, freely, i might get 1.5y-0.5 + 0.5*sqrt(25y^2-6y+21) as a complex number right?

I try this way before too and get the complex number.

I need the contour set of z=0 when z=f(x,y). I have the graph, but not the set.

Torsten Hennig <Torsten.Hennig@umsicht.fhg.de> wrote in message <1780645233.99952.1281623886497.JavaMail.root@gallium.mathforum.org>...
> > Question
> > How can i do that?
> > I've been trying, solve, explot and subs.
> > I can get the graph, but i cannot get the (x,y) pairs
> > that I want.
> >
> > When I use function solve to solve the equation in
> > term of x or y and then substitute the numeric value
> > for one of them to find the other, I got the problem
> > about complex numer. This might be because that
> > numeric value that I substitute is not the number
> > that satisfy the equation, so the program give me the
> > result in complex number.
> >
> > Background.
> > I need to use the pairs to find the optimal value of
> > my objective function.
> > I tried to use the fmincon, but it gave me the
> > optimal value that is not reliable, so i try to do it
> > manually.
> > Note that my equality constraint is in the form of
> > the equation in the subject.
> > I also have a couple of inequality constraints.
> >
>
> x^2+x+y^2+3y = 5y^2+3y+3xy+5
> x^2+x(1-3y)+(-4y^2-5)=0
> x^2-2x*(1.5y-0.5)-(4y^2+5)=0
> x = 1.5y-0.5 +/- sqrt((2.25y^2-1.5y+0.25)+(4y^2+5))
> x = 1.5y-0.5 +/- 0.5*sqrt(25y^2-6y+21)
>
> So all points of the form
> (1.5y-0.5 + 0.5*sqrt(25y^2-6y+21),y) or
> (1.5y-0.5 - 0.5*sqrt(25y^2-6y+21),y)
> for y in IR satisfy our equation.
>
> Best wishes
> Torsten.
``` 0  Kittithad
8/12/2010 3:17:24 PM
```Yeah basically, that what I want. But I need to obtain the value of
those pairs, because I want to use it to sub into my objective function
to find that which pair max my objective.

As Steve indicated, there are an infinite number of solution points.
Exactly how much RAM or disk space do you have to hold all of those
infinite results, and how long are you prepared to let your minimizer run?
``` 0  Walter
8/12/2010 4:53:07 PM
```Kittithad Wangveerathananon wrote:
> all points of the form
> (1.5y-0.5 + 0.5*sqrt(25y^2-6y+21),y) or
> (1.5y-0.5 - 0.5*sqrt(25y^2-6y+21),y)
>
> If I sub the value of y, freely, i might get 1.5y-0.5 +
> 0.5*sqrt(25y^2-6y+21) as a complex number right?
>
> I try this way before too and get the complex number.
>
> I need the contour set of z=0 when z=f(x,y). I have the graph, but not
> the set.

Yes, if you substitute x and y freely into an arbitrary function then
you might get a complex number.

original question had no z or f(x,y) in it. If you are switching topics,
please start a new thread giving the information relevant to that new
topic (such as the nature of f() )
``` 0  Walter
8/12/2010 4:55:19 PM
```"Kittithad Wangveerathananon" <kittithad@startfromyou.com> wrote in message <i413a4\$682\$1@fred.mathworks.com>...
>  all points of the form
> (1.5y-0.5 + 0.5*sqrt(25y^2-6y+21),y) or
> (1.5y-0.5 - 0.5*sqrt(25y^2-6y+21),y)
>
> If I sub the value of y, freely, i might get 1.5y-0.5 + 0.5*sqrt(25y^2-6y+21) as a complex number right?
>
> I try this way before too and get the complex number.
> .......
- - - - - - - - - -
No, that isn't correct!  Torsten has given you a valid solution.  For all real y numbers Torsten's quantity inside the square root is always a positive quantity and can never give you a complex result for x.  Write it like this:

25y^2-6y+21 = (5*y-3/5)^2+516/25

and you can see that it can never be less that 516/25, no matter what x is.

The locus of your equation is a hyperbola in which the two branches lie to the left and the right.  There are some x's in between for which no real y exists, but for every possible real y there are two distinct x's which satisfy the equation.

Roger Stafford
``` 0  Roger
8/12/2010 5:35:05 PM
```Kittithad Wangveerathananon wrote:
> Could somebody help me on this, please?
> It may sound absurd, but i've been trying to do this for, like, many hours.

Sorry; next time something this important comes up, have your country's State
Department call our Ambassador, who will cable over to my country to get the
appropriate ministry to send someone over to my residence to wake me up.
``` 0  Walter
8/12/2010 8:04:31 PM