Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Using interact

I want to visualize these functions in the complex plane:

$$f_n(z)=\exp(z) - \sum_{k=0}^{n} \frac{z^k}{k!}$$

I tried this code, but it gives me an error.

z,k = var('z,k')
@interact
    def _(n=(1..8)):
    complex_plot(exp(z)- sum(z^k/factorial(k), k, 0, n), (-5, 5), (-5, 5))

I am new to Sage (I previously used Mathematica). I wrote the code based on this example: http://wiki.sagemath.org/interact/ . How can I fix that?

Using interact

I want to visualize these functions in the complex plane:

$$f_n(z)=\exp(z) - \sum_{k=0}^{n} \frac{z^k}{k!}$$

I tried this code, but it gives me an error.

z,k = var('z,k')
@interact
    def _(n=(1..8)):
    complex_plot(exp(z)- sum(z^k/factorial(k), k, 0, n), (-5, 5), (-5, 5))

I am new to Sage (I previously used Mathematica). I wrote the code based on this example: http://wiki.sagemath.org/interact/ . How can I fix that?

EDIT: I would also like to know why doesn't this work either

def myPlot(n):
   complex_plot(exp(z)- sum(z^k/factorial(k), k, 0, n), (-5, 5), (-5, 5))

Then I type myPlot(2) in the notebook, but I get nothing. However, if I type:

complex_plot(exp(z)- sum(z^k/factorial(k), k, 0, 2), (-5, 5), (-5, 5))

I get the correct plot.

Using interact

I want to visualize these functions in the complex plane:

$$f_n(z)=\exp(z) - \sum_{k=0}^{n} \frac{z^k}{k!}$$

I tried this code, but it gives me an error.

z,k = var('z,k')
@interact
    def _(n=(1..8)):
    complex_plot(exp(z)- sum(z^k/factorial(k), k, 0, n), (-5, 5), (-5, 5))

I am new to Sage (I previously used Mathematica). I wrote the code based on this example: http://wiki.sagemath.org/interact/ . How can I fix that?

EDIT: I would also like to know why doesn't this work either

def myPlot(n):
   complex_plot(exp(z)- sum(z^k/factorial(k), k, 0, n), (-5, 5), (-5, 5))

Then I type myPlot(2) in the notebook, but I get nothing. However, if I type:

complex_plot(exp(z)- sum(z^k/factorial(k), k, 0, 2), (-5, 5), (-5, 5))

I get the correct plot.

EDIT 2:

I tried

myPlot = lambda n: complex_plot(exp(z)- sum(z^k/factorial(k), k, 0, n), (-5, 5), (-5, 5))

And now I can evaluate it. However, I still can't use @Interact.

This doesn't make sense to me.