# Knowledge Base

## Solution 40442: Texas Instruments Computer Algebra System (CAS) Calculators Produce an Unexpected Derivative Result for Function Defined with Constant.

### Why do Texas Instruments CAS calculators produce an unexpected result for function defined with constant that is used later to evaluate function derivatives?

Texas Instruments CAS calculators may produce an unexpected result for function defined with constant that is used later to evaluate function derivatives as listed in the example below:

Define f(x)=x^3-3k^2*x
Define fss(x)=derivative(f(x),x,2)

When computing for the function above:

fss(x) = 6x
fss(k) = -12k

The function fss(x) is defined as:
fss(x):=derivative(f(x),x,2)
The function gets evaluated as:
fss(k)=derivative(f(k),k,2)
Since f(x) is defined using the parameter k, evaluating fss(k) substitutes k giving the unexpected result.

You can workaround this behavior by using the with "|" command to assign a different variable:

Define f(x)=x^3-3k^2*x
Define fss(x)=derivative(f(z),z,2)|z=x

fss(x) = 6x
fss(k) = 6k