### CAS-Solve Commands

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. RPN Entry will not be covered in this section.

Examples given in this section is with the CAS Simplify setting set to Maximum. The “Include complex results in variables” option is turned off.

#### solve

Solves an equation or set of polynomials. Real results are returned. If possible, exact results are returned. There are many possibilities with the solve command.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

Solve f(x)=0 for x:
solve( f(x) )

Solve f(x) = g(x) for x:
solve( f(x) = g(x) )

Solve an equation for any variable:
solve( equation, variable)

Solve a system of equations (polynomials in particular):
solve( vector of equations, vector of variables to solve for )

Examples:

CAS Mode

Solve f(x)=0 for x:
solve(x²-6*x+1) returns {-2*√2+3, 2*√2+3}
Prime may give a message that the equation “f(x)=0” is solved.

solve(x^3+1) returns {-1}

Solve f(x) = g(x) for x:
solve(SIN(x)=1/2) returns {π/6, 5*π/6}

solve(EXP(x)=2) returns {LN(2)}

solve(x²-3=11*x) returns { (-√133 +11)/2, (√133 + 11)/2 }

Solve an equation for any variable:
solve(8*r-3,r) returns {3/8}

solve(8*r*x-3*x=2*r, r) returns { (3*x)/(8*x-2) }

Solve a system of equations (polynomials in particular):
solve([x+y=1, 2*x-3*y=0],[x,y]) returns {[3/5, 2/5]}

solve([x*(y^2+4)=16, x^2-y^2=2], [x,y]) returns
{[2.25634779672, 1.7581539693], [2.25634779672, -1.7581539693]}

Notes: The solve command is not really useful in Home Mode, often returning {0} or {variable}.

Access: Toolbox, CAS, 3. Solve, 1. Solve

#### zeros

Returns the zeros (roots) of an expression. The zeros command can solve multiple expressions. By default, zeros return real roots only.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

Finding the roots of f(x):
zeros( f(x) )

Finding the real roots of an equation of any variable:
zeros(expression, variable)

When possible, the exact roots are returned.

Home Mode, Algebraic or Textbook Entry
Regular Program Editor

CAS.zeros(expression, variable)

The variable must be in CAPITAL LETTERS in Home mode. The roots are returned as decimal approximations.

Home Mode - RPN Entry

2: 'expression in single quotes' 1: 'variable in single quotes' CAS.zeros(2), press Enter

Examples:

CAS Mode

zeros(x²-4) returns [2, -2]

zeros(x²+4) returns []

zeros(n*(n-3)-6,n) returns [ (√33 + 3)/2, (-√33 + 3)/2 ]

Home Mode - Algebraic Entry
zeros(N*(N-3)-6,N) returns [4.3722813237, -1.37228132327]

Access: Toolbox, CAS, 3. Solve, 2. zeros

#### cSolve

Solves an equation or set of polynomials. Real and complex results are returned. If possible, exact results are returned. Like solve, cSolve has many possibilities of use.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

Solve f(x)=0 for x:
cSolve( f(x) )

Solve f(x) = g(x) for x:
cSolve( f(x) = g(x) )

Solve an equation for any variable:
cSolve( equation, variable)

Solve a system of equations (polynomials in particular):
cSolve( vector of equations, vector of variables to solve for )

Examples:

CAS Mode

Solve f(x)=0 for x:
cSolve(x²-6*x+1) returns {-2*√2+3, 2*√2+3}
Prime may give a message that the equation “f(x)=0” is solved.

cSolve(x^3+1) returns {-1, (i*√3+1)/2, (-i*√3+1)/2}

Solve f(x) = g(x) for x:
cSolve(SIN(x)=1/2) returns {π/6, 5*π/6}

cSolve(EXP(x)=-2) returns {LN(-2)}

cSolve(x²=i+x) returns
{ ( √17 * √(2*(√17+1)) + 2*√17 + (1+4*i)*√(2*(√17+1)) + 2)/(4*√17 + 4),
(- √17 * √(2*(√17+1)) + 2*√17 - (1+4*i)*√(2*(√17+1)) + 2)/(4*√17 + 4) }

Solve an equation for any variable:
cSolve(8*r-3,r) returns {3/8}

cSolve(8*r*x-3*x=2*i*r, r) returns { (3*x)/(8*x-2*i) }

Solve a system of equations (polynomials in particular):
cSolve( [x+y=1, 2*x-3*y²=0],[x,y]) returns
{ [ (√7 + 4)/3, (-√7-1)/3 ] , [ (-√7 + 4)/3, (√7 - 1)/3 ] }

cSolve( [x²+y=1, 2*x-3*y²=-1],[x,y]) returns
{ [-0.95781842831 + 0.302361832019*i, 0.17400653583+0.579215469458*i],
[-0.95781842831 - 0.302361832019*i, 0.17400653583-0.579215469458*i],
[0.451270904, 0.796354571027], [1.46436595245, -1.14436764269]}

Notes: The cSolve command is not really useful in Home Mode, often returning {0} or {variable}.

Access: Toolbox, CAS, 3. Solve, 3. cSolve

#### cZeros

Returns both real and complex zeros (roots) of an expression. The zeros command can solve multiple expressions.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

Finding the roots of f(x):
cZeros( f(x) )

Finding the real roots of an equation of any variable:
cZeros(expression, variable)

When possible, the exact roots are returned.

Home Mode, Algebraic or Textbook Entry
Regular Program Editor

CAS.cZeros(expression, variable)

The variable must be in CAPITAL LETTERS in Home mode. Home Mode - RPN Entry

2: 'expression in single quotes' 1: 'variable in single quotes' CAS.cZeros(2), press Enter

Examples:

CAS Mode

cZeros(x²-4) returns [2, -2]

cZeros(x²+4) returns [-2*i, 2*i]

cZeros(n*(2*i*n-3),n) returns [0, (-3*i)/2]

Home Mode - Textbook Entry
cZeros(N²-3*N+6,N) returns [1.5+1.9364916731*i, 1.5-1.9364916731*i]

Access: Toolbox, CAS, 3. Solve, 4. cZeros

#### nSolve

Numeric Solver. Returns a real numerical solution near a given guess.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

nSolve( equation, variable=initial guess)

If the equation is an expression, then the expression is assumed to equal zero.

Examples:

CAS Mode

nSolve(x²+5*x-6,x=0) returns 1

nSolve(x²+5*x-6,x=-10) returns -6

nSolve(EXP(t-3)=2*t+1, t=10) returns 5.48188249798

Notes: The nSolve command returns a bad argument error in Home mode.

Access: Toolbox, CAS, 3. Solve, 5. nSolve

#### deSolve

Gives the generic solution to a differential equation, if there is one. Solves many first order differential equations and linear differential equations with constant coefficients.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

desolve( equation, independent variable, dependent variable)

You can either signify the derivative by using the diff command, nested if necessary, or by single quotes. For example:

y' can be typed by pressing ALPHA + 1, Shift + ( ), Backspace

y' ' can be typed by pressing ALPHA + 1, Shift + ( )

The independent variable can be left out (x is assumed to be the independent variable).

G_0, G_1, G_2, … are constants.

Examples:

CAS Mode

desolve(y' '-y'=SIN(x),x,y) returns
G_0 + G_1 * EXP(x) - G_1 + 1/2*COS(x) + 1/2*EXP(x) + -1/2*SIN(x) - 1

desolve(y' '+2*y'+1=0,t,y) returns
(4*G_0 - 2*G_1*EXP(-2*t) + 2*G_1 - 2*t - EXP(2*t)+ 1)/4

desolve(y'+a*y=0,x,y) returns
G_0*EXP(-a*x)

desolve(x'=√x,t,x) returns
[(G_0² - 2*G_0*t + t²)/4]

Notes: The desolve command returns a syntax error in Home Mode.

Access: Toolbox, CAS, 3. Solve, 6. desolve

#### odesolve

Estimates y(t) given an ordinary differential equation and its initial conditions. Symbolically:

Find y(t) given y'=f(t,y) with the initial conditions y(t_0) = y_0

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

Let y' = f(t,y), t be the independent variable, y be the dependent variable. The initial condition is the point (t0, y0). The syntax for odesolve would be:

odesolve( y', [t, y], [t0, y0], t1)

Leaving out [t,y] will cause a “Error: Bad Argument Type”.

Output: The approximation will be returned in an one-element vector.

Examples:

CAS Mode

odesolve(t*y, [t,y], [0,1], 0.5) returns [1.13314845307]

odesolve(COS(x²*y),[x,y],[π/2,1],π/4) returns [1.03810590405]

Notes: The odesolve command returns a syntax error in Home Mode.

Access: Toolbox, CAS, 3. Solve, 7. odesolve

#### linsolve

The linsolve command solves a system of linear equations. Answers are returned in a vector.

Syntax

Input:

CAS Mode
Program Editor - CAS Programs

linsolve( [vector of equations], [common variable set])

If the expression lacks an equals sign, the expression is assumed to equal 0.

Examples:

CAS Mode

linsolve( [a+b=-2, 2*a+4*b=1/4], [a, b] ) returns [ -33/8, 17/8 ]

linsolve( [2*a*x-4*y=5, x+3*y=9, [x,y] ) returns [ 51/(6*a+4), (18*a-5)/(6*a+4)]

linsolve( [x+y, 3*x-5*y], [x,y] ) returns [0, 0]
linsolve( [x+y=0, 3*x-5*y=0], [x,y] ) returns [0, 0]

For nonlinear equations, non-numerical solutions will be returned:
linsolve( [a²+b=-2, 2*a+4*b=1/4], [a,b] ) returns [ -33/(32*a-8), (a+8)/(16*a-4) ]

Notes: The linsolve command returns a syntax error in Home Mode.

Access: Toolbox, CAS, 3. Solve, 8. linsolve