Value of "e" in the C log() function

D

Dik T. Winter

> How is that relevant to the issue? Yes, 'e' is a very special number,
> with a number of interesting properties, including the fact that
> ln(e)=1. But it is the properties of 'e', not it's actual value, which
> are used in deriving and implementing algorithms for evaluating log(x).

Not even that. It is the properties of the exp and log functions that
give the properties and from that the properties of 'e' (defined as
exp(1)) are derived.
 
C

CBFalconer

James said:
.... snip ...

How is that relevant to the issue? Yes, 'e' is a very special
number, with a number of interesting properties, including the
fact that ln(e)=1. But it is the properties of 'e', not it's
actual value, which are used in deriving and implementing
algorithms for evaluating log(x).

That's got nothing to do with its being special. After all, log(x)
to the base x is always 1, for any x.

The unique thing is that d/dx (e^x) == e^x, where d/dx expresses
the derivative wrt x, and ^ expresses exponentiation. This is why
ln(x) is called the 'natural' log.
 
P

Phil Carmody

JosephKK said:
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.

The derivative of logarithm to any base is 1/x or something
different.

The derivative of *any* differentiable function is 1/x or something
different.

For only one base is the derivative of the logarithm to that
base 1/x. That makes that base a special case.

Phil
 
R

Richard Tobin

How is that relevant to the issue? Yes, 'e' is a very special
number, with a number of interesting properties, including the
fact that ln(e)=1. But it is the properties of 'e', not it's
actual value, which are used in deriving and implementing
algorithms for evaluating log(x).
[/QUOTE]
That's got nothing to do with its being special. After all, log(x)
to the base x is always 1, for any x.

If ln(x) were defined as "the log to base e of x", then you would have
a point. But since - as has been pointed out elsewhere in the thread -
that's not where you usually start from in defining ln(x) mathematically,
the fact that ln(e) = 1 is an interesting result.

-- Richard
 
J

JosephKK

The derivative of logarithm to any base is 1/x or something
different.

The derivative of *any* differentiable function is 1/x or something
different.

For only one base is the derivative of the logarithm to that
base 1/x. That makes that base a special case.

Phil

OK in your POV ln() is special. It is certainly convenient for
algorithm development. Now can you, Phil, or James explain what the
value of log10(4-i5) is and why that is the correct answer.
 
J

JosephKK

How is that relevant to the issue? Yes, 'e' is a very special number,
with a number of interesting properties, including the fact that
ln(e)=1. But it is the properties of 'e', not it's actual value, which
are used in deriving and implementing algorithms for evaluating log(x).

And log2(2) = 1 as does log10(10) = 1. Please answer the question.
 
J

JosephKK

That's got nothing to do with its being special. After all, log(x)
to the base x is always 1, for any x.

If ln(x) were defined as "the log to base e of x", then you would have
a point. But since - as has been pointed out elsewhere in the thread -
that's not where you usually start from in defining ln(x) mathematically,
the fact that ln(e) = 1 is an interesting result.

-- Richard[/QUOTE]

Actually it is less than trivial result.
.
 
J

JosephKK

That's got nothing to do with its being special. After all, log(x)
to the base x is always 1, for any x.

The unique thing is that d/dx (e^x) == e^x, where d/dx expresses
the derivative wrt x, and ^ expresses exponentiation. This is why
ln(x) is called the 'natural' log.

Nothing but a scalar difference i say.
.
 
J

JosephKK

Irrelevant. The mathematical definition of exp is as follows:
exp is a function f(x) such that d/dx f = f and f(0) = 1
the mathematical definition of log is as follows:
log(x) = int{1, x} dx/x
Where in those definitions is 'e' mentioned?

x^i*pi has not a single value when x = 2 or 10.

Since when? Or are you twisting away from trying to evaluate those
two cases?
The mathematical definition
of the exponentiation operator is:
a^b = exp(b.log(a))
where that is well-defined. Where in that definition is 'e' used?

The base value of the exp() and log()[really ln()] functions??
.
 
U

user923005

Irrelevant.  The mathematical definition of exp is as follows:
   exp is a function f(x) such that d/dx f = f and f(0) = 1
the mathematical definition of log is as follows:
   log(x) = int{1, x} dx/x
Where in those definitions is 'e' mentioned?
x^i*pi has not a single value when x = 2 or 10.

Since when?  Or are you twisting away from trying to evaluate those
two cases?
 The mathematical definition
of the exponentiation operator is:
  a^b = exp(b.log(a))
where that is well-defined.  Where in that definition is 'e' used?

The base value of the exp() and log()[really ln()] functions??

Arguing with Dik Winter about math is like arguing with Donald Knuth
about an algorithm, or with Dennis Ritchie about C.

By the way, here is a fairly well done implementation of the exp()
function by Moshier with no hint of the constant "e":

/* exp.c

* Exponential function
*
*
*
* SYNOPSIS:
*
* double x, y, exp();
*
* y = exp( x );
*
*
*
* DESCRIPTION:
*
* Returns e (2.71828...) raised to the x power.
*
* Range reduction is accomplished by separating the argument
* into an integer k and fraction f such that
*
* x k f
* e = 2 e.
*
* A Pade' form 1 + 2x P(x**2)/( Q(x**2) - P(x**2) )
* of degree 2/3 is used to approximate exp(f) in the basic
* interval [-0.5, 0.5].
*
*
* ACCURACY:
*
* Relative error:
* arithmetic domain # trials peak rms
* DEC +- 88 50000 2.8e-17 7.0e-18
* IEEE +- 708 40000 2.0e-16 5.6e-17
*
*
* Error amplification in the exponential function can be
* a serious matter. The error propagation involves
* exp( X(1+delta) ) = exp(X) ( 1 + X*delta + ... ),
* which shows that a 1 lsb error in representing X produces
* a relative error of X times 1 lsb in the function.
* While the routine gives an accurate result for arguments
* that are exactly represented by a double precision
* computer number, the result contains amplified roundoff
* error for large arguments not exactly represented.
*
*
* ERROR MESSAGES:
*
* message condition value returned
* exp underflow x < MINLOG 0.0
* exp overflow x > MAXLOG INFINITY
*
*/


/*
Cephes Math Library Release 2.8: June, 2000
Copyright 1984, 1995, 2000 by Stephen L. Moshier
*/


/* Exponential function */

#include "mconf.h"

#ifdef UNK

static double P[] =
{
1.26177193074810590878E-4,
3.02994407707441961300E-2,
9.99999999999999999910E-1,
};
static double Q[] =
{
3.00198505138664455042E-6,
2.52448340349684104192E-3,
2.27265548208155028766E-1,
2.00000000000000000009E0,
};
static double C1 = 6.93145751953125E-1;
static double C2 = 1.42860682030941723212E-6;
#endif

#ifdef DEC
static unsigned short P[] =
{
0035004, 0047156, 0127442, 0057502,
0036770, 0033210, 0063121, 0061764,
0040200, 0000000, 0000000, 0000000,
};
static unsigned short Q[] =
{
0033511, 0072665, 0160662, 0176377,
0036045, 0070715, 0124105, 0132777,
0037550, 0134114, 0142077, 0001637,
0040400, 0000000, 0000000, 0000000,
};
static unsigned short sc1[] =
{0040061, 0071000, 0000000, 0000000};
#define C1 (*(double *)sc1)
static unsigned short sc2[] =
{0033277, 0137216, 0075715, 0057117};
#define C2 (*(double *)sc2)
#endif

#ifdef IBMPC
static unsigned short P[] =
{
0x4be8, 0xd5e4, 0x89cd, 0x3f20,
0x2c7e, 0x0cca, 0x06d1, 0x3f9f,
0x0000, 0x0000, 0x0000, 0x3ff0,
};
static unsigned short Q[] =
{
0x5fa0, 0xbc36, 0x2eb6, 0x3ec9,
0xb6c0, 0xb508, 0xae39, 0x3f64,
0xe074, 0x9887, 0x1709, 0x3fcd,
0x0000, 0x0000, 0x0000, 0x4000,
};
static unsigned short sc1[] =
{0x0000, 0x0000, 0x2e40, 0x3fe6};
#define C1 (*(double *)sc1)
static unsigned short sc2[] =
{0xabca, 0xcf79, 0xf7d1, 0x3eb7};
#define C2 (*(double *)sc2)
#endif

#ifdef MIEEE
static unsigned short P[] =
{
0x3f20, 0x89cd, 0xd5e4, 0x4be8,
0x3f9f, 0x06d1, 0x0cca, 0x2c7e,
0x3ff0, 0x0000, 0x0000, 0x0000,
};
static unsigned short Q[] =
{
0x3ec9, 0x2eb6, 0xbc36, 0x5fa0,
0x3f64, 0xae39, 0xb508, 0xb6c0,
0x3fcd, 0x1709, 0x9887, 0xe074,
0x4000, 0x0000, 0x0000, 0x0000,
};
static unsigned short sc1[] =
{0x3fe6, 0x2e40, 0x0000, 0x0000};
#define C1 (*(double *)sc1)
static unsigned short sc2[] =
{0x3eb7, 0xf7d1, 0xcf79, 0xabca};
#define C2 (*(double *)sc2)
#endif

extern double LOGE2, LOG2E, MAXLOG, MINLOG, MAXNUM;
#ifdef INFINITIES
extern double INFINITY;
#endif

double
exp (double x)
{
double px, xx;
int n;

#ifdef NANS
if (isnan (x))
return (x);
#endif
if (x > MAXLOG)
{
#ifdef INFINITIES
return (INFINITY);
#else
mtherr ("exp", OVERFLOW);
return (MAXNUM);
#endif
}
if (x < MINLOG)
{
#ifndef INFINITIES
mtherr ("exp", UNDERFLOW);
#endif
return (0.0);
}
/* Express e**x = e**g 2**n
* = e**g e**( n loge(2) )
* = e**( g + n loge(2) )
*/
px = floor (LOG2E * x + 0.5); /* floor() truncates toward -infinity.
*/
n = px;
x -= px * C1;
x -= px * C2;

/* rational approximation for exponential
* of the fractional part:
* e**x = 1 + 2x P(x**2)/( Q(x**2) - P(x**2) )
*/
xx = x * x;
px = x * polevl (xx, P, 2);
x = px / (polevl (xx, Q, 3) - px);
x = 1.0 + 2.0 * x;

/* multiply by power of 2 */
x = ldexp (x, n);
return (x);
}
 
D

Dik T. Winter

> On 14 Mar 2009 12:01:03 GMT, (e-mail address removed) (Richard Tobin)
> wrote: .... ....
> Actually it is less than trivial result.

It is trivial. Given the following definitions:
exp(x) is the function whose derivative is exp(x) with exp(0) = 1
log(x) = integral{1..x} dx/x
Now I use the following theorem:
given a function f and a function g where g is the inverse of f in
that case we have (primes note derivative function):
g'(x) = 1/[f'(g(x)]
which is fairly easy to prove using basic properties of derivatives.

Set f = log(x), we have:
g'(x) = 1/[log'(g(x)] = 1/[1/g(x)]] = g(x)
so the inverse function has the functional definition of exp(x). It remains
to prove that g(0) = 1, but that follows because f(1) = 0. So exp(x) is the
inverse of log(x).

So, if we define e = exp(1) we find immediately log(e) = 1.

What part of the above is not trivial?
 
D

Dik T. Winter

> On Fri, 13 Mar 2009 11:27:13 GMT, "Dik T. Winter" <[email protected]>
> wrote: ....
>
> Since when? Or are you twisting away from trying to evaluate those
> two cases?

Since those "functions" are applied to complex numbers. In complex
analysis log(x) is not a single-valued "function" (read something about
Riemann surfaces). That is, for any x log(x) is the set of values
{Log(x) + 2k*pi*i}
where Log(x) indicates some main value (for real x it is the real valued
log(x)).
(You can see that for each of these values exp will give the same result,
the reason is that exp(z) is a periodic function with period 2*pi*i.)
So, when we allow multi-valued functions on a proper Riemann surface
we get (using Log for some main value, and I use -k rather than k):
2^(i * pi) = exp(i * pi * log(2)) =
= exp(i * pi * (Log(2) - 2 * k * pi * i)) =
= exp(i * pi * Log(2) + 2 * k * pi * pi) =
= exp(i * pi * Log(2)) * exp(2 * k * pi * pi) =
= (cos(Log(2)*pi) + i * sin(Log(2)*pi) * exp(2 * k * pi * pi).
for arbitrary k.
> > The mathematical definition
> >of the exponentiation operator is:
> > a^b = exp(b.log(a))
> >where that is well-defined. Where in that definition is 'e' used?
>
> The base value of the exp() and log()[really ln()] functions??

Where in the definitions is the term "base" used? And in mathematics
generally when you state "log" you mean the natural logarithm. A quote
from mathworld.com:
"Note that while logarithm base 10 si denoted 'log x' in this work, on
calculators, and in elementary algebra and calculus textbooks,
mathematicians and advanced mathematics text uniformly use the
notation 'log x' to mean 'ln x', and therefore use 'log_10 x' to
mean the common logarithm. Extreme care is therefore needed when
consulting the literature.'
And I warn you for number theorists they sometimes give a completely
different meaning to 'log_10 x'.
 
P

Phil Carmody

JosephKK said:
OK in your POV ln() is special.

No. From a mathematians PoV it's special. Look at its history,
its properties, and its uses.
It is certainly convenient for
algorithm development.

Bullcrap. I've seen lg(n) a thousand times more than log(n) in
discussions about algorithm development.
Now can you, Phil, or James explain what the
value of log10(4-i5) is and why that is the correct answer.

Yes.

Phil
 
J

James Kuyper

JosephKK wrote:
....
OK in your POV ln() is special. ...

Yes, like most mathematicians, scientists, and engineers, we think it's
special. There's a very good reason why it's on of the few "special
functions" that are actually present in the C standard library.
... Now can you, Phil, or James explain what the
value of log10(4-i5) is and why that is the correct answer.

I'm sure that I can, but I sense a trap; I suspect that you're looking
for something different from what I would naively think you're asking
for. Therefore, could you show me what the kind of answer you're looking
for, by giving me an example of what you think the correct answer would
look like to a similar but simpler question: "What is the value of
ln(4), and why is that the correct answer?".
 
J

James Kuyper

JosephKK said:
Nothing but a scalar difference i say.

There's nothing but a scalar difference separating 1 from e, or e from
pi, or pi from 10. If scalar differences are important, than there are
no special numbers.
 
A

Antoninus Twink

It is trivial.

There are several non-trivial things that you have brushed under the
carpet.
Given the following definitions:
exp(x) is the function whose derivative is exp(x) with exp(0) = 1

Is it obvious that there is a unique function on R that is its own
derivative? Is it obvious that there aren't non-analytic functions with
that property?

Why not just use the standard definition as a power series?
exp(x) = 1 + x + x^2/2! + x^3/3! + ...
log(x) = integral{1..x} dx/x
Now I use the following theorem:
given a function f and a function g where g is the inverse of f in
that case we have (primes note derivative function):
g'(x) = 1/[f'(g(x)]
which is fairly easy to prove using basic properties of derivatives.

Set f = log(x), we have:
g'(x) = 1/[log'(g(x)] = 1/[1/g(x)]] = g(x)

But how do you know that f has an inverse and that it's differentiable?
You need some version of the Inverse Function Theorem, which is
distinctly non-trivial. (And to apply it, you need to show that exp'(x)
never vanishes.)
 
D

Dik T. Winter

>
> There are several non-trivial things that you have brushed under the
> carpet.

You think so. Note that the triviality was about log(e) = 1, nothing else.
>
> Is it obvious that there is a unique function on R that is its own
> derivative? Is it obvious that there aren't non-analytic functions with
> that property?

It must be immediately clear there are no non-analytic functions with that
property. Analytic means that the function has a derivative in the region
over which it is analytic.
> Why not just use the standard definition as a power series?
> exp(x) = 1 + x + x^2/2! + x^3/3! + ...

Why not use the standard definition as I gave it? In general exp(x) is
*not* defined by the power series, that would make proving the properties
quite a bit more difficult.
> > log(x) = integral{1..x} dx/x
> > Now I use the following theorem:
> > given a function f and a function g where g is the inverse of f in
> > that case we have (primes note derivative function):
> > g'(x) = 1/[f'(g(x)]
> > which is fairly easy to prove using basic properties of derivatives.
> >
> > Set f = log(x), we have:
> > g'(x) = 1/[log'(g(x)] = 1/[1/g(x)]] = g(x)
>
> But how do you know that f has an inverse and that it's differentiable?
> You need some version of the Inverse Function Theorem, which is
> distinctly non-trivial. (And to apply it, you need to show that exp'(x)
> never vanishes.)

Note: the triviality was proving that log(e) = 1.
 
A

Antoninus Twink

It must be immediately clear there are no non-analytic functions with
that property. Analytic means that the function has a derivative in
the region over which it is analytic.

Perhaps I am being dim, but why does that immediately imply it?

By analytic, I mean given by a convergent power series. For functions
from C to C, this is equivalent to being infinitely differentiable (in
the complex sense), but for functions from R to R, being analytic is a
stronger property.

I happily agree that it's immediately clear that
exp(x) = 1 + x + x^2/2! +...
is the unique analytic function from R to R (or from C to C) with
exp'=exp, but I don't see a simple reason why there couldn't be a
non-analytic function f:R->R with f'=f (of course, f could not be the
restriction of a holomorphic function on C).
 
U

user923005

Perhaps I am being dim, but why does that immediately imply it?

By analytic, I mean given by a convergent power series. For functions
from C to C, this is equivalent to being infinitely differentiable (in
the complex sense), but for functions from R to R, being analytic is a
stronger property.

I happily agree that it's immediately clear that
exp(x) = 1 + x + x^2/2! +...
is the unique analytic function from R to R (or from C to C) with
exp'=exp, but I don't see a simple reason why there couldn't be a
non-analytic function f:R->R with f'=f (of course, f could not be the
restriction of a holomorphic function on C).

Previously we had this:
AT:
Dik:
It must be immediately clear there are no non-analytic functions with that
property. Analytic means that the function has a derivative in the region
over which it is analytic.

If a function does not have a derivative {in the region of interest}
then it cannot possibly be its own derivative.
It follows instantly from the definition.
 
A

Antoninus Twink

Dik:

If a function does not have a derivative {in the region of interest}
then it cannot possibly be its own derivative.
It follows instantly from the definition.

I think you're making the mistake of assuming that a statement is
equivalent to the converse of its contrapositive :)

A function f is analytic on R if there is a power series Sum(a_n x^n)
such that the series converges to f(x) for every x in R.

This implies that f is differentiable. (In fact, that f is infinitely
differentiable, and the power series Sum(a_n x^n) is none other than the
Taylor series of f about 0.)

But the converse is false: there are differentiable functions that are
not analytic. The canonical example is
f(x)= exp(-1/x^2) if x!=0
= 0 if x==0
This is infinitely differentiable, but all its derivatives at 0 are 0,
so the Taylor series of f does not converge to f.
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top