windchill formula uses exponents, how do we do that?

the windchill formula uses exponents

Windchill  = 35.74 + 0.6215*T - 35.75(V^0.16) + 0.4275*T(V^0.16);

where T is temperature
V is wind speed
^0.16 is an exponent.
this is the layout from the nws site but ofcourse the ^0.16 is giving errors on compile, can someone help me please?

pow(V, 0.16f);

most awesome of you. thank you very much JarkkoL.

for reference, works fine tested with nws windchill calculator
the 2 float values temperature and windspeed are just test numbers, i dont have an anemometer? yet.

void setup(){
Serial.begin(9600);
float T=49;
float V=10;

float Windchill  = 35.74 + 0.6215*T - 35.75*pow(V,0.16) + 0.4275*T*pow(V,0.16);
Serial.print(Windchill);

}

void loop(){}

grendle:
the windchill formula uses exponents

Windchill  = 35.74 + 0.6215*T - 35.75(V^0.16) + 0.4275*T(V^0.16);

where T is temperature
V is wind speed
^0.16 is an exponent.
this is the layout from the nws site but ofcourse the ^0.16 is giving errors on compile, can someone help me please?

As 35.74 and 35.75 are very nearly equal, this formula could be rewritten as
Windchill = 35.74(1 - (V^0.16)) + T((0.4275(V^0.16)) + 0.6215) with very little error.

Henry_Best:

grendle:
the windchill formula uses exponents

Windchill  = 35.74 + 0.6215*T - 35.75(V^0.16) + 0.4275*T(V^0.16);

where T is temperature
V is wind speed
^0.16 is an exponent.
this is the layout from the nws site but ofcourse the ^0.16 is giving errors on compile, can someone help me please?

As 35.74 and 35.75 are very nearly equal, this formula could be rewritten as
Windchill = 35.74(1 - (V^0.16)) + T((0.4275(V^0.16)) + 0.6215) with very little error.

much appreciated henry, thank you kindly. i will certainly experiment with this info XD

Ans as V^0.16 is used twice one could store it in a variable so it can be reused iso recalculated.

this prints a lookup table for diff values of T and V

void setup()
{
  Serial.begin(115200);

  for (int T = 0; T < 100; T++)
  {
    for (int V = 0; V < 15; V++)
    {
      float tt = pow(V, 0.16);
      float Windchill  = 35.74 + 0.6215*T - 35.75*tt + 0.4275*T*tt;
      Serial.print(Windchill);
      Serial.print("\t");
    }
    Serial.println();
  }
}

void loop()
{
}

robtillaart:
Ans as V^0.16 is used twice one could store it in a variable so it can be reused iso recalculated.

this prints a lookup table for diff values of T and V

void setup()

{
  Serial.begin(115200);

for (int T = 0; T < 100; T++)
  {
    for (int V = 0; V < 15; V++)
    {
      float tt = pow(V, 0.16);
      float Windchill  = 35.74 + 0.6215T - 35.75tt + 0.4275Ttt;
      Serial.print(Windchill);
      Serial.print("\t");
    }
    Serial.println();
  }
}

void loop()
{
}

very nice Rob, im gonna have to start paying you lol thats twice you rescued me from math :D. this is sweet and this is the format im gonna use. thank you.

Please note that tt = pow(V, 0.16); is called 1500 times in the above example for only 15 different values, that is rather inefficient math - but yes it could be worse :wink:

Please note that tt = pow(V, 0.16); is called 1500 times in the above example for only 15 different

I'm pretty sure that the compiler would notice that, too. In the machine code, that would have been moved out of the inner loop, since in that loop the value never changes. Unless V or tt are marked volatile.

I'm pretty sure that the compiler would notice that, too. In the machine code, that would have been moved out of the inner loop, since in that loop the value never changes. Unless V or tt are marked volatile.

V changes in the inner loop, thats why it is called 1500 times see code below

int x = 0;

void setup()
{
  Serial.begin(115200);

  for (int T = 0; T < 100; T++)
  {
    for (int V = 0; V < 15; V++)
    {
      float tt = pov(V);
      Serial.print(tt);
      Serial.print("\t");
    }
    Serial.println();
  }
  Serial.println(x);
}

void loop()
{
}

float pov(float V)
{
  x++;
  return V * V;
}

This would be more efficient;

float lookupPow[15];

void setup()
{
  Serial.begin(115200);

  // fill the lookup array
  for (int V = 0; V < 15; V++)
  {
    lookupPow[V] = pow(V, 0.16);
  }

  for (int T = 0; T < 100; T++)
  {
    for (int V = 0; V < 15; V++)
    {
      float tt = lookupPow[V];
      float Windchill  = 35.74 + 0.6215*T - 35.75*tt + 0.4275*T*tt;
      Serial.print(Windchill);
      Serial.print("\t");
    }
    Serial.println();
  }
}

void loop()
{
}

there are more optimizations possible but they are outside the scope of this thread.