How to solve simultaneous equation with trigonometric function
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
Hello, any one can help me
syms alpha gamma R d
R = 0.08;
d = 1.4;
R^2 == 4*(alpha)^2 / [(2*(alpha)^2 + 1) * acos*(2*gamma) + (2*(alpha)^2 - 1) * cos*(2*gamma) + 2*alpha*(asin*(2*gamma)) - sin*(2*gamma)]
d == atan*[(atan(2*alpha*tan*gamma + 1) + tan*gamma) / (tan*gamma - atan*gamma + 2*alpha)]
sol = solve ([R^2, d] , [alpha, gamma])
alphaSol = sol.alpha
gammaSol = sol.gamma
I need to obtain alpha and gamma
There is : Error using acos
Not enough input arguments.
- if I delete acos, another error is appear (cos, ect)
Accepted Answer
KSSV
on 26 Jul 2022
You cannot write acos*(2*gamma) and tan*gamma. Note that they are function and they need someinput. It migh be: acos(2*gamma) and tan(gamma)
syms alpha gamma R d
R = 0.08;
d = 1.4;
R^2 == 4*(alpha)^2 / ((2*(alpha)^2 + 1) * acos(2*gamma) + (2*(alpha)^2 - 1) * cos(2*gamma) + 2*alpha*(asin(2*gamma)) - sin(2*gamma))
d == atan((atan(2*alpha*tan(gamma) + 1) + tan(gamma)) / (tan(gamma) - atan(gamma) + 2*alpha))
sol = solve ([R^2, d] , [alpha, gamma])
alphaSol = sol.alpha
gammaSol = sol.gamma
Though the above is not giving any solution, you need to check your expression properly.
17 Comments
christina widyaningtyas
on 26 Jul 2022
Torsten
on 26 Jul 2022
syms alpha gamma %R d
R = 0.08;
d = 1.4;
expr1 = R^2 == 4*(alpha)^2 / ((2*(alpha)^2 + 1) * acos(2*gamma) + (2*(alpha)^2 - 1) * cos(2*gamma) + 2*alpha*(asin(2*gamma)) - sin(2*gamma))
expr1 =

expr2 = d == atan((atan(2*alpha*tan(gamma) + 1) + tan(gamma)) / (tan(gamma) - atan(gamma) + 2*alpha))
expr2 =
sol = solve ([expr1,expr2] , [alpha, gamma])
Warning: Unable to solve symbolically. Returning a numeric solution using vpasolve.
sol = struct with fields:
alpha: 0.89004376539962278983379602051241 + 0.38919789229051247720270451525197i
gamma: 78.222544477417321649984876860727 - 3.0960897467326888301848990655128i
alphaSol = sol.alpha
alphaSol = 
gammaSol = sol.gamma
gammaSol = 
christina widyaningtyas
on 27 Jul 2022
christina widyaningtyas
on 27 Jul 2022
Dear @Torsten
I apologize in advance, it looks like I made a mistake by writing the equation at first.
The equation I mean as attached,
I don't know why I can't check it into that form.
If you don't mind, can you check my writing equation :
expr1 = (R)^2 == 4*(alpha)^2 / (2*(alpha)^2 + 1) * acos(2*gamma) + ((2*(alpha)^2 - 1) * cos(2*gamma)) + (2*alpha*(asin(2*gamma) - sin(2*gamma)))
is it same with the attached equation or not, please?
If I use live editor with latex equation, it's same,
|R|^2 = \dfrac{4\alpha^2} {(2\alpha^2 + 1) cosh 2\gamma + (2\alpha^2 - 1) cos 2\gamma + 2\alpha (sinh 2\gamma - sin 2\gamma)}
but I haven't been successful to use it in the live editor, so I wrote it manually.
Thank you in advance
Note that tanh, sinh and cosh are the hyperbolic tangent, hyperbolic sine and hyperbolic cosine, not atan, asin and acos which are the inverse tangent, inverse sin and inverse cosine functions.
syms alpha gamma %R d
R = 0.08;
d = 1.4;
expr1 = R^2 == 4*alpha^2/((2*alpha^2+1)*cosh(2*gamma)+(2*alpha^2-1)*cos(2*gamma)+2*alpha*(sinh(2*gamma)-sin(2*gamma)))
expr1 =

expr2 = d == atan((tanh(2*alpha*tan(gamma)+1)+tan(gamma))/(tan(gamma)-tanh(gamma)+2*alpha))
expr2 =
sol = solve ([expr1,expr2] , [alpha, gamma])
Warning: Unable to solve symbolically. Returning a numeric solution using vpasolve.
sol = struct with fields:
alpha: 0.74245496926973860397234179524781
gamma: 2.627014792787395537585234942901
alphaSol = sol.alpha
alphaSol =
0.74245496926973860397234179524781
gammaSol = sol.gamma
gammaSol =
2.627014792787395537585234942901
christina widyaningtyas
on 29 Jul 2022
Thank you so much @Torsten
I still trying for others R and d values,
R = 0.022 to 0.12
d = 60 to 150
but the results are :
alphaSol = Empty sym: 0-by-1
gammaSol = Empty sym: 0-by-1
If I read, they said it might be because there isn't any solution to the equation
Torsten
on 29 Jul 2022
atan is between -pi/2 and pi/2. So I don't understand how "d" could be between 60 and150 - except you want to get complex solutions, maybe.
christina widyaningtyas
on 29 Jul 2022
actually d is phase difference in degree
Last time I use in radians, but it should be in degree
Torsten
on 29 Jul 2022
In your test equation, d was 7/5 which does not seem to be in degrees.
However: if you want to prescribe d in degrees, change
expr2 = d == atan((tanh(2*alpha*tan(gamma)+1)+tan(gamma))/(tan(gamma)-tanh(gamma)+2*alpha))
to
expr2 = d == atand((tanh(2*alpha*tan(gamma)+1)+tan(gamma))/(tan(gamma)-tanh(gamma)+2*alpha))
christina widyaningtyas
on 29 Jul 2022
I already tried that one @Torsten
I checked with substituting R = 0.07 and d = -135, they will give alpha = 0.15 and gamma 1.7
but, the results still
alphaSol =
Empty sym: 0-by-1
gammaSol =
Empty sym: 0-by-1
:((((((
Torsten
on 29 Jul 2022
Your equations cannot be solved symbolically for alpha and gamma. That's why MATLAB uses vpasolve to return a numerical solution.
christina widyaningtyas
on 30 Jul 2022
I tried :
%%
syms alpha gamma %R d
R = 0.07;
d = -135;
[sol_alpha, sol_gamma] = vpasolve([(R)^2 == 4*alpha^2/((2*alpha^2+1)*cosh(2*gamma)+(2*alpha^2-1)*cos(2*gamma)+2*alpha*(sinh(2*gamma)-sin(2*gamma))), d == atand((tanh(2*alpha*tan(gamma)+1)+tan(gamma))/(tan(gamma)-tanh(gamma)+2*alpha))], [alpha,gamma])
But :
- Undefined function 'atand' for input arguments of type 'sym'.
then, when I change atand to atan back to eror : sol_alpha = Empty sym: 0-by-1 ; sol_gamma = Empty sym: 0-by-1
Alex Sha
on 30 Jul 2022
Hi, Christina, if your equations are:
R = 0.08;
d = 1.4;
R^2 == 4*(alpha)^2 / ((2*(alpha)^2 + 1) * acos(2*gamma) + (2*(alpha)^2 - 1) * cos(2*gamma) + 2*alpha*(asin(2*gamma)) - sin(2*gamma))
d == atan((atan(2*alpha*tan(gamma) + 1)+ tan(gamma)) / (tan(gamma) - atan(gamma) + 2*alpha))
The results will be:
alpha: 0.0503567460786745
gamma: -0.234530822330344
While if your eauqtions are:
R = 0.08;
d = 1.4;
R^2 == 4*(alpha)^2 / ((2*(alpha)^2 + 1) * acos(2*gamma) + (2*(alpha)^2 - 1) * cos(2*gamma) + 2*alpha*(asin(2*gamma)) - sin(2*gamma))
(R)^2 == 4*(alpha)^2 / (2*(alpha)^2 + 1) * acos(2*gamma) + ((2*(alpha)^2 - 1) * cos(2*gamma)) + (2*alpha*(asin(2*gamma) - sin(2*gamma)))
then there will not be solution in real data type
christina widyaningtyas
on 30 Jul 2022
Thank you for your comment @Alex Sha
I run code :
%%
syms alpha gamma %R d
R = 0.07;
d = -135;
expr1 = (R)^2 == 4*alpha^2/((2*alpha^2+1)*cosh(2*gamma)+(2*alpha^2-1)*cos(2*gamma)+2*alpha*(sinh(2*gamma)-sin(2*gamma)))
expr2 = d == atan((tanh(2*alpha*tan(gamma)+1)+tan(gamma))/(tan(gamma)-tanh(gamma)+2*alpha))
sol = solve ([expr1,expr2] , [alpha, gamma])
alphaSol = sol.alpha
gammaSol = sol.gamma
also :
%%
syms alpha gamma %R d
R = 0.07;
d = -135;
[sol_alpha, sol_gamma] = vpasolve([(R)^2 == 4*alpha^2/((2*alpha^2+1)*cosh(2*gamma)+(2*alpha^2-1)*cos(2*gamma)+2*alpha*(sinh(2*gamma)-sin(2*gamma))), d == atand((tanh(2*alpha*tan(gamma)+1)+tan(gamma))/(tan(gamma)-tanh(gamma)+2*alpha))], [alpha,gamma])
I tried the code by substituting R (0.07) and d (-135 in degress) to check my code, it should be give alpha = 0.15 and gamma = 1.7
But still gives an errors
Walter Roberson
on 30 Jul 2022
Take the tand out of both sides of the second equation, so
tand(d) == tand(atand(Expression))
and simplify to
tand(d) == Expression
it makes it easier for vpasolve to find solutions
Torsten
on 30 Jul 2022
Seems there are several solutions to your equations:
R = 0.07;
d = -135;
fun = @(alpha,gamma)[4*alpha^2/((2*alpha^2+1)*cosh(2*gamma)+(2*alpha^2-1)*cos(2*gamma)+2*alpha*(sinh(2*gamma)-sin(2*gamma)))-R^2;...
(tanh(2*alpha*tan(gamma)+1)+tan(gamma))/(tan(gamma)-tanh(gamma)+2*alpha)-tand(d)];
options = optimset('TolFun',1e-8,'TolX',1e-8);
alpha0 = 0.15;
gamma0 = 1.7;
x0 = [alpha0,gamma0];
sol = fsolve(@(x)fun(x(1),x(2)),x0,options);
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
alpha = sol(1)
alpha = 0.1786
gamma = sol(2)
gamma = 1.7811
fun(alpha,gamma)
ans = 2×1
1.0e-11 *
0.0055
-0.7673
alpha0 = -0.4;
gamma0 = -2.3;
x0 = [alpha0,gamma0];
sol = fsolve(@(x)fun(x(1),x(2)),x0,options);
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
alpha = sol(1)
alpha = -0.3679
gamma = sol(2)
gamma = -2.3475
fun(alpha,gamma)
ans = 2×1
1.0e-08 *
-0.0013
0.1872
syms alpha gamma %R d
R = 0.07;
d = -135;
expr1 = R^2 == 4*alpha^2/((2*alpha^2+1)*cosh(2*gamma)+(2*alpha^2-1)*cos(2*gamma)+2*alpha*(sinh(2*gamma)-sin(2*gamma)));
expr2 = tand(d) == (tanh(2*alpha*tan(gamma)+1)+tan(gamma))/(tan(gamma)-tanh(gamma)+2*alpha);
[sol_alpha, sol_gamma] = solve([expr1,expr2], [alpha,gamma])
Warning: Unable to solve symbolically. Returning a numeric solution using vpasolve.
sol_alpha = 
sol_gamma = 
fun(double(sol_alpha),double(sol_gamma))
ans = 2×1
1.0e-15 *
-0.0017
0.4441
More Answers (0)
Categories
Find more on Linear Algebra in Help Center and File Exchange
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)