Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
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.

Subject: 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.

From: Kittithad Wangveerathananon

Date: 12 Aug, 2010 13:02:06

Message: 1 of 12

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

Subject: 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.

From: Kittithad Wangveerathananon

Date: 12 Aug, 2010 14:16:25

Message: 2 of 12

Could somebody help me on this, please?
It may sound absurd, but i've been trying to do this for, like, many hours.

Subject: 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.

From: Sean

Date: 12 Aug, 2010 14:30:28

Message: 3 of 12

"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.

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')

Subject: suppose I have an equation x^2+x+y^2+3*y=5*y^2+3*y+3*x*y+5 and

From: Torsten Hennig

Date: 12 Aug, 2010 14:37:36

Message: 4 of 12

> 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

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.

Subject: 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.

From: Steven_Lord

Date: 12 Aug, 2010 14:46:14

Message: 5 of 12



"Kittithad Wangveerathananon" <kittithad@startfromyou.com> wrote in message
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.

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@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

Subject: 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.

From: Kittithad Wangveerathananon

Date: 12 Aug, 2010 14:53:08

Message: 6 of 12

> 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);

Subject: 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.

From: Kittithad Wangveerathananon

Date: 12 Aug, 2010 15:06:05

Message: 7 of 12

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>...
>
>
> "Kittithad Wangveerathananon" <kittithad@startfromyou.com> wrote in message
> 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.
>
> 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@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

Subject: suppose I have an equation x^2+x+y^2+3*y=5*y^2+3*y+3*x*y+5 and

From: Kittithad Wangveerathananon

Date: 12 Aug, 2010 15:17:24

Message: 8 of 12

 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.
> >
> > Thanks in advance
>
> 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.

Subject: suppose I have an equation x^2+x+y^2+3*y=5*y^2+3*y+3*x*y+5 and

From: Walter Roberson

Date: 12 Aug, 2010 16:53:07

Message: 9 of 12

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?

Subject: suppose I have an equation x^2+x+y^2+3*y=5*y^2+3*y+3*x*y+5 and

From: Walter Roberson

Date: 12 Aug, 2010 16:55:19

Message: 10 of 12

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.

The matter is, however, irrelevant to your original question as your
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() )

Subject: suppose I have an equation x^2+x+y^2+3*y=5*y^2+3*y+3*x*y+5 and

From: Roger Stafford

Date: 12 Aug, 2010 17:35:05

Message: 11 of 12

"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

Subject: suppose I have an equation x^2+x+y^2+3*y=5*y^2+3*y+3*x*y+5 and

From: Walter Roberson

Date: 12 Aug, 2010 20:04:31

Message: 12 of 12

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.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us