3
$\begingroup$

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

$\endgroup$
7
$\begingroup$

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]]]]]
$\endgroup$
  • $\begingroup$ Right, and Log[100.] evaluates so it has no deeper pieces. $\endgroup$ – rcollyer Jan 9 '14 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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