Failure to solve symbolic equations in the form 'A*sin(x) + B*cos(x) == C'

6 次查看(过去 30 天)
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.
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

采纳的回答

John D'Errico
John D'Errico 2018-3-7
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 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by