Howto calculate ln(x) with arduino?
Moderators: adafruit_support_bill, adafruit

Howto calculate ln(x) with arduino?

by Northriver on Thu Feb 04, 2010 8:41 am

Hi,

I´am doing a weather station using arduino.

I need to calculate ln(x)

How do I write the code to calculate ln(x)?

Best regards
Northriver
Northriver
 
Posts: 3
Joined: Thu Feb 04, 2010 8:32 am

Re: Howto calculate ln(x) with arduino?

by bastard on Thu Feb 04, 2010 9:18 am

Read the manual:

The AVR math library, which is included in your sketch by using the line

#include <math.h> // (no semicolon)

Includes a great number of useful mathematical functions, including trigonometric, and logarithmic functions.

[...]

Bye

Stefan
bastard
 
Posts: 54
Joined: Tue Aug 25, 2009 6:10 am
Location: Germany, Bavaria

Re: Howto calculate ln(x) with arduino?

by Northriver on Thu Feb 04, 2010 12:32 pm

Thanks for reply Stefan,

But I can´t find ln(x) in the math.h library.

only:
double log (double __x)
double log10 (double __x)

Best regards
Northriver




bastard wrote:Read the manual:

The AVR math library, which is included in your sketch by using the line

#include <math.h> // (no semicolon)

Includes a great number of useful mathematical functions, including trigonometric, and logarithmic functions.

[...]

Bye

Stefan
Northriver
 
Posts: 3
Joined: Thu Feb 04, 2010 8:32 am

Re: Howto calculate ln(x) with arduino?

by hlantz on Thu Feb 04, 2010 1:30 pm

Northriver wrote:Thanks for reply Stefan,

But I can´t find ln(x) in the math.h library.

only:
double log (double __x)


Isn't that what you're looking for?

From the math.h manual page:
double log (double __x) // natural logarithm of x

Natural logarithm of x = ln(x), right?
hlantz
 
Posts: 115
Joined: Wed Oct 14, 2009 2:14 pm
Location: Falun, Sweden

Re: Howto calculate ln(x) with arduino?

by Northriver on Thu Feb 04, 2010 3:15 pm

Thanks again Stefan,

I was trying to calculate the Dew Point

I found the correct formula.

H = (log10(RH)-2.0)/0.4343+(17.62*t)/(243.12+t);
td = 243.12*H/(17.62-H);

RH = Humidity in %

t=temperature in celcius

td= dew point temperature in celsius

Best regards
Northriver



hlantz wrote:
Northriver wrote:Thanks for reply Stefan,

But I can´t find ln(x) in the math.h library.

only:
double log (double __x)


Isn't that what you're looking for?

From the math.h manual page:
double log (double __x) // natural logarithm of x

Natural logarithm of x = ln(x), right?
Northriver
 
Posts: 3
Joined: Thu Feb 04, 2010 8:32 am