From: Kittithad Wangveerathananon on
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.

Thanks in advance
From: Kittithad Wangveerathananon on
Could somebody help me on this, please?
It may sound absurd, but i've been trying to do this for, like, many hours.
From: Sean on
"Kittithad Wangveerathananon" <kittithad(a)startfromyou.com> wrote in message <i40vno$9fm$1(a)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.

Also, please don't post the problem only in the thread title.

What's wrong with this?
>>solve('x^2+x+y^2+3*y=5*y^2+3*y+3*x*y+5','x')
From: Steven_Lord on


"Kittithad Wangveerathananon" <kittithad(a)startfromyou.com> wrote in message
news:i40rce$qur$1(a)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.

Don't do that. Please put your ENTIRE question in the body of your message,
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(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

From: Kittithad Wangveerathananon on
> 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);