Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Log formula
#11
Perhaps I should reclarify. For those who don't know, StatLib stores numbers as strings, so I can't use ordinary qbasic math functions to get results, because the whole point of someone using StatLib would be when they have a problem like 3862389762387x10^23.37154178217812786 etc. So I can work out 10^23, but the .37154... is the tricky part. So what I need is a way to work out 10 to the power of a decimal without using any inbuilt qb functions. What you can use is: + - */ and any other function that can be built from those operators.

So TBBQ has it sort of right. I can't calculate decimal parts of powers, but I need to be able to without using logs. Or, if using logs is the only way, then what is the formula for log?
Reply
#12
Quote:
TheBigBasicQ Wrote:So your calculation would be:
2.4 x log(10)

In fact it would give the log of the result. The true result is
exp(2.4Xlog(10))

Yeah, I know that Antoni but some how my post got changed before I edited it :o
Reply
#13
Oracle,
You're gonna have a tough time. Logs are based on exponents, and exponents can be expressed as logs. If you can't do either, then you have a problem. Back when I went to school, logs were looked up in logarithm tables. Maybe you could get a file version of some good log table, and do a lookup. Just an idea.

You say the data is in strings. If it were me, I'd convert the string data to numeric (maybe double precision floating point), and then perform the required exponent or logarithm function using the corresponding QB functions provided. What would be your objection to doing it this way?
*****
Reply
#14
Like I said, when the exponent is 2000 characters long, double precision won't cut it. All I need is the formula to calculate the log of a number. People didn't just make up logarithms, there must have been a formula for them. Just like sine, if you know what I mean. You don't just take the "sine" of a number, internally a computer uses a taylor series or something.
Reply
#15
Oracle,
Your right. For numbers of that magnitud, double precision won't be enough. Originally logorithm tables must have been calculated somehow. You need that method of calculation, or formula. I'll look around.
*****
Reply
#16
Oracle what you need is some numerical background.

You can calculate exponential and logarithm using just +,-,*,/. You need same mathematical background. Check the math world page
http://mathworld.wolfram.com/ExponentialFunction.html look at the MacLaurin series.

To calculate logarithms is somewhat more dificult. You may need someone with calculus and numerical skills.

Note: A computer uses that formula for calculating exponentials.

Note2: There's a library called bigint, you start taking a look on it.
Reply
#17
Calculus and numerical skills? Bah. A computer calculates the natural logarithm, and uses identities to calculate any logarithm with it. You can find the infinite series that's used to calculate it here

I'm still dumbfounded as to how you actually calculate x^y with logarithms though, which is how i've always understood comptures calculate exponents. There was a formula in my calculus book that involves derivatives somewhere, but I no longer have that book, and it's nowhere on the internet.
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#18
Quote:Calculus and numerical skills? Bah. A computer calculates the natural logarithm, and uses identities to calculate any logarithm with it. You can find the infinite series that's used to calculate it here

I'm still dumbfounded as to how you actually calculate x^y with logarithms though, which is how i've always understood comptures calculate exponents. There was a formula in my calculus book that involves derivatives somewhere, but I no longer have that book, and it's nowhere on the internet.

Look at my post and I think you may understand how you can calculate x^y using logs. Its simple only thing is that you must know your formulae! 8)
Reply
#19
I guess I dont see how you do that. antilogs are calculated with exponents, it's just 10^x. You'd send yourself into a vicious cycle.

The formula I'm thinking of involves derivation... rrgh!!
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#20
Oracle,
The MacLauren Series for ln is
Code:
ln(1 + x) = x - (x^2) / 2 + (x^3) / 3  ... + (-1)^n * x^(n + 1) / (n+1)
Converges for -1 < x < 1]
This is easy to calculate, but only converges in a very small range.
The Taylor Series is
Code:
ln(x) = ln(c) + (x - c) / c - ((x - c)^2) / (2 * c^2) + ((x - c)^3) / (3 * c^3) . . . + ((-1)^(n - 1))*[(x - c)^n] / (n * c^n)
Converges if |x - c| < c
This can theorectically be used to find the natural log of any number, but you need to find a c > x / 2 (the closer to x the better for convergence) that you already know the ln. With the numbers that you are trying to calculate this might not be easy, but a table of values could help. You could generate the table using c = e^x. For good convergence you would probably want at least the even powers of e. Your table could easily become huge, so I don't know if this is practical for you.
edit:
As far as using the ln:
Code:
x = e^(ln x)
     x^a = e^(a * ln x)
e^x = 1 + x + (x^2) / 2! + . . . + (X^n) / n!
hrist Jesus came into the world to save sinners, of whom I am first.(I Timothy 1:15)

For God so loved the world, that He gave His only begotten Son,
that whoever believes in Him should not perish, but have eternal life.(John 3:16)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)