*Author

Offline SavageTopic starter

  • Jr. Member
  • **
  • Posts: 133
  • Country: us
  • Reputation Power: 2
  • Savage is a Spark waiting for a buff.
  • Elements Veteran
Log question (ln(75)) https://elementscommunity.org/forum/index.php?topic=61765.msg1230293#msg1230293
« on: April 11, 2016, 01:21:15 am »
So, I am trying to develop a report on how one could program their calculator to calculate a logarithm

For example, someone presses log _ 9 (75)

I would then use the change of base formula to convert log _ 9 (75) to ln(75)/ln(9) and my reason for choosing the e-base is because of its nice taylor series.

Problem: asking a computer to calculate the ln(.5) for example is easy because ln(.5) = ln(1 + -.5) and ln(1+x) has a nice  Maclaurin series that involves no logarithms and -.5 converges in that series.

Unfortunately neither 75, nor 9 can be manipulated like .5 to fit in the radius of convergence. I was curious if anyone had some sort of trick on how to create a taylor series to deal with this situation.

I know for a fact 9 to the "1 point something" power is 75, so I considered a taylor series around 2, but that won't converge for numbers as high as 75 or 9 still.

Offline andretimpa

  • Master of Gravity
  • *
  • ******
  • Posts: 3813
  • Country: br
  • Reputation Power: 58
  • andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.
  • OMG how did I get here I'm not good with computers
  • Awards: Slice of Elements 15th Birthday CakeSlice of Elements 12th Birthday Cake14th Trials - Master of GravitySong of the Day Tourney Most Creative DeckSlice of Elements 11th Birthday Cake13th Trials - Master of GravitySlice of Elements 10th Birthday CakeArt Competition - RedecoratingSlice of Elements 9th Birthday CakeArt Competition: MS Paint #9 WinnerArt Competition: League of the Battle Champion WinnerArt Competition: Foil ArtWeekly Tournament WinnerSlice of Elements 8th Birthday CakeArt Competition: Paint With Elements - The Elemental AvatarsSlice of Elements 7th Birthday CakeCompetition - A Challenge of Challenges1st Place WC Winner: October 20151st Place Weekly Challenge Winner: September 2015Weekly Design August 2015 - GoldWeekly Design July 2015 - SilverSlice of Elements 6th Birthday CakeForum Brawl #4 WinnerPaint with Elements Competition WinnerSlice of Elements 5th Birthday CakeWeekly Tournament WinnerSlice of Elements 4th Birthday Cake
Re: Log question (ln(75)) https://elementscommunity.org/forum/index.php?topic=61765.msg1230301#msg1230301
« Reply #1 on: April 11, 2016, 01:54:13 am »
So, I am trying to develop a report on how one could program their calculator to calculate a logarithm

For example, someone presses log _ 9 (75)

I would then use the change of base formula to convert log _ 9 (75) to ln(75)/ln(9) and my reason for choosing the e-base is because of its nice taylor series.

Problem: asking a computer to calculate the ln(.5) for example is easy because ln(.5) = ln(1 + -.5) and ln(1+x) has a nice  Maclaurin series that involves no logarithms and -.5 converges in that series.

Unfortunately neither 75, nor 9 can be manipulated like .5 to fit in the radius of convergence. I was curious if anyone had some sort of trick on how to create a taylor series to deal with this situation.

I know for a fact 9 to the "1 point something" power is 75, so I considered a taylor series around 2, but that won't converge for numbers as high as 75 or 9 still.

Use ln(a.b) = ln(a) + ln(b) such that you know ln(a) and b is in the radius of convergence. An easy but not so efficient way is to keep dividing by e until the result is small enough and add the number of times you divided in the end.
Every time a graboid evolves, an elemental gets his wings.
:gravity Guild (old), War 9 & 13 (gen) / :time Brawl 2 & 3, War 7 & 14 / :death War 8 & 12 / :fire Brawl 4 / :entropy Brawl 5 / :darkness War 10

Offline SavageTopic starter

  • Jr. Member
  • **
  • Posts: 133
  • Country: us
  • Reputation Power: 2
  • Savage is a Spark waiting for a buff.
  • Elements Veteran
Re: Log question (ln(75)) https://elementscommunity.org/forum/index.php?topic=61765.msg1230314#msg1230314
« Reply #2 on: April 11, 2016, 03:56:41 am »
Ugh, I understand exactly what you are saying, but that is going to get super messy very quick. I have also tried expressing, for example, 75 as:

sqrt(3) * sqrt(3) * 4th root (5) * ... * 4th root (5) (8 4th-roots here)

Reason: Now, I can express these roots as 1+number (Were doing a taylor series for ln(1+x)), where "number" is guaranteed to be between (-1,1].

Is there any taylor series out there that "moves' its radius of convergence and is still somewhat as simple as ln(1+x)? By moves, I mean moving (-1,1] to...say (74.5,75.5] or something.

Offline andretimpa

  • Master of Gravity
  • *
  • ******
  • Posts: 3813
  • Country: br
  • Reputation Power: 58
  • andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.
  • OMG how did I get here I'm not good with computers
  • Awards: Slice of Elements 15th Birthday CakeSlice of Elements 12th Birthday Cake14th Trials - Master of GravitySong of the Day Tourney Most Creative DeckSlice of Elements 11th Birthday Cake13th Trials - Master of GravitySlice of Elements 10th Birthday CakeArt Competition - RedecoratingSlice of Elements 9th Birthday CakeArt Competition: MS Paint #9 WinnerArt Competition: League of the Battle Champion WinnerArt Competition: Foil ArtWeekly Tournament WinnerSlice of Elements 8th Birthday CakeArt Competition: Paint With Elements - The Elemental AvatarsSlice of Elements 7th Birthday CakeCompetition - A Challenge of Challenges1st Place WC Winner: October 20151st Place Weekly Challenge Winner: September 2015Weekly Design August 2015 - GoldWeekly Design July 2015 - SilverSlice of Elements 6th Birthday CakeForum Brawl #4 WinnerPaint with Elements Competition WinnerSlice of Elements 5th Birthday CakeWeekly Tournament WinnerSlice of Elements 4th Birthday Cake
Re: Log question (ln(75)) https://elementscommunity.org/forum/index.php?topic=61765.msg1230362#msg1230362
« Reply #3 on: April 11, 2016, 01:48:23 pm »
The problem is that in this case using a different Taylor series boils down to the trick I gave you earlier.

What determines the radius of convergence of a Taylor series centered about a number a is the distance a is from a singularity of the function (in some series this is a bit harder to see because the singularities are complex numbers instead of real ones). The only singularity ln has is 0, so if you make a series centered about a you get a radius of convergence equal to a allowing you to calculate ln(x) for x in (0, 2a]. This would be

ln(x) = ln(a) + ln'(a)(x-a) + ln''(a)(x-a)^2 /2 + ln'''(a)(x-a)^3 /6 + ... = ln(a) + (x-a)/a - (x-a)^2/(2a) + (x-a)^3/(3a) - ...

Define z = (x-a)/a. This means that z + 1 = x/a, so ln(z + 1) = ln(x) - ln(a), putting it in our Taylor series we get

ln(z+1) = z - z^2/2 + z^3/3 - z^4/4 + ...

and we are back to where we started, which is just a popular rewording of the Taylor series centered about 1.
Every time a graboid evolves, an elemental gets his wings.
:gravity Guild (old), War 9 & 13 (gen) / :time Brawl 2 & 3, War 7 & 14 / :death War 8 & 12 / :fire Brawl 4 / :entropy Brawl 5 / :darkness War 10

Offline Lost in Nowhere

  • Jr. Member
  • **
  • Posts: 74
  • Country: us
  • Reputation Power: 2
  • Lost in Nowhere is a Spark waiting for a buff.
  • Never drive a skyscraper
Re: Log question (ln(75)) https://elementscommunity.org/forum/index.php?topic=61765.msg1230663#msg1230663
« Reply #4 on: April 14, 2016, 03:11:28 am »
Probably the best option you have is to use the identity that ln(x)=-ln(1/x). With the Taylor series for ln(x) around 1 and positive x, if the series does not converge at x, it will converge at 1/x. This essentially gives you a second series with radius of convergence [.5,∞), allowing you to calculate the natural logarithm of any positive real number.
Smoke 'Em the Bear said: Only you can stop me from starting forest fires!

[09:49:49] ‹skyironsword› Google is perfect. Google is flawless. GOOGLE IS INFINITY

Offline andretimpa

  • Master of Gravity
  • *
  • ******
  • Posts: 3813
  • Country: br
  • Reputation Power: 58
  • andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.
  • OMG how did I get here I'm not good with computers
  • Awards: Slice of Elements 15th Birthday CakeSlice of Elements 12th Birthday Cake14th Trials - Master of GravitySong of the Day Tourney Most Creative DeckSlice of Elements 11th Birthday Cake13th Trials - Master of GravitySlice of Elements 10th Birthday CakeArt Competition - RedecoratingSlice of Elements 9th Birthday CakeArt Competition: MS Paint #9 WinnerArt Competition: League of the Battle Champion WinnerArt Competition: Foil ArtWeekly Tournament WinnerSlice of Elements 8th Birthday CakeArt Competition: Paint With Elements - The Elemental AvatarsSlice of Elements 7th Birthday CakeCompetition - A Challenge of Challenges1st Place WC Winner: October 20151st Place Weekly Challenge Winner: September 2015Weekly Design August 2015 - GoldWeekly Design July 2015 - SilverSlice of Elements 6th Birthday CakeForum Brawl #4 WinnerPaint with Elements Competition WinnerSlice of Elements 5th Birthday CakeWeekly Tournament WinnerSlice of Elements 4th Birthday Cake
Re: Log question (ln(75)) https://elementscommunity.org/forum/index.php?topic=61765.msg1230688#msg1230688
« Reply #5 on: April 14, 2016, 11:36:00 am »
That's actually a good idea. I don't know which method would arrive at the answer faster.
Every time a graboid evolves, an elemental gets his wings.
:gravity Guild (old), War 9 & 13 (gen) / :time Brawl 2 & 3, War 7 & 14 / :death War 8 & 12 / :fire Brawl 4 / :entropy Brawl 5 / :darkness War 10

Offline Jenkar

  • Legendary Member
  • ******
  • Posts: 4199
  • Country: fr
  • Reputation Power: 58
  • Jenkar is truly a Titan, worthy of respect and acknowledgement.Jenkar is truly a Titan, worthy of respect and acknowledgement.Jenkar is truly a Titan, worthy of respect and acknowledgement.Jenkar is truly a Titan, worthy of respect and acknowledgement.Jenkar is truly a Titan, worthy of respect and acknowledgement.Jenkar is truly a Titan, worthy of respect and acknowledgement.Jenkar is truly a Titan, worthy of respect and acknowledgement.Jenkar is truly a Titan, worthy of respect and acknowledgement.Jenkar is truly a Titan, worthy of respect and acknowledgement.Jenkar is truly a Titan, worthy of respect and acknowledgement.Jenkar is truly a Titan, worthy of respect and acknowledgement.
  • Heart's made of shadows
  • Awards: Slice of Elements 8th Birthday CakeSlice of Elements 7th Birthday CakeChampionship League 2/2013 WinnerSlice of Elements 4th Birthday Cake6th Trials - Master of AirWinner of Revive the Archive 2!Slice of Elements 3rd Birthday CakeBeginners League 1/2012 WinnerWeekly Tournament Winner5th Trials - Master of AirAvatar of Patience - Winner of the 7 Heavenly Virtues Deck CompetitionBeginners League 3/2011 3rd PlaceC-C-C-Combo Maker Winner!
Re: Log question (ln(75)) https://elementscommunity.org/forum/index.php?topic=61765.msg1230691#msg1230691
« Reply #6 on: April 14, 2016, 12:00:16 pm »
That's actually a good idea. I don't know which method would arrive at the answer faster.
Your answer has a complexity of roughly log(number) * complexity of the different operations of the taylor series
His answer has a complexity of roughly complexity of the different operations of the taylor series.
His seems better :3
The madness is in each of us. Close your eyes, sing, and open your webbed wings to the silent winds.
Beautiful art : http://i.imgur.com/eUhyYCC.png

Offline andretimpa

  • Master of Gravity
  • *
  • ******
  • Posts: 3813
  • Country: br
  • Reputation Power: 58
  • andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.andretimpa is truly a Titan, worthy of respect and acknowledgement.
  • OMG how did I get here I'm not good with computers
  • Awards: Slice of Elements 15th Birthday CakeSlice of Elements 12th Birthday Cake14th Trials - Master of GravitySong of the Day Tourney Most Creative DeckSlice of Elements 11th Birthday Cake13th Trials - Master of GravitySlice of Elements 10th Birthday CakeArt Competition - RedecoratingSlice of Elements 9th Birthday CakeArt Competition: MS Paint #9 WinnerArt Competition: League of the Battle Champion WinnerArt Competition: Foil ArtWeekly Tournament WinnerSlice of Elements 8th Birthday CakeArt Competition: Paint With Elements - The Elemental AvatarsSlice of Elements 7th Birthday CakeCompetition - A Challenge of Challenges1st Place WC Winner: October 20151st Place Weekly Challenge Winner: September 2015Weekly Design August 2015 - GoldWeekly Design July 2015 - SilverSlice of Elements 6th Birthday CakeForum Brawl #4 WinnerPaint with Elements Competition WinnerSlice of Elements 5th Birthday CakeWeekly Tournament WinnerSlice of Elements 4th Birthday Cake
Re: Log question (ln(75)) https://elementscommunity.org/forum/index.php?topic=61765.msg1230692#msg1230692
« Reply #7 on: April 14, 2016, 12:45:23 pm »
That's actually a good idea. I don't know which method would arrive at the answer faster.
Your answer has a complexity of roughly log(number) * complexity of the different operations of the taylor series
His answer has a complexity of roughly complexity of the different operations of the taylor series.
His seems better :3

My sugestion is actually log(log(number)) + taylor (you can divide by e, if that doesn't work, then by e^2, e^4, e^8, etc. If you find a number that works you can work your way back to refine the value. You only use Taylor once you figured which number you'll take the logarithm). Doing some tests, the real problem is error propagation with my idea, which starts to get ugly with ~ 10 digit numbers. You could probably get rid of that by using powers of 2 and storing ln(2) in the memory to make the conversion.

After thinking a bit, using 1/x is a bad idea if x is very large because of the rate of convergence. Since

ln(z+1) = 1-z+z^2/2-z^3/3+...

and we'd have z+1=1/x, that would mean z=1-1/x and so the term in the position n*x in the series would be (1-1/x)^(n*x)/(n*x) ~ e^(-n)/(n*x), so we'd need roughly O(x) steps to get each decimal place in the result, which becomes a problem for large x.

I also noticed that if you are using floating point numbers (which is how computers store real numbers) you can cheat your answer a bit.

These numbers are stored as a*2^b, so if you store ln(2) in your code you can get the logarithm with
b*ln(2) - ln(1/a).
By construction a is between 1 and 2, so using 1/a gives you a number between 1/2 and 1, that have all fast convergence.
« Last Edit: April 14, 2016, 06:29:05 pm by andretimpa »
Every time a graboid evolves, an elemental gets his wings.
:gravity Guild (old), War 9 & 13 (gen) / :time Brawl 2 & 3, War 7 & 14 / :death War 8 & 12 / :fire Brawl 4 / :entropy Brawl 5 / :darkness War 10

 

blarg: