C
CBFalconer
Dik T. Winter said:It might surprise you how many implementations of sin and cos
use an exact rational value for pi...
That isn't a value, it is an approximation.
Dik T. Winter said:It might surprise you how many implementations of sin and cos
use an exact rational value for pi...
I suspect it performs reasonably well on machines with condition
codes on a wider class of operations than just branches (so ARM,
and {f,}cmov* on x86). Of course, the tightness of the loop makes
interdependencies turn into real latencies too, alas. FPU's have
certainly been the focus of an awful lot of developement in the
past few decades, and low-latency, high gate count multipliers have
become the hammer that's turned a lot of problems into nails.
No need with long words, as the non-CORDIC algorithms scale
better. CORDIC loops on 64-bit significands may be pretty,
but leave you plenty of time to appreciate that ;-).
Phil
An even better answer (already given) is that the computation of log()
typically doesn't depend on any approximation of e.
JosephKK said:Actually (the initial use and) the shift away from CORDIC was a gate
count issue.
No major current implementation uses CORDIC any more.
Not MIPS, not SPARC, not x86, not HP-PA, not Power, not 68K. CORDIC
is an effectve low gate/transitor count implementation. But in the
days of a billion gates; faster, more direct implemenations are
preferred.
JosephKK said:....
While any particular implementation of log() may not have any visible
reference to the base of the logarithm it would quite impossible to
develop that algorithm without reference to that base value.
Erm, what bit about the sentence partially underlined makes you think
that's news to me?
Having said that, Intel have repeatedly run out of gates and had
to cripple an otherwise very potent architecture, so they're not
an infinite resource by any means.
I'm starting to dabble with FPGA coding. I might try to see
how many hand-written cordic blocks I can squeeze into the
same space as one optimised fixed point operational block for
the usual CORDIC functions (log, exp, atan2, maybe sqrt if
I can remember how to do it). The only problem is that I have
no personal use for such a block, I'm more into discrete
mathematics.
Phil
You can develop the entire power series for log(x) using the fact that
it's derivative is 1/x, and that log(1) is 0, without making any
reference to the fact that there exists a number 'e' such that
log(e)==1, and there's nothing particularly unnatural about doing so. I
believe that you can equally easily and naturally derive the details of
at least some of the more sophisticated techniques for implementing
log() that have been mentioned in this thread, without making any use of
'e', though I haven't verified that.
JosephKK said:Some possibly really nice sine/cosine cross interpolating tables to
feed coefficients to radix 4 arbitrary length FFT and DFT might be
quite useful.
Discrete math like commutative rings, or for other applications?
Trying to learn just what Lie groups are, is a back burner thing for
me.
JosephKK said:On Mon, 09 Mar 2009 12:00:29 GMT, James Kuyper
In both cases the target value is the logarithm to the base e. Do you
get the same algorithm with the same constants if you calculate to a
logarithm base of 2, pi, 10, 8, 16, or sqrt(157)? Second and tougher
test, does your algorithm break down if you use complex numbers? It
might if the base is not e.
This is the concept i an driving at. All logarithms are to some
particular base. Most machine algorithms are to base e or 10 (and
often derive base 10 with a multiply after generating a log base e).
JosephKK said:In both cases the target value is the logarithm to the base e. Do you
get the same algorithm with the same constants if you calculate to a
logarithm base of 2, pi, 10, 8, 16, or sqrt(157)?
... Second and tougher
test, does your algorithm break down if you use complex numbers? It
might if the base is not e.
Actually that's a very good, if not perfect, example of the
where fast FPU operations would be very useful. FFTs traditionally
use huge precomputed arrays for such coefficients, and that tends
to waste cache. Smaller tables quickly interpolated would be great.
Might be rings, might commute... Computational Number Theory.
Phil
Yes, logarithms are to a particular base. The point is that, at least
if the base is e, you don't need the value of that base to compute the
logarithm. The same is true of the exp() function. In a sense, the
value of e comes from the algorithm, not vice versa.
And a typical case of programmers versus mathmaticians. BOTH areNo, that's why log() is special. My comments, and as far as I can tell
all of the comments made on this thread, refer specifically to log().
We're not talking about log10(), log2(), logb(), ilogb(), logsqrt157(),
sytemlog(), or any other arbitrary function that happens to have 'log'
in the function name. This discussion has been very specifically about
the C standard library function named log().
Mostly happenstance due to mathmatical properties of e itself. AnThe same power series works for complex numbers. Since the base for
log() happens, oddly enough, to be 'e', it's not an issue. And,
incidentally, the solution for calculating logarithms to a different
base is the same as for real numbers: clog(z)/clog(base); no reference
to the actual value 'e' is required.
JosephKK said:....
This is clc, and your programmers point of view is noted for what it
is. It is not the mathematical POV. And somewhere they must meet or
the algorithm won't reliably work.
> Mostly happenstance due to mathmatical properties of e itself. An
> improper implementation can still mess it up.
The fact that ln(x) means the logarithm of x to the base 'e' doesn't
mean that the algorithm needs to use 'e' in any way, nor does the
derivation of that algorithm. That's because 'e' isn't some random
number that you just happen to want to use as the base for your
logarithms. It is the very specific number that gives the logarithm to
that base the special property that the derivative is 1/x. That property
allows derivation of the algorithm without knowing or caring what the
value of 'e' actually is that makes that property true.
No. Happenstance due to the mathematical proprties of log. The mathematical
definition of 'log' does not mention 'e' at all, neither does the mathematical
definition of 'exp'.
The derivitive of logarithim to any base is 1/x or a constant scalar
multiple of 1/x. It is intrinsic to the nature of the logarithm
function. ln(x) is not special in that way.
JosephKK said:Please tell me what do you get for x^i*pi for x = 2, or 10? Explain
why and how it is different than e^i*pi.
> On Thu, 12 Mar 2009 12:26:47 GMT, "Dik T. Winter" <[email protected]>
> wrote: ....
>
> Please tell me what do you get for x^i*pi for x = 2, or 10? Explain
> why and how it is different than e^i*pi.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.