From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculations with long equations

Solved!
Go to solution

You can further simplify the "pure" LabVIEW  code as shown below. One of the nice things about the Compound Arithmetic node is that you can invert the inputs independently.

Example_VI_JTR.png

Message 11 of 17
(940 Views)

@Yamaeda wrote:

10M loops yields ~700 vs ~100ms (formula node in other case). So no, it's not noticable in a single run. But as i said, if the requirements are such that'll run many times in a tight loop, a factor of 8 is noticable. 🙂


Wow.  I saw closer to a 10x difference.  However, I think it is due to constant folding with the equation you supplied and the Formula Node is not able to do that.  I will have to find time to mess around with it (which might not be hard since I am mostly just waiting for an FPGA to compile).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 12 of 17
(934 Views)

@crossrulz wrote:

@Yamaeda wrote:

10M loops yields ~700 vs ~100ms (formula node in other case). So no, it's not noticable in a single run. But as i said, if the requirements are such that'll run many times in a tight loop, a factor of 8 is noticable. 🙂


Wow.  I saw closer to a 10x difference.  However, I think it is due to constant folding with the equation you supplied and the Formula Node is not able to do that.  I will have to find time to mess around with it (which might not be hard since I am mostly just waiting for an FPGA to compile).


Well, it looks like I was mostly right.  I moved the pi^2 and sqrt(2) out of the Formula Node and the times more mostly comparable.  The "pure" code still has a slight advantage, but not enough that I am going to do statistical analysis on it.

 

So in summary, using the actual math functions are likely to give you faster results than the Formula Node due to constant folding and parallelism.  Enough to worry?  Well, that depends on your application.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 13 of 17
(921 Views)

Interesting discussion overall. I am still searching for any "long equation", though. 😁

 

(I've seen equations that had to be wrapped to multiple lines in a publication 🐵

0 Kudos
Message 14 of 17
(886 Views)

@Alexis_Koul wrote:

 

I am giving an example of the formula: X,Y,Z and C are my input data from the sensors and 120,12,50 and 30 are constants

A = (120*pi*X)/(12*Y) + (Z*50)/(C+30)


Am I missing something or shouldn't you just cancel the 120 and 12 into 10?  Or are those just example constants and sometimes they don't cancel and you put them in the example anyway?

0 Kudos
Message 15 of 17
(851 Views)

Hello,

The equation that I wrote is a smaller example of what I have in mind 😀

0 Kudos
Message 16 of 17
(843 Views)

I assumed it had something to do with constant folding also, and it rather shows the optimization of LV.

Changing Everything to variables it's less than a factor 2 difference.

FormulaNode2.png

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 17 of 17
(799 Views)