Doing 'log' maths without a log function

Hi, This is probably more of a maths question than a programming question, but how do I do log mathematics without a log function?

I want to write a function to convert pressure to altitude, the formula I found (after a lot of searching) includes log maths, is there a way of doing this without a log function?

The function can be seen here (it's the 2nd function on the page)....

Most of it seems pretty simple, but how do I get around the log bit?

Cheers

It would depend on the accuracy. You could do a look up table for a range of values from 0..1. The better the accuracy, the more values in the table. This type of look up table is used a lot for trig functions.

log10() is part of math.h. Is there a reason you cannot use that?

And if you have to resort to a lookup table, remember to use the progmem/flash RAM to store it, not SRAM. However, I would check out math.h first. Potentially a quicker way to get the job done.

This seems to work pretty close to what the table shows

void setup() {

double Alt;
double PF= 450;
double PS=1013;
double div = -6.8755856E-6;
Serial.begin(9600); 
  
  double param, result;
  param = log10 (PF/PS);
  result = pow(10,param/5.255856)-1 ;
  Alt = result/div;
  Serial.println (Alt );

}

void loop() {

  //do nothing
  
}

log10() is part of math.h. Is there a reason you cannot use that?

I've not used that library before, I checked the language reference page Arduino - Home, I didn't think of checking for a library.

I'll flush my head down the loo a couple of times to punish myself!

Thanks guys!