Failure to solve symbolic equations in the form 'A*sin(x) + B*cos(x) == C'
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Gorkem
am 7 Mär. 2018
Beantwortet: John D'Errico
am 7 Mär. 2018
Left hand side of this equation is known to admit A*sin(x) + B*cos(x) = R*cos(x-alpha) with R = sqrt(A^2+B^2) and alpha = arctan(b/a). and x can be solved using this identity.
(see http://www.mathcentre.ac.uk/resources/uploaded/mc-ty-rcostheta-alpha-2009-1.pdf for derivation).
However, MATLAB never finds the solution to x symbolically. It either looks for complex solutions (though I define everything to be real and positive) or returns really complicated expressions or returns an empty solution.
What's the best way to deal with these kind of equations?
--------------------------------------------------------
here is a sample code for the most general case:
syms a b c x real;
S = solve(a*sin(x) + b*cos(x) == c, x);
This returns an empty solution
1 Kommentar
Akzeptierte Antwort
John D'Errico
am 7 Mär. 2018
I would point out that for SOME values (ok, many) of {a,b,c}, there is no real solution. So if you specify that all are real, including x, then what can you expect?
If abs(c)/sqrt(a^2 + b^2) is greater than 1, no real solution can exist.
I'll admit, I'd probably be lazy and just do the thinking for MATLAB here.
syms u
syms a b c real
S = solve(a*u + b*sqrt(1-u^2) == c,u)
S =
(a*c + b*(a^2 + b^2 - c^2)^(1/2))/(a^2 + b^2)
(a*c - b*(a^2 + b^2 - c^2)^(1/2))/(a^2 + b^2)
And we know that x = asin(u).
Sometimes symbolic solvers need to be gently coaxed down a reasonable path.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!