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 件のコメント

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 8 月 29 日
編集済み: KALYAN ACHARJYA 2019 年 8 月 29 日
x and y solution?? Note on "==" and "=" ??

サインインしてコメントする。

 採用された回答

Star Strider
Star Strider 2019 年 8 月 29 日

0 投票

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 件のコメント

Abdessami Jalled
Abdessami Jalled 2019 年 8 月 29 日
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.
Star Strider
Star Strider 2019 年 8 月 29 日
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.
Abdessami Jalled
Abdessami Jalled 2019 年 9 月 12 日
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.
Star Strider
Star Strider 2019 年 9 月 12 日
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.
Abdessami Jalled
Abdessami Jalled 2019 年 9 月 12 日
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.
Star Strider
Star Strider 2019 年 9 月 12 日
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.
Abdessami Jalled
Abdessami Jalled 2019 年 9 月 12 日
thank you a lot. i think every think is ok now. but is the obtained solutions for the two equations are unique ?
Star Strider
Star Strider 2019 年 9 月 12 日
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.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by