Solve two equations for unknown

4 visualizzazioni (ultimi 30 giorni)
Philip Hoskinson
Philip Hoskinson il 1 Set 2016
Commentato: Philip Hoskinson il 19 Gen 2017
I need to find the possible solutions for (x) using the following equations:
(Where A,B,C are some numbers)
0 = A + B*cos(x) + C*sin(x)
1 = cos^2(x) + sin^2(x)
I looked through the solve functions to no avail

Risposte (2)

Star Strider
Star Strider il 1 Set 2016
Modificato: Star Strider il 2 Set 2016
You have 1 equation in 3 unknowns, since the second equation is an identity. There are an infinity of solutions for ‘A’, ‘B’, and ‘C’, especially since ‘x’ is not constrained.
EDIT Even if ‘A’, ‘B’, and ‘C’ are known, there remain an infinity of solutions for ‘x’, since the result is periodic.
For example, for any initial angle ‘x’ and specified constant values of ‘B’ and ‘C’, ‘A’ will always be the same, while ‘x’ varies with a periodicity of ±2*pi:
x = 2*pi/7;
xv = x : 2*pi : 50*x;
A = B*cos(xv) + C*sin(xv)
So there are an infinity of solutions for ‘x’.

John D'Errico
John D'Errico il 1 Set 2016
Modificato: John D'Errico il 1 Set 2016
Not possible.
You have two equations, one of which contains some values for A,B,C. Assume they are not unknowns, but fixed values.
The second equation is a bit problematic though. You need to recognize that it is an IDENTITY, true for ALL possible values of X. You might as well have written the equation
1 = 1
In fact, effectively, you HAVE written that equation!
Therefore, you are asking to find all possible solutions to the equation
0 = A + B*cos(x) + C*sin(x)
There are infinitely many solutions. (Or there may be no real solutions.) Lets try an example so you can understand what happens.
format long g
>> A = rand
A =
0.978364201483333
>> B = 1 + rand
B =
1.0437523628799
>> C = 1 + rand
C =
1.39727633041192
>> syms x
>> xres = vpa(solve(0 == A + B*sin(x) + C*cos(x),x))
xres =
2.8079188393389282644048170234206 + 1.8367099231598242312011508394098e-40i
- 1.5247741492421242379557340733022 - 1.8367099231598242312011508394098e-40i
>> xres = real(xres)
xres =
2.8079188393389282644048170234206
-1.5247741492421242379557340733022
So solve found a pair of solutions. We can ignore the tiny imaginary part as floating point trash.
But in fact there are infinitely many solutions. Think of them as the primary solutions. All possible solutions are given as
xres + 2*n*pi
for any integer value of n, positive, negative, or zero. So, pick ANY integer value for n:
n = 4;
>> A + B*sin(xres+2*pi*n) + C*cos(xres + 2*pi*n)
ans =
0
-1.3775324423698681734008631295573e-40
The second is zero too, since the e-40 exponent is floating point trash.
So, you CAN solve the problem, as long as you understand that the second equation is useless, and that there are infinitely many solutions, and you understand how to characterize the infinitely many solutions.
  3 Commenti
John D'Errico
John D'Errico il 3 Set 2016
Modificato: John D'Errico il 3 Set 2016
I'm sorry, but did you not read my answer? I showed you how to solve for two solutions. In fact, I showed you how to solve for infinitely many solutions. More so, I chose three arbitrary values for A,B,C, then I solved the problem, yielding two solutions. Then I showed how to compute all possible solutions from that infinite set. So what is the question here? READ WHAT I WROTE ABOVE!
The identity that you want to use is not relevant if you are using MATLAB. Yes, it will be useful IF you are using pencil and paper to solve the problem. Is this question about MATLAB? If not, then your question is off-topic on Answers.
Philip Hoskinson
Philip Hoskinson il 19 Gen 2017
My comment was supposed to be an edit, it loaded after your response apparently.
I'm working with your answer now.
Thanks...........

Accedi per commentare.

Categorie

Scopri di più su Mathematics in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by