Integral of 1/x faulty?
Feb 18, 2010
03:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Feb 18, 2010
03:00 AM
Integral of 1/x faulty?
Just ran across what seems to be an error.
Then Integral of 1/x should be ln(|x|) but Mathcad sysmbolics (MC14_M030) forgets the absoulute value.
It seems to ignore the assumption of a variable range too. I remember having a similar effect with solve (trying to force the negative solution and Mathcad still serving a positive one). I'll try to find the file to post.
Another strange effect is that it refuses to plot a function which ist defined as the integral of a funcion, while it works fine with the derivation.
RMix
Then Integral of 1/x should be ln(|x|) but Mathcad sysmbolics (MC14_M030) forgets the absoulute value.
It seems to ignore the assumption of a variable range too. I remember having a similar effect with solve (trying to force the negative solution and Mathcad still serving a positive one). I'll try to find the file to post.
Another strange effect is that it refuses to plot a function which ist defined as the integral of a funcion, while it works fine with the derivation.
RMix
Labels:
- Labels:
-
Calculus_Derivatives
7 REPLIES 7
Feb 18, 2010
03:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Feb 18, 2010
03:00 AM
The use of ln(|x|) as the integral of 1/x is shown in some elementary texts. But it is actually wrong. It can be useful in some cases, with x sufficiently restricted, but it turns out that it provides correct answers in some cases only because of two canceling errors.
The indefinite integral is (by Mathcad definition) for symbolic evaluation only. It cannot be evaluated numerically, which is what the plot routine needs to do. Nor is it even properly a function. It is a family of functions, any two of which differ by a constant. No proper value can be assigned to the indefinite integral per se.
__________________
� � � � Tom Gutman
The indefinite integral is (by Mathcad definition) for symbolic evaluation only. It cannot be evaluated numerically, which is what the plot routine needs to do. Nor is it even properly a function. It is a family of functions, any two of which differ by a constant. No proper value can be assigned to the indefinite integral per se.
__________________
� � � � Tom Gutman
Feb 19, 2010
03:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Feb 19, 2010
03:00 AM
Feb 19, 2010
03:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Feb 19, 2010
03:00 AM
On 2/18/2010 10:44:46 PM, Tom_Gutman wrote:
>The use of ln(|x|) as the
>integral of 1/x is shown in
>some elementary texts. But it
>is actually wrong. It can be
>useful in some cases, with x
>sufficiently restricted, but
Thats why I had the "assume, x=real" modifier.
And with the "assume, x<0" to me the MC-Answer "ln(x)" is definitely wrong. So I call it a bug.
>it turns out that it provides
>correct answers in some cases
>only because of two canceling
>errors.
??
>The indefinite integral is (by
>Mathcad definition) for
>symbolic evaluation only. It
>cannot be evaluated
>numerically, which is what the
>plot routine needs to do.
Yes, but you can assign it to a function which then can be numerically evaluated and plotted.
It works with the derivative, which also is for symbolic evaluation only, so why not with the integral?
>is it even properly a
>function. It is a family of
>functions, any two of which
>differ by a constant.
Sure, but Mathcads symbolic is not considering that constant and serves the user with just one function out of the familiy which you can use in a function definition an plot.
The question is what MC does when you assign f(x):={indefinite integral} without following the definition with the symbolic evaluation. Obviously f(x) is only defined symbolically and not numerically. If you follow the definition by the symbolic evaluation the function is also defined numerically and can be evaluated and plotted. Not really intuitive, to say the least.
Its also inconsistant that the behaviour is changed when using the derivation instead of the integral - it does not matter if you evaluate symbolically after the function definition or not.
RMix
>The use of ln(|x|) as the
>integral of 1/x is shown in
>some elementary texts. But it
>is actually wrong. It can be
>useful in some cases, with x
>sufficiently restricted, but
Thats why I had the "assume, x=real" modifier.
And with the "assume, x<0" to me the MC-Answer "ln(x)" is definitely wrong. So I call it a bug.
>it turns out that it provides
>correct answers in some cases
>only because of two canceling
>errors.
??
>The indefinite integral is (by
>Mathcad definition) for
>symbolic evaluation only. It
>cannot be evaluated
>numerically, which is what the
>plot routine needs to do.
Yes, but you can assign it to a function which then can be numerically evaluated and plotted.
It works with the derivative, which also is for symbolic evaluation only, so why not with the integral?
>is it even properly a
>function. It is a family of
>functions, any two of which
>differ by a constant.
Sure, but Mathcads symbolic is not considering that constant and serves the user with just one function out of the familiy which you can use in a function definition an plot.
The question is what MC does when you assign f(x):={indefinite integral} without following the definition with the symbolic evaluation. Obviously f(x) is only defined symbolically and not numerically. If you follow the definition by the symbolic evaluation the function is also defined numerically and can be evaluated and plotted. Not really intuitive, to say the least.
Its also inconsistant that the behaviour is changed when using the derivation instead of the integral - it does not matter if you evaluate symbolically after the function definition or not.
RMix
Feb 19, 2010
03:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Feb 19, 2010
03:00 AM
On 2/19/2010 10:46:08 AM, rmix22 wrote:
Thats why I had the "assume, x=real"
>modifier.
And with the "assume, x<0" to
>me the MC-Answer "ln(x)" is definitely
>wrong. So I call it a bug.
No, it is correct. Why do you say it is "definitely" wrong?
>The indefinite
>integral is (by
>Mathcad definition)
>for
>symbolic evaluation only.
>It
>cannot be evaluated
>numerically,
>which is what the
>plot routine needs to
>do.
Yes, but you can assign it to a
>function which then can be numerically
>evaluated and plotted.
An indefinite integral cannot be numerically evaluated. That is not possible. Numerical evaluation of an integral is only possible if it has limits.
>It works with the
>derivative, which also is for symbolic
>evaluation only, so why not with the
>integral?
The derivative is not only for symbolic evaluation. You can calculate a numeric derivative.
>The question is what MC does when
>you assign f(x):={indefinite integral}
>without following the definition with
>the symbolic evaluation. Obviously f(x)
>is only defined symbolically and not
>numerically. If you follow the
>definition by the symbolic evaluation
>the function is also defined numerically
>and can be evaluated and plotted. Not
>really intuitive, to say the least.
Why? It seems clear to me. If you evaluate the integral symbolically then you have an expression that can be evaluated numerically. If you do not evaluate the integral symbolically then you do not have an expression that can be evaluated numerically.
>Its
>also inconsistant that the behaviour is
>changed when using the derivation
>instead of the integral - it does not
>matter if you evaluate symbolically
>after the function definition or
>not.
Yes it does. Without the symbolic evaluation the derivative is evaluated numerically, and the answer is approximate (depending on a few factors, according to the help to about 7 or 8 significant digits). With the symbolic evaluation the final expression is evaluated numerically, and the precision will typically be limited by computer roundoff.
Richard
Thats why I had the "assume, x=real"
>modifier.
And with the "assume, x<0" to
>me the MC-Answer "ln(x)" is definitely
>wrong. So I call it a bug.
No, it is correct. Why do you say it is "definitely" wrong?
>The indefinite
>integral is (by
>Mathcad definition)
>for
>symbolic evaluation only.
>It
>cannot be evaluated
>numerically,
>which is what the
>plot routine needs to
>do.
Yes, but you can assign it to a
>function which then can be numerically
>evaluated and plotted.
An indefinite integral cannot be numerically evaluated. That is not possible. Numerical evaluation of an integral is only possible if it has limits.
>It works with the
>derivative, which also is for symbolic
>evaluation only, so why not with the
>integral?
The derivative is not only for symbolic evaluation. You can calculate a numeric derivative.
>The question is what MC does when
>you assign f(x):={indefinite integral}
>without following the definition with
>the symbolic evaluation. Obviously f(x)
>is only defined symbolically and not
>numerically. If you follow the
>definition by the symbolic evaluation
>the function is also defined numerically
>and can be evaluated and plotted. Not
>really intuitive, to say the least.
Why? It seems clear to me. If you evaluate the integral symbolically then you have an expression that can be evaluated numerically. If you do not evaluate the integral symbolically then you do not have an expression that can be evaluated numerically.
>Its
>also inconsistant that the behaviour is
>changed when using the derivation
>instead of the integral - it does not
>matter if you evaluate symbolically
>after the function definition or
>not.
Yes it does. Without the symbolic evaluation the derivative is evaluated numerically, and the answer is approximate (depending on a few factors, according to the help to about 7 or 8 significant digits). With the symbolic evaluation the final expression is evaluated numerically, and the precision will typically be limited by computer roundoff.
Richard
Mar 20, 2010
03:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Mar 20, 2010
03:00 AM
>And with the "assume, x<0" to
>>me the MC-Answer "ln(x)" is definitely
>>wrong. So I call it a bug.
>
>No, it is correct. Why do you say it is
>"definitely" wrong?
Not mathematically wrong, as ln(-x)=ln(x)+pi*i, but to me it seems that MC is ignoring the assumption (x=real, x<0). With these assumptions I would consider ln(-x) to be more appropriate. At least I canfind no other way of telling Mathcad to stay in the real range whenever possible other than assuming the variables to be real numbers.
>>definition by the symbolic evaluation
>>the function is also defined numerically
>>and can be evaluated and plotted. Not
>>really intuitive, to say the least.
>
>Why? It seems clear to me. If you
After rethinking about that I agree. The behaviour is as is should be and as one should expect. Thanks for your explanations. Maybe I was a little bit confused about what the assignment operator does assign - its the expression to the very right, not the one immedeately after the assignment. Therefore it makes a difference if a symbolic evaluation is made after the assignment (actually its done before) or not.
RMix
>>me the MC-Answer "ln(x)" is definitely
>>wrong. So I call it a bug.
>
>No, it is correct. Why do you say it is
>"definitely" wrong?
Not mathematically wrong, as ln(-x)=ln(x)+pi*i, but to me it seems that MC is ignoring the assumption (x=real, x<0). With these assumptions I would consider ln(-x) to be more appropriate. At least I canfind no other way of telling Mathcad to stay in the real range whenever possible other than assuming the variables to be real numbers.
>>definition by the symbolic evaluation
>>the function is also defined numerically
>>and can be evaluated and plotted. Not
>>really intuitive, to say the least.
>
>Why? It seems clear to me. If you
After rethinking about that I agree. The behaviour is as is should be and as one should expect. Thanks for your explanations. Maybe I was a little bit confused about what the assignment operator does assign - its the expression to the very right, not the one immedeately after the assignment. Therefore it makes a difference if a symbolic evaluation is made after the assignment (actually its done before) or not.
RMix
Feb 19, 2010
03:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Feb 19, 2010
03:00 AM
>>>it turns out that it provides
>correct answers in some cases
>only because of two canceling
>errors.
??<<
Start by remembering that the log function is only properly defined for positive real numbers. While there are various extensions to negative and complex numbers, none really work right. Using the typical principal value approach you end up with a function that is not a proper inverse to the exp function, and which does not satisfy the basic logarithmic identities (such as ln(ab)=ln(a)+ln(b)).
The proper general indefinite integral of 1/x is ln(kx), where k is a constant. For this to make sense, it is required that kx be real and positive. It is not required that k and x individually be so, nor have their logarithms defined (they could be negative, complex, or even physical quantities with units).
The form ln(|x|) is equivalent, for real x, to choosing k=1 for positive x and -1 for negative x. This form then works with no problems for an integral from a to b where a and b have the same sign. If a and b have different signs, then using that form is equivalent to using a different value of k (the constant of integration) for the two end points. This is an error, and introduces an error of πi in the result. But integrating from a to b with a and b having different signs means integrating over the singularity at zero. That is also an error, and introduces an error of πi. It turns out that the two errors cancel, so the form ln(|x|) gives the correct result integrating from a to b (a, b real) regardless of the signs of a and b. Hence the possible usefulness of this incorrect form.
__________________
� � � � Tom Gutman
>correct answers in some cases
>only because of two canceling
>errors.
??<<
Start by remembering that the log function is only properly defined for positive real numbers. While there are various extensions to negative and complex numbers, none really work right. Using the typical principal value approach you end up with a function that is not a proper inverse to the exp function, and which does not satisfy the basic logarithmic identities (such as ln(ab)=ln(a)+ln(b)).
The proper general indefinite integral of 1/x is ln(kx), where k is a constant. For this to make sense, it is required that kx be real and positive. It is not required that k and x individually be so, nor have their logarithms defined (they could be negative, complex, or even physical quantities with units).
The form ln(|x|) is equivalent, for real x, to choosing k=1 for positive x and -1 for negative x. This form then works with no problems for an integral from a to b where a and b have the same sign. If a and b have different signs, then using that form is equivalent to using a different value of k (the constant of integration) for the two end points. This is an error, and introduces an error of πi in the result. But integrating from a to b with a and b having different signs means integrating over the singularity at zero. That is also an error, and introduces an error of πi. It turns out that the two errors cancel, so the form ln(|x|) gives the correct result integrating from a to b (a, b real) regardless of the signs of a and b. Hence the possible usefulness of this incorrect form.
__________________
� � � � Tom Gutman
Mar 20, 2010
03:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Mar 20, 2010
03:00 AM
On 2/19/2010 4:53:20 PM, Tom_Gutman wrote:
>>>>it turns out that it provides
>>correct answers in some cases
>>only because of two canceling
>>errors.
>??<<
>
>Start by remembering that the
>log function is only properly
> ...
It good to see the forum is up and running again.
Thanks for your patient and detailed explanations - they are highly appreciated. While I was aware of some ambiguity and problems with the definition of ln(x) I must confess, that the explanation with the two canceling errors was interesting and quite illuminative.
>The proper general indefinite
>integral of 1/x is ln(kx),
>where k is a constant. For
>this to make sense, it is
>required that kx be real and
>positive.
This is exactly why I would prefer INT(1/x,x) be shown as ln(-x) at least when I assume x<0.
Thanks and regards
RMix
>>>>it turns out that it provides
>>correct answers in some cases
>>only because of two canceling
>>errors.
>??<<
>
>Start by remembering that the
>log function is only properly
> ...
It good to see the forum is up and running again.
Thanks for your patient and detailed explanations - they are highly appreciated. While I was aware of some ambiguity and problems with the definition of ln(x) I must confess, that the explanation with the two canceling errors was interesting and quite illuminative.
>The proper general indefinite
>integral of 1/x is ln(kx),
>where k is a constant. For
>this to make sense, it is
>required that kx be real and
>positive.
This is exactly why I would prefer INT(1/x,x) be shown as ln(-x) at least when I assume x<0.
Thanks and regards
RMix
