Question

My program (at this stage) is trying to use newtons method on a function with complex roots (z^3=2). My code looks like this:

f(z)=(z^3-2)
p(z)= f(z)-(f(z)/diff(f(z),z))

Where p(z) is Newton's Method

var('q')
i==1
q[i]=z
    for i in range (0,9):
        q[i+1]=p(q[i])
        print q[i+1]

And the error I'm getting is:

TypeError: Unable to coerce I to an integer

But I don't need it to make I an integer. How do I tell it that, or is there something else I need to do?

Was it helpful?

Solution

There's a typo in your code. You want i=1 instead of i==1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top