Haw can I plot these two equations
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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
2019년 8월 29일
편집: KALYAN ACHARJYA
2019년 8월 29일
x and y solution?? Note on "==" and "=" ??
채택된 답변
Star Strider
2019년 8월 29일
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
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.
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
2019년 9월 12일
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.
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.
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
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 ?
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개)
카테고리
도움말 센터 및 File Exchange에서 Plot Settings에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
