• Advertisement

Archived

This topic is now archived and is closed to further replies.

Natural log C++

This topic is 5120 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

basically I want to get this equation x = log (x) * 3 to work in C++. I have #include <math.h> in the header, but its not working right. ALso I need "ln" not "log". how can I do that?

Share this post


Link to post
Share on other sites
Advertisement
Define "not working right". Compile error? Link error? Runtime error? Bad result?

If you want the natural log, you can divide log(x) by log(e).

Share this post


Link to post
Share on other sites
ok, nvm. I got it working. For some reason I had x =1 and it was just giving me garbage like, 3jkl2. But changing x to any other number works.

Share this post


Link to post
Share on other sites
And despite you having already solved your problem, I'm bored and need to say things...

quote:
If you want the natural log, you can divide log(x) by log(e).
True, but unnecessary since log() already is natural log in the CRT.

quote:
For some reason I had x=1 and it was just giving me garbage like, 3jkl2
If e^0==1 then ln(1)==0 so if you iterate and pass x=1 then you will eventually find yourself doing ln(0) ... which you can't.

Jans.

[edited by - jansic on April 15, 2004 5:12:19 PM]

Share this post


Link to post
Share on other sites

  • Advertisement