Skip to main content
1-Visitor
October 3, 2011
Solved

Log of a square or square of a log?

  • October 3, 2011
  • 5 replies
  • 3074 views

On seeing an expression of the form ln(x+a)^2 I would assume that to evaluate it (x+a) is first squared and then the log of the result is found. I was surprised to find that in Mathcad the log is evaluated first and then the result is squared. This seems to apply to other functions. It took me a while to figure out this as the cause of the error in some calculations. Has anyone else been caught out by this or am I being naive?

Best answer by AlanStevens

Brian Earthrowl wrote:

On seeing an expression of the form ln(x+a)^2 I would assume that to evaluate it (x+a) is first squared and then the log of the result is found. I was surprised to find that in Mathcad the log is evaluated first and then the result is squared. This seems to apply to other functions. It took me a while to figure out this as the cause of the error in some calculations. Has anyone else been caught out by this or am I being naive?

If you choose a function from the function menu you will notice that in all cases it is inserted into the worksheet with a name and a pair of brackets, thus: ln(#) or sin(#) or mod(#,#) ...etc. (where the # is a rectangular black placeholder in Mathcad). Thus the function includes the brackets, so ln(#)^2 raises the whole function to the power 2. This also holds if you type the function in by hand. You need to write ln((x+a)^2) if you want to square the argument before activating the function.

Alan

5 replies

24-Ruby IV
October 3, 2011

I always say to my students: use not 2+2*2 but 2+(2*2), not log(2) but log(2, 10) Etc and no problem

24-Ruby IV
October 4, 2011

... and a correct sine - without brackets:

Correct-Sin.png

19-Tanzanite
October 5, 2011

Valery Ochkov wrote:

... and a correct sine - without brackets:

Correct-Sin.png

Interesting one Valery! An unfortunate inconsistency of approach in my view.

Alan

19-Tanzanite
October 3, 2011

Brian Earthrowl wrote:

On seeing an expression of the form ln(x+a)^2 I would assume that to evaluate it (x+a) is first squared and then the log of the result is found. I was surprised to find that in Mathcad the log is evaluated first and then the result is squared. This seems to apply to other functions. It took me a while to figure out this as the cause of the error in some calculations. Has anyone else been caught out by this or am I being naive?

If you choose a function from the function menu you will notice that in all cases it is inserted into the worksheet with a name and a pair of brackets, thus: ln(#) or sin(#) or mod(#,#) ...etc. (where the # is a rectangular black placeholder in Mathcad). Thus the function includes the brackets, so ln(#)^2 raises the whole function to the power 2. This also holds if you type the function in by hand. You need to write ln((x+a)^2) if you want to square the argument before activating the function.

Alan

1-Visitor
October 4, 2011

Thanks Alan. I had copied formulae verbatim from a text book and did not use the function menu. The way Mathcad deals with functions as you describe is logical but caught me unaware at first. I had already fixed the problem with additional pairs of brackets.

Brian