Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This is Right.

NestWhile[Log, 100, # > 1 &]
{100} //. {x_} /; x > 1 :> {Log[x]}
100. //. x_ /; x > 1 :> Log[x]

This is wrong,why?

100 //. x_ /; x > 1 :> Log[x]

enter image description here

share|improve this question
add comment

1 Answer 1

The reason your final form fails is that ReplaceRepeated will replace deeper parts of the expression when the first pattern test fails. Like this:

Log[Log[Log[100]]] /. x_ /; x > 1 :> flag[x]
Log[flag[Log[Log[100]]]]

You'll get a similar (though not identical) error message from this:

Nest[Log, 100, 50] > 1;

Greater::nord: Invalid comparison with Log[Log[Log[Log[Log[Log[Log[Log[<<1>>]]]]]]]] attempted. >>

After Log is nested five times you get the I Pi term seen in your original message:

 Nest[Log, 100, 5]
I π + Log[-Log[Log[Log[Log[100]]]]]
share|improve this answer
    
Right, and Log[100.] evaluates so it has no deeper pieces. –  rcollyer Jan 9 at 14:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.