Revision history [back]

Condition in sum() function?

Hello,

I'm trying to use the exponential form of the Fourier series representation of a function to plot an approximation of said function using the first five terms.

The actual function is f(t) = 1/2 + j/(2pi) * E from (n = -5) to (n = 5) of ((-1)^n - 1)/n * e^(j2npi*t), where n =/= 0

Here I'm using 'E' to indicate summation notation. I apologize if this deviates from an established standard, but I'm having trouble uploading images right now (which would have made the function clearer).

The code I'm using for this function is

var('n, t')
j = i    # imaginary unit
expr = ((-1)^n - 1)/n * exp(2*pi*n*j*t)    # I think the problem is the division by 'n' here
assume(n, 'integer'); assume(n != 0)
f(t) = 1/2 + j/(2*pi) * sum(expr, n, -5, 5)


However, when I try this, I get the following exception:

 RuntimeError: ECL says: Error executing code in Maxima: expt: undefined: 0 to a negative exponent. 

This seems to be due to the division by n in expr. Are my assumptions not working here? Thus, my actual question is how can I add the condition n != 0 to the sum() function in sage?

Condition in sum() function?

Hello,

I'm trying to use the exponential form of the Fourier series representation of a function to plot an approximation of said function using the first five terms.

The actual function is f(t) = 1/2 + j/(2pi) * E from (n = -5) to (n = 5) of ((-1)^n - 1)/n * e^(j2npi*t), where n =/= 0

Here I'm using 'E' to indicate summation notation. I apologize if this deviates from an established standard, but I'm having trouble uploading images right now (which would have made the function clearer).

The code I'm using for this function is

var('n, t')
j = i    # imaginary unit
expr = ((-1)^n - 1)/n * exp(2*pi*n*j*t)    # I think the problem is the division by 'n' here
assume(n, 'integer'); assume(n != 0)
f(t) = 1/2 + j/(2*pi) * sum(expr, n, -5, 5)


However, when I try this, I get the following exception:

 RuntimeError: ECL says: Error executing code in Maxima: expt: undefined: 0 to a negative exponent. 

This seems to be due to the division by n in expr. Are my assumptions not working here? Thus, my actual question is how can I add the condition n != 0 to the sum() function in sage?

 3 retagged tmonteil 14608 ●19 ●100 ●263 http://wiki.sagemath.o...

Condition in sum() function?

Hello,

I'm trying to use the exponential form of the Fourier series representation of a function to plot an approximation of said function using the first five terms.

The actual function is f(t) = 1/2 + j/(2pi) * E from (n = -5) to (n = 5) of ((-1)^n - 1)/n * e^(j2npi*t), where n =/= 0

Here I'm using 'E' to indicate summation notation. I apologize if this deviates from an established standard, but I'm having trouble uploading images right now (which would have made the function clearer).

The code I'm using for this function is

var('n, t')
j = i    # imaginary unit
expr = ((-1)^n - 1)/n * exp(2*pi*n*j*t)    # I think the problem is the division by 'n' here
assume(n, 'integer'); assume(n != 0)
f(t) = 1/2 + j/(2*pi) * sum(expr, n, -5, 5)


However, when I try this, I get the following exception:

 RuntimeError: ECL says: Error executing code in Maxima: expt: undefined: 0 to a negative exponent. 

This seems to be due to the division by n in expr. Are my assumptions not working here? Thus, my actual question is how can I add the condition n != 0 to the sum() function in sage?

 4 retagged FrédéricC 1666 ●1 ●20 ●30

Condition in sum() function?

Hello,

I'm trying to use the exponential form of the Fourier series representation of a function to plot an approximation of said function using the first five terms.

The actual function is f(t) = 1/2 + j/(2pi) * E from (n = -5) to (n = 5) of ((-1)^n - 1)/n * e^(j2npi*t), where n =/= 0

Here I'm using 'E' to indicate summation notation. I apologize if this deviates from an established standard, but I'm having trouble uploading images right now (which would have made the function clearer).

The code I'm using for this function is

var('n, t')
j = i    # imaginary unit
expr = ((-1)^n - 1)/n * exp(2*pi*n*j*t)    # I think the problem is the division by 'n' here
assume(n, 'integer'); assume(n != 0)
f(t) = 1/2 + j/(2*pi) * sum(expr, n, -5, 5)


However, when I try this, I get the following exception:

 RuntimeError: ECL says: Error executing code in Maxima: expt: undefined: 0 to a negative exponent. 

This seems to be due to the division by n in expr. Are my assumptions not working here? Thus, my actual question is how can I add the condition n != 0 to the sum() function in sage?