How to automate/solve this process in MATLAB

1 view (last 30 days)
Lets say that I have this equation in MATLAB: . I am trying to determine at what value of u will the equation yield complex solutions with the imaginary part for all those solutions being equal. For example, for this equation I gave, I know for a fact that there is at least 1 soution for u that makes all imaginary part of the solutions equal. I am so tired of performing this process by hand and graphing, but for the life of me cannot figure out how to make MATLAB efficiently do it.

Accepted Answer

Walter Roberson
Walter Roberson on 1 Nov 2023
Moved: Walter Roberson on 1 Nov 2023
syms s u
eqn = 1472*s^4 - 256*s^2*u^2 + 1392*s^2 - 24*u^2 + 150 == 0
eqn = 
sol = solve(eqn, s, 'maxdegree', 4)
sol = 
We can see by examination that and are both solutions. If had a non-zero imaginary component then would have an imaginary component that was the negative of the one for and therefore the system could not have all imaginary components equal. Likewise for which has the same situation.
Therefore for the imaginary components of the system to all be equal, the solutions must all be real-valued, and the question then becomes under what conditions and are both real-valued.
eqn2 = [sol(1)^2 > 0, sol(2)^2 > 0]
eqn2 = 
solu1 = solve(eqn2(1) + eqn2(2), u, 'returnconditions', true)
solu1 = struct with fields:
u: [2×1 sym] parameters: x conditions: [2×1 sym]
solu1.u
ans = 
solu1.conditions
ans = 
vpa(solu1.conditions)
ans = 
solu2 = solve(eqn2(1) - eqn2(2), u, 'maxdegree', 4, 'returnconditions', true)
solu2 = struct with fields:
u: z parameters: z conditions: (2*imag(z^2))/23 - imag((256*z^4 - 2232*z^2 + 4119)^(1/2))/184 == 0 & (z < -87^(1/2)/4 | 87^(1/2)/4 < z)
solu2.u
ans = 
z
solu2.conditions
ans = 
The z < and z > bounds for solu1 and solu2 are the same -- those are simple bounds.
But is there a z (also known as u) such that 256*z^4 - 2232*z^2 + 4119 is real and negative?
syms z real
rr = 256*z^4 - 2232*z^2 + 4119
rr = 
solz = solve(rr, 'real', true, 'maxdegree', 4)
solz = 
vpa(solz)
ans = 
If we compare the second of those results, 2.46-ish to the simple bound for u, about 2.33-ish, then we can deduce that there might be
u2 = vpasolve(children(solu2.conditions, 1), solz(2))
u2 = 
2.4630284291817806857810551476394
backcheck1 = subs(solu2, solu2.parameters, u2)
backcheck1 = struct with fields:
u: 2.4630284291817806857810551476394 parameters: 2.4630284291817806857810551476394 conditions: (2.4630284291817806857810551476394 < -87^(1/2)/4 | 87^(1/2)/4 < 2.4630284291817806857810551476394) & 0.0 == 0
simplify(backcheck1.conditions)
ans = 
symtrue
backcheck2 = subs(solu2, solu2.parameters, u2-1/100)
backcheck2 = struct with fields:
u: 2.4530284291817806857810551476394 parameters: 2.4530284291817806857810551476394 conditions: (2.4530284291817806857810551476394 < -87^(1/2)/4 | 87^(1/2)/4 < 2.4530284291817806857810551476394) & -0.035367965693993714188628736710893 == 0
simplify(backcheck2.conditions)
ans = 
symfalse
backcheck3 = subs(solu2, solu2.parameters, u2+1/100)
backcheck3 = struct with fields:
u: 2.4730284291817806857810551476394 parameters: 2.4730284291817806857810551476394 conditions: (2.4730284291817806857810551476394 < -87^(1/2)/4 | 87^(1/2)/4 < 2.4730284291817806857810551476394) & 0.0 == 0
simplify(backcheck3.conditions)
ans = 
symtrue
u3 = solz(2);
backcheck4 = subs(solu2, solu2.parameters, u3)
backcheck4 = struct with fields:
u: (11937^(1/2)/64 + 279/64)^(1/2) parameters: (11937^(1/2)/64 + 279/64)^(1/2) conditions: 0 == 0 & ((11937^(1/2)/64 + 279/64)^(1/2) < -87^(1/2)/4 | 87^(1/2)/4 < (11937^(1/2)/64 + 279/64)^(1/2))
simplify(backcheck4.conditions)
ans = 
symtrue
backcheck5 = subs(solu2, solu2.parameters, u3-1/100)
backcheck5 = struct with fields:
u: (11937^(1/2)/64 + 279/64)^(1/2) - 1/100 parameters: (11937^(1/2)/64 + 279/64)^(1/2) - 1/100 conditions: (87^(1/2)/4 < (11937^(1/2)/64 + 279/64)^(1/2) - 1/100 | (11937^(1/2)/64 + 279/64)^(1/2) - 1/100 < -87^(1/2)/4) & -(2232*((11937^(1/2)/64 + 279/64)^(1/2) - 1/100)^2 - 256*((11937^(…
simplify(backcheck5.conditions)
ans = 
symfalse
backcheck6 = subs(solu2, solu2.parameters, u3+1/100)
backcheck6 = struct with fields:
u: (11937^(1/2)/64 + 279/64)^(1/2) + 1/100 parameters: (11937^(1/2)/64 + 279/64)^(1/2) + 1/100 conditions: (87^(1/2)/4 < (11937^(1/2)/64 + 279/64)^(1/2) + 1/100 | (11937^(1/2)/64 + 279/64)^(1/2) + 1/100 < -87^(1/2)/4) & 0 == 0
simplify(backcheck6.conditions)
ans = 
symtrue
So the actual bounds are +/- solz(2) -- that outside that range, the imaginary components of eqn should all be 0 and so should all be equal as required.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!