Jeremy,
Now that I am thinking about it... I understand that the cube root of p5 doesn't have to be imaginary... I just had to switch the P5 term to a negative because Qlarity would give an error when I would try to do a cube root on a negative.
If I incorporate your method in to my code as follows:
Code:
p1=(1/(6*power(2,(1.0/3.0))*dur))*(1-SQRT(3))
p2=(-2*power(dist,3))-(6*MA*power(dist,2))-(6*dist*power(MA,2))-(2*power(MA,3))+(6*power(dist,2)*MD)+(12*dist*MA*MD)+(6*power(MA,2)*MD)-(6*dist*power(MD,2))-(6*MA*power(MD,2))+(2*power(MD,3))+(18*dist*MA*dur*initspeed)+(18*power(MA,2)*dur*initspeed)-(18*MA*MD*dur*initspeed)-(27*MA*power(dur,2)*power(initspeed,2))
p3=(4*power(((6*MA*dur*initspeed)-power(dist+MA-MD,2)),3))
p4=SQRT((p3+power(p2,2)))
tmp=(p2+p4)
if tmp < 0 then
p6 = -power(-tmp, 1.0/3.0)
else
p6 = power(tmp, 1.0/3.0)
endif
... I get a value for P6 of -1475.23 using the sample values given in the code I posted previously...
resulting from -power(-(p2+p4), 1.0/3.0) :
(p2) =-3373920000
(P4)= 9120000*Sqrt[321])^(1/3)
The problem is that when I use Mathematica to evaluate (p2+p4)^1/3 I get:
737.613 + 1277.58 i
...a complex number containing a real number component and an imaginary number component. Now since this is all beyond me, I naturally turn to Wikipedia where I learn that all cube roots of non zero real numbers have 1 real cube root and a pair of complex conjugate roots.
Since Mathematica returns the correct answer in the end for the whole formula, I assume that I must be using this complex number root. Now if I can only determine how this complex root is obtained and write it up in Qlarity, somehow handling the imaginary unit produced, along with the imaginary units already present in the source formula, I'll be set!
Any ideas?