Help ! two nonlinear equations

1 view (last 30 days)
Muhammed Adel
Muhammed Adel on 21 Apr 2016
Commented: Muhammed Adel on 8 Oct 2016
cos(3x)-cos(3y)+1 =0
cos(5x)-cos(5y)+1 =0
please, i can not answer these two nonlinear equations by matlab .

Accepted Answer

John D'Errico
John D'Errico on 21 Apr 2016
Actually, solve has no problems, returning only a set of 6 solutions that all lie in the interval [-pi,pi]. Of course they will not be represented in the form of radicals since those equations are equivalent to a high order (10th degree) polynomial, so vpa is then needed to recover the actual values.
syms x y
xy = solve(cos(3*x)-cos(3*y)+1 ==0,cos(5*x)-cos(5*y)+1 ==0)
xy =
x: [6x1 sym]
y: [6x1 sym]
vpa(xy.x)
ans =
-0.92557695405354896912598298502098
3.1415926535897932384626433832795
0.92557695405354896912598298502098
1.5707963267948966192313216916398
-0.92557695405354896912598298502098
0.92557695405354896912598298502098
Personally, I always like a graphical solution here. One can learn a lot from a picture.
[xx,yy] = meshgrid(linspace(-pi,pi,200));
zz1 = cos(3*xx)-cos(3*yy)+1;
zz2 = cos(5*xx)-cos(5*yy)+1;
contour(xx,yy,zz1,[0 0],'color','r')
hold on
contour(xx,yy,zz2,[0 0],'color','b')
grid on
axis equal
All crossings of the two contour colors are a solution to the nonlinear system. As you can see, there is a nice periodicity to those solutions. There will be infinitely many such solutions of course.

More Answers (2)

Roger Stafford
Roger Stafford on 21 Apr 2016
This doesn't solve your equations, but you can gain a better insight into their nature by expanding the cosine expressions in terms of cos(x) and cos(y). Let s = cos(x) and t = cos(y). Then your equations can be expressed:
(4*s^3-3*s)-(4*t^3-3*t)+1 = 0
(16*s^5-20*s^3+5*s)-(16*t^5-20*t^3+5*t)+1 = 0
There will be only a finite number of solution pairs to these polynomial equations whereas each solution (s,t) will have infinitely many combinations of corresponding x and y values which are also solutions. Changing to s and t avoids this confusing infinitude of solutions. I suspect 'solve' will be unable to obtain a specific solution to the above, so you may have to resort to numerical methods with 'fsolve'.

John BG
John BG on 22 Apr 2016
Edited: John BG on 22 Apr 2016
Muhammed
the expression
cos(3*x)-cos(3*y)+1=0
is same as
-2*sin((3*(x+y+x-y))/2)*sin((3*(x+y-(x-y)))/2)=-1
sin(1.5*x)*sin(1.5*y)=.5
the second equation
sin(2.5*x)*sin(2.5*y)=.5
and the solution are the points:
sin(1.5*x)*sin(1.5*y)-sin(2.5*x)*sin(2.5*y)=0
that d'Errico shows in the 2D graph, only the intersections of blue and red circles that are available directly from the contours:
[c1,h1]=contour(xx,yy,zz1,[0 0],'color','r')
[c2,h2]=contour(xx,yy,zz2,[0 0],'color','b')
the points of the circles are
blue circles
ax1=h1.XData
ay1=h1.YData
red circles
ax2=h2.XData
ay2=h2.YData
the solution:
x1=intersect(ax1,ax2)
y1=intersect(ay1,ay2)
only happens when
1.5*M*(x+y)=N*2.5*(x-y)
for any positive or negative integer M N
Mr d'Errico, do you agree?
John
note about trigonometry basics:
  2 Comments
John D'Errico
John D'Errico on 22 Apr 2016
I don't see that the relationship
1.5*M*(x+y)=N*2.5*(x-y)
trivially follows from your derivation, nor is it at all useful in predicting solutions.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!