User Tools

Site Tools


prime:programming:cas-calculus_commands

CAS-Calculus Commands

Return to the Prime Programming Page: Prime Programming Language (PPL)

This section will cover the Calculus commands of the HP Prime. Unless noted, the commands are practically useful only in CAS Mode and in CAS programs.

Examples given in this section is with the CAS Simplify setting set to Maximum. The “Include complex results in variables” option is turned off. Angle Mode is set to Radians - the recommended mode for Calculus commands.

diff

Returns the derivative of the function. diff can be used to return partial derivatives. If only one argument is used, the expression is assumed to be a function of x, with all other variables treated as constants.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

For functions of x:
diff(function of x)

For other functions, including multivariate:
diff(function, variable)

Home Mode - Textbook and Algebraic Entry

Enclose the function and variable in single quotes. Use Shift + (). For powers, use the x^y key.

For functions of X:
CAS.diff('function of X')

General:
CAS.diff('function', 'variable')

Home Mode - RPN Entry

Function of X:
1: 'function of X'
CAS.diff(1), press Enter

General:
2: 'function'
1: 'variable'
CAS.diff(2), press Enter

Examples:

CAS Mode: Functions of x - all other variables are treated as constants:
diff(a) returns 0
diff(x) returns 1
diff(a*x²+b*x+c) returns 2*a*x+b

diff using two arguments:
diff(a*x²+b*x+c, b) returns x

Partial derivatives:
diff(SIN(x*y²),x) returns y²*COS(x*y²)
diff(SIN(x*y²),y) returns 2*x*y*COS(x*y²)

Notes: You can use the single quote character (') to quickly calculate the derivative of f(x).

Example: (a*x²+b*x+c)' returns 2*a*x+b

Access: Toolbox, CAS, 2. Calculus, 1. diff

See Also: int, limit, series

int

Calculates the integral of a function. Depending on the number of arguments used, an indefinite (symbolic) or definite (numeric) integral will be calculated.

There are three ways to work with int. See the Syntax section for details.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

Indefinite Integral of f(x):
int(function)

Indefinite Integral of a specified variable:
int(function, variable)

Definite Integral:
int(function, variable, lower limit, upper limit)

Home Mode - Textbook and Algebraic Entry

Enclose the function and variable in single quotes. Use Shift + (). For powers, use the x^y key.

Indefinite Integral:
CAS.int('function', 'variable')

You can leave out the 'variable' if you are working with a function of X.

Definite Integral:
CAS.int('function', 'variable', lower limit, upper limit)

Home Mode - RPN Entry

Attempting to execute CAS.int will return a Bad Argument Error.

Examples:

CAS Mode:
Indefinite Integral of f(x):
int(2*x*EXP(x)) returns 2*x*EXP(x)-2*EXP(x)

Indefinite Integral of a specified variable:
int(SIN(t),t) returns -COS(t)

Definite Integral:
int(2*x^3,x,.25,.85) returns .25905

Notes: Make sure “int” is in lower case. INT in upper case is the integer function.

Access: Toolbox, CAS, 2. Calculus, 2. int

See Also: ∫, ibpdv, ibpu, preval

limit

Calculates the limit of a function as it approaches a particular value. See the Syntax section for details.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

Two sided limit:
lim(function, variable, value)

One sided limit from the right:
lim(function, variable, value, +1)

One sided limit from the left:
lim(function, variable, value, -1)

Examples:

CAS Mode:
Two sided limit:
lim(1/x, x, 1) returns 1

One sided limit from the right:
lim(1/x, x, 0, +1) returns ∞

One sided limit from the left:
lim(1/x, x, 0, -1) returns -∞

Access: Toolbox, CAS, 2. Calculus, 3. limit

See Also: int, diff

series

Calculates the Taylor series expansion of an function. The general syntax is:

series(expression, var=limit point, order, direction)

expression: algebraic expression. Required argument.

var=limit: variable to be expanded on. If limit is not specified, then the limit is assumed to be zero. Required argument.

order: the desired order for the series expansion. This argument is optional. If order is not specified, firth order is specified.

direction: the direction of the series. -1 for negative, 0 for bidirectional, 1 for positive.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

Basic fifth order-series at limit = 0:
series(expression, var)

Series with specified limit and order:
series(expression, var=limit, order)

Series with specified limit, order, and direction:
series(expression, var=limit, order, direction)

Home Mode - Textbook and Algebraic Entry

Enclose the function and variable in single quotes. Use Shift + (). For powers, use the x^y key.

General Syntax:
CAS.series('expression', 'variable', 'limit', 'order', 'direction')

Optional arguments: 'limit', 'order', 'direction'

Examples:

CAS Mode:
Basic fifth order-series at limit = 0:
series(COS(x),x) returns 1 - 1/2*x^2 + 1/24*x^4 + x^6*order_size(x)

Series with specified limit and order:
series(COS(x),x=-1,3) returns
COS(1) + SIN(1) * (x+1) - COS(1)/2 * (x+1)^2 - SIN(1)/6 * (x+1)^3 + (x+1)^4*order_size(x+1)

Series with specified limit, order, and direction:
series(LN(x+1),x,4,1) returns LN(5) + (x-4)*order_size(x-4)

series(LN(x+1),x,4,1) returns LN(5) + 1/5*(x-4) + (x-4)^2*order_size(x-4)

series(LN(x+1),x,4,-1) returns LN(5) + order_size(x-4)

Notes: The last term, which contains order_size, is an arbitrary term similar to the Big O notation.

The taylor command for most purposes works in the exact same way as series.

Access: Toolbox, CAS, 2. Calculus, 4. series

See Also: diff, taylor

sum

Calculates the sum of an expression.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

sum(expression, variable, lower limit, upper limit, step)

step can be omitted. When step is omitted, the increment is assumed to be 1.

Examples:

CAS Mode:
sum(2*x,x,1,5) returns 30

sum(2*x,x,1,5,2) returns 18

sum(n^3,n,1,x) returns (x^4 + 2*x^3 + x^2)/4

Notes: An alternate way to use this function is to call the summation template, see Σ.

Access: Toolbox, CAS, 2. Calculus, 5. sum

See Also: Σ

curl

The curl of the algebraic vector. The result is a the cross product the gradient x vector field.

curl([f(x,y,z), g(x,y,z), h(x,y,z)] = [-∂g/∂z + ∂h/∂y, ∂f/∂z - ∂h/∂x, -∂f/∂y + ∂g/∂x ]

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

curl([function_1, function_2, function_3] , [variable_1, variable_2, variable_3])

Examples:

CAS Mode:
curl([5*x*y, z², 2*x*SIN(y)],[x,y,z]) returns [2*x*COS(y)-2*z, -2*SIN(y), -5*x]

Access: Toolbox, CAS, 2. Calculus, 6. Differential, 1. curl

See Also: divergence, grad, hessian, diff

divergence

The divergence of the algebraic vector. The result is a sum of the partial derivatives of each function respect to their variables.

divergence([f(x,y,z), g(x,y,z), h(x,y,z)]) = ∂f/∂x + ∂g/∂y + ∂h/∂z.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

divergence([function_1, function_2, function_3] , [variable_1, variable_2, variable_3])

Examples:

CAS Mode:
divergence([5*x*y, z², 2*x*SIN(y)],[x,y,z]) returns 5*y

Access: Toolbox, CAS, 2. Calculus, 6. Differential, 2. divergence

See Also: curl, grad, hessian, diff  

grad

The gradient of trivariate function. The result is a vector of the partial derivatives of the function respect to their variables.

grad(f(x,y,z)) = [ ∂f/∂x, ∂f/∂y, ∂f/∂z ]

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

grad([function , [variable_1, variable_2, variable_3])

Examples:

CAS Mode:
grad(x²*(2*x*y+3*z*LN(x)),[x,y,z]) returns
[6*x²*y+6*x*z*LN(x)+3*x*z, 2*x^3, 3*x²*LN(x)]

Access: Toolbox, CAS, 2. Calculus, 6. Differential, 3. grad

See Also: curl, divergence, hessian, diff

hessian

Creates the Hessian matrix of second partial dervatives, dependent on the function and vector of variables.

Example, for a bivariate function f(x,y), the Hessian matrix is:

H =

∂²f/∂x² ∂²f/∂x∂y
∂²f/∂y∂x ∂²f/∂y²

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

hessian(function, vector of variables)

Examples:

CAS Mode:
hessian(8*x²-3*x*y^3, [x, y]) returns

16 -9*y²
-9*y² -18*x*y

Access: Toolbox, CAS, 2. Calculus, 6. Differential, 4. hessian

See Also: curl, divergence, grad, diff  

ibpdv

Integration by Parts. There are five arguments to ibpdv but only two are required. The general syntax:

ibpdv( u*v', v, variable, lower limit, upper limit)

Concept: ∫ u*v' dx = u*v - ∫u'*v dx

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

Indefinite Integration by Parts of f(x):
ibpdv( u*v', v)

Definite Integration by Parts:
ibpdv( u*v', v, variable, lower limit, upper limit)

Output : [ u*v, -u*v ] If limits are supplied, then the definite integral ∫ u*v dx is calculated (first part).

Examples:

CAS Mode:

Indefinite Integration by Parts of f(x):

ibpdv(x²*COS(x), SIN(x)) returns [x²*SIN(x), -2*x*SIN(x)]

Note: v = SIN(X)

ibpdv(x*EXP(x), EXP(x)) returns [x*EXP(x), -EXP(x)]

Note: EXP(x)

Definite Integration by Parts:

ibpdv(x²*COS(x), SIN(x), x, 0, π) returns [0, -2*x*SIN(x)]

Note: v= COS(x)

Access: Toolbox, CAS, 2. Calculus, 7. Integral, 1. ibpdv

See Also: int, ibpu, ∫  

ipbu

Integration by Parts. There are five arguments to ipbu but only two are required. The general syntax:

ibpu( u*v', u, variable, lower limit, upper limit)

Concept: ∫ u*v' dx = u*v - ∫u'*v dx

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

Indefinite Integration by Parts of f(x):

ibpu( u*v', v)

Definite Integration by Parts:

ibpu( u*v', v, variable, lower limit, upper limit)

Output : [ u*v, -u*v ] If limits are supplied, then the definite integral ∫ u*v dx is calculated (first part).

Examples:

CAS Mode:
Indefinite Integration by Parts of f(x):

ibpu(x²*COS(x),x²) returns [x²*SIN(x), -2*x*SIN(x)]

Note: u = x²

ibpdv(x*EXP(x), EXP(x)) returns [x²*EXP(x)/2, -x²*EXP(x)/2]

Note: u = EXP(x)

Definite Integration by Parts:

ibpdv(x²*COS(x), COS(x), x, 0, π) returns [-π^3/3, x^3*SIN(x)/3]

Note: u = COS(x)

Access: Toolbox, CAS, 2. Calculus, 7. Integral, 2. ibpu

See Also: int, ∫, ibpdv

preval

Calculates F(b) - F(a). This is useful for calculating definite integrals where the anti-derivative is already known.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

F is a function of x:

preval(F, lower limit, upper limit)

F is a function of some other variable:

preval(F, lower limit, upper limit, variable)

Examples:

CAS Mode:

preval(x^3, 4, 10) = 10^3 - 4^3 returns 936

preval(9*d, 1, 9, d) returns 72

Notes: preval does not work in Home Mode

Access: Toolbox, CAS, 2. Calculus, 7. Integral, 3. preval

See Also: int, ∫, ibpdv, ibpu  

sum_riemann

Calculates the sum:

Σ( f(n,k) from k=1 to n ) in the neighborhood of n = ∞, when the sum associated with a continuous function defined on the closed interval [0, 1].

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

sum_riemann( f(n,k), [n, k] )

Examples:

CAS Mode:
sum_riemann(k^3/n^5, [n,k]) returns 1/(4*n)

sum_riemann(1/k + 1/n, [n, k]) returns ∞

sum_riemann(1/(n*k-1), [n, k]) returns “Probably not a Riemann sum”

Notes: If a Riemann sum cannot be reached, the HP Prime returns the error message “it is not probably not a Riemann sum”.

Attempting to execute sum_riemann function in any of the Home modes will return an error message.

Access: Toolbox, CAS, 2. Calculus, 8. Limits, 1. sum_riemann

See Also: diff, limit

taylor

Calculates the Taylor series expansion of an function. The general syntax is:

taylor(expression, var=limit point, order, direction)

expression: algebraic expression. Required argument.

var=limit: variable to be expanded on. If limit is not specified, then the limit is assumed to be zero. Required argument.

order: the desired order for the series expansion. This argument is optional. If order is not specified, firth order is specified.

direction: the direction of the series. -1 for negative, 0 for bidirectional, 1 for positive.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

Basic fifth order-series at limit = 0:
taylor(expression, var)

Series with specified limit and order:
taylor(expression, var=limit, order)

Series with specified limit, order, and direction:
taylor(expression, var=limit, order, direction)

Examples:

CAS Mode:
Basic fifth order-series at limit = 0:
taylor(COS(x),x) returns 1 - 1/2*x^2 + 1/24*x^4 + x^6*order_size(x)

Series with specified limit and order:
taylor(COS(x),x=-1,3) returns
COS(1) + SIN(1) * (x+1) - COS(1)/2 * (x+1)^2 - SIN(1)/6 * (x+1)^3 + (x+1)^4*order_size(x+1)

Series with specified limit, order, and direction:
taylor(LN(x+1),x,4,0) returns
x - 1/2*x² + 1/3*x^3 - 1/4*x^4 + x^5*order_size(x)

taylor(LN(x+1),x,4,1) returns
LN(2) + 1/2*(x-1) - 1/8*(x-1)² + 1/24*(x-1)^3 - 1/64*(x-1)^4 + (x-1)^5*order_size(x-1)

series(LN(x+1),x,4,-1) returns LN(x)

Notes: The last term, which contains order_size, is an arbitrary term similar to the Big O notation.

The series command for most purposes works almost in the exact same way as taylor. Except taylor will attempt to return a polynomial when possible.

Access: Toolbox, CAS, 2. Calculus, 8. Limits, 2. taylor

See Also: diff, series

divpc

Division by increasing power order. The result is a Taylor expansion of a(x)/b(x) at the order of n in the vicinity of x=0. a(x) and b(x) are polynomials of x.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

divpc( a(x), b(x), n )

Examples:

CAS Mode:
divpc( (x² + 2*x + 1)/x, 5) returns
±∞*x^5 ±∞*x^4 ±∞*x^3 ± ∞*x^2 ±∞*x ± ∞

divpc( x²+3*x^3, 1+x, 5) returns
2*x^5 - 2*x^4 + 2*x^3 + x^2

Access: Toolbox, CAS, 2. Calculus, 8. Limits, 3. divpc

See Also: diff, limit, taylor  

laplace

Performs the Laplace Transform.

F(s) = ∫ exp(-s*t) *f(t) dt from t=0 to ∞

The HP Prime returns the Laplace Transform using the same variable unless you specify which variables are to be used.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

Basic:
laplace(expression)

Variables Specified:
laplace(expression, var, lapvar)

Examples:

CAS Mode:
laplace(a) returns a/x

laplace(t², t, s) returns 2/s^3

laplace(EXP(t)*SIN(t),t,s) returns 1/(s²-2*s+2)

Access: Toolbox, CAS, 2. Calculus, 9. Transform, 1. laplace See Also: invlaplace  

invlaplace

Performs the Inverse Laplace Transform.

F(s) = ∫ exp(-s*t) *f(t) dt from t=0 to ∞

If the following equation, invlaplace finds f(t). The HP Prime returns the Inverse Laplace Transform using the same variable unless you specify which variables are to be used.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

Basic:
invlaplce(expression)

Variables Specified:
invlaplace(expression, variable, invlap var)

Examples:

CAS Mode:
invlaplace(a) returns a*Dirac(x)

invlaplace(1/s^4, s, t) returns t^3/6

invlaplace(1/(s-1),s,t) returns EXP(t)

Access: Toolbox, CAS, 2. Calculus, 9. Transform, 2. invlaplace

See Also: invlaplace

fft

Discrete Fast Fourier Transform

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

Basic Fast Fourier Transform:
fft(vector)

Field of z/pz with a primitive nth root of 1:
fft(vector, A, P)

Home Mode
Normal Programming Editor

Basic Fast Fourier Transform - Numerical Only:
CAS.fft(vector)

Field of z/pz with a primitive nth root of 1 - Numerical Only:
CAS.fft(vector, A, P)

Examples:

CAS Mode:
fft([7,1,2]) returns [10, 5.5+.866025403784i, 5.5-.866025403784i]

fft([7,1,2],2,3) returns [1, -1, 0]

Access: Toolbox, CAS, 2. Calculus, 9. Transform, 3. fft

See Also: ifft

ifft

Inverse Fast Fourier Transform

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

ifft(vector)

Home Mode
Normal Programming Editor

Numerical Only:
CAS.ifft(vector)

Examples:

CAS Mode:
ifft([1,2+i,2-i]) returns [1.66666666667, -.910683602523, .244016935856]

Access: Toolbox, CAS, 2. Calculus, 9. Transform, 4. ifft

See Also: fft

Return to the Prime Programming Page: Prime Programming Language (PPL)

prime/programming/cas-calculus_commands.txt · Last modified: 2013/10/24 06:45 by ed314