cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Log of a square or square of a log?

bearthrowl
1-Newbie

Log of a square or square of a log?

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

5 REPLIES 5

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

... and a correct sine - without brackets:

Correct-Sin.png

Valery Ochkov wrote:

... and a correct sine - without brackets:

Correct-Sin.png

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

Alan

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

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

Top Tags