# Revision history [back]

### Why Sage cannot pass a value of variable from one function to another nested function?

The first i ran this:

sage: f(x)=(2/n)*(sin(n*x)*(-1)^(n+1))
sage: sum(f, n, 1, 2) #using summation function
-sin(2*x) + 2*sin(x)


So, In this case the result was evaluated correctly.

But if i tried to combine the first line and the second line together:

sage: f(x,k) = sum((2/n)*(sin(n*x)*(-1)^(n+1)), n, 1, k)
#where n = 1,2,3 ... k
sage: f(x,2)
-2*sum((-1)^n*sin(n*x)/n, n, 1, 2)


The result was wrong!

Why sage cannot evaluate mathematical expression in this case?

Another tried to prove that Sage can pass its variable from left function to right function even though the right function was a nested function:

sage: f(x) = sin(arcsin(x))
sage: f(0.5)
0.500000000000000

 2 No.2 Revision kcrisman 12082 ●39 ●126 ●246

### Why Sage cannot pass a value of variable from one function to another nested function?

The first i ran this:

sage: f(x)=(2/n)*(sin(n*x)*(-1)^(n+1))
sage: sum(f, n, 1, 2) #using summation function
-sin(2*x) + 2*sin(x)


So, In this case the result was evaluated correctly.

But if i tried to combine the first line and the second line together:

sage: f(x,k) = sum((2/n)*(sin(n*x)*(-1)^(n+1)), n, 1, k)
#where n = 1,2,3 ... k
sage: f(x,2)
-2*sum((-1)^n*sin(n*x)/n, n, 1, 2)


The result was wrong!

Why sage cannot evaluate mathematical expression in this case?

Another tried to prove that Sage can pass its variable from left function to right function even though the right function was a nested function:

sage: f(x) = sin(arcsin(x))
sage: f(0.5)
0.500000000000000


Edit: (See the same question on SO.

 3 No.3 Revision kcrisman 12082 ●39 ●126 ●246

### Why Sage cannot pass a value of variable from one function to another nested function?

The first i ran this:

sage: f(x)=(2/n)*(sin(n*x)*(-1)^(n+1))
sage: sum(f, n, 1, 2) #using summation function
-sin(2*x) + 2*sin(x)


So, In this case the result was evaluated correctly.

But if i tried to combine the first line and the second line together:

sage: f(x,k) = sum((2/n)*(sin(n*x)*(-1)^(n+1)), n, 1, k)
#where n = 1,2,3 ... k
sage: f(x,2)
-2*sum((-1)^n*sin(n*x)/n, n, 1, 2)


The result was wrong!

Why sage cannot evaluate mathematical expression in this case?

Another tried to prove that Sage can pass its variable from left function to right function even though the right function was a nested function:

sage: f(x) = sin(arcsin(x))
sage: f(0.5)
0.500000000000000


Edit: (See the same question on SO..)

### Why Sage cannot pass a value of variable from one function to another nested function?

The first i ran this:

sage: f(x)=(2/n)*(sin(n*x)*(-1)^(n+1))
sage: sum(f, n, 1, 2) #using summation function
-sin(2*x) + 2*sin(x)


So, In this case the result was evaluated correctly.

But if i tried to combine the first line and the second line together:

sage: f(x,k) = sum((2/n)*(sin(n*x)*(-1)^(n+1)), n, 1, k)
#where n = 1,2,3 ... k
sage: f(x,2)
-2*sum((-1)^n*sin(n*x)/n, n, 1, 2)


The result was wrong! wasn't finished!

Why sage cannot evaluate mathematical expression in this case?

Another tried to prove that Sage can pass its variable from left function to right function even though the right function was a nested function:

sage: f(x) = sin(arcsin(x))
sage: f(0.5)
0.500000000000000


Edit: (See the same question on SO.)

 5 retagged FrédéricC 4199 ●3 ●37 ●85

### Why Sage cannot pass a value of variable from one function to another nested function?

The first i ran this:

sage: f(x)=(2/n)*(sin(n*x)*(-1)^(n+1))
sage: sum(f, n, 1, 2) #using summation function
-sin(2*x) + 2*sin(x)


So, In this case the result was evaluated correctly.

But if i tried to combine the first line and the second line together:

sage: f(x,k) = sum((2/n)*(sin(n*x)*(-1)^(n+1)), n, 1, k)
#where n = 1,2,3 ... k
sage: f(x,2)
-2*sum((-1)^n*sin(n*x)/n, n, 1, 2)


The result wasn't finished!

Why sage cannot evaluate mathematical expression in this case?

Another tried to prove that Sage can pass its variable from left function to right function even though the right function was a nested function:

sage: f(x) = sin(arcsin(x))
sage: f(0.5)
0.500000000000000


Edit: (See the same question on SO.)