Math.pow for power of a number

Hello All,

I am trying to do this equation in a function Node -

RAW = sensor value = w. I am writing it like this -

var VWC = 6.771 * math.pow(10, -10) * math.pow(w, -3)-5.105 * math.pow(10, -6) * math.pow(w, 2) + 1.302 * math.pow(10, -2) * w -10.848;

and it is returning this error -

ReferenceError: math is not defined (line 3, col 19)

This is the full script in the function node -

var w = msg.payload.col14;

var VWC = 6.771 * math.pow(10, -10) * math.pow(w, -3)-5.105 * math.pow(10, -6) * math.pow(w, 2) + 1.302 * math.pow(10, -2) * w -10.848;

msg.payload=VWC
return msg;

Does anyone possibly know if I'm close or a million miles away?

If anyone knows how to fix it would be fantastic.

JavaScript is case sensitive.

Math.pow()

1 Like

Thank you very much!!!!

Worked straight away.

1 Like

Alternate option is using the exponentiation operator. That's ** ... I was doing exponents just last week and first tried with Math.pow (which works fine) but found it simpler to just use the double asterisk. Could be easier to read your long equation with this...

So 4^8 would just be 4 ** 8 Instead of Math.pow(4, 8)

2 Likes

Nice. Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.