03-26-2002 08:23 PM
03-27-2002 11:30 AM
02-13-2007 01:45 PM
Following the question above, is there anyway of outputting a complex number from a formula node? Whenever I try it (for example as shown in the VI attached) I get a NaN even if the indicator is defined as a complex single. Is there any way of getting an imaginary result from a formula node then? The answer to the equation in the sample VI should be 3i but I am not getting that out.
Thanks for your help
02-13-2007 05:03 PM
02-14-2007 05:10 AM
02-14-2007 10:10 AM
02-14-2007 11:44 AM - edited 02-14-2007 11:44 AM
@chevinator wrote:
I would like to enter the following into a forumla node - exp(j*x) where j is the square root of -1
Don't underestimate the power of LabVIEW!
"Exp" is an atomic function that works correctly with complex inputs. There is no reason to use a formula node at all.
Simply feed your complex number to the "exponential" function and you're all set! 😄
(If you want to to textual complex math, upgrade to LabVIEW 8.0 and use a Mathscript node ;))
Message Edited by altenbach on 02-14-2007 09:46 AM
07-11-2013 08:32 AM - edited 07-11-2013 08:34 AM
Dear altenbach,
it is not about computing any (complex) value with a LabVIEW primitive, but to get the formula node to calculate/evaluate complex values specifically. The formula node cannot be combined with LabVIEW primitives, can it? And one cannot implement/write a complex value in the formula node, i.e., there is no function for it. Search for "Formula Node and Expression Node Functions" in any LabVIEW help.
And indeed, the square root primitive chokes in negative numbers (i.e., the result is NaN).
Kind regards
07-11-2013 09:27 AM
Why this response to a 6 1/2 year old thread?
Correct, formula nodes don't handle complex numbers.
But you don't need formula nodes when LabVIEW primitives will work. Square root DOES work on -1 as long as you properly define the control/wire going into the function as a complex double representation as well as the indicator coming out of it.
07-11-2013 10:19 AM - edited 07-11-2013 10:24 AM
Dear RavensFan,
thank you for your post.
There is a reason why formula nodes and formula strings exist. And they do not allow for evaluating complex numbers. That is a state-of-art in LV12 and lower. Answering, that the user can solve it with a complex-friendly primitive does not change this fact.
My personal example is a "Downhill Simplex nD.vi", which theoretically allows for optimising a real 2D function f(DBL1,DBL2)=DBL, but it does not allow solving complex function f(CDB)=DBL. Some CDB functions are just too complex to be separated to f(DBL1,DBL2) (where CDB=DBL1+iDBL2).
In the above example, one could possibly change the operation 34 in the following file:
C:\Program Files (x86)\National Instruments\LabVIEW 2012\vi.lib\gmath\parser.llb\Three Register Calculation.VI
but sqrt does not allow for "DBL -> sqrt -> CDB" conversion. So, your suggestion cannot be implemented.
Kind regards
p.s. This thread is not LV-version dependent and the question is not answered or is unclear, IMHO. Therefore, I decided to post and update. Please, suggest automatic locking of threads older than X years to administrators of the forum, if you feel there is a need for it.