Haw can I plot these two equations

I want to plot these two equation in the same image if it is possible. Thank yous a lot
exp(x)*(sin(y)-cos(y)-(exp(x)*sin(2*y)))==0
exp(x)*(-sin(y)-cos(y)+(2*exp(x)*cos(2*y))) ==0

1 Comment

KALYAN ACHARJYA
KALYAN ACHARJYA on 29 Aug 2019
Edited: KALYAN ACHARJYA on 29 Aug 2019
x and y solution?? Note on "==" and "=" ??

Sign in to comment.

 Accepted Answer

Probably the easiest way is to use the contour function:
f1 = @(x,y) exp(x).*(sin(y)-cos(y)-(exp(x).*sin(2*y)));
f2 = @(x,y) exp(x).*(-sin(y)-cos(y)+(2*exp(x).*cos(2*y)));
[X,Y] = ndgrid(-10:0.1:10);
figure
contour(X, Y, f1(X,Y), [0 0], 'r')
hold on
contour(X, Y, f2(X,Y), [0 0], 'g')
hold off
grid on
Experiment to get the result you want.

8 Comments

Thank you star strider for this answer. I think both equations can not be zero in the same time (graphically). and this what i can see from the obtained graph. do you agree with me?
because this is in fact what i want to (the two equations cannot be zero in the same time. ie if one is zero then the other is not.
As always, my pleasure.
The contour plot finds where each is zero over the range of the x and y variables. They appear to both be 0 at (0.4,-7), (0.4,-0.8), (0.4,5.5), and other locations on the plot.
If you want to test them for equality and to see where they both equal zero, use the fsolve function:
[B1, fv1] = fsolve(@(b) f1(b(1),b(2)) - f2(b(1),b(2)), [1; 1]) % Equal: ‘f1’ = ‘f2’
[B2, fv2] = fsolve(@(b)[ f1(b(1),b(2)); f2(b(1),b(2))], [1; 1]) % Equal Zero: ‘f1’=0, ‘f2’=0
producing:
B1 =
9.897632182562868e-01
8.869154150512346e-01
fv1 =
-1.104005775687256e-12
and:
B2 =
-7.390156647214075e+00
1.402800047643945e-01
fv2 =
-5.250299468032177e-04
-6.968141395717806e-04
so it appears that you are correct, they both do not equal zero at the same (x,y) near those initial parameter estimates, at least within the tolerances fsolve uses. The values of ‘fv2’ are as close as they get to zero. It might be interesting to see if the Symbolic Math Toolbox can estimate their region of equality with greater precision. I leave that to you.
dear Mr Star Strider. I hope that every thing is well with you.
sir, I'm sorry if I disturb you. but I'm counting on you to help me finish a proof of a theorem in one of my articles (complex geometry).
how can i solve the following equation in matlab.
exp(x)*(cos(y)+sin(y))-2*exp(x^2-y^2)*cos(2*x*y)=0
i use the following
solve('exp(x)*(cos(y)+sin(y))-2*exp(x^2-y^2)*cos(2*x*y)=0','x,y')
and i obtain the empty set.
When I run:
syms x y
[Sx,Sy] = solve(exp(x)*(cos(y)+sin(y))-2*exp(x^2-y^2)*cos(2*x*y)==0,[x,y])
in R2019a, the result is:
Sx =
0.44530495600422752473371664478028
Sy =
0.36746489034466857328774517070352
That result is the best I can do. Considering that ‘x’ and ‘y’ appear in the exponential function arguments likely means a periodic result is not possible.
Thank very much. I have an old version of matlab (r2010a) which give us the empty set !!!
now what about the following equation
exp(x^2-y^2)*sin(2*x*y)-exp(x)*(cos(y)-sin(y))=0
if the solution is different to the couple you find in the previous equation, then this is good and the proof is completed. can you please check with me in your version of matlab the solution of this second equation? becquse i dont want that the two equations be zero in the same time. ie if one is zero than the other will not.
it's very nice.
It appears to be different:
fun = @(x,y) exp(x^2-y^2)*sin(2*x*y)-exp(x)*(cos(y)-sin(y));
B0 = [0;0];
[B,fval] = fsolve(@(b) fun(b(1),b(2)), B0)
producing:
B =
0.082880704929335
0.739000804887249
The earlier expression with the same code:
B =
0.444280017162454
0.367713898130392
I will let you draw your own conclusions.
thank you a lot. i think every think is ok now. but is the obtained solutions for the two equations are unique ?
As always, my pleasure.
Probably not unique. Use different values for ‘B0’ to explore that possibiloity:
fun1 = @(x,y) exp(x^2-y^2)*sin(2*x*y)-exp(x)*(cos(y)-sin(y));
fun2 = @(x,y) exp(x)*(cos(y)+sin(y))-2*exp(x^2-y^2)*cos(2*x*y);
for k = 1:20;
B0(:,k) = randi(25, 2, 1);
B1(:,k) = fsolve(@(b) fun1(b(1),b(2)), B0(:,k));
B2(:,k) = fsolve(@(b) fun2(b(1),b(2)), B0(:,k));
end
figure
plot((1:20), B1, 'pg')
hold on
plot((1:20), B2, 'pm')
grid
So some initial estimates converge on the same values, while others do not. I encourage you to explore that at your leisure.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!