Re: Natural log Calculation
Re: Natural log Calculation
Thanks, I'll look at the maths later.
Re: Natural log Calculation
The formula holds only for
-1 < x <= 1
Therefore when x is out of this range you decompose it.
If v = y*10w then,
ln v = ln y + w ln 10
and then you use the formula for v. For example:
ln 7777 = ln 0.7777 + 4*ln 10
and now use the formula:
ln 0.7777 = ln [1 + (-0.2223)]
Re: Natural log Calculation
:) thanks for the explaination, I needed it :). Could you please explain the square root one? All I can gather is that it is a sum of a sequence. The reason for this question is i'm trying to make a calculator that is accurate to
1000 numbers.
Re: Natural log Calculation
Quote:
Originally Posted by Rich2189
:) thanks for the explaination, I needed it :). Could you please explain the square root one? All I can gather is that it is a sum of a sequence. The reason for this question is i'm trying to make a calculator that is accurate to
1000 numbers.
If you're looking for that type of precision in a calculator, the fastest way I can think of it to store e (2.71828182845905...) to 1000 digits and use that to calculate bases with. Since you already have an algorithm for logs, you can use this to calculate arbitrary roots. The x root of y can be expressed like this:
Code:
e ^ (Log(y) * (1 / x))
Or for example the square root of 9 would be:
Code:
e ^ (Log(9) * (1 / 2))
I think some really early calculator worked this way for calculating roots, and it should be accurate enough.
Re: Natural log Calculation
Quote:
Originally Posted by Comintern
If you're looking for that type of precision in a calculator, the fastest way I can think of it to store e (2.71828182845905...) to 1000 digits and use that to calculate bases with. Since you already have an algorithm for logs, you can use this to calculate arbitrary roots. The x root of y can be expressed like this:
Code:
e ^ (Log(y) * (1 / x))
Or for example the square root of 9 would be:
Code:
e ^ (Log(9) * (1 / 2))
I think some really early calculator worked this way for calculating roots, and it should be accurate enough.
But in order to store e to that many places i must first make my big Number class. Which raises the question how do you perform ^ operations, on numbers that large when neither of the numbers are integers:
2.71828182845905.............^some disgusting decimal. :) I need to sit down and have a serious think about this. Everything is going round in circles. IN addition to that I'm storing everything in base 256 :confused: :eek2: :eek2:
Re: Natural log Calculation
Quote:
Originally Posted by Rich2189
:) thanks for the explaination, I needed it :). Could you please explain the square root one? All I can gather is that it is a sum of a sequence. The reason for this question is i'm trying to make a calculator that is accurate to
1000 numbers.
Accurate to 1000 numbers??? That's beyond the power of my magic wand :)
The use of logs is probably to best way to go to calculate a square root. However, a different way to calculate is using a sequence:
{ai} -> Sqrt(A)
As a0 you can pick any number because the convergence is very fast, for example you pick ai = A. The new terms are calculated as:
ai+1 = (A/ai + ai) / 2
This is called the Newton-Raphson method, you can read about it in zillions of web sites, for example:
http://mathworld.wolfram.com/NewtonsMethod.html
Re: Natural log Calculation
Quote:
Originally Posted by krtxmrtz
Accurate to 1000 numbers??? That's beyond the power of my magic wand :)
The use of logs is probably to best way to go to calculate a square root. However, a different way to calculate is using a sequence:
{ai} -> Sqrt(A)
As a0 you can pick any number because the convergence is very fast, for example you pick ai = A. The new terms are calculated as:
ai+1 = (A/ai + ai) / 2
Thanks guys :), 1000 decimal places is too much of a challenge then, well i'll try for something more realistic like 200. Ill sit down with a piece(lots of) paper and work through some of this stuff.
Also, would you have any idea how to work out something like this via an algorithm?
4.6^5.83
Re: Natural log Calculation
Quote:
Originally Posted by Rich2189
Thanks guys :), 1000 decimal places is too much of a challenge then, well i'll try for something more realistic like 200. Ill sit down with a piece(lots of) paper and work through some of this stuff.
Also, would you have any idea how to work out something like this via an algorithm?
4.6^5.83
200? Well, handheld calculators give you just 9 or 10 decimal places, that should be enough for mostly everything... or are you trying to send your own rocket to the Moon or something?
Also in computers floating point values give you just a few digits of accuracy, usually less than 20.
4.65.83 = 105.83 log(4.6)
Re: Natural log Calculation
Quote:
Originally Posted by krtxmrtz
200? Well, handheld calculators give you just 9 or 10 decimal places, that should be enough for mostly everything... or are you trying to send your own rocket to the Moon or something?
Also in computers floating point values give you just a few digits of accuracy, usually less than 20.
4.65.83 = 105.83 log(4.6)
:) I just want to best Microsofts Calculator. Plus I don't like seeing
1.9382938x10^99
there is no way all the other numbers are 0. What would you suggest a realistic value was? 30? then move into x10^.....?
4.65.83 = 105.83 log(4.6) Thanks on 2 accounts, didn't know about the [sup ] tag and yet another use for logs :).
Re: Natural log Calculation
What is it you exactly want to do? Be accurate to the 200th decimal place? Or work with large numbers beyond the range of 1099?
Re: Natural log Calculation
Quote:
Originally Posted by krtxmrtz
What is it you exactly want to do? Be accurate to the 200th decimal place? Or work with large numbers beyond the range of 1099?
Well initially I had thoughts of working with numbers accurate to 200 d.p but it seems that is pointless and not needed. So working with numbers beyond 1099 would be my current aim. so 20/30 decimal places of accuracy with and exponent of upto 101000.
Re: Natural log Calculation
Quote:
Originally Posted by Rich2189
Well initially I had thoughts of working with numbers accurate to 200 d.p but it seems that is pointless and not needed. So working with numbers beyond 1099 would be my current aim. so 20/30 decimal places of accuracy with and exponent of upto 101000.
If you're going to work with integers only, then it shouldn't be too difficult, but I never went into something like this.
Good luck anyway.
Re: Natural log Calculation
Quote:
Originally Posted by krtxmrtz
If you're going to work with integers only, then it shouldn't be too difficult, but I never went into something like this.
Good luck anyway.
It's including decimals :). Thank-you both for all the advice, if I manage to get it sorted I'll send you a link.