Roots and powers playing nicely together...
#21
Well I consider myself a math-e-mortician. A place where numbers come to die!

I'll have a look as soon as I clean up this existing code.

Pete
Reply
#22
In a nutshell, for power take the natural log (Ln) of x ^ y = y * ln(x) and convert it back with e^(y*ln(x)).

Just need good algorithms to do the calculations.
b = b + ...
Reply
#23
For string math, I would have to write a way to do natural logs by an existing string math process. That's why I avoided this method.

Well, let's have a look at a small numeric piece of code...

Code: (Select All)
PRINT Log10(64)
FUNCTION Log10# (value AS DOUBLE) STATIC
    Log10# = LOG(value) / LOG(10.#)
END FUNCTION

So the question would be when does the numeric log function crap out and where is the point where the accuracy is in question? It is usually the last digit but rounding errors can make a mess of that, too.

Pete
If eggs are brain food, Biden takes his scrambled.
Reply
#24
Don't get the problem - not really. When does it become inaccurate? -- I still have to practice with Locate so that the columns are next to each other.

Input 10,000 results in: 4.0000
Code: (Select All)
'Logarithmusuebung. Wann Programmabsturz? - 1. Okt. 2022

Declare Function Log10(wert As Double) As Long

Dim As Double wert
Dim As Integer i

Input "Log(i): ", i

For i = 1 To i
  wert = Log10(i)
  Print Using "####.#####"; wert
Next

Function Log10 (value As Double) Static

  Dim ergebnis As Double

  ergebnis = Log(value) / Log(10)
  Log10 = ergebnis
End Function
Reply
#25
I got it working but like doing Powers with Binary of nested Square Roots of 2, it takes a long time with not very accurate results. The main problem is removing non significant digits in calculations to get square root of 4 done in this century.
b = b + ...
Reply
#26
(10-01-2022, 03:51 PM)bplus Wrote: I got it working but like doing Powers with Binary of nested Square Roots of 2, it takes a long time with not very accurate results. The main problem is removing non significant digits in calculations to get square root of 4 done in this century.

One still have 78 years to do that. Just don't rush!  Big Grin
Reply
#27
Speaking of 78 years...

I got to thinking last night about how much faster factoring is when you can go from 500 binomial iterations where the numbers get hundreds of digits long to just 5 iterations by 10 root 8 = x 10 root x = x 5 root x = answer. Now the problem is large PRIME numbers. You can't factor those down. When you get like or higher than 503 root whatever, you are back to going away the morning to wait for you result.

I don't know if there are any other equation manipulations that could be made to always reduce the radicand under 500 and preserve the answer. Anyone know of a method?

As far as the log method. I did try out that function I posted with some very large string numbers. It did return values that did not fall apart, but I have not found a high precision log calculator to check them for accuracy. I know next to nothing about log functions. I think natural logs is base 10, so it is surprising to me a base 10 operation in computer math isn't noticeably falling apart. I need to do more research.

Mark, the significant figures rabbit hole can be avoided with long division nth root routines, but speed is still an issue with radicands in the hundreds+. Lookup tables are the way around that, but to what limit? 1000? 10,000? Could you imagine having to fill up a program with 90,000 indexed strings, many hundreds of digits long?

Pete
Reply
#28
@Pete I will post current status of my String Math for estimating natural logs (base e, compared to log 10 base 10) and string math routine for calc e^x basically x^y = e ^(y * ln(x)) see WIP board lots of tweaking still needed but ShowDP is coming in real handy for reducing digits.

QB64 Log(x) is for natural logarithms base e, that is big player in calculus classes, because integrals and derivatives are pretty easy like polynomials.
b = b + ...
Reply
#29
Pete, what you gave as an example is an Excel function. Or am I wrong?
"You can use the Excel LOG10 function to find the base 10 logarithm of a number. For example, =LOG10(100) returns 2 and =LOG10(1000) returns 3." - That is correct.

Oh, now I can't see through it anymore. This is mayhem!  Cry

And this is the result with the Log-Function in QBasic64:

Code: (Select All)
'Logarithmusuebung mit "Log" - 1. Okt. 2022

Option _Explicit

Declare Function LogX(wert As Double) As Long

Dim As Double wert
Dim As Integer i

Input "Log(i): ", i

For i = 1 To i
  wert = Log(i)
  Print Using "####.#####"; wert
Next

Print
'Log(100)
Print Using "Log: ####.##### -- From: MS QBasic - Programmer's Guide"; Log(100)

End 'Programm

Function LogX (value As Double) Static

  Dim ergebnis As Double

  ergebnis = Log(value) / Log(10)
  LogX = ergebnis
End Function
Reply




Users browsing this thread: 11 Guest(s)