# TI-89 Programming: When Function Error

Discussion in 'Programmer's Corner' started by Adanovinivici, Sep 20, 2015.

1. ### Adanovinivici Thread Starter Member

Sep 5, 2014
58
0
Hello All,

I'm trying to program a simple statement into my calculator to assign a function c(k) to cc(k) since the value of c(k) is undefined at 0, but the limit of c(k) as k approaches 0 is 1/2. However, the calculator keeps telling me I'm missing parentheses, even though the number of parenthesis facing right is equal to the number of parentheses facing left. I tried finding the solution on the internet, but I did not see a description of this specific problem. Could anyone help me out?

when(k=0, 1/2, c(k)-->cc(k))

Much Appreciated,
Adanovinivici

2. ### Papabravo Expert

Feb 24, 2006
11,083
2,159
I think your problem is the function assignment in the 'false part'. I think what it wants is an expression not an assignment. Can you provide the context for the when statement?
Isn't the when() statement is used in graphing, and in no other context.

Last edited: Sep 20, 2015
3. ### Adanovinivici Thread Starter Member

Sep 5, 2014
58
0
I'm creating a Fourier Series on the calculator using the exponential form Sum(-n,+n) Dn*e^-j*w0*t where w0 is the fundamental angular frequency and Sum is a sigma sign from -n to n. c(k) is equal to Dn=1/To * integral(-T0/2, T0/2) f(k)*e^-j*n*w0*t.

The main point of the statement is that Dn or c(k) at 0 is undefined so I have to take the limit at k=0, so I won't receive an error when I plot the function. By assigning c(k) to cc(k), I am left with a function without an undefined value at k=0.

4. ### Papabravo Expert

Feb 24, 2006
11,083
2,159
You missed entirely what I was asking. Do you understand the difference between an 'expression' and an 'assignment'?
Do I understand that cc(k) is a function that is the same as c(k), except that, unlike c(k), it is defined at k=0?
So the 'context' I was looking for is the complete definition of the function cc(k)

5. ### Adanovinivici Thread Starter Member

Sep 5, 2014
58
0
Thank you for the response . However, if I try to use an equal sign,
Alright then. cc(k) is the fourier series of a square wave in exponential form where cc(0)=1/2.

6. ### Papabravo Expert

Feb 24, 2006
11,083
2,159
The definition of the 'when' statement won't allow you to use an assignment statemnt in place of an expression. Some languages and compilers will let you do this an others won't. If I could see the entire multi-line definition of the function I might be able to help. Otherwise, I guess I'm done.