# Solving a sine-cosine equation ( Warning: Explicit solution could not be found.)

3 views (last 30 days)
gianluca messina on 27 Jul 2011
Hi,
I'm trying to solve a symbolic equation (the more solution I get the better is), this is my code:
clear all; close all;
syms x n a;
eq = '(n*a/2 * sin(n*a*x) * sin(a*x/2)^2 - a/2 * sin(a*x) * sin(n*a*x/2)^2) / sin(a*x/2)^4 = 0';
[S]=solve(eq,x)
and I get this message:
Warning: Explicit solution could not be found. > In solve at 83
S =
[ empty sym ]
The function eq has infinite zeros, so what's wrong in my code? Is it possible to get some solutions, let's say in the range -5<x<+5?
Any help is appreciated.
Gianluca
##### 1 CommentShowHide None
Walter Roberson on 27 Jul 2011
Do you need symbolic roots? If numeric roots are acceptable then there may be mechanisms to find all the roots within a given range.

Giovanni on 27 Jul 2011
Hi Gianluca, I don't know if it's possible to limit the solutions to an interval using symbolic algebra. You might want to try solving it numerically? Also, assuming n is an integer:
equation = simple( (n*a/2 * sin(n*a*x) * sin(a*x/2)^2 - a/2 * sin(a*x) * sin(n*a*x/2)^2) / sin(a*x/2)^4 )
equationN = simple( subs(equation,n,3) );
solve(equationN,x)
ans =
0
(2*pi)/(3*a)
-(2*pi)/(3*a)
and so on if you replace n you'll get multiple solutions. It's just a work-around but maybe it'll help?
gianluca messina on 27 Jul 2011
Well,
in this case the zeros are periodic,
but I need to find the zeros of another function in which the zeros are not periodic.
Thank you for your help.
Gianluca

Walter Roberson on 27 Jul 2011
2*RootOf(tan(Z)*n-tan(n*Z),Z)/a
is the general form.
For n=3, the general solutions are
(set of 4*Pi*Z/a) union set of (2*(Pi+2*Pi*Z)/a)
where Z ranges over all of the integers.
The solutions for higher n are more extensive -- e.g., 10 sets for n=6 .

Stefan Wehmeier on 28 Jul 2011
There is no closed-form symbolic solution for general n, and for given n nobody can say which solutions are between -5 and 5 without knowing a. If you insert integer values for n, the solution will be found, but the complete (infinite) solution can only be represented in the symbolic engine, not on the matlab level, so you may want to proceed with
evalin(symengine, 'solve(your_equation, x)')
or use feval.

gianluca messina on 1 Aug 2011
Hi all, I'm in trouble because I need to find the zeros of this equation:
f1 = (1./(1-cax) .* (cax-1+cnax.*(1-cax)+snax.*sax) + 1./(1-cbx).*(cbx-1+(1-cbx).*cmbx+smbx.*sbx) ) .*... (1./(2-2.*cax) .*(-sax.*a+(cnax.*sax+snax.*cax).*a.*(1+n)-snax.*na) -2./(2-2.*cax).^2.*(cax-1+cnax.*(1-cax)+snax.*sax).*sax.*a+... 1./(2-2.*cbx) .*(-sbx.*b+(1+m).*b.*(cmbx.*sbx+smbx.*cbx)-smbx.*mb)-2./(2-2.*cbx).^2.*(cbx-1+cmbx.*(1-cbx)+smbx.*sbx).*sbx.*b) +... 2.*(-1./(2-2.*cax).*( (1-cax).*snax+(1-cnax).*sax ) - 1./(2-2.*cbx).*( (1-cbx).*smbx+(1-cmbx).*sbx) ).*... (-1./(2-2.*cax).*( (snax.*sax-cax.*cnax).*a.*(n+1)+cnax.*na+cax.*a) + 2./(2-2.*cax).^2.*((1-cax).*snax +(1-cnax).*sax).*sax.*a -... 1./(2-2.*cbx).*((smbx.*sbx-cbx.*cmbx).*b.*(1+m)+cmbx.*mb+cbx.*b) +2./(2-2.*cbx).^2.*((1-cbx).*smbx+(1-cmbx).*sbx ).*sbx.*b );
where cax = cos(a.*x); sax = sin(a.*x), cmbx = cos(m.*b.*x), and so on.
I would like to find a relation among the parameters (a,b,n,m) and x, if exists (for the former equation was x = 2*pi/(n*a)*k with k integer ) but all the code I used can't find anything(unless I use numerical method). I used solve and evalin.
Do you think Matlab is able to solve this equation in a symbolic way?