Getting complex solutions from solve in SymPy.jl

question

#1

Paraphrased from SymPy Issue #150.


Description:

I’m trying to get a real solution from 4 complex solutions that encircle it.

What I’m trying to do is take the norm of the 4 solutions and scale it.

However the scaling turns the value back into a complex number.

Is there a way to have my cake and eat it too? // get the real solution


edit: i’m now investigating non-norm scaling options


#2

Summarized:

cur_ignition_requirement = ignition_requirement()

cur_R_0 = symbol_dict["R_0"]

solved_system = SymPy.solve(cur_ignition_requirement, cur_R_0)

returns

-I*(-1.15+29*B_0^0.15*T_k^0.96*sigma_v_hat*(1/(-17.0*sigma_v_hat + 19))^0.93/(-8.88+37*T_k*sigma_v_hat^0.69*(-1/(88.0*sigma_v_hat - 98))^0.97 + 7.9+37*T_k*sigma_v_hat^1.69*(-1/(88.0*sigma_v_hat - 98))^0.97) + 3.43297327500117e+26*B_0^0.15*T_k^1.46*(1/(-17.0*sigma_v_hat + 19))^0.93/(-8.88+37*T_k*sigma_v_hat^0.69*(-1/(88.0*sigma_v_hat - 98))^0.97 + 7.9+37*T_k*sigma_v_hat^1.69*(-1/(88.0*sigma_v_hat - 98))^0.97))^(25/4)
I*(-1.15+29*B_0^0.15*T_k^0.96*sigma_v_hat*(1/(-17.0*sigma_v_hat + 19))^0.93/(-8.88+37*T_k*sigma_v_hat^0.69*(-1/(88.0*sigma_v_hat - 98))^0.97 + 7.9+37*T_k*sigma_v_hat^1.69*(-1/(88.0*sigma_v_hat - 98))^0.97) + 3.43297327500117e+26*B_0^0.15*T_k^1.46*(1/(-17.0*sigma_v_hat + 19))^0.93/(-8.88+37*T_k*sigma_v_hat^0.69*(-1/(88.0*sigma_v_hat - 98))^0.97 + 7.9+37*T_k*sigma_v_hat^1.69*(-1/(88.0*sigma_v_hat - 98))^0.97))^(25/4)
-(-1.15+29*B_0^0.15*T_k^0.96*sigma_v_hat*(1/(-17.0*sigma_v_hat + 19))^0.93/(-8.88+37*T_k*sigma_v_hat^0.69*(-1/(88.0*sigma_v_hat - 98))^0.97 + 7.9+37*T_k*sigma_v_hat^1.69*(-1/(88.0*sigma_v_hat - 98))^0.97) + 3.43297327500117e+26*B_0^0.15*T_k^1.46*(1/(-17.0*sigma_v_hat + 19))^0.93/(-8.88+37*T_k*sigma_v_hat^0.69*(-1/(88.0*sigma_v_hat - 98))^0.97 + 7.9+37*T_k*sigma_v_hat^1.69*(-1/(88.0*sigma_v_hat - 98))^0.97))^(25/4)
(-1.15+29*B_0^0.15*T_k^0.96*sigma_v_hat*(1/(-17.0*sigma_v_hat + 19))^0.93/(-8.88+37*T_k*sigma_v_hat^0.69*(-1/(88.0*sigma_v_hat - 98))^0.97 + 7.9+37*T_k*sigma_v_hat^1.69*(-1/(88.0*sigma_v_hat - 98))^0.97) + 3.43297327500117e+26*B_0^0.15*T_k^1.46*(1/(-17.0*sigma_v_hat + 19))^0.93/(-8.88+37*T_k*sigma_v_hat^0.69*(-1/(88.0*sigma_v_hat - 98))^0.97 + 7.9+37*T_k*sigma_v_hat^1.69*(-1/(88.0*sigma_v_hat - 98))^0.97))^(25/4)

// i.e. -I*blah, +I*blah, -1*blah, +1*blah


I want to get a real solution from this, by doing:

1st:

an_eq = norm(solved_system)

2nd:

a_constant = -0.8918
an_eq *= a_constant

The constant, a_constant, was chosen to make an_eq the correct value after substitutions are made.

However, when actually doing the scaling, a complex number comes out of the substituted mess.


I’d appreciate any help. Please ask me to clarify anything that doesn’t make sense.


#3

i’ve been thinking about it and maybe the problem stems from not simplifying:

-2282.55434896033*(1/(-175329.0*sigma_v + 196349.540849362))^(93/100)/(sigma_v^(69/100)*(-1/(87664500000000.0*sigma_v - 98174770424681.0))^(97/100)*(87664500000000.0*sigma_v - 98174770424681.0))

Do you know how this could be done? I’ve been trying the slew of SymPy methods, but can’t get any of them to work.

One thing I’d really like is to do is a collect on:

collect_symbol = ( 1 - K_CD() * sigma_v )