How to solve the “You can’t use ‘k’ as an index because it’s already defined” issue on Desmos Function Grapher

desmos

My input is:

formula input

And I am using the Desmos function grapher which has an issue and the issue is that it alerts me on the third function:

You can't use 'k' as an index because it's already defined.

But 'k' suppose to be local iterative variable defined inside the sum expression only and I expect that 'k' can be redefined, reused and reassigned also somewhere else.

How do I tell it that 'k' is local or to redefine, reuse and reassign it? Is this possible to do that?

Best Answer

When Desmos looks at your third expression, it sees something like (ignoring a lot): sum of k inside a sum of k

Mathematically speaking, this would be bad notation, so Desmos throws an error. The developers put a lot of thought into balancing expectations of math teachers/students and programmers/computer scientists (c.f. Logs and Infinities), and I think they made the right call here.

You can make use of the total() function to get the result you want: total([1...n])