 # Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
 It is currently Thu Aug 22, 2019 4:37 am

 All times are UTC - 7 hours  Page 3 of 3 [ 33 posts ] Go to page Previous  1, 2, 3
 Print view Previous topic | Next topic
Author Message
 Post subject: Re: Long equations...imaginary numbers? Posted: Tue Nov 29, 2011 6:58 am QSI Support  Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Keep in mind that i * i = -1. You can keep both imaginary and real terms around. When you have to multiply two complex numbers, you follow the basic algebra formula you learned in school

(x1 + y1i) * (x2 + y2i) => x1*x2 + -1*(y1*y2) + (x1*y2 + x2*y1)i.

I did that from memory, so double check it. The hope becomes that x1*y2 = -x2*y1 so that you get 0i and have only the real term left.

_________________
Jeremy
http://www.beijerinc.com

Top Post subject: Re: Long equations...imaginary numbers? Posted: Tue Nov 29, 2011 1:36 pm Joined: Thu Aug 09, 2007 4:44 pm
Posts: 67
Jeremy,

I solved it! I have the code working now and it seems to mirror Mathematica's output in the sample situations I have tried so far. It's hard to explain exactly what I did because I only somewhat understand... but I followed how mathematica broke down the equation piece by piece, watching to see when the i imaginary numbers disappeared. The trick seems to be to keep the (1-i*SQRT(3)) and (1+i*SQRT(3)) portions of the equation seperate, as they are used to cancel out the "i" that would have resulted from the cubed root of (p2+p4).

p5a and p5b are the two values that make up the complex number that results from the cubed root. I noticed that when mathematica multiplied this complex number by (1-i*SQRT(3)) the result was the same as if p5b had been multiplied by 3 instead of SQRT(3), and the "i" number disappeared. So the "i"'s canceled each other out, and the square root signs canceled each other out. So i never even included the (1-i*SQRT(3)) portion of the equation in what I wrote up in Qlarity, I just modified p5b accordingly when I incorporated it in to p6.

That might not be the clearest explanation, but here is the working code. p13 is the value (Vs) I was looking to solve for in the original equation.

Code:
p1=(1/(6*power(2,(1.0/3.0))*dur))
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
p5 = power(-tmp, 1.0/3.0)
else
p5= power(tmp, 1.0/3.0)
endif
p5a= p5/2
p5b= ((p5/2)*SQRT(3))
p6 = p5/2+((p5/2)*3)

p7=(dist+MA-MD)/(3*dur)
p8=((6*MA*dur*initspeed)-power(dist+MA-MD,2))
p9=(3*power(2,(2.0/3.0))*dur)
p10=p8/p9
p11=1+SQRT(3)
p12=p5a+p5b
p13=(p1*p6)+(p7-(p10*(p11/p12)))

Thanks for all your help on this Jeremy!

Top Post subject: Re: Long equations...imaginary numbers? Posted: Tue Nov 29, 2011 4:08 pm QSI Support  Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Congratulations. Glad you were able to get that working.

_________________
Jeremy
http://www.beijerinc.com

Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending  Page 3 of 3 [ 33 posts ] Go to page Previous  1, 2, 3

 All times are UTC - 7 hours

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ Beijer Electronics News and Press    Press Releases    Qlarity News    TREQ News Beijer Electronics Support    Qlarity FAQ    Qlarity Software Support    Qlarity Code Samples       Ethernet       File System       Keypad       Modbus       Language    Qlarity-based Terminal Hardware    iX Support    Windows CE Terminal FAQ    Windows CE Terminal Support    QTERM-G56/G58 with Windows CE    General Beijer Electronics Support Beijer Electronics Forums Information    Forum Support Internal Discussions    Qlarity II / Qlarity 3.0    Production Test Powered by phpBB® Forum Software © phpBB Group