I'm trying to run this code, a simple-minded implementation of Newton's method:
g(x) = cos(x)-x
      g_prime(x) = g.diff()
      start = 1
      number_of_steps = 5
      x = start
      for n in range(number_of_steps+1):
          print('step number: ',n,'; Newton estimate: ',x.n())
          if g_prime(x)!=0:
             x = x - g(x)/g_prime(x)
On my old Windows based 9.2 (terminal), it takes a minute but prints out steps 0 to 5 and gives me a new prompt.
On 10.6, however (running in WSL, Jupyter notebook), it prints out steps 0 to 4, waits quite a while, prints out step 5, and then the notebook prompt stays [*] indicating that the kernel is still running.
If I change the number of steps to 8, even in 9.2 it hangs. And it slows down dramatically in the later steps. I'm clearly doing something wrong. What?
Thanks,
Fernando
-- ============================================================= Fernando Q. Gouvea http://www.colby.edu/~fqgouvea Carter Professor of Mathematics Dept. of Mathematics Colby College 5836 Mayflower Hill Waterville, ME 04901 You can go wrong by being too skeptical as readily as by being too trusting. -- Robert A. Heinlein
Update: I left it running and yes, it does eventually exit. So perhaps the question is why it takes so much longer to do the next step when n=5 than when n=4. The values of x seem to be identical in both steps.
Fernando
Ah, I think I see it. The step should be x = (x - g(x)/g_prime(x)).n(); otherwise x is becoming an immensely long expression with sin(1) and cos(1).
Sorry to bother y'all.
Fernando
Carter Professor of Mathematics Dept. of Mathematics Colby College 5836 Mayflower Hill Waterville, ME 04901 Frankfurt School advocates are closest to Manichaeans or Gnostics. You need to internalize an amazingly complex mythology and swallow a number of impossible things (especially Marxist impossible things) as a midnight snack to prepare yourself for what you'll be having for breakfast the next day. It's impressive -- they don't mention Marx much, but without him it's hard to make out what's being said. The gist seems to be that the Enlightenment gave everyone the ability to reason whatever they wanted, so now we can't say anything objective). Because of this, Adorno writes essays in fragments, without theses or conclusions. I kid you not. His disciples, however, conveniently summarize them in introductions to his books. I'm still not kidding. -- Marcos B. Gouvêa, in "The New Faiths"