470,849 Members | 698 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

Logarithms

Guys,

Here is my sample ASP code

<%
response.write log(2.63852242744063E-03)
%>

It shows -5.93753620508243 for result.

The same formula in Excel (or Google calculator) returns -2.57863921

Am I missing something?!?

K
Jul 21 '05 #1
13 2316
Konstantin Loguinov wrote:
Guys,

Here is my sample ASP code

<%
response.write log(2.63852242744063E-03)
%>

It shows -5.93753620508243 for result.

The same formula in Excel (or Google calculator) returns -2.57863921

Am I missing something?!?

K


Yes. The vbscript log function returns the natural log of a number, not the
base-10 log. From the documentation:

You can calculate base-n logarithms for any number x by dividing the natural
logarithm of x by the natural logarithm of n as follows:

Logn(x) = Log(x) / Log(n)The following example illustrates a custom Function
that calculates base-10 logarithms:

Function Log10(X)
Log10 = Log(X) / Log(10)
End FunctionOh! The vbscript documentation can be downloaded
here:http://www.microsoft.com/downloads/d...01592c48-207d-
4be1-8a76-1c4099d7bbb9&DisplayLang=en
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 21 '05 #2
Nevermind... Log and Ln in Excel are aparently two different functions.

K

"Konstantin Loguinov" <st*********@hotmail.com.NOSPAM> wrote in message
news:O3**************@TK2MSFTNGP12.phx.gbl...
Guys,

Here is my sample ASP code

<%
response.write log(2.63852242744063E-03)
%>

It shows -5.93753620508243 for result.

The same formula in Excel (or Google calculator) returns -2.57863921

Am I missing something?!?

K

Jul 21 '05 #3
Konstantin Loguinov wrote:
Nevermind... Log and Ln in Excel are aparently two different
functions.


And yet they differ only by a constant.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 21 '05 #4
Dave Anderson wrote on 03 nov 2004 in
microsoft.public.inetserver.asp.general:
Konstantin Loguinov wrote:
Nevermind... Log and Ln in Excel are aparently two different
functions.


And yet they differ only by a constant.


Impossible, but the results could.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 21 '05 #5
Evertjan. wrote:
Nevermind... Log and Ln in Excel are aparently two different
functions.


And yet they differ only by a constant.


Impossible, but the results could.


Not impossible - fact. ln(10) is a constant, and ln(x) = ln(10) * log(x).
Put another way, ln(x)/log(x) is a constant, so one is merely a scaled
version of the other.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 21 '05 #6
Dave Anderson wrote on 03 nov 2004 in
microsoft.public.inetserver.asp.general:
Evertjan. wrote:
Nevermind... Log and Ln in Excel are aparently two different
functions.

And yet they differ only by a constant.


Impossible, but the results could.


Not impossible - fact. ln(10) is a constant, and ln(x) = ln(10) *
log(x). Put another way, ln(x)/log(x) is a constant, so one is merely
a scaled version of the other.


But Dave, they are not functions. ln(1) is not a function in itself., it
is a function of 10.

If this where true, all functions resulting [for fixed parameters] in a
constant value could only differ by a constant.

=========

I concede to the fact that some routines without external variable
parameters and resultiong in a constant are mistakenly(!) called
functions in vbs, js and other languages.

function ten()
ten=10
ensd function

function ten(){
return 10
}
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 21 '05 #7
Evertjan. wrote:
Not impossible - fact. ln(10) is a constant, and ln(x) = ln(10) *
log(x). Put another way, ln(x)/log(x) is a constant, so one is merely
a scaled version of the other.
But Dave, they are not functions. ln(1) is not a function in itself.,
it is a function of 10.


I assume you mean ln(10), not ln(1). In either case, you are not quite
correct. ln(x) is a function of x. ln(10) is not a function of 10, it is a
constant. x is a variable, 10 is a constant. ln(x) *depends* on x, ln(10)
does not depend on anything. it is always the same value, hence a
"constant".

If this where true, all functions resulting [for fixed parameters] in
a constant value could only differ by a constant.
But ln(x)/log(x) is exactly the same for EVERY x**. This has nothing to do
with fixed parameters.
I concede to the fact that some routines without external variable
parameters and resultiong in a constant are mistakenly(!) called
functions in vbs, js and other languages.

function ten()
ten=10
ensd function

function ten(){
return 10
}


That is not the issue. I am referring to two true functions which are scalar
multiples of each other, such as:

f(x) = the bitlength of string x
g(x) = the bytelength of string x


**Bearing in mind, of course, that neither ln(x) nor log(x) makes sense
unless x > 0

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 21 '05 #8
Dave Anderson wrote on 03 nov 2004 in
microsoft.public.inetserver.asp.general:
ln(10)
does not depend on anything. it is always the same value, hence a
"constant".


Yes, it is constant in value.

No it is not a(!) constant, it is a function.
The return of a value takes much longer than that of a constant.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 21 '05 #9
Evertjan. wrote:
ln(10)
does not depend on anything. it is always the same value, hence a
"constant".


Yes, it is constant in value.

No it is not a(!) constant, it is a function.
The return of a value takes much longer than that of a constant.


It is a constant.
http://msdn.microsoft.com/library/en...6jsproln10.asp
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 21 '05 #10
Evertjan. wrote:
No it is not a(!) constant, it is a function.
The return of a value takes much longer than that of a constant.


I should clarify. The last response was meant to be tongue-in-cheek, but
perhaps more like kidding on the square. ln(10) is a constant in the
mathematical sense, and frequently in the *implementation* sense, as in the
JScript example I provided.

But any way you look at it, it is precisely the ratio of ln(x) to log(x),
when log(x) uses a base of 10. And in that context -- the whole point of
this diversion -- a fixed value is no different from a constant. You cannot
pretend that log(x) differs from ln(x) in any way but a constant scalar.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 21 '05 #11
Dave Anderson wrote on 04 nov 2004 in
microsoft.public.inetserver.asp.general:
Evertjan. wrote:
No it is not a(!) constant, it is a function.
The return of a value takes much longer than that of a constant.
I should clarify. The last response was meant to be tongue-in-cheek,
but perhaps more like kidding on the square. ln(10) is a constant in
the mathematical sense, and frequently in the *implementation* sense,
as in the JScript example I provided.

But any way you look at it, it is precisely the ratio of ln(x) to
log(x), when log(x) uses a base of 10. And in that context -- the
whole point of this diversion -- a fixed value is no different from a
constant. You cannot pretend that log(x) differs from ln(x) in any way
but a constant scalar.


Oh yes, I do pretend it is not a constant in the computer programming
language sense, even the way you write it is different. [The proof of
that I can is in this last sentense]
ln(10) is a constant in the mathematical sense


Certainly not, only the resulting value is constant.

There is a difference between a constant and a variable having a constant
value.

While you could say, a variable is always a constant, I would disagree,
as much as a function is not a constant.

A variable has a constant value AS LONG AS the value is not changed.

A constant has a constant value, that is not allowed to be changed after
creation.

A function is always a function OF something, where the something is able
to change the function.

A tongue in cheek is a joy forever, but if you realy keep it constant, it
could turn out to cause a pain in the neck.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 21 '05 #12
Evertjan. wrote:
Oh yes, I do pretend it is not a constant in the computer programming
language sense, even the way you write it is different. [The proof of
that I can is in this last sentense]
Math.LN10 is not read-write. It is constant. You may continue to ignore the
fact that implementation matters if you want.
ln(10) is a constant in the mathematical sense


Certainly not, only the resulting value is constant.


I can only conclude that you don't understand mathematics.
There is a difference between a constant and a variable having a
constant value.


This is tedious. I have been using the notation ln(10) as a syntactic
shorthand for the constant value represented by the natural logaritm of ten,
but you insist this means I am calling a function. Go ahead - be obtuse. My
point is made.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 21 '05 #13
Dave Anderson wrote on 04 nov 2004 in
microsoft.public.inetserver.asp.general:
Evertjan. wrote:
Oh yes, I do pretend it is not a constant in the computer programming
language sense, even the way you write it is different. [The proof of
that I can is in this last sentense]
Math.LN10 is not read-write. It is constant.


Jscript Math.LN10 is NOT a function.
The Math collection has predefined constants.

btw: functions are never read/write.
You may continue to
ignore the fact that implementation matters if you want.
Plase explain if you think that your implementation changes the
definitions of mathematical and programme language concept like
"function".
ln(10) is a constant in the mathematical sense


Certainly not, only the resulting value is constant.


I can only conclude that you don't understand mathematics.


No need to get personal. Getting personal does not strengthen a point
becaus it degrades credability.

I thought we were talking primarily wich is the ASP platform and it's
computer languages.

But in mathematics the concept "function" only exists as a result
variably dependent on its "function of" input value[s].

There is a difference between a constant and a variable having a
constant value.


This is tedious.


No, it is not, Dave. The notion of "function" in programming and also in
pure mathematics is an important concept.

However, it could be tedious to you, and if so, I suggest you do not
answer anymore.
I have been using the notation ln(10) as a syntactic
shorthand for the constant value represented by the natural logaritm
of ten, but you insist this means I am calling a function. Go ahead -
be obtuse.
Thank you for allowing me to go agead.

You definitely are calling a function here, I insist.

Using a function as a "syntactic shorthand for the constant value" is
what I told you about the difference between "a constant" and something,
here a function, having "a constant value".

I am glad you in fact use that difference in your answer.

The function ln() only has a constant value, because you feed it with a
constant argument. That is exactly what the definition of a function is.
My point is made.


Certainly.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 21 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

24 posts views Thread by Philipp | last post: by
3 posts views Thread by Alex Vinokur | last post: by
2 posts views Thread by cowboyboborton | last post: by
11 posts views Thread by Russ | last post: by
1 post views Thread by Oscar Patarroyo Velasco | last post: by
109 posts views Thread by jmcgill | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.