Help with power function in a Maths Expression

Discussion and support for i2 Standard and i2 Pro applications

Help with power function in a Maths Expression

Postby moc on Tue Oct 22, 2013 9:05 pm

I'm trying to create a Math channel in I2 PRO that will display a boost value taking the altitude into consideration.

The formula for this is:

boost = manifold pressure - atmospheric pressure

To estimate atmospheric pressure at a given altitude you can use this formula:
(kPa at sea level * e ^ -(altitude/7000)*100)

which at Wakefield would be:
(1.01 * 2.7182818285 ^ -(661/7000)*100) = 91.925 kPa

So I attemted to create a Maths channel in I2 PRO like this:
power(1.01*2.7182818285,-1*('GPS Altitude' [m])/7000)*100

and it tells me that the expression is invalid. So I attempted this:
power(1.01*2.7182818285,-661/7000)*100

which I2 will happily resolve to the wrong value. Assuming there was a problem with negative exponents with the power function I tried to create a simple unitless expression to 4 decimal places like this:
power(10,-2)

The result I get is 0 not 0.01. So getting desperate I tried:
1/power(10,2)

and I still got 0 as the result. Getting even more desperate I tried:
1/10/10

and I still got 0 as a result.

Does anyone know what is going on here? There must be some sort of rounding issue I'm not seeing as I2 thinks 3/2 = 1.0000
moc
 
Posts: 3
Joined: Wed Jul 16, 2008 6:53 pm

Re: Help with power function in a Maths Expression

Postby MattW on Thu Nov 21, 2013 10:41 am

Hi moc,

Don't know why this wasn't answered sooner, so sorry for the delay.

There a a few issues here, some in the logic and some the way i2 does it's integer maths.
The problem is if you feed it all integers it's result will be an integer.
The simple solutions to put .0
e.g
power(10,-2) gives the result 0.00
power(10,-2.0) gives the result 0.02
2/3 gives the result 0.00 (Integer maths always rounds down, even from .99)
2/3.0 gives the result 0.67

So this fix, combined with re-ordering your maths a little (brackets, then power, then multiplication) and we get the correct result.

1.01*power(2.7182818285,-(661.0/7000))*100
MattW
 
Posts: 30
Joined: Thu May 17, 2012 11:17 am

Re: Help with power function in a Maths Expression

Postby moc on Thu Nov 21, 2013 11:56 pm

Thanks Matt,

That explains a few things and I can now get this to work: 1.01*power(2.7182818285,-(661/7000.0))*100

However this: 1.01*power(2.7182818285,-('GPS Altitude' [m]/7000.0))*100 gives me an expression invalid error.

Can you please point me in the right direction again?

Regards,

Mark
moc
 
Posts: 3
Joined: Wed Jul 16, 2008 6:53 pm


Return to i2 Data Analysis Software

Who is online

Users browsing this forum: No registered users and 9 guests