0% found this document useful (0 votes)
996 views334 pages

HP Prime Graphing Calculator - User Guide Supplement

Hp prime

Uploaded by

Israel Sousa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
996 views334 pages

HP Prime Graphing Calculator - User Guide Supplement

Hp prime

Uploaded by

Israel Sousa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 334

HP Prime Graphing Calculator

User Guide Supplement


Legal notices
The information contained herein is subject to change without notice. The only war-
ranties for HP products and services are set forth in the express warranty statements
accompanying such products and services. Nothing herein should be construed as
constituting an additional warranty. HP shall not be liable for technical or editorial
errors or omissions contained herein.
Portions of this software are copyright 2013 The FreeType Project (www.freetype.org). All rights
reserved.
• HP is distributing FreeType under the FreeType License.
• HP is distributing google-droid-fonts under the Apache Software License v2.0.
• HP is distributing HIDAPI under the BSD license only.
• HP is distributing Qt under the LGPLv2.1 license. HP is providing a full copy of the Qt
source.
• HP is distributing QuaZIP under LGPLv2 and the zlib/libpng licenses. HP is providing a full
copy of the QuaZIP source.
Hewlett-Packard Company shall not be liable for any errors or for incidental or consequential
damages in connection with the furnishing, performance, or use of this manual or the exam-
ples contained herein.

Product Regulatory & Environment Information


Product Regulatory and Environment Information is provided on the CD shipped with this
product.

© Copyright 2014 Hewlett-Packard Development Company, L.P.


Reproduction, adaptation, or translation of this manual is prohibited without prior written
permission of Hewlett-Packard Company, except as allowed under the copyright laws.
First Edition: April 2014
Document Part Number: 775775-001
About this guide
The information in this guide updates the information in the following chapters of the
HP Prime Calculator User Guide:
• Geometry
• Inference app
• Functions and commands
• Variables
• Programming in HP PPL
If there is a conflict between the information in these guides, use the information
provided in this guide.
Contents

1 Geometry
Getting started with the Geometry app ...................................... 5
Plot view in detail.................................................................. 12
The Options menu ............................................................ 17
Plot Setup view................................................................. 18
Symbolic view in detail .......................................................... 19
Symbolic Setup view......................................................... 20
Numeric view in detail .......................................................... 20
Plot view: Cmds menu ........................................................... 23
Geometry functions and commands......................................... 39
Symbolic view: Cmds menu ............................................... 40
Numeric view: Cmds menu................................................ 55
Other Geometry functions.................................................. 60
2 Inference app
Getting started with the Inference app ..................................... 70
Importing statistics ................................................................. 74
Hypothesis tests .................................................................... 77
One-Sample Z-Test............................................................ 77
Two-Sample Z-Test ............................................................ 78
One-Proportion Z-Test........................................................ 79
Two-Proportion Z-Test ........................................................ 80
One-Sample T-Test ............................................................ 81
Two-Sample T-Test ............................................................ 82
Confidence intervals .............................................................. 84
One-Sample Z-Interval....................................................... 84
Two-Sample Z-Interval ....................................................... 84
One-Proportion Z-Interval................................................... 85
Two-Proportion Z-Interval ................................................... 86
One-Sample T-Interval ....................................................... 87
Two-Sample T-Interval........................................................ 87
Chi-square tests..................................................................... 88
Goodness of fit test ........................................................... 88
Two-way table test ............................................................ 89
Inference for regression ......................................................... 90
Linear t-test ...................................................................... 91
Confidence interval for slope ............................................. 92
Confidence interval for intercept......................................... 94
Confidence interval for a mean response............................. 95
Prediction interval............................................................. 96
.......................................................................................... 97

Contents 1
........................................................................................... 97
........................................................................................... 97
3 Functions and commands
Keyboard functions .............................................................. 101
Math menu ......................................................................... 105
Numbers........................................................................ 105
Arithmetic ...................................................................... 106
Trigonometry .................................................................. 108
Hyperbolic ..................................................................... 109
Probability ..................................................................... 109
List ................................................................................ 114
Matrix ........................................................................... 115
Special .......................................................................... 115
CAS menu .......................................................................... 116
Algebra ......................................................................... 116
Calculus ........................................................................ 118
Solve............................................................................. 122
Rewrite .......................................................................... 124
Integer........................................................................... 129
Polynomial ..................................................................... 131
Plot ............................................................................... 138
App menu .......................................................................... 138
Function app functions..................................................... 139
Solve app functions ......................................................... 140
Spreadsheet app functions ............................................... 140
Statistics 1Var app functions............................................. 154
Statistics 2Var app functions............................................. 156
Inference app functions.................................................... 157
Finance app functions ..................................................... 166
Linear Solver app functions .............................................. 168
Triangle Solver app functions ........................................... 168
Linear Explorer functions .................................................. 170
Quadratic Explorer functions ............................................ 171
Common app functions.................................................... 171
Ctlg menu........................................................................... 172
Creating your own functions ................................................. 213
4 Variables
Qualifying variables ............................................................ 219
Home variables ................................................................... 220
App variables ..................................................................... 221
Function app variables .................................................... 221
Geometry app variables .................................................. 222
Spreadsheet app variables............................................... 223

2 Contents
Solve app variables ........................................................ 223
Advanced Graphing app variables .................................. 224
Statistics 1Var app variables............................................ 225
Statistics 2Var app variables............................................ 227
Inference app variables................................................... 229
Parametric app variables................................................. 233
Polar app variables ........................................................ 234
Finance app variables..................................................... 234
Linear Solver app variables ............................................. 235
Triangle Solver app variables .......................................... 235
Linear Explorer app variables .......................................... 235
Quadratic Explorer app variables .................................... 235
Trig Explorer app variables ............................................. 236
Sequence app variables .................................................. 236
5 Programming in HP PPL
The Program Catalog .......................................................... 238
Creating a new program ..................................................... 241
The Program Editor ......................................................... 242
The HP Prime programming language ................................... 251
The User Keyboard: Customizing key presses .................... 256
App programs ............................................................... 260
Program commands ............................................................ 267
Commands under the Tmplt menu ..................................... 268
Block ............................................................................ 268
Branch .......................................................................... 268
Loop ............................................................................. 269
Variable ........................................................................ 273
Function ........................................................................ 273
Commands under the Cmds menu .................................... 274
Strings .......................................................................... 274
Drawing........................................................................ 277
Matrix........................................................................... 289
App Functions ................................................................ 290
Integer .......................................................................... 292
I/O .............................................................................. 294
More ............................................................................ 299
Variables and Programs .................................................. 301
Index ................................................................................... 327

Contents 3
4 Contents
1

Geometry
The Geometry app enables you to draw and explore
geometric constructions. A geometric construction can be
composed of any number of geometric objects, such as
points, lines, polygons, curves, tangents, and so on. You can
take measurements (such as areas and distances), manipulate
objects, and note how measurements change.
There are five app views:
• Plot view: provides drawing tools for you to construct
geometric objects
• Symbolic view: provides editable definitions of the
objects in Plot view
• Numeric view: for making calculations about the objects
in Plot view
• Plot Setup view: for customizing the appearance of Plot
view
• Symbolic Setup view: for overriding certain system-wide
settings
There is no Numeric Setup view in this app.
To open the Geometry app, press I and select
Geometry. The app opens in Plot view.

Getting started with the Geometry app


The following example shows how you can graphically
represent the derivative of a curve, and have the value of the
derivative automatically update as you move a point of
tangency along the curve. The curve to be explored is y =
3sin(x).
Since the accuracy of our calculation in this example is not too
important, we will first change the number format to fixed at
3 decimal places. This will also help keep our geometry
workspace uncluttered.

Geometry 5
Preparation 1. Press SK.
2. On the first CAS settings page, set the number format to
Standard and the number of decimal places to 4.

Open the app 3. Press I and select Geometry.


and plot the If there are objects showing that you don’t need, press
graph SJ and confirm your intention by tapping .
The app opens in Plot view. This view displays a
Cartesian plane with a menu bar at the bottom. Next to
the menu bar, this view displays the coordinates of the
cursor. After you interact with the app, the bottom of the
display displays the currently active tool or command,
help for the current tool or command, and a list of all
objects recognized as being under the current pointer
location.
4. Select the type of graph you want to plot. In this example
we are plotting a simple sinusoidal function, so choose:
> Plot > Function
5. With plotfunc( on the entry line, enter 3*sin(x):
3seASsE
Note that x must be entered in lowercase in the
Geometry app.
If your graph doesn’t
resemble the illustration
at the right, adjust the X
Rng and Y Rng values
in Plot Setup view
(SP).
We’ll now add a point
to the curve, a point that
will be constrained always to follow the contour of the
curve.

Add a 6. Tap , tap Point, and then select Point On.


constrained Choosing Point On rather than Point means that the
point point will be constrained to whatever it is placed on.

6 Geometry
7. Tap anywhere on the
graph, press E
and then press J.
Notice that a point is
added to the graph and
given a name (B in this
example). Tap a blank
area of the screen to
deselect everything. (Objects colored light blue are
selected.)

Add a tangent 8. We will now add a tangent to the curve, making point B
the point of tangency:
> Line > Tangent
9. When prompted to
select a curve, tap
anywhere on the curve
and press E.
When prompted to
select a point, tap point
B and press E to
see the tangent. Press
J to close the Tangent tool.
Depending on where you placed point B, your
illustration might be different from the one at the right.
Now, make the tangent stand out by giving it a bright
color.
10. Tap on the tangent to select it. After the tangent is
selected, the new menu key appears. Tap
or press Z, and then select Choose color.
11. Pick a color, and then tap on a blank area of the screen
to see the new color of the tangent line.
12. Tap point B and drag it along the curve; the tangent
moves accordingly. You can also drag the tangent line
itself.
13. Tap point B and then press E to select the point.
The point turns light blue to show that it has been
selected. Now, you can either drag the point with your
finger or use the cursor keys for finer control of the

Geometry 7
movement of point B. To deselect point B, either press
J or tap point B and press E.
Note that whatever you do, point B remains constrained to the
curve. Moreover, as you move point B, the tangent moves as
well. If it moves off the screen, you can bring it back by
dragging your finger across the screen in the appropriate
direction.

Create a The derivative of a graph at any point is the slope of its


derivative point tangent at that point. We’ll now create a new point that will
be constrained to point B and whose ordinate value is the
derivative of the graph at point B. We’ll constrain it by forcing
its x coordinate (that is, its abscissa) to always match that of
point B, and its y coordinate (that is, its ordinate) to always
equal the slope of the tangent at that point.
14. To define a point in
terms of the attributes of
other geometric objects,
you need to go to
Symbolic view:
Y
Note that each object
you have so far created
is listed in Symbolic view. Note too that the name for an
object in Symbolic view is the name it was given in Plot
view but prefixed with a “G”. Thus the graph—labeled A
in Plot view—is labeled GA in Symbolic view.
15. Highlight the blank definition following GC and tap
.
When creating objects that are dependent on other
objects, the order in which they appear in Symbolic view
is important. Objects are drawn in Plot view in the order
in which they appear in Symbolic view. Since we are
about to create a new point that is dependent on the
attributes of GB and GC, it is important that we place its
definition after that of both GB and GC. That is why we
made sure we were at the bottom the list of definitions
before tapping . If the new definition appeared
higher up in Symbolic view, the point created in the
following step would not be active in Plot view.

8 Geometry
16. Tap and choose Point > point
You now need to specify the x and y coordinates of the
new point. The former is defined as the abscissa of point
B (referred to as GB in Symbolic view) and the latter is
defined as the slope of tangent line C (referred to as GC
in Symbolic view).
17. You should have point() on the entry line. Between
the parentheses, add:
abscissa(GB),slope(GC)
For the abscissa command, tap , select Cartesian,
and then select abscissa. For the slope command, tap
, select Measure, and then select slope.
18. Tap .
The definition of your
new point is added to
Symbolic view. When
you return to Plot view,
you will see a point
named D and it will
have the same x-
coordinate as point B.
19. Press P.
If you can’t see point D,
pan until it comes into
view. The y coordinate
of D will be the
derivative of the curve at
point B.
Since it is difficult to
read coordinates off the screen, we’ll add a calculation
that will give the exact derivative (to three decimal
places) and which we can display in Plot view.

Add some 20.Press M.


calculations Numeric view is where you enter calculations.
21. Tap .
22. Tap and choose Measure > slope

Geometry 9
23. Between parentheses, add the name of the tangent,
namely GC, and tap .
Notice that the current slope is calculated and displayed.
The value here is dynamic, that is, if the slope of the
tangent changes in Plot view, the value of the slope is
automatically updated in Numeric view.
24.With the new calculation highlighted in Numeric view,
tap .
Selecting a calculation in Numeric view means that it will
also be displayed in Plot view.
25. Press P to return to
Plot view.
Notice the calculation
that you have just
created in Numeric view
is displayed at the top
left of the screen.
Let’s now add two more
calculations to Numeric view and have them displayed
in Plot view.
26. Press M to return to Numeric view.
27. Tap the last blank field to select it, and then tap to
start a new calculation. Tap , select Cartesian,
and then select Coordinates. Between the
parentheses, enter GB and then tap .
28.To start a third calculation, tap , select
Cartesian, and then select Equation of. Between
the parentheses, enter GC and then tap .
29. Make sure both of these new equations are selected (by
choosing each one and pressing ).
30.Press P to return to
Plot view.
Notice that your new
calculations are
displayed.

10 Geometry
31. Tap point B and then press E to select it.
32. Use the cursor keys to move point B along the graph.
Note that with each move, the results of the calculations
shown at the top left of the screen change. To deselect
point B, tap point B and then press E.

Calculations in By default, calculations in Plot view are docked to the upper


Plot view left of the screen. You can drag a calculation from its dock and
position it anywhere you like; however, after being undocked,
the calculation scrolls with the display. Tap and hold a
calculation to edit its label. An edit line opens so that you can
enter your own label. You can also tap and select a
different color for the calculation and its label. Tap
when you are done.

Trace the Point D is the point whose ordinate value matches the
derivative derivative of the curve at point B. It is easier to see how the
derivative changes by looking at a plot of it rather than
comparing subsequent calculations. We can do that by
tracing point D as it moves in response to movements of point
B.
First we’ll hide the calculations so that we can better see the
trace curve.
33. Press M to return to Numeric view.
34.Select each calculation in turn and tap . All
calculations should now be deselected.
35. Press P to return to Plot view.
36.Tap point D and then press E to select it.
37. Tap (or press Z) and then select Trace. Press
E to deselect point D.
38.Tap point B and then press E to select it.
39. Using the cursor keys,
move point B along the
curve. Notice that a
shadow curve is traced
out as you move point B.
This is the curve of the

Geometry 11
derivative of 3sin(x). Tap point B and then press E
to deselect it.

Plot view in detail


In Plot view you can directly
draw objects on the screen
using various drawing tools.
For example, to draw a
circle, tap , tap
Curve, and then select
Circle. Now, tap where
you want the center of the
circle to be and press E. Next, tap a point that is to be
on the circumference and press E. A circle is drawn
with a center at the location of your first tap, and with a radius
equal to the distance between your first tap and second tap.
Note that there are on-screen instructions to help you. These
instructions appear near the bottom of the screen, next to the
command listing for the active tool (circle, point, and so on).
You can draw any number of geometric objects in Plot view.
See “Plot view: Cmds menu” on page 23 for a list of the
objects you can draw. The drawing tool you choose—line,
circle, hexagon, and so on—remains selected until you
deselect it. This enables you to quickly draw a number of
objects of the same type (such as a number of hexagons).
After you have finished drawing objects of a particular type,
deselect the drawing tool by pressing J. You can tell if a
drawing tool is still active by the presence of the on-screen
instructions and the command name at the bottom of the
screen.
An object in Plot view can be manipulated in numerous ways,
and its mathematical properties can be easily determined
(see page 20).

Selecting objects Selecting an object involves at least two steps: tapping the
object and pressing E. Pressing E is necessary
to confirm your intention to select an object.
When you tap a location, objects recognized as being under
the pointer are colored light red and added to the list of

12 Geometry
objects in the bottom right corner of the display. You can
select any or all of these objects by pressing E. You can
tap the screen and then use the cursor keys to accurately
position the pointer before pressing E.
When more than one object is recognized as being under the
pointer, in most cases, preference is given to any point under
the pointer when E is pressed. In other cases, a pop-
up box appears enabling you to select the desired objects.
You can also select multiple objects using a selection box. Tap
and hold your finger at the location on the screen that
represents one corner of the selection rectangle. Then drag
your finger to the opposite corner of the selection rectangle.
A light blue selection rectangle is drawn as you drag. Objects
that touch this rectangle are selected.

Hiding names You can choose to hide the name of an object in Plot view:
1. Select the object whose label you want to hide.
2. Tap or press Z.
3. Select Hide Label.
Redisplay a hidden name by repeating this procedure and
selecting Show Label.

Moving objects There are many ways to move objects. First, to move an object
quickly, you can drag the object without selecting it.
Second, you can tap an object and press E to select it.
Then, you can drag the object to move it quickly or use the
cursor keys to move it one pixel at a time. With the second
method, you can select multiple objects to move together.
When you have finished moving objects, tap a location where
there are no objects and press E to deselect everything.
If you have selected a single object, you can tap the object
and press E to deselect it.
Third, you can move a point on an object. Each point on an
object has a calculation labeled with its name in Plot view.
Tap and hold this item to display a slider bar. You can drag
the slider or use the cursor keys to move it. appears as
a new menu key. Tap this key to display a dialog box where
you can specify the start, step, and stop values for the slider.
Also, you can create an animation based on this point using

Geometry 13
the slider. You can set the speed and pause for the animation,
as well as its type. To start or stop an animation, select it, tap
, and then select or clear the Animate option.

Coloring objects Objects are colored black by default. The procedure to


change the color of an object depends on which view you are
in. In both the Symbolic and Numeric view, each item includes
a set of color icons. Tap these icons and select a color. In Plot
view, select the object, tap (or press Z), tap Choose
Color, and then select a color.

Filling objects An object with closed contours (such as a circle or polygon)


can be filled with color.
1. Select the object.
2. Tap or press Z.
3. Select Filled.
Filled is a toggle. To remove
a fill, repeat the above
procedure.

Clearing an To clear one object, select it and tap C. Note that an object
object is distinct from the points you entered to create it. Thus
deleting the object does not delete the points that define it.
Those points remain in the app. For example, if you select a
circle and press C, the circle is deleted but the center point
and radius point remain.
If other objects are
dependent on the one you
have selected for deletion, a
pop-up displays the selected
object and all dependent
objects checked for deletion.
Confirm your intention by
tapping .
You can select multiple items for deletion. Either select them
one at a time or use a selection box, and then press C.
Note that points you add to an object once the object has
been defined are cleared when you clear the object. Thus if
you place a point (say D) on a circle and delete the circle, the

14 Geometry
circle and D are deleted, but the defining points—the center
and radius points—remain.

Clearing all To clear the app of all geometric objects, press SJ. You
objects will be asked to confirm your intention to do so. Tap
to clear all objects defined in Symbolic view or to keep
the app as it is. You can clear all measurements and
calculations in Numeric view in the same way.

Gestures in Plot You can pan by dragging a finger across the screen: either
view up, down, left, or right. You can also use the cursor keys to
pan once the cursor is at the edge of the screen. You can use
a pinch gesture to zoom in or out. Place two fingers on the
screen. Move them apart to zoom in or bring them together
to zoom out. You can also press + to zoom in on the
pointer or press w to zoom out on the pointer.

Zooming You can zoom by tapping and choosing a zoom


option. The zoom options are the same as you find in the Plot
view of many apps in the calculator.

Geometry 15
Plot view: buttons and keys
Button or key Purpose

Opens the Commands menu. See “Plot


view: Cmds menu” on page 23.
Opens the Options menu for the selected
object.
Hides (or displays) the axes.
a
Selects the circle drawing tool. Follow the
F
instructions on the screen (or see page
28).
Erases all trace lines.
c
Selects the intersection drawing tool. Fol-
g
low the instructions on the screen (or see
page 24).
Selects the line drawing tool. Follow the
j
instructions on the screen (or see page
25).
Selects the point drawing tool. Follow the
B
instructions on the screen (or see page
24).
Selects the segment drawing tool. Follow
r
the instructions on the screen (or see page
25).
Selects the triangle drawing tool. Follow
n
the instructions on the screen (or see page
26).
C Deletes a selected object (or the character
to the left of the cursor if the entry line is
active).
J Deselects the current drawing tool.
SJ Clears the Plot view of all geometric
objects or the Numeric view of all mea-
surements and calculations.

16 Geometry
The Options menu
When you select an object, a new menu key appears:
. Tap this key to view and select options for the selected
object, such as color. The Options menu changes depending
on the type of object selected. The complete set of Geometry
options are listed in the following table and are also
displayed when you press Z.

Option Purpose

Displays a set of color icons so you can


Choose
Color select a color for the selected object.

Hides the selected object. This is a


Hide
shortcut for deselecting the object in
Symbolic view. To select an object to
display after it has been hidden, go to
Symbolic or Numeric view.
Hides the label of a selected object. This
Hide Label
option changes to Show Label if the
selected object has a hidden label.
Fills the selected object with a color.
Filled
Clear this option to remove the fill.
Starts tracing for any selected point if
Trace
selected, then stops tracing for the
selected point.
Erases the current trace of the selected
Clear Trace
point but does not stop tracing.
Starts the current animation of a selected
Animate
point on an object. If the selected point is
currently animated, this option stops the
animation.

Geometry 17
Plot Setup view
The Plot Setup view enables
you to configure the
appearance of Plot view.
The fields and options are as
follows:
• X Rng: There are two
boxes, but only the
minimum x-value is
editable. The maximum x-value is calculated
automatically, based on the minimum value and the
pixel size. You can also change the x range by panning
and zooming in Plot view.
• Y Rng: There are two boxes, but only the minimum y-
value is editable. The maximum y-value is calculated
automatically, based on the minimum value and the
pixel size. You can also change the y range by panning
and zooming in Plot view.
• Pixel Size: Each pixel in the Plot view must be square.
You can change the size of each pixel. The lower left
corner of the Plot view display remains the same, but the
upper right-corner coordinates are automatically
recalculated.
• Axes: A toggle option to hide (or show) the axes in Plot
view.
Keyboard shortcut: a
• Labels: A toggle option to hide (or show) the labels for
the axes.
• Grid Dots: A toggle option to hide (or show) the grid
dots.
• Grid Lines: A toggle option to hide (or show) the grid
lines.

18 Geometry
Symbolic view in detail
Every object—whether a
point, segment, line,
polygon, or curve—is given
a name, and its definition is
displayed in Symbolic view
(Y). The name is the
name for it you see in Plot
view, but prefixed by “G”.
Thus a point labeled A in Plot view is given the name GA in
Symbolic view.
The G-prefixed name is a variable that can be read by the
computer algebra system (CAS). Thus in the CAS you can
include such variables in calculations. Note in the illustration
above that GC is the name of the variable that represents a
circle drawn in Plot view. If you are working in the CAS and
wanted to know what the area of that circle is, you could enter
area(GC) and press E.
Note Calculations referencing geometry variables can be made in
the CAS or in the Numeric view of the Geometry app
(explained below on page 20).

You can change the definition of an object by selecting it,


tapping , and altering one or more of its defining
parameters. The object is modified accordingly in Plot view.
For example, if you selected point GB in the illustration above,
tapped , changed one or both of the point’s
coordinates, and tapped , you would find, on returning
to Plot view, a circle of a different size.

Creating objects You can also create an object in Symbolic view. Tap ,
define the object—for example, point(4,6)—and press
E. The object is created and can be seen in Plot view.
Another example: to draw a line through points P and Q,
enter line(GP,GQ) in Symbolic view and press E.
When you return to Plot view, you will see a line passing
through points P and Q.

Geometry 19
The object-creation
commands available in
Symbolic view can be seen
by tapping . The
syntax for each command is
given in “Geometry
functions and commands”
on page 39.

Re-ordering You can re-order the entries in Symbolic view. Objects are
entries drawn in Plot view in the order in which they are defined in
Symbolic view. To change the position of an entry, highlight it
and tap either (to move it down the list) or (to
move it up).

Hiding an object To prevent an object displaying in Plot view, deselect it in


Symbolic view:
1. Highlight the item to be hidden.
2. Tap .
Repeat the procedure to make the object visible again.

Deleting an As well as deleting an object in Plot view (see page 14) you
object can delete an object in Symbolic view.
1. Highlight the definition of the object you want to delete.
2. Press C.
To delete all objects, press SJ. When prompted, tap
to confirm the deletion.

Symbolic Setup view


The Symbolic view of the Geometry app is common with
many apps. It is used to override certain system-wide settings.

Numeric view in detail


Numeric view (M) enables you to do calculations in the
Geometry app. The results displayed are dynamic—if you
manipulate an object in Plot view or Symbolic view, any
calculations in Numeric view that refer to that object are

20 Geometry
automatically updated to reflect the new properties of that
object.
Consider circle C in the
illustration at the right. To
calculate the area and
radius of C:
1. Press M to open
Numeric view.
2. Tap .
3. Tap and choose
Measure > Area.
Note that area()
appears on the entry
line, ready for you to
specify the object whose
area you are interested
in.
4. Tap , choose Curves and then the curve whose
area you are interested in.
The name of the object is placed between the
parentheses.
You could have entered the command and object name
manually, that is, without choosing them from menus. If
you enter object names manually, remember that the
name of the object in Plot view must be given a “G”
prefix if it is used in any calculation. Thus the circle
named C in Plot view must be referred to as GC in
Numeric view and Symbolic view.
5. Press E or tap . The area is displayed.
6. Tap .
7. Enter radius(GC) and
tap . The radius is
displayed. Use
to verify both of these
measurements so that
they will be available in
Plot view.

Geometry 21
Note that the syntax used here is the same as you use in
the CAS to calculate the properties of geometric objects.
The Geometry functions and their syntax are described
in “Geometry functions and commands” on page 39.
8. Press P to go back to Plot view. Now, manipulate the
circle in some way that changes its area and radius. For
example, select the center point (A) and use the cursor
keys to move it to a new location. Notice that the area
and radius calculations update automatically as you
move the point. Remember to press J when you are
finished.
Note If an entry in Numeric view is too long for the screen, you can
press > to scroll the rest of the entry into view. Press < to
scroll back to the original view.

Listing all When you are creating a


objects new calculation in Numeric
view, the menu item
appears. Tapping
gives you a list of all the
objects in your Geometry
workspace.
If you are building a
calculation, you can select an object’s variable name from this
menu. The name of the selected object is placed at the
insertion point on the entry line.

Displaying To have a calculation made


calculations in in Numeric view appear in
Plot view Plot view, just highlight it in
Numeric view and tap
. A checkmark
appears beside the
calculation.
Repeat the procedure to
prevent the calculation being displayed in Plot view. The
checkmark is cleared.

22 Geometry
Editing a 1. Highlight the calculation that you want to edit.
calculation 2. Tap to change the calculation or tap to
change the label.
3. Make your changes and tap .

Deleting a 1. Highlight the calculation you want to delete.


calculation 2. Press C.
To delete all calculations, press SJ. Note that deleting
a calculation does not delete any geometric objects from
either the Plot or Symbolic view.

Plot view: Cmds menu


The geometric objects discussed in this section are those that
can be created in either Plot view or Symbolic view using the
Commands menu ( ). This section discusses how to use
the commands in Plot view. Objects can also be created in
Symbolic view—more, in fact, than in Plot view—but these are
discussed in “Geometry functions and commands” on
page 39. Finally, measurements and other calculations can
be performed in Plot view as well.
In Plot view, you choose a drawing tool to draw an object. The
tools are listed in this section. Note that once you select a
drawing tool, it remains selected until you deselect it. This
enables you to quickly draw a number of objects of the same
type (such as a number of circles). To deselect the current
drawing tool, press J. You can tell if a drawing tool is still
active by the presence of the on-screen help in the bottom left-
side of the screen and the current command statement to its
right.
The steps provided in this section are based on touch entry.
For example, to add a point, the steps will tell you to tap on
the screen where you want the point to be and press E.
However, you can also use the cursor keys to position the
cursor where you want the point to be and then press
E.
The drawing tools for the geometric objects listed in this
section can be selected from the Commands menu at the
bottom of the screen ( ). Some objects can also be

Geometry 23
entered using a keyboard shortcut. For example, you can
select the triangle drawing tool by pressing n. See “Plot
view: buttons and keys” on page 16.

Point Tap to display a menu and submenus of options for


entering various types of points. The menus and submenus
are:

Point Tap where you want the point to be and press E.


Keyboard shortcut: B

Point On Tap the object where you want the new point to be and press
E. If you select a point that has been placed on an
object and then move that point, the point will be constrained
to the object on which it was placed. For example, a point
placed on a circle will remain on that circle regardless of how
you move the point.

Midpoint Tap where you want one point to be and press E. Tap
where you want the other point to be and press E. A
point is automatically created midway between those two
points.
If you choose an object first—such as a segment—choosing
the Midpoint tool and pressing E adds a point midway
between the ends of that object. (In the case of a circle, the
midpoint is created at the circle’s center.)

Center Tap a circle and press E. A point is created at the


center of the circle.

Intersection Tap the desired intersection and press E. A point is


created at one of the points of intersection.
Keyboard shortcut: g

Intersections Tap one object other than a point and press E. Tap
another object and press E. The point(s) where the two
objects intersect are created and named. Note that an
intersections object is created in Symbolic view even if the two
objects selected do not intersect.

24 Geometry
Random Points Press E to randomly create a point in Plot view.
Continue pressing E to create more random points.
Press J when you are done.

Line

Segment Tap where you want one endpoint to be and press E.


Tap where you want the other endpoint to be and press
E. A segment is drawn between the two end points.
Keyboard shortcut: r

Ray Tap where you want the endpoint to be and press E.


Tap a point that you want the ray to pass through and press
E. A ray is drawn from the first point and through the
second point.

Line Tap at a point you want the line to pass through and press
E. Tap at another point you want the line to pass
through and press E. A line is drawn through the two
points.
Keyboard shortcut: j
Tap a third point (C) and press E. A line is drawn
through A bisecting the angle formed by AB and AC.

Parallel Tap on a point (P) and press E. Tap on a line (L) and
press E. A new line is draw parallel to L and passing
through P.

Perpendicular Tap on a point (P) and press E. Tap on a line (L) and
press E. A new line is draw perpendicular to L and
passing through P.

Tangent Tap on a curve (C) and press E. Tap on a point (P) and
press E. If the point (P) is on the curve (C), then a single
tangent is drawn. If the point (P) is not on the curve (C), then
zero or more tangents may be drawn.

Median Tap on a point (A) and press E. Tap on a segment and


press E. A line is drawn through the point (A) and the
midpoint of the segment.

Geometry 25
Altitude Tap on a point (A) and press E. Tap on a segment and
press E. A line is drawn through the point (A)
perpendicular to the segment (or its extension).

Angle bisector Tap the point that is the vertex of the angle to be bisected (A)
and press E. Tap another point (B) and press E.

Polygon The Polygon menu provides tools for drawing various


polygons.

Triangle Tap at each vertex, pressing E after each tap.


Keyboard shortcut: n

Isosceles Draws an isosceles triangle defined by two of its vertices and


Triangle an angle. The vertices define one of the two sides equal in
length and the angle defines the angle between the two sides
of equal length. Like equilateral_triangle, you have
the option of storing the coordinates of the third point into a
CAS variable.
isosceles_triangle(point1, point2, angle)

Example:
isosceles_triangle(GA, GB, angle(GC, GA, GB)
defines an isosceles triangle such that one of the two sides of
equal length is AB, and the angle between the two sides of
equal length has a measure equal to that of ∡ ACB.

Right Triangle Draws a right triangle given two points and a scale factor.
One leg of the right triangle is defined by the two points, the
vertex of the right angle is at the first point, and the scale
factor multiplies the length of the first leg to determine the
length of the second leg.
right_triangle(point1, point2, realk)

Example:
right_triangle(GA, GB, 1) draws an isosceles right
triangles with its right angle at point A, and with both legs
equal in length to segment AB.

Quadrilateral Tap at each vertex, pressing E after each tap.

26 Geometry
Parallelogram Tap at one vertex and press E. Tap at another vertex
and press E. Tap at a third vertex and press E.
The location of the fourth vertex is automatically calculated
and the parallelogram is drawn.

Rhombus Draws a rhombus, given two points and an angle. As with


many of the other polygon commands, you can specify
optional CAS variable names for storing the coordinates of
the other two vertices as points.
rhombus(point1, point2, angle)

Example
rhombus(GA, GB, angle(GC, GD, GE)) draws a
rhombus on segment AB such that the angle at vertex A has
the same measure as ∡ DCE.

Rectangle Draws a rectangle given two consecutive vertices and a point


on the side opposite the side defined by the first two vertices
or a scale factor for the sides perpendicular to the first side.
As with many of the other polygon commands, you can
specify optional CAS variable names for storing the
coordinates of the other two vertices as points.
rectangle(point1, point2, point3) or
rectangle(point1, point2, realk)

Examples:
rectangle(GA, GB, GE) draws a rectangle whose first
two vertices are points A and B (one side is segment AB).
Point E is on the line that contains the side of the rectangle
opposite segment AB.
rectangle(GA, GB, 3, p, q) draws a rectangle whose
first two vertices are points A and B (one side is segment AB).
The sides perpendicular to segment AB have length 3*AB.
The third and fourth points are stored into the CAS variables
p and q, respectively.

Polygon Draws a polygon from a set of vertices.


polygon(point1, point2, …, pointn)

Example:
polygon(GA, GB, GD) draws ΔABD

Geometry 27
Regular Draws a regular polygon given the first two vertices and the
Polygon number of sides, where the number of sides is greater than 1.
If the number of sides is 2, then the segment is drawn. You can
provide CAS variable names for storing the coordinates of the
calculated points in the order they were created. The
orientation of the polygon is counterclockwise.
isopolygon(point1, point2, realn), where realn
is an integer greater than 1.

Example
isopolygon(GA, GB, 6) draws a regular hexagon
whose first two vertices are the points A and B.

Square Tap at one vertex and press E. Tap at another vertex


and press E. The location of the third and fourth
vertices are automatically calculated and the square is drawn.

Curve

Circle Tap at the center of the circle and press E. Tap at a


point on the circumference and press E. A circle is
drawn about the center point with a radius equal to the
distance between the two tapped points.
Keyboard shortcut: F
You can also create a circle by first defining it in Symbolic
view. The syntax is circle(GA,GB) where A and B are two
points. A circle is drawn in Plot view such that A and B define
the diameter of the circle.

Circumcircle A circumcircle is the circle


that passes through each of
the triangle’s three vertices,
thus enclosing the triangle.
Tap at each vertex of the
triangle, pressing E
after each tap.

Excircle An excircle is a circle that is tangent to one segment of a


triangle and also tangent to the rays through the segment’s
endpoints from the vertex of the triangle opposite the segment.

28 Geometry
Tap at each vertex of the
triangle, pressing E
after each tap.
The excircle is drawn tangent
to the side defined by the last
two vertices tapped. In the
example at the right, the last
two vertices tapped were A
and C (or C and A). Thus the excircle is drawn tangent to the
segment AC.

Incircle An incircle is a circle that is tangent to all three sides of a


triangle. Tap each vertex of the triangle, pressing E
after each tap.

Ellipse Tap at one focus point and press E. Tap at the second
focus point and press E. Tap at point on the
circumference and press E.

Hyperbola Tap at one focus point and press E. Tap at the second
focus point and press E. Tap at point on one branch of
the hyperbola and press E.

Parabola Tap at the focus point and press E. Tap either on a line
(the directrix) or a ray or segment nd press E.

Conic Plots the graph of a conic section defined by an expression in


x and y.
conic(expr)

Example:
conic(x^2+y^2-81) draws a circle with center at (0,0)
and radius of 9

Locus Takes two points as its arguments: the first is the point whose
possible locations form the locus; the second is a point on an
object. This second point drives the first through its locus as the
second moves on its object.

Geometry 29
In the example at the right,
circle C has been drawn and
point D is a point placed on
C (using the Point On
function described above).
Point I is a translation of
point D. Choosing Curve >
Special > Locus places
locus( on the entry line. Complete the command as
locus(GI,GD) and point I traces a path (its locus) that
parallels point D as it moves around the circle to which it is
constrained.

Plot You can plot expressions of the following types in Plot view:
• Function
• Parametric
• Polar
• Sequence
Tap , select Plot, and
then the type of expression
you want to plot. The entry
line is enabled for you to
define the expression.
Note that the variables you
specify for an expression
must be in lowercase.
In this example, Function
has been selected as the plot
type and the graph of y = 1/
x is plotted.

Function Syntax: plotfunc(Expr)


Draws the plot of a function, given an expression in the
independent variable x. An edit line appears. Enter your
expression and press E. Note the use of lowercase x.

30 Geometry
Example:
plotfunc(3*sin(x)) draws the graph of y=3*sin(x)

Parametric Syntax: plotparam(f(Var)+i*g(Var), Var=


Start..Stop, [tstep=Value])
Takes a complex expression in one variable and an interval
for that variable as arguments. Interprets the complex
expression f(t)+i*g(t) as x=f(t) and y=g(t) and
plots the parametric equation over the interval specified in the
second argument. An edit line opens for you to enter the
complex expression and the interval.
Examples:
plotparam(cos(t)+ i*sin(t), t=0..2*π) plots the
unit circle
plotparam(cos(t)+ i*sin(t), t=0..2*π,
tstep=π/3) plots a regular hexagon inscribed in the unit
circle (note the tstep value)

Polar Syntax: plotpolar(Expr,Var=Interval, [Step]) or


plotpolar(Expr, Var, Min, Max, [Step])
Draws a polar graph in Plot view. An edit line opens for you
to enter an expression in x as well as an interval (and optional
step).
plotpolar(f(x),x,a,b) draws the polar curve r=f(x)
for x in [a,b]

Sequence Syntax: plotseq(f(Var), Var={Start, Xmin,


Xmax}, Integer n)
Given an expression in x and a list containing three values,
draws the line y=x, the plot of the function defined by the
expression over the domain defined by the interval between
the last two values, and draws the cobweb plot for the first n
terms of the sequence defined recursively by the expression
(starting at the first value).

Geometry 31
Example:
plotseq(1-x/2, x={3 -1 6}, 5) plots y=x and
y=1–x/2 (from x=–1 to x=6), then draws the first 5 terms of
the cobweb plot for u(n)=1-(u(n–1)/2, starting at
u(0)=3

Implicit Syntax: plotimplicit(Expr, [XIntrvl, YIntrvl])


Plots an implicitly defined curve from Expr (in x and y).
Specifically, plots Expr=0. Note the use of lowercase x and y.
With the optional x-interval and y-interval, this command plots
only within those intervals.
Example:
plotimplicit((x+5)^2+(y+4)^2-1) plots a circle,
centered at the point (-5, -4), with a radius of 1

Slopefield Syntax: plotfield(Expr, [x=X1..X2 y=Y1..Y2],


[Xstep, Ystep], [Option])
Plots the graph of the slopefield for the differential equation
y’=f(x,y) over the given x-range and y-range. If Option is
normalize, the slopefield segments drawn are equal in
length.
Example:
plotfield(x*sin(y), [x=-6..6, y=-
6..6],normalize) draws the slopefield for
y'=x*sin(y), from -6 to 6 in both directions, with
segments that are all of the same length

ODE Syntax: plotode(Expr, [Var1, Var2, ...],


[Val1, Val2. ...])
Draws the solution of the differential equation y’=f(Var1, Var2,
...) that contains as initial condition for the variables Val1,
Val2,... The first argument is the expression f(Var1, Var2,...),
the second argument is the vector of variables, and the third
argument is the vector of initial conditions.
Example:
plotode(x*sin(y), [x,y], [–2, 2]) draws the
graph of the solution to y’=x*sin(y) that passes through
the point (–2, 2) as its initial condition

32 Geometry
List Syntax: plotlist(Matrix 2xn)
Plots a set of n points and connects them with segments. The
points are defined by a 2xn matrix, with the abscissas in the
first row and the ordinates in the second row.
Example:
plotlist([[0,3],[2,1],[4,4],[0,3]]) draws a
triangle

Slider Creates a slider bar that can be used to control the value of
a parameter. A dialog box displays the slider bar definition
and any animation for the slider.

Transform The Transform menu provides numerous tools for you to


perform transformations on geometric objects in Plot view. You
can also define transformations in Symbolic view

Translation A translation is a transformation of a set of points that moves


each point the same distance in the same direction. T: (x,y) →
(x+a, y+b).
Suppose you want to
translate circle B at the right
down a little and to the right:
1. Tap , tap
Transform, and select
Translation.
2. Tap the object to be
moved and press
E.
3. Tap an initial location
and press E.
4. Tap a final location and
press E.
The object is moved the
same distance and
direction from the initial
to the final locations.
The original object is left in place.

Geometry 33
Reflection A reflection is a
transformation which maps
an object or set of points
onto its mirror image, where
the mirror is either a point or
a line. A reflection through a
point is sometimes called a
half-turn. In either case, each
point on the mirror image is the same distance from the mirror
as the corresponding point on the original. In the example at
the right, the original triangle D is reflected through point I.
1. Tap , tap Transform, and select Reflection.
2. Tap the point or straight object (segment, ray, or line) that
will be the symmetry axis (that is, the mirror) and press
E.
3. Tap the object that is to be reflected across the symmetry
axis and press E. The object is reflected across the
symmetry axis defined in step 2.

Rotation A rotation is a mapping that


rotates each point by a fixed
angle around a center point.
The angle is defined using
the angle() command,
with the vertex of the angle
as the first argument.
Suppose you wish to rotate
the square (GC) around point K (GK) through ∡ LKM in the
figure to the right.
1. Tap , tap Transform, and select Rotation.
rotation() appears on the entry line.
2. Between the
parentheses, enter:
GK,angle(GK,GL,GM
),GC
3. Press E or tap
.

34 Geometry
4. Press P to return to Plot view to see the rotated square.

Dilation A dilation (also called a homothety or uniform scaling) is a


transformation where an object is enlarged or reduced by a
given scale factor around a given point as center.
In the illustration at the right,
the scale factor is 2 and the
center of dilation is
indicated by a point near the
top right of the screen
(named I). Each point on the
new triangle is collinear with
its corresponding point on
the original triangle and point I. Further, the distance from
point I to each new point will be twice the distance to the
original point (since the scale factor is 2).
1. Tap , tap Transform, and select Dilation.
2. Tap the point that is to be the center of dilation and press
E.
3. Enter the scale factor and press E.
4. Tap the object that is to be dilated and press E.

Similarity Dilates and rotates a geometric object about the same center
point.
similarity(point, realk, angle, object)

Example:
similarity(0, 3, angle(0,1,i),point(2,0))
dilates the point at (2,0) by a scale factor of 3 (a point at
(6,0)), then rotates the result 90° counterclockwise to create a
point at (0, 6).

Projection A projection is a mapping of one or more points onto an


object such that the line passing through the point and its
image is perpendicular to the object at the image point.
1. Tap , tap Transform, and select Projection.
2. Tap the object onto which points are to be projected and
press E.

Geometry 35
3. Tap the point that is to be projected and press E.
Note the new point added to the target object.

Inversion An inversion is a mapping involving a center point and a


scale factor. Specifically, the inversion of point A through
center C, with scale factor k, maps A onto A’, such that A’ is
on line CA and CA*CA’=k, where CA and CA’ denote the
lengths of the corresponding segments. If k=1, then the
lengths CA and CA’ are reciprocals.
Suppose you wish to find the inversion of point B with respect
to point A.
1. Tap , tap Transform, and select Inversion.
2. Tap point A and press E.
3. Enter the inversion ratio—use the default value of 1—and
press E.
4. Tap point B and press
E.
In the figure, point C is
the inversion of point B
in respect to point A.

Reciprocation A reciprocation is a special case of inversion involving circles.


A reciprocation with respect to a circle transforms each point
in the plane into its polar line. Conversely, the reciprocation
with respect to a circle maps each line in the plane into its
pole.
1. Tap , tap Transform, and select
Reciprocation.
2. Tap the circle and press E.

36 Geometry
3. Tap a point and press
E to see its polar
line.
4. Tap a line and press
E to see its pole.
In the illustration to the
right, point K is the
reciprocation of line DE
(G) and Line I (at the bottom of the display) is the
reciprocation of point H.

Cartesian

Abcissa Tap a point and press E to select it. The abscissa (x-
coordinate) of the point will appear at the top left of the
screen.

Ordinate Tap a point and press E to select it. The ordinate (y-
coordinate) of the point will appear at the top left of the
screen.

Coordinates Tap a point and press E to select it. The coordinates of


the point will appear at the top left of the screen.

Equation of Tap an object other than a point and press E to select


it. The equation of the object (in x and/or y) is displayed.

Parametric Tap an object other than a point and press E to select


it. The parametric equation of the object (x(t)+i*y(t)) is
displayed.

Polar Tap a point and press E to select it. The polar


coordinates coordinates of the point will appear at the top left of the
screen.

Measure

Distance Tap a point and press E to select it. Repeat to select a


second point. The distance between the two points is
displayed.

Geometry 37
Radius Tap a circle and press E to select it. The radius of the
circle is displayed.

Perimeter Tap a circle and press E to select it. The perimeter of the
circle is displayed.

Slope Tap a straight object (segment, line, and so on) and press
E to select it. The slope of the object is displayed.

Area Tap a circle or polygon and press E to select it. The area
of the object is displayed.

Angle Tap a point and press E to select it. Repeat to select


three points. The measure of the directed angle from the
second point through the third point, with the first point as
vertex, is displayed.

Arc Length Tap a curve and press E to select it. Then, enter a start
value and a stop value. The length of the arc on the curve
between the two x-values is displayed.

Tests

Collinear Tap a point and press E to select it. Repeat to select


three points. The test appears at the top of the display, along
with its result. The test returns 1 if the points are collinear;
otherwise, it returns 0.

On circle Tap a point and press E to select it. Repeat to select four
points. The test appears at the top of the display, along with
its result. The test returns 1 if the points are on the same circle;
otherwise, it returns 0.

On object Tap a point and press E to select it. Then tap an object
and press E. The test appears at the top of the display,
along with its result. The test returns 1 if the point is on the
object; otherwise, it returns 0.

Parallel Tap a straight object (segment, line, and so on) and press
E to select it. Then tap another straight object and press
E. The test appears at the top of the display, along with

38 Geometry
its result. The test returns 1 if the objects are parallel;
otherwise, it returns 0.

Perpendicular Tap a straight object (segment, line, and so on) and press
E to select it. Then tap another straight object and press
E. The test appears at the top of the display, along with
its result. The test returns 1 if the objects are perpendicular;
otherwise, it returns 0.

Isosceles Tap a triangle and press E to select it. Or select three


points in order. Returns 0 if the triangle is not isosceles or if
the three points do not form an isosceles triangle. If the
triangle is isosceles (or the three points form an isosceles
triangle), returns the number order of the common point of the
two sides of equal length (1, 2, or 3). Returns 4 if the three
points form an equilateral triangle or if the selected triangle is
equilateral.

Equilateral Tap a triangle and press E to select it. Or select three


points in order. Returns 1 if the triangle is equilateral or if the
three points form an equilateral triangle; otherwise, it returns
0.

Parallelogram Tap a point and press E to select it. Repeat to select four
points. The test appears at the top of the display, along with
its result. The test returns 0 if the points do not form a
parallelogram. Returns 1 if they form a parallelogram, 2 if
they form a rhombus, 3 if they form a rectangle, and 4 if they
form a square.

Conjugate Tap a circle and press E to select it. Then, select two
points or two lines. The test returns 1 if the two points or lines
are conjugates for the circle; otherwise, it returns 0.

Geometry functions and commands


The list of geometry-specific functions and commands in this
section covers those that can be found by tapping in
both Symbolic and Numeric view and those that are only
available from the Catlg menu.

Geometry 39
The sample syntax provided has been simplified. Geometric
objects are referred to by a single uppercase character (such
as A, B,C and so on). However, calculations referring to
geometric objects—in the Numeric view of the Geometry app
and in the CAS—must use the G-prefixed name given for it in
Symbolic view. For example:
altitude(A,B,C) is the simplified form given in this
section
altitude(GA,GB,GC) is the form you need to use in
calculations
Further, in many cases the specified parameters in the syntax
below—A, B, C etc.—can be the name of a point (such as
GA) or a complex number representing a point. Thus
angle(A,B,C) could be:
• angle(GP,GR,GB)
• angle(3+2i,1–2i,5+i) or
• a combination of named points and points defined by a
complex number, as in angle(GP,1–2*i,i).

Symbolic view: Cmds menu


For the most part, the Commands menu in Symbolic View is
the same as it is in Plot view. The Zoom category does not
appear in Symbolic view, nor do the Cartesian, Measure,
and Tests categories, although the latter three appear in
Numeric view. In Symbolic view, the commands are entered
using their syntax. Highlight a command and press W to
learn its syntax. The advantage of entering or editing a
definition in Symbolic view is that you can specify the exact
location of points. After the exact locations of points are
entered, the properties of any dependent objects (lines,
circles, and so on) are reported exactly by the CAS. Use this
fact to test conjectures on geometric objects using the Test
commands. All these commands can be used in the CAS
view, where they return the same objects.

40 Geometry
Point
Point
Creates a point, given the coordinates of the point. Each
coordinate may be a value or an expression involving
variables or measurements on other objects in the geometric
construction.
point(real1, real2) or point(expr1, expr2)

Examples:
point(3,4) creates a point whose coordinates are (3,4).
This point may be selected and moved later.
point(abscissa(A), ordinate(B)) creates a point
whose x-coordinate is the same as that of a point A and
whose y-coordinate is the same as that of a point B. This point
will change to reflect the movements of point A or point B.
Point on
Creates a point on a geometric object whose abscissa is a
given value or creates a real value on a given interval.
element(object, real) or element(real1..real2)

Examples:
element(plotfunc(x2),–2) creates a point on the
graph of y = x2. Initially, this point will appear at (–2,4). You
can move the point, but it will always remain on the graph of
its function.
element(0..5) creates a slider bar with a value of 2.5
initially. Tap and hold this value to open the slider. Select >
or < to increase or decrease the value on the slider bar.
Press J to close the slider bar. The value that you set can
be used as a coefficient in a function that you subsequently
plot or in some other object or calculation.
Midpoint
Returns the midpoint of a segment. The argument can be
either the name of a segment or two points that define a
segment. In the latter case, the segment need not actually be
drawn.
midpoint(segment) or midpoint(point1, point2)

Example: midpoint(0,6+6i) returns point(3,3)

Geometry 41
Center
Syntax: center(Circle)
Plots the center of a circle. The circle can be defined by the
circle command or by name (for example, GC).
Example: center(circle(x^2+y2–x–y)) plots
point(1/2,1/2)
Intersection
Syntax: single_inter(Curve1, Curve2, [Point])
Plots the intersection of Curve1 and Curve2 that is closest to
Point.
Example:
single_inter(line(y=x), circle(x^2+y^2=1),
point(1,1)) plots point((1+i)*√2/2)
Intersections
Returns the intersection of two curves as a vector.
inter(Curve1, Curve2)

Example:
inter(8-x^2/6, x/2-1) returns [[6 2],[-9 -11/2]]

Line
Segment
Draws a segment defined by its endpoints.
segment(point1, point2)

Examples:
segment(1+2i, 4) draws the segment defined by the
points whose coordinates are (1, 2) and (4, 0).
segment(GA, GB) draws segment AB.
Ray
Given 2 points, draws a ray from the first point through the
second point.
half_line((point1, point2)

42 Geometry
Line
Draws a line. The arguments can be two points, a linear
expression of the form a*x+b*y+c, or a point and a slope as
shown in the examples.
line(point1, point2) or line(a*x+b*y+c) or
line(point1, slope=realm)

Examples:
line(2+i, 3+2i) draws the line whose equation is
y=x–1; that is, the line through the points (2,1) and (3,2).
line(2x–3y–8) draws the line whose equation is
2x–3y=8
line(3–2i,slope=1/2) draws the line whose equation
is x–2y=7; that is, the line through (3, –2) with slope m=1/2.
Parallel
Draws a line through a given point that is parallel to a given
line.
parallel(point,line)

Examples:
parallel(A, B) draws the line through point A that is
parallel to line B.
parallel(3–2i, x+y–5) draws the line through the point
(3, –2) that is parallel to the line whose equation is x+y=5;
that is, the line whose equation is y=–x+1.
Perpendicular
Draws a line through a given point that is perpendicular to a
given line. The line may be defined by its name, two points,
or an expression in x and y.
perpendicular(point, line) or
perpendicular(point1, point2, point3)

Examples:
perpendicular(GA, GD) draws a line perpendicular to
line D through point A.
perpendicular(3+2i, GB, GC) draws a line through
the point whose coordinates are (3, 2) that is perpendicular
to line BC.

Geometry 43
perpendicular(3+2i,line(x–y=1)) draws a line
through the point whose coordinates are (3, 2) that is
perpendicular to the line whose equation is x – y = 1; that is,
the line whose equation is y=–x+5.
Tangent
Draws the tangent(s) to a given curve through a given point.
The point does not have to be a point on the curve.
tangent(curve, point)

Examples:
tangent(plotfunc(x^2), GA) draws the tangent to the
graph of y=x^2 through point A.
tangent(circle(GB, GC–GB), GA) draws one or more
tangent lines through point A to the circle whose center is at
point B and whose radius is defined by segment BC.
Median
Given three points that define a triangle, creates the median
of the triangle that passes through the first point and contains
the midpoint of the segment defined by the other two points.
median_line(point1, point2, point3)

Example:
median_line(0, 8i, 4) draws the line whose equation
is y=2x; that is, the line through (0,0) and (2,4), the midpoint
of the segment whose endpoints are (0, 8) and (4, 0).
Altitude
Given three non-collinear points, draws the altitude of the
triangle defined by the three points that passes through the
first point. The triangle does not have to be drawn.
altitude(point1, point2, point3)

Example: altitude(A, B, C) draws a line passing


through point A that is perpendicular to BC.
Bisector
Given three points, creates the bisector of the angle defined
by the three points whose vertex is at the first point. The angle
does not have to be drawn in the Plot view.
bisector(point1, point2, point3)

44 Geometry
Examples:
bisector(A,B,C) draws the bisector of ∡ BAC.
bisector(0,-4i,4) draws the line given by y=–x

Polygon
Triangle
Draws a triangle, given its three vertices.
triangle(point1, point2, point3)

Example:
triangle(GA, GB, GC) draws ΔABC.
Isosceles Triangle
Draws an isosceles triangle defined by two of its vertices and
an angle. The vertices define one of the two sides equal in
length and the angle defines the angle between the two sides
of equal length. Like equilateral_triangle, you have
the option of storing the coordinates of the third point into a
CAS variable.
isosceles_triangle(point1, point2, angle)

Example:
isosceles_triangle(GA, GB, angle(GC, GA, GB)
defines an isosceles triangle such that one of the two sides of
equal length is AB, and the angle between the two sides of
equal length has a measure equal to that of ∡ ACB.
Right Triangle
Draws a right triangle given two points and a scale factor.
One leg of the right triangle is defined by the two points, the
vertex of the right angle is at the first point, and the scale
factor multiplies the length of the first leg to determine the
length of the second leg.
right_triangle(point1, point2, realk)

Example:
right_triangle(GA, GB, 1) draws an isosceles right
triangles with its right angle at point A, and with both legs
equal in length to segment AB.

Geometry 45
Quadrilateral
Draws a quadrilateral from a set of four points.
quadrilateral(point1, point2, point3, point4)

Example:
quadrilateral(GA, GB, GC, GD) draws quadrilateral
ABCD.
Parallelogram
Draws a parallelogram given three of its vertices. The fourth
point is calculated automatically but is not defined
symbolically. As with most of the other polygon commands,
you can store the fourth point’s coordinates into a CAS
variable. The orientation of the parallelogram is
counterclockwise from the first point.
parallelogram(point1, point2, point3)

Example:
parallelogram(0,6,9+5i) draws a parallelogram
whose vertices are at (0, 0), (6, 0), (9, 5), and (3,5). The
coordinates of the last point are calculated automatically.
Rhombus
Draws a rhombus, given two points and an angle. As with
many of the other polygon commands, you can specify
optional CAS variable names for storing the coordinates of
the other two vertices as points.
rhombus(point1, point2, angle)

Example
rhombus(GA, GB, angle(GC, GD, GE)) draws a
rhombus on segment AB such that the angle at vertex A has
the same measure as ∡ DCE.
Rectangle
Draws a rectangle given two consecutive vertices and a point
on the side opposite the side defined by the first two vertices
or a scale factor for the sides perpendicular to the first side.
As with many of the other polygon commands, you can
specify optional CAS variable names for storing the
coordinates of the other two vertices as points.

46 Geometry
rectangle(point1, point2, point3) or
rectangle(point1, point2, realk)

Examples:
rectangle(GA, GB, GE) draws a rectangle whose first
two vertices are points A and B (one side is segment AB).
Point E is on the line that contains the side of the rectangle
opposite segment AB.
rectangle(GA, GB, 3, p, q) draws a rectangle whose
first two vertices are points A and B (one side is segment AB).
The sides perpendicular to segment AB have length 3*AB.
The third and fourth points are stored into the CAS variables
p and q, respectively.
Polygon
Draws a polygon from a set of vertices.
polygon(point1, point2, …, pointn)

Example:
polygon(GA, GB, GD) draws ΔABD
Regular Polygon
Draws a regular polygon given the first two vertices and the
number of sides, where the number of sides is greater than 1.
If the number of sides is 2, then the segment is drawn. You can
provide CAS variable names for storing the coordinates of the
calculated points in the order they were created. The
orientation of the polygon is counterclockwise.
isopolygon(point1, point2, realn), where realn
is an integer greater than 1.

Example
isopolygon(GA, GB, 6) draws a regular hexagon
whose first two vertices are the points A and B.
Square
Draws a square, given two consecutive vertices as points.
square(point1, point2)

Example:
Example: square(0, 3+2i, p, q) draws a square with vertices
at (0, 0), (3, 2), (1, 5), and (-2, 3). The last two vertices are

Geometry 47
computed automatically and are saved into the CAS variables
p and q.

Curve
Circle
Draws a circle, given the endpoints of the diameter, or a
center and radius, or an equation in x and y.
circle(point1, point2) or circle(point1, point 2-point1) or
circle(equation)
Examples:
circle(GA, GB) draws the circle with diameter AB.
circle(GA, GB-GA) draws the circle with center at point
A and radius AB.
circle(x^2+y^2=1) draws the unit circle.
This command can also be used to draw an arc.
circle(GA, GB, 0, π/2) draws a quarter-circle with
diameter AB.
Circumcircle
Draws the circumcircle of a triangle; that is, the circle
circumscribed about a triangle.
circumcircle(point1, point2, point3)

Example:
circumcircle(GA, GB, GC) draws the circle
circumscribed about ΔABC
Excircle
Given three points that define a triangle, draws the excircle of
the triangle that is tangent to the side defined by the last two
points and also tangent to the extensions of the two sides
where the common vertex is the first point.
Example:
excircle(GA, GB, GC) draws the circle tangent to
segment BC and to the rays AB and AC.

48 Geometry
Incircle
An incircle is a circle that is
tangent to each of a
polygon’s sides. The HP
Prime can draw an incircle
that is tangent to the sides of
a triangle.
Tap at each vertex of the
triangle, pressing E
after each tap.
Ellipse
Draws an ellipse, given the foci and either a point on the
ellipse or a scalar that is one half the constant sum of the
distances from a point on the ellipse to each of the foci.
ellipse(point1, point2, point3) or
ellipse(point1, point2, realk)

Examples:
ellipse(GA, GB, GC) draws the ellipse whose foci are
points A and B and which passes through point C.
ellipse(GA, GB, 3) draws an ellipse whose foci are
points A and B. For any point P on the ellipse, AP+BP=6.
Hyperbola
Draws a hyperbola, given the foci and either a point on the
hyperbola or a scalar that is one half the constant difference
of the distances from a point on the hyperbola to each of the
foci.
hyperbola(point1, point2, point3) or
hyperbola(point1, point2, realk)

Examples:
hyperbola(GA, GB, GC) draws the hyperbola whose foci
are points A and B and which passes through point C.
hyperbola(GA, GB, 3) draws a hyperbola whose foci
are points A and B. For any point P on the hyperbola, |AP-
BP|=6.

Geometry 49
Parabola
Draws a parabola, given a focus point and a directrix line, or
the vertex of the parabola and a real number that represents
the focal length.
parabola(point,line) or parabola(vertex,real)

Examples:
parabola(GA, GB) draws a parabola whose focus is point
A and whose directrix is line B.
parabola(GA, 1) draws a parabola whose vertex is point
A and whose focal length is 1.
Conic
Plots the graph of a conic section defined by an expression in
x and y.
conic(expr)

Example:
conic(x^2+y^2-81) draws a circle with center at (0,0)
and radius of 9
Locus
Given a first point and a second point that is an element of (a
point on) a geometric object, draws the locus of the first point
as the second point traverses its object.
locus(point,element)

Plot
Function
Draws the plot of a function, given an expression in the
independent variable x. Note the use of lowercase x.
Syntax: plotfunc(Expr)
Example:
plotfunc(3*sin(x)) draws the graph of y=3*sin(x)
Parametric
Takes a complex expression in one variable and an interval
for that variable as arguments. Interprets the complex
expression f(t)+i*g(t) as x=f(t) and y=g(t) and

50 Geometry
plots the parametric equation over the interval specified in the
second argument.
Syntax: plotparam(f(Var)+i*g(Var), Var=
Start..Stop, [tstep=Value])
Examples:
plotparam(cos(t)+ i*sin(t), t=0..2*π) plots the
unit circle
plotparam(cos(t)+ i*sin(t), t=0..2*π,
tstep=π/3) plots a regular hexagon inscribed in the unit
circle (note the tstep value)
Polar
Draws a polar plot.
Syntax: plotpolar(Expr,Var=Interval, [Step]) or
plotpolar(Expr, Var, Min, Max, [Step])
plotpolar(f(x),x,a,b) draws the polar curve r=f(x)
for x in [a,b]
Sequence
Given an expression in x and a list containing three values,
draws the line y=x, the plot of the function defined by the
expression over the domain defined by the interval between
the last two values, and draws the cobweb plot for the first n
terms of the sequence defined recursively by the expression
(starting at the first value).
Syntax: plotseq(f(Var), Var={Start, Xmin,
Xmax}, Integern)
Example:
plotseq(1-x/2, x={3 -1 6}, 5) plots y=x and
y=1–x/2 (from x=–1 to x=6), then draws the first 5 terms of
the cobweb plot for u(n)=1-(u(n–1)/2, starting at
u(0)=3
Implicit
Plots an implicitly defined curved from Expr (in x and y).
Specifically, plots Expr=0. Note the use of lowercase x and y.
With the optional x-interval and y-interval, plots only within
those intervals.
Syntax: plotimplicit(Expr, [XIntrvl, YIntrvl])

Geometry 51
Example:
plotimplicit((x+5)^2+(y+4)^2-1) plots a circle,
centered at the point (-5, -4), with a radius of 1
Slopefield
Plots the graph of the slopefield for the differential equation
y’=f(x,y), where f(x,y) is contained in Expr. VectorVar is a
vector containing the variables. If VectorVar is of the form
[x=Interval, y=Interval], then the slopefield is plotted over the
specified x-range and y-range. Given xstep and ystep values,
plots the slopefield segments using these steps. If Option is
normalize, then the slopefield segments drawn are equal in
length.
Syntax: plotfield(Expr, VectorVar, [xstep=Val,
ystep=Val, Option])
Example: plotfield(x*sin(y), [x=-6..6, y=-
6..6],normalize) draws the slopefield for
y'=x*sin(y), from -6 to 6 in both directions, with
segments that are all of the same length.
ODE
Draws the solution of the differential equation y’=f(Va1, Var2,
...) that contains as initial condition for the variables Val1,
Val2,... The first argument is the expression f(Var1, Var2,...),
the second argument is the vector of variables, and the third
argument is the vector of initial conditions.
Syntax: plotode(Expr, [Var1, Var2, ...],
[Val1, Val2. ...])
Example:
plotode(x*sin(y), [x,y], [–2, 2]) draws the
graph of the solution to y’=x*sin(y) that passes through
the point (–2, 2) as its initial condition
List
Plots a set of n points and connects them with segments. The
points are defined by a 2xn matrix, with the abscissas in the
first row and the ordinates in the second row.
Syntax: plotlist(Matrix 2xn)

52 Geometry
Example:
plotlist([[0,3],[2,1],[4,4],[0,3]]) draws a
triangle
Slider
Creates a slider bar that can be used to control the value of
a parameter. A dialog box displays the slider bar definition
and any animation for the slider. When completed, the slider
bar appears near the top left of Plot view. You can then move
it to another location.

Transform
Translation
Translates a geometric object along a given vector. The vector
is given as the difference of two points (head-tail).
translation(vector, object)

Examples:
translation(0-i, GA) translates object A down one
unit.
translation(GB-GA, GC) translates object C along the
vector AB.
Reflection
Reflects a geometric object over a line or through a point. The
latter is sometimes referred to as a half-turn.
reflection(line, object) or reflection(point,
object)

Examples:
reflection(line(x=3),point(1,1)) reflects the
point at (1, 1) over the vertical line x=3 to create a point at
(5,1).
reflection(1+i, 3-2i) reflects the point at (3,–2)
through the point at (1, 1) to create a point at (–1, 4).
Rotation
Rotates a geometric object, about a given center point,
through a given angle.
rotate(point, angle, object)

Geometry 53
Example:
rotate(GA, angle(GB, GC, GD),GK) rotates the
geometric object labeled K, about point A, through an angle
equal to ∡ CBD.
Dilation
Dilates a geometric object, with respect to a center point, by
a scale factor.
homothety(point, realk, object)

Example:
homothety(GA, 2, GB) creates a dilation centered at
point A that has a scale factor of 2. Each point P on geometric
object B has its image P’ on ray AP such that AP’=2AP.
Similarity
Dilates and rotates a geometric object about the same center
point.
similarity(point, realk, angle, object)

Example:
similarity(0, 3, angle(0,1,i),point(2,0))
dilates the point at (2,0) by a scale factor of 3 (a point at
(6,0)), then rotates the result 90° counterclockwise to create a
point at (0, 6).
Projection
Draws the orthogonal projection of a point onto a curve.
projection(curve, point)

Inversion
Draws the inversion of a point, with respect to another point,
by a scale factor.
inversion(point1, realk, point2)

Example:
inversion(GA, 3, GB) draws point C on line AB such
that AB*AC=3. In this case, point A is the center of the
inversion and the scale factor is 3. Point B is the point whose
inversion is created.

54 Geometry
In general, the inversion of point A through center C, with
scale factor k, maps A onto A’, such that A’ is on line CA and
CA*CA’=k, where CA and CA’ denote the lengths of the
corresponding segments. If k=1, then the lengths CA and CA’
are reciprocals.
Reciprocation
Given a circle and a vector of objects that are either points or
lines, returns a vector where each point is replaced with its
polar line and each line is replaced with its pole, with respect
to the circle.
reciprocation(Circle, [Obj1, Obj2,...Objn])

Example:
reciprocation(circle(0,1),[line(1+i,2),poin
t(1+i*2)]) returns [point(1/2, 1/2) line(y=-x/
2+1/2)]

Numeric view: Cmds menu


Cartesian
Abscissa
Returns the x coordinate of a point or the x length of a vector.
abscissa(point) or abscissa(vector)

Example:
abscissa(GA) returns the x-coordinate of the point A.
Ordinate
Returns the y coordinate of a point or the y length of a vector.
ordinate(point) or ordinate(vector)

Example:
Example: ordinate(GA) returns the y-coordinate of the
point A.

Geometry 55
Coordinates
Given a vector of points, returns a matrix containing the x- and
y-coordinates of those points. Each row of the matrix defines
one point; the first column gives the x-coordinates and the
second column contains the y-coordinates.
coordinates([point1, point2, …, pointn]))

Equation of
Returns the Cartesian equation of a curve in x and y, or the
Cartesian coordinates of a point.
equation(curve) or equation(point)

Example:
If GA is the point at (0, 0), GB is the point at (1, 0), and GC
is defined as circle(GA, GB-GA), then equation(GC)
returns x2 + y2 = 1.
Parametric
Works like the equation command, but returns parametric
results in complex form.
parameq(GeoObj )

Polar Coordinates
Returns a vector containing the polar coordinates of a point
or a complex number.
polar_coordinates(point) or
polar_coordinates(complex)

Example:
polar_coordinates(√2, √2) returns [2, π/4])

Measure
Distance
Returns the distance between two points or between a point
and a curve.
distance(point1, point2) or distance(point,
curve)

Examples:
distance(1+i, 3+3i) returns 2.828… or 2√2.

56 Geometry
if GA is the point at (0, 0) and GB is defined as
plotfunc(4–x^2/4), then distance (GA, GB) returns 3.464…
or 2√3.
Radius
Returns the radius of a circle.
radius(circle)

Example:
If GA is the point at (0, 0), GB is the point at (1, 0), and GC
is defined as circle(GA, GB-GA), then radius(GC) returns 1.
Perimeter
Returns the perimeter of a polygon or the circumference of a
circle.
perimeter(polygon) or perimeter(circle)

Examples:
If GA is the point at (0, 0), GB is the point at (1, 0), and GC
is defined as circle(GA, GB-GA), then perimeter(GC)
returns 2π.
If GA is the point at (0, 0), GB is the point at (1, 0), and GC
is defined as square(GA, GB-GA), then perimeter(GC)
returns 4.
Slope
Returns the slope of a straight object (segment, ray, or line).
slope(Object)

Example:
slope(line(point(1, 1), point(2, 2))) returns 1.
Area
Returns the area of a circle or polygon.
area(circle) or area(polygon)

This command can also return the area under a curve


between two points.
area(expr, value1, value2)

Geometry 57
Examples:
If GA is defined to be the unit circle, then area(GA) returns
π.
area(4-x^2/4, -4,4) returns 14.666…
Angle
Returns the measure of a directed angle. The first point is
taken as the vertex of the angle as the next two points in order
give the measure and sign.
angle(vertex, point2, point3)

Example:
angle(GA, GB, GC) returns the measure of ∡ BAC.
Arc Length
Returns the length of the arc of a curve between two points on
the curve. The curve is an expression, the independent
variable is declared, and the two points are defined by values
of the independent variable.
This command can also accept a parametric definition of a
curve. In this case, the expression is a list of 2 expressions (the
first for x and the second for y) in terms of a third independent
variable.
arcLen(expr, real1, real2)

Examples:
arcLen(x^2, x, –2, 2) returns 9.29….
arcLen({sin(t), cos(t)}, t, 0, π/2) returns
1.57…

Tests
Collinear
Takes a set of points as argument and tests whether or not they
are collinear. Returns 1 if the points are collinear and 0
otherwise.
is_collinear(point1, point2, …, pointn)

Example:
is_collinear(point(0,0), point(5,0),
point(6,1)) returns 0

58 Geometry
On circle
Takes a set of points as argument and tests if they are all on
the same circle. Returns 1 if the points are all on the same
circle and 0 otherwise.
is_concyclic(point1, point2, …, pointn)

Example:
is_concyclic(point(-4,-2), point(-4,2),
point(4,-2), point(4,2)) returns 1
On object
Tests if a point is on a geometric object. Returns 1 if it is and
0 otherwise
is_element(point, object)

Example:
is_element(point (---2 2
-) , circle(0,1)) returns 1.
-,---
2 2
Parallel
Tests whether or not two lines are parallel. Returns 1 if they
are and 0 otherwise.
is_parallel(line1, line2)

Example:
is_parallel(line(2x+3y=7),line(2x+3y=9)
returns 1.
Perpendicular
Similar to is_orthogonal. Tests whether or not two lines are
perpendicular.
is_perpendicular(line1, line2)

Isosceles
Takes three points and tests whether or not they are vertices of
a single isosceles triangle. Returns 0 if they are not. If they are,
returns the number order of the common point of the two sides
of equal length (1, 2, or 3). Returns 4 if the three points form
an equilateral triangle.
is_isosceles(point1, point2, point3)

Geometry 59
Example:
is_isoscelesl(point(0,0), point(4,0),
point(2,4)) returns 3.
Equilateral
Takes three points and tests whether or not they are vertices of
a single equilateral triangle. Returns 1 if they are and 0
otherwise.
is_equilateral(point1, point2, point3)

Example:
is_equilateral(point(0,0), point(4,0),
point(2,4)) returns 0.
Parallelogram
Tests whether or not a set of four points are vertices of a
parallelogram. Returns 0 if they are not. If they are, then
returns 1 if they form only a parallelogram, 2 if they form a
rhombus, 3 if they form a rectangle, and 4 if they form a
square.
is_parallelogram(point1, point2, point3,
point4)

Example:
is_parallelogram(point(0,0), point(2,4),
point(0,8), point(-2,4)) returns 2.
Conjugate
Tests whether or not two points or two lines are conjugates for
the given circle. Returns 1 if they are and 0 otherwise.
is_conjugate(circle, point1, point2) or
is_conjugate(circle, line1, line2)

Other Geometry functions


The following functions are not available from a menu in the
Geometry app, but are available from the Catlg menu.
affix
Returns the coordinates of a point or both the x- and y-lengths
of a vector as a complex number.
affix(point) or affix(vector)

60 Geometry
Example:
if GA is a point at (1, –2), then affix(GA) returns 1–2i.
barycenter
Calculates the hypothetical center of mass of a set of points,
each with a given weight (a real number). Each point, weight
pair is enclosed in square brackets as a vector.
barycenter([[point1, weight1], [point2,
weight2],…,[pointn, weightn]])

Example:  point(1) 1 
 
barycenter  point(1+i) 2  returns point (1/2, 1/4)
 
convexhull  point(1–i) 1 

Returns a vector containing the points that serve as the convex


hull for a given set of points.
convexhull(point1, point2, …, pointn)

Example:
convexhull(0,1,1+i,1+2i,-1-i,1-3i,-2+i)
returns [1-3*i 1+2*i -2+ i -1- i ]
distance2
Returns the square of the distance between two points or
between a point and a curve.
distance2(point1, point2) or distance2(point,
curve)

Examples:
distance2(1+i, 3+3i) returns 8.
If GA is the point at (0, 0) and GB is defined as plotfunc(4-
x^2/4), then distance2(GA, GB) returns 12.
division_point
For two points A and B, and a numerical factor k, returns a
point C such that C-B=k*(C-A).
division_point(point1, point2, realk)

Example: division_point(0,6+6*i,4) returns point


(8,8)

Geometry 61
equilateral_triangle
Draws an equilateral triangle defined by one of its sides; that
is, by two consecutive vertices. The third point is calculated
automatically, but is not defined symbolically. If a lowercase
variable is added as a third argument, then the coordinates
of the third point are stored in that variable. The orientation of
the triangle is counterclockwise from the first point.
equilateral_triangle(point1, point2) or
equilateral_triangle(point1, point2, var)

Examples:
equilateral triangle(0,6) draws an equilateral
triangle whose first two vertices are at (0, 0) and (6,0); the
third vertex is calculated to be at (3,3*√3).
equilateral triangle(0,6, v) draws an equilateral
triangle whose first two vertices are at (0, 0) and (6,0); the
third vertex is calculated to be at (3,3*√3) and these
coordinates are stored in the CAS variable v. In CAS view,
entering v returns point(3*(√3*i+1)), which is equal to
(3,3*√3).
exbisector
Given three points that define a triangle, creates the bisector
of the exterior angles of the triangle whose common vertex is
at the first point. The triangle does not have to be drawn in the
Plot view.
exbisector(point1, point2, point3)
Examples:
exbisector(A,B,C) draws the bisector of the exterior
angles of ΔABC whose common vertex is at point A.
exbisector(0,–4i,4) draws the line given by y=x
extract_measure
Returns the definition of a geometric object. For a point, that
definition consists of the coordinates of the point. For other
objects, the definition mirrors their definition in Symbolic view,
with the coordinates of their defining points supplied.
extract_measure(Var)

62 Geometry
harmonic_conjugate
Returns the harmonic conjugate of 3 points. Specifically,
returns the harmonic conjugate of point3 with respect to
point1 and point2. Also accepts three parallel or concurrent
lines; in this case, it returns the equation of the harmonic
conjugate line.
harmonic_conjugate(point1, point2, point3) or
harmonic_conjugate(line1, line2, line3)

Example:
harmonic_conjugate(point(0, 0), point(3, 0),
point(4, 0)) returns point(12/5, 0)
harmonic_division
Returns the harmonic conjugate of 3 points. Specifically,
returns the harmonic conjugate of point3 with respect to
point1 and point2 and stores the result in the variable var.
Also accepts three parallel or concurrent lines; in this case, it
returns the equation of the harmonic conjugate line.
harmonic_division(point1, point2, point3, var)
or harmonic_division(line1, line2, line3, var)

Example:
harmonic_division(point(0, 0), point(3, 0),
point(4, 0), p) returns point(12/5, 0) and stores it
in the variable p
isobarycenter
Returns the hypothetical center of mass of a set of points.
Works like barycenter but assumes that all points have equal
weight.
isobarycenter(point1, point2, …,pointn)

Example: isobarycenter(–3,3,3*√3*i) returns


point(3*√3*i/3), which is equivalent to (0,√3).
is_harmonic
Tests whether or not 4 points are in a harmonic division or
range. Returns 1 if they are or 0 otherwise.
is_harmonic(point1, point2, point3, point4)
is_harmonic(point1, point2, point3, point4)

Geometry 63
Example:
is_harmonic(point(0, 0), point(3, 0),
point(4, 0), point(12/5, 0)) returns 1
is_harmonic_circle_bundle
Returns 1 if the circles build a beam, 2 if they have the same
center, 3 if they are the same circle and 0 otherwise.
is_harmonic_circle_bundle({circle1, circle2,
…, circlen})

is_harmonic_line_bundle
Returns 1 if the lines are concurrent, 2 if they are all parallel,
3 if they are the same line and 0 otherwise.
is_harmonic_line_bundle({line1, line2, …,
linen}))

is_orthogonal
Tests whether or not two lines or two circles are orthogonal
(perpendicular). In the case of two circles, tests whether or not
the tangent lines at a point of intersection are orthogonal.
Returns 1 if they are and 0 otherwise.
is_orthogonal(line1, line2) or
is_orthogonal(circle1, circle2)

Example:
is_orthogonal(line(y=x),line(y=-x)) returns 1.
is_rectangle
Tests whether or not a set of four points are vertices of a
rectangle. Returns 0 if they are not, 1 if they are, and 2 if they
are vertices of a square.
is_rectangle(point1, point2, point3, point4)

Examples:
is_rectangle(point(0,0), point(4,2),
point(2,6), point(-2,4)) returns 2.
With a set of only three points as argument, tests whether or
not they are vertices of a right triangle. Returns 0 if they are
not. If they are, returns the number order of the common point
of the two perpendicular sides (1, 2, or 3).
is_rectangle(point(0,0), point(4,2),
point(2,6)) returns 2.

64 Geometry
is_rhombus
Tests whether or not a set of four points are vertices of a
rhombus. Returns 0 if they are not, 1 if they are, and 2 if they
are vertices of a square.
is_rhombus(point1, point2, point3, point4)

Example:
is_rhombus(point(0,0), point(-2,2),
point(0,4), point(2,2)) returns 2
is_square
Tests whether or not a set of four points are vertices of a
square. Returns 1 if they are and 0 otherwise.
is_square(point1, point2, point3, point4)

Example:
is_square(point(0,0), point(4,2),
point(2,6), point(-2,4)) returns 1.
LineHorz
Draws the horizontal line y=a.
LineHorz(a)

Example:
LineHorz(-2) draws the horizontal line whose equation is
y = –2
LineVert
Draws the vertical line x=a.
LineVert(a)

Example:
LineVert(–3) draws the vertical line whose equation is x
= –3
open_polygon
Connects a set of points with line segments, in the given order,
to produce a polygon. If the last point is the same as the first
point, then the polygon is closed; otherwise, it is open.
open_polygon(point1, point2, …, point1) or
open_polygon(point1, point2, …, pointn)

Geometry 65
orthocenter
Returns the orthocenter of a triangle; that is, the intersection of
the three altitudes of a triangle. The argument can be either
the name of a triangle or three non-collinear points that define
a triangle. In the latter case, the triangle does not need to be
drawn.
orthocenter(triangle) or orthocenter(point1,
point2, point3)

Example: orthocenter(0,4i,4) returns (0,0)


perpendicular bisector
Draws the perpendicular bisector of a segment. The segment
is defined either by its name or by its two endpoints.
perpen_bisector(segment) or
perpen_bisector(point1, point2)

Examples:
perpen_bisector(GC) draws the perpendicular bisector
of segment C.
perpen_bisector(GA, GB) draws the perpendicular
bisector of segment AB.
perpen_bisector(3+2i, i) draws the perpendicular
bisector of a segment whose endpoints have coordinates (3,
2) and (0, 1); that is, the line whose equation is y=x/3+1.
point2d
Randomly re-distributes a set of points such that, for each
point, x ∈ [–5,5] and y ∈ [–5,5]. Any further movement of
one of the points will randomly re-distribute all of the points
with each tap or direction key press.
point2d(point1, point2, …, pointn)

polar
Returns the polar line of the given point as pole with respect
to the given circle.
polar(circle, point)

Example:
polar(circle(x^2+y^2=1),point(1/3,0)) returns
x=3

66 Geometry
pole
Returns the pole of the given line with respect to the given
circle.
pole(circle, line)

Example:
pole(circle(x^2+y^2=1), line(x=3)) returns
point(1/3, 0)
powerpc
Given a circle and a point, returns the difference between the
square of the distance from the point to the circle’’s center and
the square of the circle’s radius.
powerpc(circle, point)

Example
powerpc(circle(point(0,0), point(1,1)-
point(0,0)), point(3,1)) returns 8
radical_axis
Returns the line whose points all have the same powerpc
values for the two given circles.
radical_axis(circle1, circle2)

Example:
radical_axis(circle(((x+2)²+y²) =
8),circle(((x-2)²+y²) = 8)) returns line(x=0)
vector
Creates a vector from point1 to point2. With one point as
argument, the origin is used as the tail of the vector.
vector(point1, point2) or vector(point)

Example:
vector(point(1,1), point(3,0)) creates a vector
from (1, 1) to (3, 0).

Geometry 67
vertices
Returns a list of the vertices of a polygon.
vertices(polygon)

vertices_abca
Returns the closed list of the vertices of a polygon.
vertices_abca(polygon)

68 Geometry
2

Inference app
The Inference app calculates hypothesis tests, confidence
intervals, and chi-square tests, in addition to both tests
and confidence intervals based on inference for linear
regression. In addition to the Inference app, the Math
menu has a full set of probability functions based on
various distributions (chi-square, F, binomial, poisson, and
so on).

Based on statistics from one or two samples, you can test


hypotheses and find confidence intervals for the following
quantities:

• mean
• proportion
• difference between two means
• difference between two proportions
You can also perform goodness of fit tests and tests on
two-way tables based on the chi-square distribution.
Finally, you can perform calculations based on inference
for linear regression:

• linear t-test
• confidence interval for slope
• confidence interval for the intercept
• confidence interval for mean response
• prediction interval for a future response

Sample data For many of the calculations, the Numeric view of the
Inference app comes with sample data (which you can
restore by resetting the app). This sample data is useful in
helping you gain an understanding of the app.

Inference app 69
Getting started with the Inference app
Let’s conduct a Z-Test on one mean using the sample data.

Open the 1. Open the Inference app:


Inference I Select
app Inference

The Inference app


opens in Symbolic
view.

Symbolic view options


The following table summarizes the options available in
Symbolic view.

Symbolic view
options
Hypothesis
Tests
Z-Test: 1 μ The Z-Test on one mean

Z-Test: μ1 – μ2 The Z-Test on the difference


between two means
Z-Test: 1 π The Z-Test on one proportion
Z-Test: π1– π2 The Z-Test on the difference
between two proportions
T-Test: 1 μ The T-Test on one mean
T-Test: μ1 – μ2 The T-Test on the difference
between two means
Confidence
Intervals
Z-Int: 1 μ The confidence interval for one
mean, based on the Normal
distribution
Z-Int: μ1 – μ2 The confidence interval for the
difference between two means,
based on the Normal
distribution

70 Inference app
Symbolic view
options
Z-Int: 1 π The confidence interval for one
proportion, based on the
Normal distribution
Z-Int: π1– π2 The confidence interval for the
difference between two
proportions, based on the
Normal distribution
T-Int: 1 μ The confidence interval for one
mean, based on the Student's t-
distribution
T-Int: μ1 – μ2 The confidence interval for the
difference between two means,
based on the Student's t-
distribution
Χ2 test
Goodness of fit The chi-square goodness of fit
test, based on categorical data
2-way test The chi-square test, based on
categorical data in a two-way
table
Regression
Linear t-test The t-test for linear regression
Interval: Slope The confidence interval for the
slope of the true linear
regression line, based on the t-
distribution
Interval: Intercept The confidence interval for the
y-intercept of the true linear
regression line, based on the t-
distribution
Interval: Mean The confidence interval for a
response mean response, based on the t-
distribution
Prediction interval The prediction interval for a
future response, based on the t-
distribution

If you choose one of the hypothesis tests, you can choose


an alternative hypothesis to test against the null
hypothesis. For each test, there are three possible choices

Inference app 71
for an alternative hypothesis based on a quantitative
comparison of two quantities. The null hypothesis is
always that the two quantities are equal. Thus, the
alternative hypotheses cover the various cases for the two
quantities being unequal: <, >, and ≠.

In this section, we will conduct a Z-Test on one mean on


the example data to illustrate how the app works.

Select the 2. Hypothesis Test


inference is the default inference
method. If it is not
method selected, tap on the
Method field and
select it.

3. Choose the type of


test. In this case, select
Z–Test: 1 μ from the
Type menu.

4. Select an alternative
hypothesis. In this
case, select μ< μ 0
from the Alt Hypoth
menu.

Enter data 5. Go to Numeric view to


see the sample data.
M

72 Inference app
The table below describes the fields in this view for
the sample data.

Field name Definition


x Sample mean
n Sample size
μ0 Assumed population mean
σ Population standard deviation
α Alpha level for the test

The Numeric view is where you enter the sample statistics


and population parameters for the situation you are
examining. The sample data supplied here belong to the
case in which a student has generated 50 pseudo-random
numbers on his graphing calculator. If the algorithm is
working properly, the mean would be near 0.5 and the
population standard deviation is known to be
approximately 0.2887. The student is concerned that the
sample mean (0.461368) seems a bit low and it testing
the less than alternative hypothesis against the null
hypothesis.

Display the 6. Display the test


test results results:

The test distribution


value and its
associated
probability are
displayed, along with the critical value(s) of the test
and the associated critical value(s) of the statistic. In
this case, the test indicates that one should not reject
the null hypothesis.

Tap to return to Numeric view.

Inference app 73
Plot the test 7. Display a graphical
results view of the test
results:
P
The graph of the
distribution is
displayed, with the
test Z-value marked. The corresponding X-value is also
shown.

Tap to see the critical Z-value. With the alpha


level showing, you can press \ or = to decrease or
increase the α-level.

Importing statistics
For many of the calculations, the Inference app can
import summary statistics from data in the Statistics 1Var
and Statistics 2Var apps. For the others, the data can be
manually imported. The following example illustrates the
process.

A series of six experiments gives the following values as


the boiling point of a liquid:

82.5, 83.1, 82.6, 83.7, 82.4, and 83.0

Based on this sample, we want to estimate the true boiling


point at the 90% confidence level.

Open the 1. Open the Statistics


Statistics 1Var app:
1Var app I Select
Statistics 1Var

Clear 2. If there is unwanted data in the app, clear it:


unwanted SJ All columns
data

74 Inference app
Enter data 3. In column D1, enter
the boiling points
found during the
experiments.
82.5 E
83.1 E
82.6 E
83.7 E
82.4 E
83 E

Calculate 4. Calculate statistics:


statistics
The statistics
calculated will now
be imported into the
Inference app.

5. Tap to close
the statistics window.

Open the 6. Open the Inference


Inference app and clear the
current settings.
app
I Select
Inference
SJ

Select 7. Tap on the Method


inference field and select
Confidence
method and Interval.
type

Inference app 75
8. Tap on Type and
select T-Int: 1 μ

Import the 9. Open Numeric view:


data M
10. Specify the data you want to import:
Tap .
11. From the App field
select the statistics app
that has the data you
want to import.
12. In the Column field
specify the column in
that app where the
data is stored. (D1 is
the default.)
13. Tap .
14. Specify a 90%
confidence interval in
the C field.

Display 15. Display the confidence


results interval in Numeric
view:
numerically
16. Return to Numeric
view:

76 Inference app
Display 17. Display the confidence
results interval in Plot view.
graphically P
The 90% confidence
interval is [82.48…,
83.28…].

Hypothesis tests
You use hypothesis tests to test the validity of hypotheses
about the statistical parameters of one or two populations.
The tests are based on statistics of samples of the
populations.

The HP Prime hypothesis tests use the Normal Z-


distribution or the Student’s t-distribution to calculate
probabilities. If you wish to use other distributions, please
use the Home view and the distributions found within the
Probability category of the Math menu.

One-Sample Z-Test
Menu name Z-Test: 1 μ

On the basis of statistics from a single sample, this test


measures the strength of the evidence for a selected
hypothesis against the null hypothesis. The null hypothesis
is that the population mean equals a specified value, Η0:
μ = μ0.

You select one of the following alternative hypotheses


against which to test the null hypothesis:

H0: μ < μ0
H0: μ > μ0
H0: μ ≠ μ0

Inference app 77
Inputs The inputs are:

Field name Definition


x Sample mean
n Sample size
μ0 Hypothetical population mean
σ Population standard deviation
α Significance level

Results The results are:

Result Description
Test Z Z-test statistic
Test x Value of x associated with the
test Z-value
P Probability associated with the
Z-Test statistic
Critical Z Boundary value(s) of Z
associated with the α level that
you supplied
Critical x Boundary value(s) of x required
by the α value that you supplied

Two-Sample Z-Test
Menu name Z-Test: μ1 – μ2

On the basis of two samples, each from a separate


population, this test measures the strength of the evidence
for a selected hypothesis against the null hypothesis. The
null hypothesis is that the means of the two populations
are equal, Η 0: μ1 = μ2.

You select one of the following alternative hypotheses to


test against the null hypothesis:

H0: μ1 < μ2
H0: μ1 > μ2
H0: μ1 ≠ μ2

78 Inference app
Inputs The inputs are:

Field name Definition


x1 Sample 1 mean
x2 Sample 2 mean
n1 Sample 1 size
n2 Sample 2 size
σ1 Population 1 standard deviation
σ2 Population 2 standard deviation
α Significance level

Results The results are:

Result Description
Test Z Z-Test statistic
Test Δ x Difference in the means associ-
ated with the test Z-value
P Probability associated with the
Z-Test statistic
Critical Z Boundary value(s) of Z associated
with the α level that you supplied
Critical Δ x Difference in the means associ-
ated with the α level you supplied

One-Proportion Z-Test
Menu name Z-Test: 1 π

On the basis of statistics from a single sample, this test


measures the strength of the evidence for a selected
hypothesis against the null hypothesis. The null hypothesis
is that the proportion of successes is an assumed value,
Η 0 : π = π0.

You select one of the following alternative hypotheses


against which to test the null hypothesis:

H0: π < π0
H0: π > π0
H0: π ≠ π0

Inference app 79
Inputs The inputs are:

Field name Definition


x Number of successes in the sample
n Sample size
π0 Population proportion of successes
α Significance level

Results The results are:

Result Description
Test Z Z-Test statistic
Test p̂ Proportion of successes in the sample
P Probability associated with the Z-Test
statistic
Critical Z Boundary value(s) of Z associated
with the α level that you supplied
Critical p̂ Proportion of successes associated
with the level you supplied

Two-Proportion Z-Test
Menu name Z-Test: π1– π2

On the basis of statistics from two samples, each from a


different population, this test measures the strength of the
evidence for a selected hypothesis against the null
hypothesis. The null hypothesis is that the proportions of
successes in the two populations are equal, Η 0: π1 = π2.

You select one of the following alternative hypotheses


against which to test the null hypothesis:

H0: π1 < π2
H0: π1 > π2
H0: π1 ≠ π2

Inputs The inputs are:

Field name Definition


x1 Sample 1 success count

80 Inference app
Field name Definition
x2 Sample 2 success count
n1 Sample 1 size
n2 Sample 2 size
α Significance level

Results The results are:

Result Description
Test Z Z-Test statistic
Test Δ p̂ Difference between the
proportions of successes in the
two samples that is associated
with the test Z-value
P Probability associated with the
Z-Test statistic
Critical Z Boundary value(s) of Z
associated with the α level that
you supplied
Critical Δ p̂ Difference in the proportion of
successes in the two samples
associated with the α level you
supplied

One-Sample T-Test
Menu name T-Test: 1 μ

This test is used when the population standard deviation is


not known. On the basis of statistics from a single sample,
this test measures the strength of the evidence for a
selected hypothesis against the null hypothesis. The null
hypothesis is that the sample mean has some assumed
value, Η 0 :μ = μ0.

Inference app 81
You select one of the following alternative hypotheses
against which to test the null hypothesis:

H0: μ < μ0
H0: μ > μ0
H0: μ ≠ μ0

Inputs The inputs are:

Field name Definition


x Sample mean
s Sample standard deviation
n Sample size
μ0 Hypothetical population mean
α Significance level

Results The results are:

Result Description
Test T T-Test statistic
Test x Value of x associated with the
test t-value
P Probability associated with the
T-Test statistic
DF Degrees of freedom
Critical T Boundary value(s) of T
associated with the α level that
you supplied
Critical x Boundary value(s) of x required
by the α value that you supplied

Two-Sample T-Test
Menu name T-Test: μ1 – μ2

This test is used when the population standard deviation is


not known. On the basis of statistics from two samples,
each sample from a different population, this test
measures the strength of the evidence for a selected
hypothesis against the null hypothesis. The null hypothesis
is that the two populations means are equal, Η 0: μ1 = μ2.

82 Inference app
You select one of the following alternative hypotheses
against which to test the null hypothesis:

H0: μ1 < μ2
H0: μ1 > μ2
H0: μ1 ≠ μ2

Inputs The inputs are:

Field Definition
name
x1 Sample 1 mean
x2 Sample 2 mean
s1 Sample 1 standard deviation
s2 Sample 2 standard deviation
n1 Sample 1 size
n2 Sample 2 size
α Significance level
Pooled Check this option to pool samples
based on their standard deviations

Results The results are:

Result Description
Test T T-Test statistic
Test Δ x Difference in the means associated
with the test t-value
P Probability associated with the T-Test
statistic
DF Degrees of freedom
Critical T Boundary values of T associated with
the α level that you supplied
Critical Difference in the means associated
Δx with the α level you supplied

Inference app 83
Confidence intervals
The confidence interval calculations that the HP Prime can
perform are based on the Normal Z-distribution or
Student’s t-distribution.

One-Sample Z-Interval
Menu name Z-Int: 1 μ

This option uses the Normal Z-distribution to calculate a


confidence interval for μ, the true mean of a population,
when the true population standard deviation, σ, is known.

Inputs The inputs are:

Field Definition
name
x Sample mean
n Sample size
σ Population standard deviation
C Confidence level

Results The results are:

Result Description
C Confidence level
Critical Z Critical values for Z
Lower Lower bound for μ
Upper Upper bound for μ

Two-Sample Z-Interval
Menu name Z-Int: μ1 – μ2

This option uses the Normal Z-distribution to calculate a


confidence interval for the difference between the means
of two populations, μ1– μ2, when the population standard
deviations, σ1 and σ2, are known.

84 Inference app
Inputs The inputs are:

Field Definition
name
x1 Sample 1 mean
x2 Sample 2 mean
n1 Sample 1 size
n2 Sample 2 size
σ1 Population 1 standard deviation
σ2 Population 2 standard deviation
C Confidence level

Results The results are:

Result Description
C Confidence level
Critical Z Critical values for Z
Lower Lower bound for Δ μ
Upper Upper bound for Δ μ

One-Proportion Z-Interval
Menu name Z-Int: 1π

This option uses the Normal Z-distribution to calculate a


confidence interval for the proportion of successes in a
population for the case in which a sample of size n has a
number of successes x.

Inputs The inputs are:

Field Definition
name
x Sample success count
n Sample size
C Confidence level

Inference app 85
Results The results are:

Result Description
C Confidence level
Critical Z Critical values for Z
Lower Lower bound for π
Upper Upper bound for π

Two-Proportion Z-Interval
Menu name Z-Int: π1 – π2

This option uses the Normal Z-distribution to calculate a


confidence interval for the difference between the
proportions of successes in two populations.

Inputs The inputs are:

Field Definition
name
x1 Sample 1 success count
x2 Sample 2 success count
n1 Sample 1 size
n2 Sample 2 size
C Confidence level

Results The results are:

Result Description
C Confidence level
Critical Z Critical values for Z
Lower Lower bound for Δπ
Upper Upper bound for Δπ

86 Inference app
One-Sample T-Interval
Menu name T-Int: 1 μ

This option uses the Student’s t-distribution to calculate a


confidence interval for μ, the true mean of a population,
for the case in which the true population standard
deviation, σ, is unknown.

Inputs The inputs are:

Field Definition
name
x Sample mean
s Sample standard deviation
n Sample size
C Confidence level

Results The results are:

Result Description
C Confidence level
DF Degrees of freedom
Critical T Critical values for T
Lower Lower bound for μ
Upper Upper bound for μ

Two-Sample T-Interval
Menu name T-Int: μ1 – μ2

This option uses the Student’s t-distribution to calculate a


confidence interval for the difference between the means
of two populations, μ1 – μ2, when the population
standard deviations, σ1and σ2, are unknown.

Inference app 87
Inputs The inputs are:

Result Definition
x1 Sample 1 mean
x2 Sample 2 mean
s1 Sample 1 standard deviation
s2 Sample 2 standard deviation
n1 Sample 1 size
n2 Sample 2 size
C Confidence level
Pooled Whether or not to pool the samples
based on their standard deviations

Results The results are:

Result Description
C Confidence level
DF Degrees of freedom
Critical T Critical values for T
Lower Lower bound for Δ μ
Upper Upper bound for Δ μ

Chi-square tests
An HP Prime calculator can perform tests on categorical
data based on the chi-square distribution. Specifically, HP
Prime calculators support both goodness of fit tests and
tests on two-way tables.

Goodness of fit test


Menu name Goodness of Fit

This option uses the chi-square distribution to test the


goodness of fit of categorical data on observed counts
against either expected probabilities or expected counts.
In the Symbolic view, make your selection in the
Expected box: choose either Probability (the
default) or Count.

88 Inference app
Inputs With Expected Probability selected, the Numeric
view inputs are as follows:

Field Definition
name
ObsList The list of observed count data
ProbList The list of expected possibilities

Results When is tapped, the results are as follows:

Field Definition
name
x2 The value of the chi-square test statistic
P The probability associated with the chi-
square value
DF The degrees of freedom

Menu keys The menu key options are as follows:

Menu Definition
key
Displays the default test results, as listed
previously
Displays the expected counts
Displays the list of contributions of each
category to the chi-square value
Selects a small, medium, or large font
Returns to the Numeric view

With Expected Count selected, the Numeric view inputs


include ExpList for the expected counts instead of
ProbList and the menu key labels in the Results screen
do not include Exp.

Two-way table test


Menu name 2-way test

This option uses the chi-square distribution to test the


goodness of fit of categorical data of observed counts
contained in a two-way table.

Inference app 89
Inputs The Numeric view inputs are as follows:

Field Definition
name
ObsMat The matrix of the observed count data in
the two-way table

Results When is tapped, the results are as follows:

Field Definition
name
x2 The value of the chi-square test statistic
P The probability associated with the chi-
square value
DF The degrees of freedom

Menu keys The menu key options are as follows:

Menu Definition
key
Displays the matrix of expected counts.
Press to exit.
Displays the matrix of contributions of
each category to the chi-square value.
Press to exit.
Selects a small, medium, or large font.
Returns to the Numeric view.

Inference for regression


An HP Prime calculator can perform tests and calculate
intervals based on inference for linear regression. These
calculations are based on the t-distribution.

Hint: If you have been using the Statistics 2Var app to


explore a linear regression and you want to use the same
data for this procedure, you will have to import it
manually. For example, suppose your x-values are in list
C1 of the Statistics 2Var app and your y-values are in list
C2.

90 Inference app
To import the data into the Inference app:

1. Open the Statistics 2Var app and press H to enter


Home view.
2. Type L1:=C1 and press E.
3. Type L2:=C2 and press E.
4. Open the Inference app and press H to enter
Home view.
5. Type Xlist:=L1 and press E.
6. Type Ylist:=L2 and press E.
7. Press Y to enter Symbolic view, and then select
Regression for the Method field.
8. Press M to enter Numeric view. Your data is
imported to Xlist and Ylist.

Linear t-test
Menu name Linear t test

This option performs a t-test on the true linear regression


equation, based on a list of explanatory data and a list of
response data. You must choose an alternative hypothesis
in Symbolic view using the Alt Hypoth field.

Inputs The Numeric view inputs are as follows:

Field Definition
name
Xlist The list of explanatory data
Ylist The list of response data

Results When is tapped, the results are as follows:

Field Definition
name
Test T The value of the t-test statistic
P The probability associated with the t-
statistic
DF The degrees of freedom

Inference app 91
Field Definition
name
β0 The intercept of the calculated regres-
sion line
β1 The slope of the calculated regression
line
serrLine The standard error of the calculated
regression line
serrSlope The standard error of the slope of the
calculated regression line
serrInter The standard error of the intercept of the
calculated regression line
r The correlation coefficient of the data
2
R The coefficient of determination of the
data

Menu keys The menu key options are as follows:

Menu Definition
key
Selects a small, medium, or large font.
Returns to the Numeric view.

Confidence interval for slope


Menu name Interval: Slope

This option calculates a confidence interval for the slope


of the true linear regression equation, based on a list of
explanatory data, a list of response data, and a
confidence level. After you enter your data in Numeric
view and tap , enter the confidence level in the
prompt that appears.

92 Inference app
Inputs The Numeric view inputs are as follows:

Field Definition
name
Xlist The list of explanatory data
Ylist The list of response data
C The confidence level (0 < C < 1)

Results When is tapped, the results are as follows:

Field Definition
name
C The input confidence level
Crit. T The critical value of t
DF The degrees of freedom
β1 The slope of the calculated regression
line
serrSlope The standard error of the slope of the
regression line
Lower The lower bound of the confidence
interval for the slope
Upper The upper bound of the confidence
interval for the slope

Menu keys The menu key options are as follows:

Menu Definition
key
Selects a small, medium, or large font.
Returns to the Numeric view.

Inference app 93
Confidence interval for intercept
Menu name Interval: Intercept

This option calculates a confidence interval for the


intercept of the true linear regression equation, based on
a list of explanatory data, a list of response data, and a
confidence level. After you enter your data in Numeric
view and tap , enter the confidence level in the
prompt that appears.

Inputs The Numeric view inputs are as follows:

Field Definition
name
Xlist The list of explanatory data
Ylist The list of response data
C The confidence level (0 < C < 1)

Results When is tapped, the results are as follows:

Field Definition
name
C The input confidence level
Crit. T The critical value of t
DF The degrees of freedom
β0 The intercept of the calculated regres-
sion line
serrInter The standard error of the y-intercept of
the regression line
Lower The lower bound of the confidence
interval for the intercept
Upper The upper bound of the confidence
interval for the intercept

94 Inference app
Menu keys The menu key options are as follows:

Menu Definition
key
Selects a small, medium, or large font.
Returns to the Numeric view.

Confidence interval for a mean response


Menu name Interval: Mean response

This option calculates a confidence interval for the mean


response (ŷ), based on a list of explanatory data, a list of
response data, a value of the explanatory variable (X),
and a confidence level. After you enter your data in
Numeric view and tap , enter the confidence level
and the value of the explanatory variable (X) in the
prompt that appears.

Inputs The Numeric view inputs are as follows:

Field Definition
name
Xlist The list of explanatory data
Ylist The list of response data
X The value of the explanatory variable for
which you want a mean response and a
confidence interval
C The confidence level (0 < C < 1)

Results When is tapped, the results are as follows:

Field Definition
name
C The input confidence level
Crit. T The critical value of t
DF The degrees of freedom
ŷ The mean response for the input X-value
serr ŷ The standard error of ŷ

Inference app 95
Field Definition
name
Lower The lower bound of the confidence
interval for the mean response
Upper The upper bound of the confidence
interval for the mean response

Menu keys The menu key options are as follows:

Menu Definition
key
Selects a small, medium, or large font.
Returns to the Numeric view.

Prediction interval
Menu name Prediction interval

This option calculates a prediction interval for a future


response, based on a list of explanatory data, a list of
response data, a value of the explanatory variable (X),
and a confidence level. After you enter your data in
Numeric view and tap , enter the confidence level
and the value of the explanatory variable (X) in the
prompt that appears.

Inputs The Numeric view inputs are as follows:

Field Definition
name
Xlist The list of explanatory data
Ylist The list of response data
X The value of the explanatory variable for
which you want a future response and a
confidence interval
C The confidence level (0 < C < 1)

96 Inference app
Results When is tapped, the results are as follows:

Field Definition
name
C The input confidence level
Crit. T The critical value of t
DF The degrees of freedom
ŷ The future response for the input X-value
serr ŷ The standard error of ŷ
Lower The lower bound of the confidence
interval for the mean response
Upper The upper bound of the confidence
interval for the mean response

Menu keys The menu key options are as follows:

Menu Definition
key
Selects a small, medium, or large font.
Returns to the Numeric view.

Inference app 97
98 Inference app
3

Functions and commands


Many mathematical functions are available from the
calculator’s keyboard. These are described in “Keyboard
functions” on page 101. Other functions and commands are
collected together in the Toolbox menus (D). There are five
Toolbox menus:
• Math
A collection of non-symbolic mathematical functions (see
“Math menu” on page 105)
• CAS
A collection of symbolic mathematical functions (see
“CAS menu” on page 116)
• App
A collection of app functions that can be called from
elsewhere in the calculator, such as Home view, CAS
view, the Spreadsheet app, and in a program (see “App
menu” on page 138)
Note that the Geometry app functions can be called
from elsewhere in the calculator, but they are designed
to be used in the Geometry app. For that reason, the
Geometry functions are not described in this chapter.
They are described in the Geometry chapter.
• User
The functions that you have created (see “Creating your
own functions” on page 213) and the programs you
have created that contain functions that have been
exported.
• Catlg
All the functions and commands:
– on the Math menu
– on the CAS menu
– used in the Geometry app

Functions and commands 99


– used in programming
– used in the Matrix Editor
– used in the List Editor
– and some additional functions and commands
See “Ctlg menu” on page 172.
Although the Catlg menu includes all the programming
commands, the Commands menu ( ) in the
Program Editor contains all the programming commands
grouped by category. It also contains the Template menu
( ), which contains the common programming
structures.
Some functions can be chosen
from the math template (displayed by
pressing F).
You can also create your own
functions. See “Creating your own
functions” on page 213.

Setting the form You can choose to have entries on the Math and CAS menus
of menu items presented either by their descriptive name or their command
name. (The entries on the Catlg menu are always presented
by their command name.)

Descriptive name Command name

Factor List ifactors

Complex Zeros cZeros

Groebner Basis gbasis

Factor by Degree factor_xn

Find Roots proot

The default menu presentation mode is to provide the


descriptive names for the Math and CAS functions. If you
prefer the functions to be presented by their command name,
deselect the Menu Display option on the second page of
the Home Settings screen.

100 Functions and commands


Abbreviations used in this chapter
In describing the syntax of functions and commands, the
following abbreviations and conventions are used:
Eqn: an equation
Expr: a mathematical expression
Fnc: a function
Frac: a fraction
Intgr: an integer
Obj: signifies that objects of more than one type are
allowable here
Poly: a polynomial
RatFrac: a rational fraction
Val: a real value
Var: a variable
Parameters that are optional are given in square brackets, as
in NORMAL_ICDF([μ,σ,]p).
For ease of reading, commas are used to separate
parameters, but these are only necessary to separate
parameters. Thus a single-parameter command needs no
comma after the parameter even if, in the syntax shown
below, there is a comma between it and an optional
parameter. An example is the syntax zeros(Expr,[Var]).
The comma is needed only if you are specifying the optional
parameter Var.

Keyboard functions
The most frequently used functions are available directly from
the keyboard. Many of the keyboard functions also accept
complex numbers as arguments. Enter the keys and inputs
shown below and press E to evaluate the expression.

In the examples below, shifted functions are represented


by the actual keys to be pressed, with the function name
shown in parentheses. For example, Se(ASIN) means
that to make an arc sine calculation (ASIN), you press
Se.

Functions and commands 101


The examples below show the results you would get in Home
view. If you are in the CAS, the results are given in simplified
symbolic format. For example:

Sj 320 returns 17.88854382 in Home view, and


8*√5 in the CAS.

+,w,s, Add, subtract, multiply, divide. Also accepts complex


n numbers, lists, and matrices.
value1 + value2, etc.

h Natural logarithm. Also accepts complex numbers.


LN(value)
Example:
LN(1) returns 0

Sh (ex) Natural exponential. Also accepts complex numbers.

evalue
Example:

e5 returns 148.413159103

i Common logarithm. Also accepts complex numbers.


LOG(value)
Example:
LOG(100) returns 2

Si (10x) Common exponential (antilogarithm). Also accepts complex


numbers.
ALOG(value)
Example:
ALOG(3) returns 1000

102 Functions and commands


efg Sine, cosine, tangent. Inputs and outputs depend on the
current angle format: degrees or radians.
SIN(value)
COS(value)
TAN(value)
Example:
TAN(45) returns 1 (degrees mode)

Se(ASIN) Arc sine: sin–1x. Output range is from –90° to 90° or –π/2
to π/2. Inputs and outputs depend on the current angle
format. Also accepts complex numbers.
ASIN(value)
Example:
ASIN(1) returns 90 (degrees mode)

Sf(ACOS) Arc cosine: cos–1x. Output range is from 0° to 180° or 0 to


π. Inputs and outputs depend on the current angle format.
Also accepts complex numbers. Output will be complex for
values outside the normal cosine domain of –1 ≤ x ≤ 1 .
ACOS(value)
Example:
ACOS(1) returns 0 (degrees mode)

Sg(ATAN) Arc tangent: tan–1x. Output range is from –90° to 90° or –π/
2 to π/2. Inputs and outputs depend on the current angle
format. Also accepts complex numbers.
ATAN(value)
Example:
ATAN(1) returns 45 (degrees mode)

j Square. Also accepts complex numbers.

value 2
Example:

182 returns 324

Functions and commands 103


Sj Square root. Also accepts complex numbers.
)√value

Example:
√320 returns 17.88854382

k x raised to the power of y. Also accepts complex numbers.

value power
Example:

2 8 returns 256

Sk The nth root of x.


root√value
Example:
3√8 returns 2

Sn Reciprocal.

value -1
Example:

3 -1 returns .333333333333

Q- Negation. Also accepts complex numbers.


-value
Example:
-(1+2*i) returns -1-2*i

SQ(|x|) Absolute value.


|value|
|x+y*i|
|matrix|
For a complex number, |x+y*i| returns x2 + y2 . For a
matrix, |matrix| returns the Frobenius norm of the matrix.
Example:
|–1| returns 1
|(1,2)|returns 2.2360679775

104 Functions and commands


Math menu
Press D to open the
Toolbox menus (one of which
is the Math menu). The
functions and commands
available on the Math menu
are listed as they are
categorized on the menu.

Numbers
Ceiling Smallest integer greater than or equal to value.
CEILING(value)

Examples:
CEILING(3.2) returns 4
CEILING(-3.2) returns -3

Floor Greatest integer less than or equal to value.


FLOOR(value)

Example:
FLOOR(3.2) returns 3
FLOOR(-3.2) returns -4

IP Integer part.
IP(value)

Example:
IP(23.2) returns 23

FP Fractional part.
FP(value)

Example:
FP (23.2) returns .2

Round Rounds value to decimal places. Also accepts complex


numbers.
ROUND(value,places)

Functions and commands 105


ROUND can also round to a number of significant digits if
places is a negative integer (as shown in the second example
below).
Examples:
ROUND(7.8676,2) returns 7.87
ROUND(0.0036757,-3) returns 0.00368

Truncate Truncates value to decimal places. Also accepts complex


numbers.
TRUNCATE(value,places)

TRUNCATE can also round to a number of significant digits if


places is a negative integer (as shown in the second example
below).
Examples:
TRUNCATE(2.3678,2) returns 2.36
TRUNCATE(0.0036757,–3) returns 0.00367

Mantissa Mantissa—that is, the significant digits—of value, where


value is a floating-point number.
MANT(value)

Example:
MANT(21.2E34) returns 2.12

Exponent Exponent of value. That is, the integer component of the


power of 10 that generates value.
XPON(value)

Example:
5.0915...
XPON(123456) returns 5 (since 10 equals 123456)

Arithmetic
Maximum Maximum. The greater of two values.
MAX(value1,value2)

Example:
MAX(8/3,11/4) returns 2.75

Note that in Home view a non-integer result is given as a


decimal fraction. If you want to see the result as a common
fraction, press c.. This key cycles through decimal,
fraction, and mixed number representations. Or, if you prefer,

106 Functions and commands


press K. This opens the computer algebra system. If you
want to return to Home view to make further calculations,
press H.

Minimum Minimum. Returns the least of the values given, or the least
value of a list.
MIN(value1,value2)

Example:
MIN(210,25) returns 25

Modulus Modulo. The remainder of value1/value2.


value1 MOD value2

Example:
74 MOD 5 returns 4

Find Root Function root-finder (like the Solve app). Finds the value for the
given variable at which expression most nearly evaluates to
zero. Uses guess as initial estimate.
FNROOT(expression,variable,guess)

Example:
FNROOT((A*9.8/600)-1,A,1) returns 61.2244897959.

Percentage x percent of y; that is, x/100*y.


%(x,y)

Example:
%(20,50) returns 10

Complex
Argument Argument. Finds the angle defined by a complex number.
Inputs and outputs use the current angle format set in Home
modes.
ARG(x+y*i)

Example:
ARG(3+3*i) returns 45 (degrees mode)

Conjugate Complex conjugate. Conjugation is the negation (sign


reversal) of the imaginary part of a complex number.
CONJ(x+y*i)

Example:

Functions and commands 107


CONJ(3+4*i) returns (3-4*i)

Real Part Real part x, of a complex number, (x+y*i).


RE(x+y*i)

Example:
RE(3+4*i) returns 3

Imaginary Part Imaginary part, y, of a complex number, (x+y*i).


IM(x+y*i)

Example:
IM(3+4*i) returns 4

Unit Vector Sign of value. If positive, the result is 1. If negative, –1. If zero,
result is zero. For a complex number, this is the unit vector in
the direction of the number.
SIGN(value)
SIGN((x,y))

Examples:
SIGN(POLYEVAL([1,2,–25,–26,2],–2)) returns –1
SIGN((3,4)) returns (.6+.8i)

Exponential
ALOG Antilogarithm (exponential).
ALOG(value)
x
EXPM1 Exponential minus 1: e –1.

EXPM1(value)

LNP1 Natural log plus 1: ln(x+1).


LNP1(value)

Trigonometry
The trigonometry functions can also take complex numbers as
arguments. For SIN, COS, TAN, ASIN, ACOS, and ATAN,
see “Keyboard functions” on page 101.

CSC Cosecant: 1/sinx.


CSC(value)

ACSC Arc cosecant.


ACSC(value)

108 Functions and commands


SEC Secant: 1/cosx.
SEC(value)

ASEC Arc secant.


ASEC(value)

COT Cotangent: cosx/sinx.


COT(value)

ACOT Arc cotangent.


ACOT(value)

Hyperbolic
The hyperbolic trigonometry functions can also take complex
numbers as arguments.

SINH Hyperbolic sine.


SINH(value)

ASINH Inverse hyperbolic sine: sinh–1x.


ASINH(value)

COSH Hyperbolic cosine


COSH(value)

ACOSH Inverse hyperbolic cosine: cosh–1x.


ACOSH(value)

TANH Hyperbolic tangent.


TANH(value)

ATANH Inverse hyperbolic tangent: tanh–1x.


ATANH(value)

Probability
Factorial Factorial of a positive integer. For non-integers, x! = Γ(x + 1).
This calculates the gamma function.
value!

Example:
5! returns 120

Functions and commands 109


Combination The number of combinations (without regard to order) of n
things taken r at a time.
COMB(n,r)

Example: Suppose you want to know how many ways five


things can be combined two at a time.
COMB(5,2)returns 10.

Permutation Number of permutations (with regard to order) of n things


taken r at a time: n!/(n–r)!.
PERM (n,r)

Example: Suppose you want to know how many permutations


there are for five things taken two at a time.
PERM(5,2)returns 20.

Random
Number Random number. With no argument, this function returns a
random number between zero and one. With one argument
a, it returns a random number between 0 and a. With two
arguments, a, and b, returns a random number between a
and b. With three arguments, n, a, and b, returns n random
number between a and b.
RANDOM
RANDOM(a)
RANDOM(a,b
RANDOM(n,a,b)

Integer Random integer. With no argument, this function returns either


0 or 1 randomly. With one integer argument a, it returns a
random integer between 0 and a. With two arguments, a,
and b, returns a random integer between a and b. With three
integer arguments, n, a, and b, returns n random integers
between a and b.
RANDINT
RANDINT(a)
RANDINT(a,b)
RANDINT(n,a,b)

Normal Random normal. Generates a random number from a normal


distribution.
RANDNORM(μ,σ)

110 Functions and commands


Example:
RANDNORM(0,1) returns a random number from the
standard Normal distribution.

Seed Sets the seed value on which the random functions operate.
By specifying the same seed value on two or more calculators,
you ensure that the same random numbers appear on each
calculator when the random functions are executed.
RANDSEED(value)

Density
Normal Normal probability density function. Computes the
probability density at value x, given the mean, μ, and
standard deviation, σ, of a normal distribution. If only one
argument is supplied, it is taken as x, and the assumption is
that μ=0 and σ=1.
NORMALD([μ,σ,]x)

Example:
NORMALD(0.5) and NORMALD(0,1,0.5) both return
0.352065326764.

T Student’s t probability density function. Computes the


probability density of the Student's t-distribution at x, given n
degrees of freedom.
STUDENT(n,x)

Example:
STUDENT(3,5.2) returns 0.00366574413491.
2 2
χ χ probability density function. Computes the probability
density of the χ2 distribution at x, given n degrees of freedom.
CHISQUARE(n,x)

Example:
CHISQUARE(2,3.2) returns 0.100948258997.

F Fisher (or Fisher–Snedecor) probability density function.


Computes the probability density at the value x, given
numerator n and denominator d degrees of freedom.
FISHER(n,d,x)

Example:
FISHER(5,5,2) returns 0.158080231095.

Functions and commands 111


Binomial Binomial probability density function. Computes the
probability of k successes out of n trials, each with a
probability of success of p. Returns Comb(n,k) if there is no
third argument. Note that n and k are integers with k ≤ n .
BINOMIAL(n,k,p)

Example: Suppose you want to know the probability that just


6 heads would appear during 20 tosses of a fair coin.
BINOMIAL(20,6,0.5) returns 0.0369644165039.

Poisson Poisson probability mass function. Computes the probability


of k occurrences of an event during a future interval given μ ,
the mean of the occurrences of that event during that interval
in the past. For this function, k is a non-negative integer and
μ is a real number.

POISSON(μ,k)

Example: Suppose that on average you get 20 emails a day.


What is the probability that tomorrow you will get 15?
POISSON(20,15) returns 0.0516488535318.

Cumulative
Normal Cumulative normal distribution function. Returns the lower-tail
probability of the normal probability density function for the
value x, given the mean, μ, and standard deviation, σ, of a
normal distribution. If only one argument is supplied, it is
taken as x, and the assumption is that μ=0 and σ=1.
NORMALD_CDF([μ,σ,]x)

Example:
NORMALD_CDF(0,1,2) returns 0.977249868052.

T Cumulative Student's t distribution function. Returns the lower-


tail probability of the Student's t-probability density function
at x, given n degrees of freedom.
STUDENT_CDF(n,x)

Example:
STUDENT_CDF(3,–3.2) returns 0.0246659214814.

112 Functions and commands


2
χ Cumulative χ2 distribution function. Returns the lower-tail
probability of the χ2 probability density function for the value
x, given n degrees of freedom.
CHISQUARE_CDF(n,k)

Example:
CHISQUARE_CDF(2, 6.3) returns 0.957147873133.

F Cumulative Fisher distribution function. Returns the lower-tail


probability of the Fisher probability density function for the
value x, given numerator n and denominator d degrees of
freedom.
FISHER_CDF(n,d,x)

Example:
FISHER_CDF(5,5,2) returns 0.76748868087.

Binomial Cumulative binomial distribution function. Returns the


probability of k or fewer successes out of n trials, with a
probability of success, p for each trial. Note that n and k are
integers with k ≤ n .
BINOMIAL_CDF(n,p,k)

Example: Suppose you want to know the probability that


during 20 tosses of a fair coin you will get either 0, 1, 2, 3,
4, 5, or 6 heads.
BINOMIAL_CDF(20,0.5,6) returns 0.05765914917.

Poisson Cumulative Poisson distribution function. Returns the


probability x or fewer occurrences of an event in a given time
interval, given μ expected occurrences.
POISSON_CDF( μ ,x)

Example:
POISSON_CDF(4,2) returns 0.238103305554.
Inverse
Normal Inverse cumulative normal distribution function. Returns the
cumulative normal distribution value associated with the lower-tail
probability, p, given the mean, μ, and standard deviation, σ, of a
normal distribution. If only one argument is supplied, it is taken as
p, and the assumption is that μ=0 and σ=1.
NORMALD_ICDF([μ,σ,]p)

Example:
NORMALD_ICDF(0,1,0.841344746069) returns 1.

Functions and commands 113


T Inverse cumulative Student's t distribution function. Returns the
value x such that the Student's-t lower-tail probability of x, with
n degrees of freedom, is p.
STUDENT_ICDF(n,p)

Example:
STUDENT_ICDF(3,0.0246659214814) returns –3.2.
2
χ Inverse cumulative χ 2 distribution function. Returns the value x
such that the χ 2 lower-tail probability of x, with n degrees of
freedom, is p.
CHISQUARE_ICDF(n,p)

Example:
CHISQUARE_ICDF(2, 0.957147873133) returns 6.3.

F Inverse cumulative Fisher distribution function. Returns the


value x such that the Fisher lower-tail probability of x, with
numerator n and denominator d degrees of freedom, is p.
FISHER_ICDF(n,d,p)

Example:
FISHER_ICDF(5,5,0.76748868087) returns 2.

Binomial Inverse cumulative binomial distribution function. Returns the


number of successes, k, out of n trials, each with a probability
of p, such that the probability of k or fewer successes is q.
BINOMIAL_ICDF(n,p,q)

Example:
BINOMIAL_ICDF(20,0.5,0.6) returns 11.

Poisson Inverse cumulative Poisson distribution function. Returns the


value x such that the probability of x or fewer occurrences of
an event, with μ expected (or mean) occurrences of the event
in the interval, is p.
POISSON_ICDF( μ ,p)

Example:
POISSON_ICDF(4,0.238103305554) returns 3.

List
These functions work on data in a list.

114 Functions and commands


Matrix
These functions work on matrix data stored in matrix
variables.

Special
Beta Returns the value of the beta function (Β) for two numbers a
and b.
Beta(a,b)

Gamma Returns the value of the gamma function (Γ) for a number a.
Gamma(a)

Psi Returns the value of the nth derivative of the digamma function
at x=a, where the digamma function is the first derivative of
ln(Γ(x)).
Psi(a,n)

Zeta Returns the value of the zeta function (Z) for a real x.
Zeta(x)

erf Returns the floating point value of the error function at x=a.
erf(a)

erfc Returns the value of the complementary error function at x=a.


erfc(a)

Ei Returns the exponential integral of an expression.


Ei(Expr)

Si Returns the sine integral of an expression.


Si(Expr)

Ci Returns the cosine integral of an expression.


Ci(Expr)

Functions and commands 115


CAS menu
Press D to open the Toolbox
menus (one of which is the
CAS menu). The functions on
the CAS menu are those most
commonly used. Many more
functions are available. See
“Ctlg menu”, beginning on
page 172.
Note that the Geometry functions appear on the App menu.
The result of a CAS command may vary depending on the
CAS settings. The examples in this chapter assume the default
CAS settings unless otherwise noted.

Algebra
Simplify Returns an expression simplified.
simplify(Expr)

Example:
simplify(4*atan(1/5)-atan(1/239))yields (1/4)*pi

Collect Collects like terms in a polynomial expression (or in a list of


polynomial expressions). Factorizes the results, depending on
the CAS settings.
collect(Poly) or collect({Poly1,
Poly2,..., Polyn})

Examples:
collect(x+2*x+1-4) returns 3*x-3

collect(x^2-9*x+5*x+3+1) returns (x-2)^2

Expand Returns an expression expanded.


expand(Expr)

Example:
expand((x+y)*(z+1))gives y*z+x*z+y+x

Factor Returns a polynomial factorized.


factor(Poly)

Example:

116 Functions and commands


factor(x^4-1) gives (x-1)*(x+1)*(x^2+1)

Substitute Substitutes a value for a variable in an expression.


Syntax: subst(Expr,Var=value)

Example:
subst(x/(4-x^2),x=3) returns -3/5

Partial Fraction Performs partial fraction decomposition on a fraction.


partfrac(RatFrac or Opt)

Example:
partfrac(x/(4-x^2)) returns (-1/2)/(x-2)-(1/2)/
((x+2)

Extract
Numerator Simplified Numerator. For the integers a and b, returns the
numerator of the fraction a/b after simplification.
numer(a/b)

Example:
numer(10/12) returns 5

Denominator Simplified Denominator. For the integers a and b, returns the


denominator of the fraction a/b after simplification.
denom(a/b)

Example:
denom(10/12) returns 6

Left Side Returns the left side of an equation or the left end of an
interval.
left(Expr1=Expr2) or left(Real1..Real2)

Example:
left(x^2-1=2*x+3) returns x^2-1

Right Side Returns the right side of an equation or the right end of an
interval.
right(Expr1=Expr2) or right(Real1..Real2)

Example:
right(x^2-1=2*x+3) returns 2*x+3

Functions and commands 117


Calculus
Differentiate With one expression as argument, returns derivative of the
expression with respect to x. With one expression and one
variable as arguments, returns the derivative or partial
derivative of the expression with respect to the variable. With
one expression and more than one variable as arguments,
returns the derivative of the expression with respect to the
variables in the second argument. These arguments can be
followed by $k (k is an integer) to indicate the number of times
the expression should be derived with respect to the variable.
For example, diff(exp(x*y),x$3,y$2,z) is the same as
diff(exp(x*y),x,x,x,y,y,z).
diff(Expr,[var])

or
diff(Expr,var1$k1,var2$k2,...)

Example:
diff(x^3-x) gives 3*x^2-1

Integrate Returns the indefinite integral of an expression. With one


expression as argument, returns the indefinite integral with
respect to x. With the optional second, third and fourth
arguments you can specify the variable of integration and the
bounds of the integrate.
int(Expr,[Var(x)],[Real(a)],[Real(b)])

Example:
int(1/x) gives ln(abs(x))

Limit Returns the limit of an expression when the variable


approaches a limit point a or +/– infinity. With the optional
fourth argument you can specify whether it is the limit from
below, above or bidirectional (–1 for limit from below, +1 for
limit from above, and 0 for bidirectional limit). If the fourth
argument is not provided, the limit returned is bidirectional.
limit(Expr,Var,Val,[Dir(1, 0, -1)])

Example:
limit((n*tan(x)-tan(n*x))/(sin(n*x)-
n*sin(x)),x,0) gives 2

118 Functions and commands


Series Returns the series expansion of an expression in the vicinity of
a given equality variable. With the optional third and fourth
arguments you can specify the order and direction of the
series expansion. If no order is specified the series returned is
fifth order. If no direction is specified, the series is
bidirectional.
series(Expr,Equal(var=limit_point),[Orde
r],[Dir(1,0,-1)])

Example:
series((x^4+x+2)/(x^2+1),x=0,5) gives 2+x-2x^2-
x^3+3x^4+x^5+x^6*order_size(x)

Summation Returns the discrete sum of Expr with respect to the variable
Var from Real1 to Real2. You can also use the summation
template in the Template menu. With only the first two
arguments, returns the discrete antiderivative of the expression
with respect to the variable.
sum(Expr,Var,Real1, Real2,[Step])

Example:
sum(n^2,n,1,5) returns 55

Differential
Curl Returns the rotational curl of a vector field. Curl([A B C], [x y
z]) is defined to be [dC/dy-dB/dz dA/dz-dC/dx dB/dx-dA/
dy].
curl([Expr1, Expr2, …, ExprN], [Var1,
Var2, …, VarN])

Example:
curl([2*x*y,x*z,y*z],[x,y,z]) returns [z-x,0,z-
2*x]

Divergence Returns the divergence of a vector field, defined by:


divergence([A,B,C],[x,y,z])=dA/dx+dB/dy+dC/dz.
divergence([Expr1, Expr2, …, ExprN],
[Var1, Var2, …, VarN])

Example:
divergence([x^2+y,x+z+y,z^3+x^2],[x,y,z])
gives 2*x+3*z^2+1

Functions and commands 119


Gradient Returns the gradient of an expression. With a list of variables
as second argument, returns the vector of partial derivatives.
grad(Expr,LstVar)

Example:
grad(2*x^2*y-x*z^3,[x,y,z]) gives [2*2*x*y-
z^3,2*x^2,-x*3*z^2]

Hessian Returns the Hessian matrix of an expression.


hessian(Expr,LstVar)

Example:
hessian(2*x^2*y-x*z,[x,y,z]) gives [[4*y,4*x,-
1],[2*2*x,0,0],[-1,0,0]]

Integral

By Parts u Performs integration by parts of the expression f(x)=u(x)*v'(x),


with f(x) as the first argument and u(x) (or 0) as the second
argument. Specifically, returns a vector whose first element is
u(x)*v(x) and whose second element is v(x)*u'(x). With the
optional third, fourth and fifth arguments you can specify a
variable of integration and bounds of the integration. If no
variable of integration is provided, it is taken as x.
ibpu(f(Var), u(Var), [Var], [Real1],
[Real2])

Example:
ibpu(x*ln(x), x) returns [x*(x*ln(x) –x*ln(x)+x]

By Parts v Performs integration by parts of the expression f(x)=u(x)*v'(x),


with f(x) as the first argument and v(x) (or 0) as the second
argument. Specifically, returns a vector whose first element is
u(x)*v(x) and whose second element is v(x)*u'(x). With the
optional third, fourth and fifth arguments you can specify a
variable of integration and bounds of the integration. If no
variable of integration is provided, it is taken as x.
ibpdv(f(Var), v(Var), [Var], [Real1],
[Real2])

Example:
ibpdv(ln(x),x) gives x*ln(x)-x

120 Functions and commands


F(b)–F(a) Returns F(b)–F(a).
preval(Expr(F(var)),Real(a),Real(b),[Var])

Example:
preval(x^2-2,2,3) gives 5

Limits
Riemann Sum Returns an equivalent of the sum of Expr for var2 from var2=1
to var2=var1 (in the neighborhood of n=+∞) when the sum is
looked at as a Riemann sum associated with a continuous
function defined on [0,1].
sum_riemann(Expr, [Var1 Var2])

Example:
sum_riemann(1/(n+k),[n,k]) gives ln(2)

Taylor Returns the Taylor series expansion of an expression at a point


or at infinity (by default, at x=0 and with relative order=5).
taylor(Expr,[Var=Value],[Order])

Example:
taylor(sin(x)/x,x=0) returns 1-(1/6)*x^2+(1/
120)*x^4+x^6*order_size(x)

Taylor of Quotient Returns the n-degree Taylor polynomial for the quotient of 2
polynomials.
divpc(Poly1,Poly2,Integer)

Example:
divpc(x^4+x+2,x^2+1,5) returns the 5th-degree
polynomial x^5+3*x^4-x^3-2*x^2+x+2

Transform
Laplace Returns the Laplace transform of an expression.
laplace(Expr,[Var],[LapVar])

Example:
laplace(exp(x)*sin(x)) gives 1/(x^2-2*x+2)

Functions and commands 121


Inverse Laplace Returns the inverse Laplace transform of an expression.
ilaplace(Expr,[Var],[IlapVar])

Example:
ilaplace(1/(x^2+1)^2) returns ((-x)*cos(x))/
2+sin(x)/2

FFT With one argument (a vector), returns the discrete Fourier


transform in R.
fft(Vect)

With two additional integer arguments a and p, returns the


discrete Fourier transform in the field Z/pZ, with a as primitive
nth root of 1 (n=size(vector)).
fft((Vector, a, p)

Example:
fft([1,2,3,4,0,0,0,0]) gives [10.0,-
0.414213562373-7.24264068712*(i),-
2.0+2.0*i,2.41421356237-1.24264068712*i,-
2.0,2.41421356237+1.24264068712*i,-2.0-2.0*i]

Inverse FFT Returns the inverse discrete Fourier transform.


ifft(Vector)

Example:
ifft([100.0,-52.2842712475+6*i,-
8.0*i,4.28427124746-
6*i,4.0,4.28427124746+6*i,8*i,-52.2842712475-
6*i]) gives
[0.99999999999,3.99999999999,10.0,20.0,25.0,2
4.0,16.0,-6.39843733552e-12]

Solve
Solve Returns a list of the solutions (real and complex) to a
polynomial equation or a set of polynomial equations.
solve(Eq,[Var]) or solve({Eq1, Eq2,…},
[Var])

Examples:
solve(x^2-3=1) returns {-2,2}

solve({x^2-3=1, x+2=0},x) returns {-2}

122 Functions and commands


Zeros With an expression as argument, returns the real zeros of the
expression; that is, the solutions when the expression is set
equal to zero.
With a list of expressions as argument, returns the matrix
where the rows are the real solutions of the system formed by
setting each expression equal to zero.
zeros(Expr,[Var]) or zeros({Expr1,
Expr2,…},[{Var1, Var2,…}])

Example:
zeros(x^2-4) returns [-2 2]

Complex Solve Returns a list of the complex solutions to a polynomial


equation or a set of polynomial equations.
cSolve(Eq,[Var])

or
cSolve({Eq1, Eq2,…}, [Var])

Example:
cSolve(x^4-1=0, x) returns {1 -1 -i i}

Complex Zeros With an expression as argument, returns a vector containing


the complex zeros of the expression; that is, the solutions
when the expression is set equal to zero.
With a list of expressions as argument, returns the matrix
where the rows are the complex solutions of the system formed
by setting each expression equal to zero.
cZeros(Expr,[Var]

or
cZeros({Expr1, Expr2,…},[{Var1, Var2,…}])

Example:
cZeros(x^4-1) returns [1 -1 -i i]

Numerical Solve Returns the numerical solution of an equation or a system of


equations.
nSolve(Eq,Var) or nSolve(Expr, Var=Guess)

Example:
nSolve(cos(x)=x,x=1.3) gives 0.739085133215

Functions and commands 123


Differential Returns the solution to a differential equation.
Equation
deSolve(Eq,[TimeVar],Var)

Example:
desolve(y''+y=0,y) returns G_0*cos(x)+G_1*sin(x)

ODE Solve Ordinary Differential Equation solver. Solves an ordinary


differential equation given by Expr, with variables declared in
VectrVar and initial conditions for those variables declared in
VectrInit. For example, odesolve(f(t,y),[t,y],[t0,y0],t1) returns
the approximate solution of y'=f(t,y) for the variables t and y
with initial conditions t=t0 and y=y0.
odesolve(Expr,VectVar,VectInitCond,Final
Val,[tstep=Val,curve])

Example:
odesolve(sin(t*y),[t,y],[0,1],2) returns
[1.82241255674]

Linear System Given a vector of linear equations and a corresponding


vector of variables, returns the solution to the system of linear
equations.
linsolve([LinEq1, LinEq2,…], [Var1,
Var2,…])
Example:
linsolve([x+y+z=1,x-y=2,2*x-z=3],[x,y,z])
returns [3/2,-1/2,0]

Rewrite
lncollect Rewrites an expression with the logarithms collected. Applies
ln(a)+n*ln(b) = ln(a*b^n) for an integer n.
lncollect(Expr)

Example:
lncollect(ln(x)+2*ln(y)) returns ln(x*y^2)

powexpand Rewrites an expression containing a power that is a sum or


product as a product of powers. Applies
a^(b+c)=(a^b)*(a^c).
powexpand(Expr)

Example:
powexpand(2^(x+y)) yields (2^x)*(2^y)

124 Functions and commands


texpand Expands a transcendental expression.
texpand(Expr)

Example:
texpand(sin(2*x)+exp(x+y)) returns exp(x)*exp(y)+
2*cos(x)*sin(x))

Exp & Ln
ey*lnx → xy Returns an expression of the form en*ln(x) rewritten as a power
of x. Applies en*ln(x)=xn.
exp2pow(Expr)

Example:
exp2pow(exp(3*ln(x))) gives x^3

xy → ey*lnx Returns an expression with powers rewritten as an


exponential. Essentially the inverse of exp2pow.
pow2exp(Expr)

Example:
pow2exp(a^b) gives exp(b*ln(a))

exp2trig Returns an expression with complex exponentials rewritten in


terms of sine and cosine.
exp2trig(Expr)

Example:
exp2trig(exp(i*x)) gives cos(x)+(i)*sin(x)

expexpand Returns an expression with exponentials in expanded form.


expexpand(Expr)

Example:
expexpand(exp(3*x)) gives exp(x)^3

Sine
asinx → acosx Returns an expression with asin(x) rewritten as π/2– acos(x).
asin2acos(Expr)

Example:
asin2acos(acos(x)+asin(x)) returns π/2

Functions and commands 125


asinx → atanx Returns an expression with asin(x) rewritten as:
 x 
atan  -------------------2-
 1–x 

asin2atan(Expr)

Example:
asin2atan(2*asin(x)) returns

 x 
2 ⋅ atan  -------------------2-
 1–x 

sinx → cosx*tanx Returns an expression with sin(x) rewritten as cos(x)*tan(x).


sin2costan(Expr)

Example:
sin2costan(sin(x)) gives tan(x)*cos(x)

Cosine
acosx → asinx Returns an expression with acos(x) rewritten as π/2–asin(x).
acos2asin(Expr)

Example:
acos2asin(acos(x)+asin(x)) returns π/2

acosx → atanx Returns an expression with acos(x) rewritten as:

π  x 
--- – atan  -------------------2-
2  1–x 

acos2atan(Expr)

Example:
acos2atan(2*acos(x)) gives

  x 
2 ⋅  --π- – atan  -------------------2- 
2  1 – x 

cosx → sinx/tanx Returns an expression with cos(x) rewritten as sin(x)/tan(x).


cos2sintan(Expr)

Example:
cos2sintan(cos(x)) gives sin(x)/tan(x)

126 Functions and commands


Tangent
atanx → asinx Returns an expression with atan(x) rewritten as:
 x 
asin  -------------------2-
 1–x 

atan2asin(Expr)

Example:
atan2asin(atan(2*x)) returns

 2⋅x 
asin  --------------------------------2-
 1 – (2 ⋅ x) 

atanx → acosx Returns an expression with atan(x) rewritten as:

π  x 
--- – acos  -------------------2-
2  1+x 

atan2acos(Expr)

tanx → sinx/cosx Returns an expression with tan(x) rewritten as sin(x)/cos(x).


tan2sincos(Expr)

Example:
tan2sincos(tan(x)) gives sin(x)/cos(x)

halftan Returns an expression with sin(x), cos(x) or tan(x) rewritten as


tan(x/2).
halftan(Expr)

Example:
x
2 ⋅ tan  ---
 2
halftan(sin(x)) returns -------------------------------
2
-
x
tan  --- + 1
 2

Trig
trigx → sinx Returns an expression simplified using the formulas
sin(x)^2+cos(x)^2=1 and tan(x)=sin(x)/cos(x). Sin(x) is given
precedence over cos(x) and tan(x) in the result.
trigsin(Expr)

Example:
trigsin(cos(x)^4+sin(x)^2) returns sin(x)^4-
sin(x)^2+1

Functions and commands 127


trigx → cosx Returns an expression simplified using the formulas
sin(x)^2+cos(x)^2=1 and tan(x)=sin(x)/cos(x). Cos(x) is
given precedence over sin(x) and tan(x) in the result.
trigcos(Expr)

Example:
trigcos(sin(x)^4+sin(x)^2) returns cos(x)^4-
3*cos(x)^2+2

trigx → tanx Returns an expression simplified using the formulas


sin(x)^2+cos(x)^2=1 and tan(x)=sin(x)/cos(x). Tan(x) is
given precedence over sin(x) and cos(x) in the result.
trigtan(Expr)

Example:
trigtan(cos(x)^4+sin(x)^2) returns
(tan(x)^4+tan(x)^2+1)/(tan(x)^4+2*tan(x)^2+1)

atrig2ln Returns an expression with inverse trigonometric functions


rewritten using the natural logarithm function.
atrig2ln(Expr)

Example:
i (i + x)
atrig2ln(atan(x)) returns --- ⋅ ln ---------------
2 (i – x)

tlin Returns a trigonometric expression with the products and


integer powers linearized.
tlin(ExprTrig)

Example:

tlin(sin(x)^3) gives 3
--- ⋅ sin ( x ) – 1
--- ⋅ sin ( 3 ⋅ x )
4 4

tcollect Returns a trigonometric expression linearized and with any


sine and cosine terms of the same angle collected together.
tcollect(Expr)

Example:
tcollect(sin(x)+cos(x)) returns

1
2 ⋅ cos  x – --- ⋅ π
 4 

128 Functions and commands


trigexpand Returns a trigonometric expression in expanded form.
trigexpand(Expr)

Example:
trigexpand(sin(3*x)) gives (4*cos(x)^2-
1)*sin(x)

trig2exp Returns an expression with trigonometric functions rewritten as


complex exponentials (without linearization).
trig2exp(Expr)

Example:
trig2exp(sin(x)) returns

–i  1 -
---- ⋅ exp ( i ⋅ x ) – -----------------------
2  exp ( i ⋅ x )

Integer
Divisors Returns the list of divisors of an integer or a list of integers.
idivis(Integer)

or

idivis({Intgr1, Intgr2,…})

Example:
idivis(12) returns [1, 2, 3, 4, 6, 12]

Factors Returns the prime factor decomposition of an integer.


ifactor(Integer)

Example:
With the CAS setting Simplify set to None, ifactor(150)
returns 2*3*5^2

Factor List Returns a vector containing the prime factors of an integer or


a list of integers, with each factor followed by its multiplicity.
ifactors(Integer)
or

ifactors({Intgr1, Intgr2,…})

Example:
ifactors(150) returns [2, 1, 3, 1, 5, 2]

Functions and commands 129


GCD Returns the greatest common divisor of two or more integers.
gcd(Intgr1, Intgr2,…)

Example:
gcd(32,120,636) returns 4

LCM Returns the least common multiple of two or more integers.


lcm(Intgr1, Intgr2,…)

Example:
lcm(6,4) returns 12

Prime
Test if Prime Tests whether or not a given integer is a prime number.
isPrime(Integer)

Example:
isPrime(19999) returns false

Nth Prime Returns the nth prime number.


ithprime(Intg(n)) where n is between 1 and 200,000

Example:
ithprime(5) returns 11

Next Prime Returns the next prime or pseudo-prime after an integer.


nextprime(Integer)

Example:
nextprime(11) returns 13

Previous Prime Returns the prime or pseudo-prime number closest to but


smaller than an integer.
prevprime(Integer)

Example:
prevprime(11) returns 7

Euler Compute’s Euler's totient for an integer.


euler(Integer)

Example:
euler(6) returns 2

130 Functions and commands


Division
Quotient Returns the integer quotient of the Euclidean division of two
integers.
iquo(Intgr1, Intgr2)

Example:
iquo(63, 23) returns 2

Remainder Returns the integer remainder from the Euclidean division of


two integers.
irem(Intgr1, Intgr2)

Example:
irem(63, 23) returns 17

an MOD p For the three integers a, n, and p, returns an modulo p in


[0, p−1].
powmod(a, n, p,[Expr],[Var])

Example:
powmod(5,2,13) returns 12

Chinese Integer Chinese Remainder Theorem for two equations. Takes


Remainder two vectors of integers, [a p] and [b q], and returns a vector
of two integers, [r n] such that x ≡ r mod n. In this case, x is
such that x ≡ a mod p and x ≡ b mod q; also n=p*q.
ichinrem([a,p],[b,q])

Example:
ichinrem([2, 7], [3, 5]) returns [-12, 35]

Polynomial
Find Roots Given a polynomial in x (or a vector containing the
coefficients of a polynomial), returns a vector containing its
roots.
proot(Poly) or proot(Vector)

Example:
proot([1,0,-2]) returns
[-1.41421356237,1.41421356237]

Functions and commands 131


Coefficients Given a polynomial in x, returns a vector containing the
coefficients. If the polynomial is in a variable other than x,
then declare the variable as the second argument. With an
integer as the optional third argument, returns the coefficient
of the polynomial whose degree matches the integer.
coeff(Poly, [Var], [Integer])
Examples:
coeff(x^2-2) returns [1 0 -2]

coeff(y^2-2, y, 1) returns 0

Divisors Given a polynomial, returns a vector containing the divisors of


the polynomial.
divis(Poly) or divis({Poly1, Poly2,…})

Example:
divis(x^2-1) returns [1 -1+x 1+x (-1+x)*(1+x)]

Factor List Returns a vector containing the prime factors of a polynomial


or a list of polynomials, with each factor followed by its
multiplicity.
factors(Poly) or factors({Poly1,
Poly2,…})

Example:
factors(x^4-1) returns [x-1 1 x+1 1 x2+1 1]

GCD Returns the greatest common divisor of two or more


polynomials.
gcd(Poly1,Poly2...)

Example:
gcd(x^4-1, x^2-1) returns x^2-1

LCM Returns the least common multiple of two or more


polynomials.
lcm(Poly1, Poly2,…)

Example:
lcm(x^2-2*x+1,x^3-1) gives (x-1)*(x^3-1)

132 Functions and commands


Create
Poly to Coef Given a polynomial, returns a vector containing the
coefficients of the polynomial. With a variable as second
argument, returns the coefficients of a polynomial with respect
to the variable. With a list of variables as the second
argument, returns the internal format of the polynomial.
symb2poly(Expr,[Var])

or
symb2poly(Expr, {Var1, Var2,…})

Example:
symb2poly(x*3+2.1) returns [3 2.1]

Coef to Poly With one vector as argument, returns a polynomial in x with


coefficients (in decreasing order) obtained from the argument
vector. With a variable as second argument, returns a similar
polynomial in that variable.
poly2symb(Vector, [Var]))
Example:
poly2symb([1,2,3],x) returns (x+2)*x+3

Roots to Coef Returns a vector containing the coefficients (in decreasing


order) of the univariate polynomial whose roots are specified
in the argument vector.
pcoef(List)

Example:
pcoeff({1,0,0,0,1}) returns [1 -2 1 0 0 0]

Roots to Poly Takes as argument a vector. The vector contains each root or
pole of a rational function. Each root or pole is followed by its
order, with poles having negative order. Returns the rational
function in x that has the roots and poles (with their orders)
specified in the argument vector.
fcoeff(Vector) where Vector has the form [Root1,
Oder1, Root2, Order2, …])

Example:
fcoeff([1,2,0,1,3,-1]) returns (x-1)^2*x*(x-3)^-
1

Functions and commands 133


Random Returns a vector of the coefficients of a polynomial of degree
Integer and where the coefficients are random integers in
the range –99 through 99 with uniform distribution or in an
interval specified by Interval. Use with poly2symbol to
create a random polynomial in any variable.
randpoly(Integer, Interval, [Dist]), where
Interval is of the form Real1..Real2.

Example:
randpoly(t, 8, -1..1) returns a vector of 9 random
integers, all of them between –1 and 1.

Minimum With only a matrix as argument, returns the minimal


polynomial in x of a matrix written as a list of its coefficients.
With a matrix and a variable as arguments, returns the
minimum polynomial of the matrix written in symbolic form
with respect to the variable.
pmin(Mtrx,[Var])

Example:
pmin([[1,0],[0,1]],x) gives x-1

Algebra
Quotient Returns a vector containing the coefficients of the Euclidean
quotient of two polynomials. The polynomials may be written
as a list of coefficients or in symbolic form.
quo(List1, List2, [Var])

or
quo(Poly1, Poly2, [Var])

Example:
quo({1, 2, 3, 4}, {-1, 2}) returns [-1 -4 -11]

Remainder Returns a vector containing the coefficients of the remainder


of the Euclidean quotient of two polynomials. The polynomials
may be written as a list of coefficients or in symbolic form.
rem(List1, List2, [Var])

or
rem(Poly1, Poly2, [Var])

Example:
rem({1, 2, 3, 4}, {-1, 2}) returns [26]

134 Functions and commands


Degree Returns the degree of a polynomial.
degree(Poly)

Example:
degree(x^3+x) gives 3

Factor by Degree For a given polynomial in x of degree n, factors out xn and


returns the resulting product.
factor_xn(Poly)

Example:
factor_xn(x^4-1) gives x^4*(1-x^-4)

Coef. GCD Returns the greatest common divisor (GCD) of the coefficients
of a polynomial.
content(Poly,[Var])

Example:
content(2*x^2+10*x+6) gives 2

Zero Count If a and b are real, this returns the number of sign changes in
the specified polynomial in the interval [a,b]. If a or b are non-
real, it returns the number of complex roots in the rectangle
bounded by a and b. If Var is omitted, it is assumed to be x.
sturmab(Poly[,Var],a,b)

Examples:
sturmab(x^2*(x^3+2),-2,0) returns 1

sturmab(n^3-1,n,-2-i,5+3i) returns 3

Chinese Given two matrices whose two rows each contain the
Remainder coefficients of polynomials, returns the Chinese remainder of
the polynomials, also written as a matrix.
chinrem(Matrix1,Matrix2)

Example:

 
1 2 0, 1 1 0
chinrem  
returns
1 0 1 1 1 1
 
[[2 2 1] [1 1 2 1 1]]

Functions and commands 135


Special
Cyclotomic Returns the list of coefficients of the cyclotomic polynomial of
an integer.
cyclotomic(Integer)

Example:
cyclotomic(20) gives [1 0 –1 0 1 0 –1 0 1]

Groebner Basis Given a vector of polynomials and a vector of variables,


returns the Groebner basis of the ideal spanned by the set of
polynomials.
gbasis([Poly1 Poly2…], [Var1 Var2…])

Example:
gbasis([x^2-y^3,x+y^2],[x,y]) returns [y^4-
y^3,x+y^2]

Groebner Given a polynomial and both a vector of polynomials and a


Remainder vector of variables, returns the remainder of the division of the
polynomial by the Groebner basis of the vector of
polynomials.
greduce(Poly1, [Poly2 Poly3 …], [Var1
Var2…])

Example:
greduce(x*y-1,[x^2-y^2,2*x*y-y^2,y^3],[x,y])
returns 1/2*y^2-1

Hermite Returns the Hermite polynomial of degree n, where n is an


integer less than 1556.
hermite(Integer)

Example:
hermite(3) gives 8*x^3-12*x

136 Functions and commands


Lagrange Given a vector of abscissas and a vector of ordinates, returns
the Lagrange polynomial for the points specified in the two
vectors. This function can also take a matrix as argument, with
the first row containing the abscissas and the second row
containing the ordinates.
lagrange([X1 X2…], [Y1 Y2…]))

or

 X1 X2 ... 
lagrange  
 Y1 Y2 ... 

Example:
lagrange([1,3],[0,1]) gives (x-1)/2

Laguerre Given an integer n, returns the Laguerre polynomial of degree n.


laguerre(Integer))

Example:
laguerre(4) returns 1/24*a^4+(-1/6)*a^3*x+5/
12*a^3+1/4*a^2*x^2+(-3/2)*a^2*x+35/24*a^2+(-
1/6)*a*x^3+7/4*a*x^2+(-13/3)*a*x+25/12*a+1/
24*x^4+(-2/3)*x^3+3*x^2-4*x+1

Legendre Given an integer n, returns the Legendre polynomial of degree


n.
legendre(Integer)

Example:

legendre(4) returns 35
4 15
------- ⋅ x + ------- ⋅ x + --3-
2
8 4 8

Chebyshev Tn Given an integer n, returns the Tchebyshev polynomial (of the


first kind) of degree n.
tchebyshev1(Integer)

Example:
tchebyshev1(3) gives 4*x^3-3*x

Chebyshev Un Given an integer n, returns the Tchebyshev polynomial (of the


second kind) of degree n.
tchebyshev2(Integer)

Example:
tchebyshev2(3) gives 8*x^3-4*x

Functions and commands 137


Plot
Function Used to define a function graph in the Symbolic view of the
Geometry app. Plots the graph of an expression written in
terms of the independent variable x. Note that the variable is
lowercase.
plotfunc(Expr)

Example:
plotfunc(3*sin(x)) draws the graph of y=3*sin(x)

Contour Used to define a contour graph in the Symbolic view of the


Geometry app. Given an expression in x and y, as well as a
list of variables and a list of values, plots the contour graph of
the surface z=f(x,y). Specifically, plots the contour lines z1,
z2, etc. defined by the list of values.
Example:
plotcontour(x^2+2*y^2-2, {x, y}, {2, 4,
6}) draws the three contour lines of z=x^2+2*y^2–2 for z=2,
z=4, and z=6.

App menu
Press D to open the
Toolbox menus (one of which
is the App menu). App
functions are used in HP
apps to perform common
calculations. For example, in
the Function app, the Plot
view Fcn menu has a
function called SLOPE that calculates the slope of a given
function at a given point. The SLOPE function can also be
used from the Home view or a program to give the same
results. The app functions described in this section are
grouped by app.

138 Functions and commands


Function app functions
The Function app functions provide the same functionality found in
the Function app's Plot view under the FCN menu. All these
operations work on functions. The functions may be expressions in
X or the names of the Function app variables F0 through F9.

AREA Area under a curve or between curves. Finds the signed area
under a function or between two functions. Finds the area
under the function Fn or below Fn and above the function Fm,
from lower X-value to upper X-value.
AREA(Fn,[Fm,]lower,upper)
Example:
AREA(-X,X2-2,-2,1) returns 4.5

EXTREMUM Extremum of a function. Finds the extremum (if one exists) of


the function Fn that is closest to the X-value guess.
EXTREMUM(Fn, guess)
Example:
EXTREMUM(X2-X-2,0) returns 0.5

ISECT Intersection of two functions. Finds the intersection (if one


exists) of the two functions Fn and Fm that is closest to the X-
value guess.
ISECT(Fn,Fm,guess)
Example:
ISECT(X,3-X,2) returns 1.5

ROOT Root of a function. Finds the root of the function Fn (if one
exists) that is closest to the X-value guess.
ROOT(Fn,guess)
Example:
ROOT(3-X2,2) returns 1.732…

SLOPE Slope of a function. Returns the slope of the function Fn at the


X-value (if the function’s derivative exists at that value).
SLOPE(Fn,value)
Example:
SLOPE(3-X2,2) returns -4

Functions and commands 139


Solve app functions
The Solve app has a single function that solves a given
equation or expression for one of its variables. En may be an
equation or expression, or it may be the name of one of the
Solve Symbolic variables E0–E9.

SOLVE Solve. Solves an equation for one of its variables. Solves the
equation En for the variable var, using the value of guess as
the initial value for the value of the variable var. If En is an
expression, then the value of the variable var that makes the
expression equal to zero is returned.
SOLVE(En,var,guess)
Example:
SOLVE(X2-X-2,X,3)returns 2
This function also returns an integer that is indicative of the
type of solution found, as follows:
0—an exact solution was found
1—an approximate solution was found
2—an extremum was found that is as close to a solution
as possible
3—neither a solution, an approximation, nor an
extremum was found

Spreadsheet app functions


The spreadsheet app functions can be selected from the App
Toolbox menu: press D, tap and select
Spreadsheet. They can also be selected from the View
menu (V) when the Spreadsheet app is open.

140 Functions and commands


The syntax for many, but not all, the spreadsheet functions
follows this pattern:

functionName(input,[optional
parameters])
Input is the input list for the function. This can be a cell range
reference, a simple list or anything that results in a list of
values.

One useful optional parameter is Configuration. This is a


string that controls which values are output. Leaving the
parameter out produces the default output. The order of the
values can also be controlled by the order that they appear in
the string.

For example:
=STAT1(A25:A37)
produces the following
default output, based on the
numerical values in cells
A25 through A37.

However, if you just wanted


to see the number of data-
points, the mean, and the
standard deviation, you
would enter
=STAT1(A25:A37,”h n
x σ”). What the
configuration string is
indicating here is that row headings are required (h), but just
return the number of data-points (n), the mean (x), and the
standard deviation (σ). See page 143 for details on the
configuration string for this command.

SUM Calculates the sum of a range of numbers.


SUM([input])

For example, SUM(B7:B23) returns the sum of the numbers


in the range B7 to B23. You can also specify a block of cells,
as in SUM(B7:C23).
An error is returned if a cell in the specified range contains a
non-numeric object.

Functions and commands 141


AVERAGE Calculates the arithmetic mean of a range of numbers.
AVERAGE([input])

For example, AVERAGE(B7:B23) returns the arithmetic


mean of the numbers in the range B7 to B23. You can also
specify a block of cells, as in AVERAG(B7:C23).
An error is returned if a cell in the specified range contains a
non-numeric object.

AMORT Amortization. Calculates the principal, interest, and balance


of a loan over a specified period. Corresponds to pressing
in the Finance app.

AMORT(Range, NbPmt, IPYR, PV, PMTV[, PPYR=12,


CPYR=PPYR, GSize=PPYR, BEG=0, fix=current],
"configuration"])

Range: the cell range where the results are to be placed. If


only one cell is specified, then the range is automatically
calculated starting from that cell.

Configuration: a string that controls what results are


shown and the order in which they appear. An empty string
"" displays the default: all results, including headers. The
options in the configuration string are separated by spaces.

h – show row headers


H – show column headers
S – show the start of the period
E – show the end of the period
P – show the principal paid this period
B – show the balance at the end of the period
I – show the interest paid this period
All the other input parameters (except fix) are Finance app
Numeric view variables; see page 234 for details. Note that
only the first four are required. fix is the number of decimal
places to be used in the displayed results.

142 Functions and commands


STAT1 The STAT1 function provides a range of one-variable statistics.
It can calculate all or any of x , Σ, Σ², s, s², σ, σ², serr,
 ( xi – x ) , n, min, q1, med, q3, and max.
2

STAT1(Input range, [mode], [outlier


removal Factor], ["configuration"])

Input range is the data source (such as A1:D8).

Mode defines how to treat the input. The valid values are:

1 = Single data. Each column is treated as an


independent dataset.
2 = Frequency data. Columns are used in pairs and the
second column is treated as the frequency of appearance
of the first column.
3 = Weight data. Columns are used in pairs and the
second column is treated as the weight of the first
column.
4 = One–Two data. Columns are used in pairs and the 2
columns are multiplied to generate a data point.
If more than one column is specified, they are each treated as
a different input data set. If only one row is selected, it is
treated as 1 data set. If two columns are selected, the mode
defaults to frequency.

Outlier Removal Factor: This allows for the removal of any


datapoint that is more than n times the standard deviation
(where n is the outlier removal factor). By default this factor is
set to 2.

Configuration: indicates which values you want to place in


which row and if you want row or columns headers. Place the
symbol for each value in the order that you want to see the
values appear in the spreadsheet. The valid symbols are:

H (Place column headers) h (Place row headers)

x Σ Σ² s s² σ

 ( xi – x )
2
σ² serr n min q1

med q3 max

Functions and commands 143


For example if you specify "h n Σ x", the first column will
contain row headers, the first row will be the number of items
in the input data, the second the sum of the items and the third
the mean of the data. If you do not specify a configuration
string, a default string will be used.

Notes:
The STAT1 f function only updates the content of the
destination cells when the cell that contains the formula is
calculated. This means that if the spreadsheet view contains
at the same time results and inputs, but not the cell that
contains the call to the STAT1 function, updating the data will
not update the results as the cell that contains STAT1 is not
recalculated (since it is not visible).
The format of cells that receive headers is changed to have
Show " " set to false.
The STAT1 function will overwrite the content of destination
cells, potentially erasing data.
Examples:

STAT1(A25:A37)
STAT1(A25:A37,”h n x σ”).

REGRS Attempts to fit the input data to a specified function (default is


linear).

REGRS(Input range,[model],
["configuration"])

• Input range: specifies the data source; for example


A1:D8. It must contain an even number of columns. Each
pair will be treated as a distinct set of datapoints.
• model: specifies the model to be used for the regression:
1 y= sl*x+int
2 y= sl*ln(x)+int
3 y= int*exp(sl*x)
4 y= int*x^sl
5 y= int*sl^x
6 y= sl/x+int

144 Functions and commands


7 y= L/(1 + a*exp(b*x))
8 y= a*sin(b*x+c)+d
9 y= cx^2+bx+a
10 y= dx^3+cx^2+bx+a
11 y= ex^4+dx^3+cx^2+bx+a
• Configuration: a string which indicates which values you
want to place in which row and if you want row and
columns headers. Place each parameter in the order that
you want to see them appear in the spreadsheet. (If you
do not provide a configuration string, a default one will
be provided.) The valid parameters are:
– H (Place column headers)
– h (Place row headers)
– sl (slope, only valid for models 1–6)
– int (intercept, only valid for models 1–6)
– cor (correlation, only valid for models 1–6)
– cd (Coefficient of determination, only valid for models
1–6, 8–10)
– sCov (Sample covariance, only valid for models 1–6)
– pCov (Population covariance, only valid for models
1–6)
– L (L parameter for model 7)
– a (a parameter for models 7-–11)
– b (b parameter for models 7-–11)
– c (c parameter for models 8–11)
– d (d parameter for models 8, 10–11)
– e (e parameter for model 11)
– py (place 2 cells, one for user input and the other to
display the predicted y for the input)
– px (place 2 cells, one for user input and the other to
display the predicted x for the input)
Example: REGRS(A25:B37,2)

Functions and commands 145


PredY Returns the predicted Y for a given x.
PredY(mode, x, parameters)

• Mode governs the regression model used:


1 y= sl*x+int
2 y= sl*ln(x)+int
3 y= int*exp(sl*x)
4 y= int*x^sl
5 y= int*sl^x
6 y= sl/x+int
7 y= L/(1 + a*exp(b*x))
8 y= a*sin(b*x+c)+d
9 y= cx^2+bx+a
10 y= dx^3+cx^2+bx+a
11 y= ex^4+dx^3+cx^2+bx+a
• Parameters is either one argument (a list of the
coefficients of the regression line), or the n coefficients
one after another.

PredX Returns the predicted x for a given y.


PredX(mode, y, parameters)

• Mode governs the regression model used:


1 y= sl*x+int
2 y= sl*ln(x)+int
3 y= int*exp(sl*x)
4 y= int*x^sl
5 y= int*sl^x
6 y= sl/x+int
7 y= L/(1 + a*exp(b*x))
8 y= a*sin(b*x+c)+d
9 y= cx^2+bx+a
10 y= dx^3+cx^2+bx+a
11 y= ex^4+dx^3+cx^2+bx+a
• Parameters is either one argument (a list of the
coefficients of the regression line), or the n coefficients
one after another.

146 Functions and commands


HypZ1mean The one-sample Z-test for a mean.
HypZ1mean( x , n,μ0,σ,α,mode, [”configuration”])

The input parameters can be a range reference, a list of cell


references, or a simple list of values.
Mode: Specifies which alternative hypothesis to use:
• 1: μ < μ0
• 2: μ > μ0
• 3: μ ≠ μ0
Configuration: a string that controls what results are shown
and the order in which they appear. An empty string ""
displays the default: all results, including headers. The options
in the configuration string are separated by spaces.
• h: header cells will be created
• acc: the test result, 0 or 1 to reject or fail to reject the null
hypothesis
• tZ: the test Z-value
• tM: the input x value
• prob: the lower-tail probability
• cZ: the critical Z-value associated with the input α-level
• cx1: the lower critical value of the mean associated with
the critical Z-value
• cx2: the upper critical value of the mean associated with
the critical Z-value
• std: the standard deviation
Example:
HypZ1mean(0.461368, 50, 0.5, 0.2887, 0.05,
1, "") returns two columns into the Spreadsheet app. The
first column contains the headers and the second column
contains the values for each of the following: Reject/Fail=1,
Test Z = -0.94621, Test x = 0.461368, P= 0.172022,
Critical Z= -1.64485, Critical x = 0.432843.

HYPZ2mean The two-sample Z-test for the difference of two means.

HypZ2mean( x 1 , x 2 , n1, n2,σ1,σ2,α,mode,


[”configuration”])

Functions and commands 147


Mode: Specifies which alternative hypothesis to use:
• 1: μ1 < μ2
• 2: μ1 > μ2
• 3: μ1 ≠ μ2
• Configuration: a string that controls what results are
shown and the order in which they appear. An empty
string "" displays the default: all results, including
headers. The options in the configuration string are
separated by spaces.
• h: header cells will be created
• acc: the test result, 0 or 1 to reject or fail to reject the null
hypothesis
• tZ: Test Z
• tM: the input Δ x value
• prob: the lower-tail probability
• cZ: the critical Z-value associated with the input α-level
• cx1: the lower critical value of Δ x associated with the
critical Z-value
• cx2: the upper critical value of Δ x associated with the
critical Z-value
• std: the standard deviation
Example:
HypZ2mean(0.461368, 0.522851, 50, 50, 0.2887,
0.2887, 0.05, 1, "")

HypZ1prop The one-sample Z-test for a proportion.

HypZ1prop(x,n,π0,α,mode,
[”configuration”]) where x is the success count of the
sample

Mode: Specifies which alternative hypothesis to use:


• 1: π < π0
• 2: π > π0
• 3: π ≠ π0

148 Functions and commands


• Configuration: a string that controls what results are
shown and the order in which they appear. An empty
string "" displays the default: all results, including
headers. The options in the configuration string are
separated by spaces.
• h: header cells will be created
• acc:0 or 1 to reject or fail to reject the null hypothesis
• tZ: the test Z-value
• tP: the test proportion of successes
• prob: the lower-tail probability
• cZ: The critical Z-value associated with the input α-level
• cp1: the lower critical proportion of successes associated
with the critical Z-value
• cp2: the upper critical proportion of successes associated
with the critical Z-value
• std: the standard deviation
Example:
HypZ1prop(21, 50, 0.5, 0.05,1, "")

HypZ2prop The two-sample Z-test for comparing two proportions.

HypZ2prop(x1,x2,n1,n2,α,mode,
[”configuration”]) where x1 and x2 are the success
counts of the two samples)

Mode: Specifies which alternative hypothesis to use:


• 1: π1 < π2
• 2: π1 > π2
• 3: π1 ≠ π2

Configuration: a string that controls what results are shown


and the order in which they appear. An empty string ""
displays the default: all results, including headers. The
options in the configuration string are separated by spaces.

• h: header cells will be created


• acc: 0 or 1 to reject or fail to reject the null hypothesis
• tZ: the test Z-value
• tP: the test Δπ value

Functions and commands 149


• prob: the lower-tail probability
• cZ: The critical Z-value associated with the input α-level
• cp1: The lower critical value of Δπ associated with the
critical Z-value
• cp2: The upper critical value of Δπ associated with the
critical Z-value
Example:
HypZ2prop(21, 26, 50, 50, 0.05, 1, "")

HypT1mean The one-sample t-test for a mean.

HypT1mean( x ,s,n,μ0, α,mode,[”configuration”])

Mode: Specifies which alternative hypothesis to use:


• 1: μ < μ0
• 2: μ > μ0
• 3: μ ≠ μ0
Configuration: a string that controls what results are shown
and the order in which they appear. An empty string ""
displays the default: all results, including headers. The options
in the configuration string are separated by spaces.
• h: header cells will be created
• acc: the test result, 0 or 1 to reject or fail to reject the null
hypothesis
• tT: the test T-value
• tM: the input x value
• prob: the lower-tail probability
• df: the degrees of freedom
• cT: the critical T-value associated with the input α-level
• cx1: the lower critical value of the mean associated with
the critical T-value
• cx2: the upper critical value of the mean associated with
the critical T-value
Example:
HypT1mean(0.461368, 0.2776, 50, 0.5, 0.05, 1,
"")

150 Functions and commands


HypT2mean The two-sample T-test for the difference of two means.

HypT2mean((x1,x2,s1,s2, n1,n2, α,pooled,mode,


[”configuration”])

Pooled: Specifies whether or not the samples are pooled


• 0: not pooled
• 1: pooled
Mode: Specifies which alternative hypothesis to use:
• 1: μ1 < μ2
• 2: μ1 > μ2
• 3: μ1 ≠ μ2
Configuration: a string that controls what results are shown
and the order in which they appear. An empty string ""
displays the default: all results, including headers. The options
in the configuration string are separated by spaces.
• h: header cells will be created
• acc: the test result, 0 or 1 to reject or fail to reject the null
hypothesis
• tT: the test T-value
• tM: the input Δ x value
• prob: the lower-tail probability
• cT: the critical T-value associated with the input α-level
• cx1: the lower critical value of Δ x associated with the
critical T-value
• cx2: the upper critical value of Δ x associated with the
critical T-value
Example:
HypT2mean(0.461368, 0.522851, 0.2776,
0.2943,50, 50, 0, 0.05, 1, "")

ConfZ1mean The one-sample Normal confidence interval for a mean.

ConfZ1mean( x ,n,s, C,[”configuration”])

Configuration is a string that controls what results are shown


and the order in which they appear. An empty string ""
displays the default: all results, including headers. The options
in the configuration string are separated by spaces.

Functions and commands 151


• h: header cells will be created
• Z: the critical Z-value
• zXl: the lower bound of the confidence interval
• zXh: the upper bound of the confidence interval
• std: the standard deviation
Example:
ConfZ1mean(0.461368, 50, 0.2887, 0.95, "")

ConfZ2mean The two-sample Normal confidence interval for the difference


of two means.

ConfZ2mean( x 1 , x 2 , n1, n2,s1,s2,C,


[”configuration”])

Configuration: a string that controls what results are shown


and the order in which they appear. An empty string ""
displays the default: all results, including headers. The options
in the configuration string are separated by spaces.
• h: header cells will be created
• Z: the critical Z-value
• zXl: the lower bound of the confidence interval
• zXh: the upper bound of the confidence interval
• zXm: the midpoint of the confidence interval
• std: the standard deviation
Example:
ConfZ2mean(0.461368, 0.522851, 50, 50, 0.2887,
0.2887, 0.95, "")

ConfZ1prop The one-sample Normal confidence interval for a proportion.

ConfZ1prop(x,n,C,[”configuration”])

Configuration: a string that controls what results are shown


and the order in which they appear. An empty string ""
displays the default: all results, including headers. The options
in the configuration string are separated by spaces.
• h: header cells will be created
• Z: the critical Z-value
• zXl: the lower bound of the confidence interval

152 Functions and commands


• zXh: the upper bound of the confidence interval
• zXm: the midpoint of the confidence interval
• std: the standard deviation
Example:
ConfZ1prop(21, 50, 0.95, "")

ConfZ2prop The two-sample Normal confidence interval for the difference


of two proportions.

ConfZ2prop(x1,x2,n1,n2,C,[”configuration”])

Configuration: a string that controls what results are shown


and the order in which they appear. An empty string ""
displays the default: all results, including headers. The options
in the configuration string are separated by spaces.
• h: header cells will be created
• Z: the critical Z-value
• zXl: the lower bound of the confidence interval
• zXh: the upper bound of the confidence interval
• zXm: the midpoint of the confidence interval
• std: the standard deviation
Example:
ConfZ2prop(21, 26, 50, 50, 0.95, "")

ConfT1mean The one-sample Student’s T confidence interval for a mean.

ConfT1mean( x ,s,n,C,[”configuration”])

Configuration: a string that controls what results are shown


and the order in which they appear. An empty string ""
displays the default: all results, including headers. The options
in the configuration string are separated by spaces.
• h: header cells will be created
• DF: the degrees of freedom
• T: the critical T-value
• tXl: the lower bound of the confidence interval
• tXh: the upper bound of the confidence interval
• std: the standard deviation

Functions and commands 153


Example:
ConfT1mean(0.461368, 0.2776, 50, 0.95,
"")

ConfT2mean The two-sample Student’s T confidence interval for the


difference of two means.

ConfT2mean( x 1 , x 2 , s1,s2,n1, n2,C,pooled,


[”configuration”])

Configuration: a string that controls what results are shown


and the order in which they appear. An empty string ""
displays the default: all results, including headers. The options
in the configuration string are separated by spaces.
• h: header cells will be created
• DF: the degrees of freedom
• T: the critical T-value
• tXl: the lower bound of the confidence interval
• tXh: the upper bound of the confidence interval
• tXm: the midpoint of the confidence interval
• std: the standard deviation
Example:
ConfT2mean(0.461368, 0.522851, 0.2776, 0.2943,
50, 50, 0, 0.95, "")

Statistics 1Var app functions


The Statistics 1Var app has three functions designed to work
together to calculate summary statistics based on one of the
statistical analyses (H1-H5) defined in the Symbolic view of
the Statistics 1Var app.

154 Functions and commands


Do1VStats Do1-variable statistics. Performs the same calculations as
tapping in the Numeric view of the Statistics 1Var app
and stores the results in the appropriate Statistics 1Var app
results variables. Hn must be one of the Statistics 1Var app
Symbolic view variables H1-H5.
Do1VStats(Hn)
Example:
Do1VStats(H1) executes summary statistics for the
currently defined H1 analysis.

SetFreq Set frequency. Sets the frequency for one of the statistical
analyses (H1-H5) defined in the Symbolic view of the
Statistics 1Var app. The frequency can be either one of the
columns D0-D9, or any positive integer. Hn must be one of the
Statistics 1Var app Symbolic view variables H1-H5. If used,
Dn must be one of the column variables D0-D9; otherwise,
value must be a positive integer.
SetFreq(Hn,Dn)
or
SetFreq(Hn,value)
Example:
SetFreq(H2,D3) sets the Frequency field for the H2
analysis to use the list D3.

SetSample Set sample data. Sets the sample data for one of the statistical
analyses (H1-H5) defined in the Symbolic view of the
Statistics 1Var app. Sets the data column to one of the column
variables D0-D9 for one of the statistical analyses H1-H5.
SetSample(Hn,Dn)
Example:
SetSample(H2,D2) sets the Independent Column
field for the H2 analysis to use the data in the list D2.

Functions and commands 155


Statistics 2Var app functions
The Statistics 2Var app has a number of functions. Some are
designed to calculate summary statistics based on one of the
statistical analyses (S1-S5) defined in the Symbolic view of
the Statistics 2Var app. Others predict X- and Y-values based
on the fit specified in one of the analyses.

PredX Predict X. Uses the fit from the first active analysis (S1-S5)
found to predict an x-value given the y-value.
PredX(value)

PredY Predict Y. Uses the fit from the first active analysis (S1-S5)
found to predict a y-value given the x-value.
PredY(value)

Resid Residuals. Returns the list of residuals for the given analysis
(S1-S5), based on the data and a fit defined in the Symbolic
view for that analysis.
Resid(Sn) or Resid()
Resid() looks for the first defined analysis in the Symbolic view
(S1-S5).

Do2VStats Do 2-variable statistics. Performs the same calculations as


tapping in the Numeric view of the Statistics 2Var app
and stores the results in the appropriate Statistics 2Var app
results variables. Sn must be one of the Statistics 2Var app
Symbolic view variables S1-S5.
Do2VStats(Sn)
Example:
Do1VStats(S1) executes summary statistics for the
currently defined S1 analysis.

SetDepend Set dependent column. Sets the dependent column for one of
the statistical analyses S1-S5 to one of the column variables
C0-C9.
SetDepend(Sn,Cn)
Example:
SetDepend(S1,C3) sets the Dependent Column field
for the S1 analysis to use the data in list C3.

156 Functions and commands


SetIndep Set independent column. Sets the independent column for one
of the statistical analyses S1-S5 to one of the column
variables C0-C9.
SetIndep(Sn,Cn)
Example:
SetIndep(S1, C2) sets the Independent Column
field for the S1 analysis to use the data in list C2.

Inference app functions


The Inference app has a single function that returns the same
results as tapping in the Numeric view of the Inference
app. The results depend on the contents of the Inference app
variables Method, Type, and AltHyp.

DoInference Calculate confidence interval or test hypothesis. Uses the


current settings in the Symbolic and Numeric views to
calculate a confidence interval or test an hypothesis. Performs
the same calculations as tapping in the Numeric view
of the Inference app and stores the results in the appropriate
Inference app results variables.
DoInference()

HypZ1mean The one-sample Z-test for a mean. Returns a list containing (in
order):
• 0 or 1 to reject or fail to reject the null hypothesis
• The test Z-value
• The input x value
• The upper-tail probability
• The upper critical Z-value associated with the input α-level
• The critical value of the statistic associated with the
critical Z-value
HypZ1mean( x , n,μ0,σ,α,mode)

Mode: Specifies which alternative hypothesis to use:


• 1: μ < μ0
• 2: μ > μ0
• 3: μ ≠ μ0

Functions and commands 157


Example:
HypZ1mean(0.461368, 50, 0.5, 0.2887, 0.05, 1)
returns {1, -.9462…, 0.4614, 0.8277…, 1.6448…,
0.5671…}

HYPZ2mean The two-sample Z-test for means. Returns a list containing (in
order):

• 0 or 1 to reject or fail to reject the null hypothesis


• The test Z-value
• The test Δ x value
• The upper-tail probability
• The upper critical Z-value associated with the input α-level
• The critical value of Δ x associated with the critical Z-
value
HypZ2mean( x 1 , x 2 , n1, n2,σ1,σ2,α,mode)

Mode: Specifies which alternative hypothesis to use:


• 1: μ1 < μ2
• 2: μ1 > μ2
• 3: μ1 ≠ μ2
Example:
HypZ2mean(0.461368, 0.522851, 50, 50, 0.2887,
0.2887, 0.05, 1) returns {1, -1.0648…, -0.0614…,
0.8565…, 1.6448…, 0.0334…}

HypZ1prop The one-proportion Z-test. Returns a list containing (in order):

• 0 or 1 to reject or fail to reject the null hypothesis


• The test Z-value
• The test π value
• The upper-tail probability
• The upper critical Z-value associated with the input α-level
• The critical value of π associated with the critical Z-value
HypZ1prop(x,n,π0,α,mode)

158 Functions and commands


Mode: Specifies which alternative hypothesis to use:
• 1: π < π0
• 2: π > π0
• 3: π ≠ π0
Example:
HypZ1prop(21, 50, 0.5, 0.05,1) returns {1,
-1.1313…, 0.42, 0.8710…, 1.6448…, 0.6148…}

HypZ2prop The two-sample Z-test for proportions. Returns a list containing


(in order):

• 0 or 1 to reject or fail to reject the null hypothesis


• The test Z-value
• The test Δπ value
• The upper-tail probability
• The upper critical Z-value associated with the input α-level
• The critical value of Δπ associated with the critical Z-value
HypZ2prop(x1,x2,n1,n2,α,mode)

Mode: Specifies which alternative hypothesis to use:


• 1: π1 < π2
• 2: π1 > π2
• 3: π1 ≠ π2
Example:
HypZ2prop(21, 26, 50, 50, 0.05, 1) returns {1,
-1.0018…, -0.1, 0.8417…, 1.6448…, 0.0633…}

HypT1mean The one-sample t-test for a mean. Returns a list containing (in
order):

• 0 or 1 to reject or fail to reject the null hypothesis


• The test T-value
• The input x value
• The upper-tail probability
• The degrees of freedom
• The upper critical T-value associated with the input α-level
• The critical value of the statistic associated with the
critical t-value
HypT1mean( x ,s,n,μ0, α,mode)

Functions and commands 159


Mode: Specifies which alternative hypothesis to use:
• 1: μ < μ0
• 2: μ > μ0
• 3: μ ≠ μ0
Example:
HypT1mean(0.461368, 0.2776, 50, 0.5, 0.05, 1)
returns {1, -.9462…, 0.4614, 0.8277…, 1.6448…,
0.5671…}

HypT2mean The two-sample T-test for means. Returns a list containing (in
order):

• 0 or 1 to reject or fail to reject the null hypothesis


• The test T-value
• The test Δ x value
• The upper-tail probability
• The degrees of freedom
• The upper critical T-value associated with the input α-level
• The critical value of Δ x associated with the critical T-
value
HypT2mean((x1,x2,s1,s2, n1,n2, α,pooled,mode)

Pooled: Specifies whether or not the samples are pooled


• 0: not pooled
• 1: pooled
Mode: Specifies which alternative hypothesis to use:
• 1: μ1 < μ2
• 2: μ1 > μ2
• 3: μ1 ≠ μ2
Example:
HypT2mean(0.461368, 0.522851, 0.2776,
0.2943,50, 50, 0.05, 0, 1) returns {1, -1.0746…,
-0.0614…, 0.8574…, 97.6674…, 1.6606…, 0.0335…}

160 Functions and commands


ConfZ1mean The one-sample Normal confidence interval for a mean.
Returns a list containing (in order):

• The lower critical Z-value


• The lower bound of the confidence interval
• The upper bound of the confidence interval
ConfZ1mean( x ,n,σ, C)

Example:
ConfZ1mean(0.461368, 50, 0.2887, 0.95) returns {-
1.9599…, 0.3813…, 0.5413…}

ConfZ2mean The two-sample Normal confidence interval for the difference


of two means. Returns a list containing (in order):

• The lower critical Z-value


• The lower bound of the confidence interval
• The upper bound of the confidence interval
ConfZ2mean( x 1 , x 2 , n1, n2,σ1,σ2,C)

Example:
ConfZ2mean(0.461368, 0.522851, 50, 50, 0.2887,
0.2887, 0.95) returns {-1.9599…,
-0.1746…, 0.0516…)}

ConfZ1prop The one-sample Normal confidence interval for a proportion.


Returns a list containing (in order):

• The lower critical Z-value


• The lower bound of the confidence interval
• The upper bound of the confidence interval
ConfZ1prop(x,n,C)

Example:
ConfZ1prop(21, 50, 0.95) returns {-1.9599…,
0.2831…, 0.5568…}

Functions and commands 161


ConfZ2prop The two-sample Normal confidence interval for the difference
of two proportions. Returns a list containing (in order):

• The lower critical Z-value


• The lower bound of the confidence interval
• The upper bound of the confidence interval
ConfZ2prop(x1,x2,n1,n2,C)

Example:
ConfZ2prop(21, 26, 50, 50, 0.95) returns
{-1.9599…, -0.2946…, 0.0946…)}

ConfT1mean The one-sample Student’s T confidence interval for a mean.


Returns a list containing (in order):

• The degrees of freedom


• The lower bound of the confidence interval
• The upper bound of the confidence interval
ConfT1mean( x ,s,n,C)

Example:
ConfT1mean(0.461368, 0.2776, 50, 0.95) returns
{49, -.2009…, 0.5402…}

ConfT2mean The two-sample Student’s T confidence interval for the


difference of two means. Returns a list containing (in order):
• The degrees of freedom
• The lower bound of the confidence interval
• The upper bound of the confidence interval
ConfT2mean( x 1 , x 2 , s1,s2,n1, n2,pooled,C)

Example:
ConfT2mean(0.461368, 0.522851, 0.2887, 0.2887,
50, 50, 0.95,0) returns {98.0000…, -1.9844, -
0.1760…, 0.0531…)}

Chi2GOF Chi-square goodness of fit test. Takes as arguments a list of


observed count data, a second list, and a value of 0 or 1. If
value=0, the second list is taken as a list of expected
probabilities. If value=1, then the second list is taken as a list

162 Functions and commands


of expected counts. Returns a list containing the chi-square
statistic value, the probability, and the degrees of freedom.
Chi2GOF(List1, List2, Value)

Example:
Chi2GOF({10,10,12,15,10,6},{.24,.2,.16,.14,.1
3,.13},0) returns {10.1799..., 0.07029..., 5}

Chi2TwoWay Chi-square two-way test. Given a matrix of count data, returns


a list containing the chi-square statistic value, the probability,
and the degrees of freedom.
Chi2TwoWay(Matrix)

Example:
Chi2TwoWay([[30,35,30],[11,2,19],[43,35,35]])
returns {14.4302..., 0.0060..., 4}

LinRegrTConf- The linear regression confidence interval for the slope. Given
Slope a list of explanatory variable data (X), a list of response
variable data (Y), and a confidence level, returns a list
containing the following values in the order shown:
• C: the given confidence level
• Critical T: the value of t associated with the given
confidence level
• DF: the degrees of freedom
• β1: the slope of the linear regression equation
• serrSlope: the standard error of the slope
• Lower: the lower bound of the confidence interval for the
slope
• Upper: the upper bound of the confidence interval for the
slope
LinRegrTConfSlope(List1, List2, C-value)

Example:
LinRegrTConfSlope({1,2,3,4},{3,2,0,-2},0.95)
returns {0.95, 4.302..., 2, -1.7, 0.1732...,
-2.445..., -0.954...}

Functions and commands 163


LinRegrTConfInt The linear regression confidence interval for the intercept.
Given a list of explanatory variable data (X), a list of response
variable data (Y), and a confidence level, returns a list
containing the following values in the order shown:
• C: the given confidence level
• Critical T: the value of t associated with the given
confidence level
• DF: the degrees of freedom
• β0: the intercept of the linear regression equation
• serrInter: the standard error of the intercept
• Lower: the lower bound of the confidence interval for the
intercept
• Upper: the upper bound of the confidence interval for the
intercept
LinRegrTConfInt(List1, List2, C-value)

Example:
LinRegrTConfInt({1, 2, 3, 4}, {3, 2, 0, -
2},0.95) returns {0.95, 4.302..., 2, 5,
0.474..., 2.959..., 7.040...}

LinRegrTMean- The linear regression confidence interval for a mean


Resp response. Given a list of explanatory variable data (X), a list
of response variable data (Y), an X-value, and a confidence
level, returns a list containing the following values in the order
shown:
• X: the given X-value
• C: the given confidence level
• DF: the degrees of freedom
• Ŷ: the mean response for the given X-value
• serr Ŷ: the standard error of the mean response
• Lower: the lower bound of the confidence interval for the
mean response
• Upper: the upper bound of the confidence interval for the
mean response
LinRegrTMeanResp(List1, List2, X-value, C-
value)

164 Functions and commands


Example:
LinRegrTMeanResp({1, 2, 3, 4}, {3, 2, 0, -2},
2.5, 0.95) returns {2.5, 0.95, 4.302..., 2,
0.75, 0.193..., −0.083, 1.583...}

LinRegrTPredInt The linear regression prediction interval for a future response.


Given a list of explanatory variable data (X), a list of response
variable data (Y), a future X-value, and a confidence level,
returns a list containing the following values in the order
shown:
• X: the given future X-value
• C: the given confidence level
• DF: the degrees of freedom
• Ŷ: the mean response for the given future X-value
• serr Ŷ: the standard error of the mean response
• Lower: the lower bound of the prediction interval for the
mean response
• Upper: the upper bound of the prediction interval for the
mean response
LinRegrTPredInt(List1, List2, X-value, C-
value)

Example:
LinRegrTPredInt({1, 2, 3, 4}, {3, 2, 0, -2},
2.5, 0.95) returns {2.5, 0.95, 4.302..., 2,
0.75, 0.433..., −1.113..., 2.613...}

LinRegrTTest The linear regression t-test. Given a list of explanatory


variable data (X), a list of response variable data (Y), and a
value for AltHyp, returns a list containing the following values
in the order shown:
• T: the t-value
• P: the probability associated with the t-value
• DF: the degrees of freedom
• β0: the y-intercept of the regression line
• β1: the slope of the regression line
• serrLine: the standard error of the regression line
• serrSlope: the standard error of the slope
• serrInter: the standard error of the y-intercept

Functions and commands 165


• r: the correlation coefficient
• R2: the coefficient of determination
The values for AltHyp are as follows:
• AltHyp=0 for μ<μ0
• AltHyp=1 for μ>μ0
• AltHyp=2 for μ≠μ0
Example:
LinRegrTTest({1,2,3,4}, {3,2,0,-2}, 0) returns
{−9.814..., 2, 5, −1.7, 0.387..., 0.173...,
0.474..., −0.989..., 0.979...}

Finance app functions


The Finance app uses a set of functions that all reference the
same set of Finance app variables. These correspond to the
fields in the Finance app Numeric view. There are 5 main
TVM variables, 4 of which are mandatory for each of these
functions, as they each solve for and return the value of the
fifth variable to two decimal places. DoFinance is the sole
exception to this syntax rule. Note that money paid to you is
entered as a positive number and money you pay to others as
part of a cash flow is entered as a negative number. There are
3 other variables that are optional and have default values.
These variables occur as arguments to the Finance app
functions in the following set order:
– NbPmt—the number of payments
– IPYR—the annual interest rate
– PV—the present value of the investment or loan
– PMTV—the payment value
– FV—the future value of the investment or loan
– PPYR—the number of payments per year (12 by
default)
– CPYR—the number of compounding periods per year
(12 by default)
– BEG—payments made at the beginning or end of the
period; the default is BEG=0, meaning that payments
are made at the end of each period

166 Functions and commands


The arguments PPYR, CPYR, and BEG are optional; if not
supplied, PPYR=12, CPYR=PPYR, and BEG=0.

CalcFV Solves for the future value of an investment or loan.


CalcFV(NbPmt,IPYR,PV,PMTV[,PPYR,CPYR,BEG]
Example:
CalcFV(360, 6.5, 150000, -948.10) returns -2.25

CalcIPYR Solves for the interest rate per year of an investment or loan.
CalcIPYR(NbPmt,PV,PMTV,FV[,PPYR,CPYR,
BEG])
Example:
CalcIPYR(360, 150000, -948.10, -2.25) returns
6.50

CalcNbPmt Solves for the number of payments in an investment or loan.


CalcNbPmt(IPYR,PV,PMTV,FV[,PPYR,CPYR,BEG])
Example:
CalcNbPmt(6.5, 150000, -948.10, -2.25) returns
360.00

CalcPMT Solves for the value of a payment for an investment or loan.


CalcPMT(NbPmt,IPYR,PV,FV[,PPYR,CPYR,BEG])
Example:
CalcPMT(360, 6.5, 150000, -2.25) returns
-948.10

CalcPV Solves for the present value of an investment or loan.


CalcPV(NbPmt,IPYR,PMTV,FV[,PPYR,CPYR,BEG])
Example:
CalcPV(360, 6.5, -948.10, -2.25) returns
150000.00

DoFinance Calculate TVM results. Solves a TVM problem for the variable
TVMVar. The variable must be one of the Finance app's
Numeric view variables. Performs the same calculation as
tapping in the Numeric view of the Finance app with
TVMVar highlighted.
DoFinance(TVMVar)

Functions and commands 167


Example:
DoFinance(FV) returns the future value of an investment in
the same way as tapping in the Numeric view of the
Finance app with FV highlighted.

Linear Solver app functions


The Linear Solver app has 3 functions that offer the user
flexibility in solving 2x2 or 3x3 linear systems of equations.

Solve2x2 Solves a 2x2 linear system of equations.


Solve2x2(a, b, c, d, e, f)
Solves the linear system represented by:
ax+by=c
dx+ey=f

Solve3x3 Solves a 3x3 linear system of equations.


Solve3x3(a, b, c, d, e, f, g, h, i, j, k, l)
Solves the linear system represented by:
ax+by+cz=d
ex+fy+gz=h
ix+jy+kz=l

LinSolve Solve linear system. Solves the 2x2 or 3x3 linear system
represented by matrix.
LinSolve(matrix)
Example:
LinSolve([[A, B, C], [D, E,F]]) solves the linear system:
ax+by=c
dx+ey=f

Triangle Solver app functions


The Triangle Solver app has a group of functions which allow
you to solve a complete triangle from the input of three
consecutive parts of the triangle (one of which must be a side
length). The names of these commands use A to signify an
angle and S to signify a side length. To use these commands,
enter three inputs in the specified order given by the

168 Functions and commands


command name. These commands all return a list of the three
unknown values (lengths of sides and/or measures of angles).

AAS Angle-Angle-Side. Takes as arguments the measures of two


angles and the length of the side opposite the first angle and
returns a list containing the length of the side opposite the
second angle, the length of the third side, and the measure of
the third angle (in that order).
AAS(angle,angle,side)
Example:
AAS(30, 60, 1) in degree mode returns {1.732…, 2,
90}

ASA Angle-Side-Angle. Takes as arguments the measure of two


angles and the length of the included side and returns a list
containing the length of the side opposite the first angle, the
length of the side opposite the second angle, and the measure
of the third angle (in that order).
ASA(angle,side,angle)
Example:
ASA(30, 2, 60) in degree mode returns {1, 1.732…,
90}

SAS Side-Angle-Side. Takes as arguments the length of two sides


and the measure of the included angle and returns a list
containing the length of the third side, the measure of the
angle opposite the third side and the measure of the angle
opposite the second side.
SAS(side,angle,side)
Example:
SAS(2, 60, 1) in degree mode returns {1.732…, 30,
90}

SSA Side-Side-Angle. Takes as arguments the lengths of two sides


and the measure of a non-included angle and returns a list
containing the length of the third side, the measure of the
angle opposite the second side, and the measure of the angle
opposite the third side. Note: In an ambiguous case, this
command will only give you one of the two possible solutions.
SSA(side,side,angle)

Functions and commands 169


Example:
SSA(1, 2, 30) returns {1.732…, 90, 60}

SSS Side-Side-Side Takes as arguments the lengths of the three


sides of a triangle and returns the measures of the angles
opposite them, in order.
SSS(side,side,side)
Example:
SSS(3, 4, 5) in degree mode returns {36.8…, 53.1…,
90}

DoSolve Solves the current problem in the Triangle Solver app. The
Triangle Solver app must have enough data entered to ensure
a successful solution; that is, there must be at least three values
entered, one of which must be a side length. Returns a list
containing the unknown values in the Numeric view, in their
order of appearance in that view (left to right and top to
bottom).
DoSolve()

Linear Explorer functions


SolveForSlope Solve for slope. Takes as input the coordinates of two points
(x1, y1) and (x2, y2) and returns the slope of the line containing
those two points.
SolveForSlope(x1, x2, y1, y2)
Example:
SolveForSlope(3,2,4,2) returns 2

SolveForYIntercept
Solve for y-intercept. Takes as input the coordinates of a point
(x, y), and a slope m, and returns the y-intercept of the line
with the given slope that contains the given point.
SolveForYIntercept(x, y, m)
Example:
SolveForYIntercept(2,3,-1) returns 5

170 Functions and commands


Quadratic Explorer functions
SOLVE Solve quadratic. Given the coefficients of a quadratic
equation ax2+bx+c=0, returns the real solutions.
SOLVE(a, b, c)
Example:
SOLVE(1,0,-4) returns {-2, 2}

DELTA Discriminant. Given the coefficients of a quadratic equation


ax2+bx+c=0, returns the value of the discriminant in the
Quadratic Formula.
DELTA(a, b, c)

Example:

DELTA(1,0,-4) returns 16

Common app functions


In addition to the app functions specific to each app, there are
three functions common to the following apps. These use as
an argument an integer from 0 to 9, which corresponds to one
of the Symbolic view variables for that app.
• Function (F0–F9)
• Solve (E0–E9)
• Statistics 1Var (H1–H5)
• Statistics 2Var (S1–S5)
• Parametric (X0/Y0–X9/Y9)
• Polar (R0–R9)
• Sequence (U0–U9)
• Advanced Graphing (V0–V9)

CHECK Check. Checks—that is, selects—the Symbolic view variable


corresponding to Digit. Used primarily in programming to
activate Symbolic view definitions in apps.
CHECK(Digit)
Example:
With the Function app as the current app, CHECK(1) checks
the Function app Symbolic view variable F1. The result is that

Functions and commands 171


F1(X) is drawn in the Plot view and has a column of function
values in the Numeric view of the Function app. With another
app as the current app, you would have to enter
Function.CHECK(1).

UNCHECK Un-Check. Un-checks—that is, deselects—the Symbolic view


variable corresponding to Digit. Used primarily in
programming to de-activate symbolic view definitions in apps.
UNCHECK(Digit)
Example:
With the Sequence app as the current app, UNCHECK(2) un-
checks the Sequence app Symbolic view variable U2. The
result is that U2(N) is no longer drawn in Plot view and has
no column of values in the Numeric view of the Sequence
app. With another app as the current app, you would have to
enter Sequence.UNCHECK(2).

ISCHECK Test for check. Tests whether a Symbolic view variable is


checked. Returns 1 if the variable is checked and 0 if it is not
checked.
ISCHECK(Digit)
Example:
With the Function app as the current app, ISCHECK(3)
checks to see if F3(X) is checked in the Symbolic view of the
Function app.

Ctlg menu
The Catlg menu brings
together all the functions and
commands available on the
HP Prime. However, this
section describes the
functions and commands
that can only be found on
the Catlg menu. The
functions and commands that are also on the Math menu are
described in “Keyboard functions” on page 101. Those that
are also on the CAS menu are described in “CAS menu” on
page 116. The functions and commands specific to the
Geometry app are described in “Geometry functions and

172 Functions and commands


commands” on page 39, and those specific to programming
are described in “Program commands” on page 267.
Some of the options on the Catlg menu can
also be chosen from the relations palette
(Sr)

! Factorial. Returns the factorial of a positive integer. For non-


integers, ! = Γ(x + 1). This calculates the Gamma function.
value!

Example:
6! returns 720

% x percent of y. Returns (x/100)*y.


%(x, y)

Example:
%(20,50) returns 10

%CHANGE Percent change from x to y. Returns 100*(y-x)/x.


%CHANGE(x, y)

Example:
%CHANGE(20,50) returns 150

%TOTAL Percent total; the percentage of x that is y. Returns 100*y/x.


%TOTAL(x, y)

Example:
%TOTAL(20,50) returns 250

( Inserts opening parenthesis.

* Multiplication symbol. Returns the product of two numbers or


the scalar product of two vectors.

+ Addition symbol. Returns the sum of two numbers, the term-by-


term sum of two lists or two matrices, or adds two strings
together.

− Subtraction symbol. Returns the difference of two numbers, or


the term-by-term subtraction of two lists or two matrices.

Functions and commands 173


.* List or matrix multiplication symbol. Returns the term-by-term
multiplication of two lists or two matrices.
List1.*List2 or Matrix1.*Matrix2

Example:
[[1,2],[3,4]].*[[3,4],[5,6]] gives
[[3,8],[15,24]]

./ List or matrix division symbol. Returns the term-by-term division


of two lists or two matrices.

.^ Returns the list or matrix where each term is the corresponding


term of the list or matrix given as argument, raised to a power.
List.^Integer or Matrix.^Integer

/ Division symbol. Returns the quotient of two numbers, or the


term by term quotient of two lists. For division of a matrix by
a square matrix, returns the left-multiplication by the inverse of
the square matrix.

:= Stores the evaluated expression in the variable. Note that:=


cannot be used with the graphics variables G0–G9. See the
command BLIT.
var:=expression

Example:
A:=3 stores the value 3 in the variable A

< Strict less-than-inequality test. Returns 1 if the left side of the


inequality is less than the right side, and 0 otherwise. Note
that more than two objects can be compared. Thus 6 < 8 <
11 returns 1 (because it is true) whereas 6 < 8 < 3 returns 0
(as it is false).

<= Less than or equal inequality test. Returns 1 if the left side of
the inequality is less than the right side or if the two sides are
equal, and 0 otherwise. Note that more than two objects can
be compared. See comment above regarding <.

<> Inequality test. Returns 1 if the inequality is true, and 0 if the


inequality is false.

= Equality symbol. Connects two members of an equation.

== Equality test. Returns 1 if the left side and right side are equal,
and 0 otherwise.

174 Functions and commands


> Strict greater than inequality test. Returns 1 if the left side of
the inequality is greater than the right side, and 0 otherwise.
Note that more than two objects can be compared. See
comment above regarding <.

>= Greater than or equal inequality test. Returns 1 if the left side
of the inequality is greater than the right side or if the two
sides are equal, and 0 otherwise. Note that more than two
objects can be compared. See comment above regarding <.

^ Power symbol. Raises a number to a power or a matrix to an


integer power.

a2q Given a symmetric matrix and a vector of variables, returns


the quadratic form of the matrix using the variables in the
vector.
a2q(Matrix, [Var1, Var2….])

Example:
a2q([[1,2],[4,4]],[x,y]) returns x^2+6*x*y+4*y^2

abcuv Given three polynomials A, B, and C, returns U and V such


that A*U+B*V=C. With a variable as the final argument, U
and V are expressed in terms of that variable (if needed);
otherwise, x is used.
abcuv(PolyA, PolyB, PolyC, [Var])

Example:
abcuv(x^2+2*x+1,x^2-1,x+1) returns [1/2 -1/2]

additionally Used in programming with assume to state an additional


assumption about a variable.
Example:
assume(n,integer);

additionally(n>5);

algvar Returns the matrix of the symbolic variable names used in an


expression. The list is ordered by the algebraic extensions
required to build the original expression.
algvar(Expr)

Example:

algvar(sqrt(x)+y) gives y
x

Functions and commands 175


AND Logical And. Returns 1 if the left and right sides both evaluate
to true and returns 0 otherwise.
Expr1 AND Expr2

Example:
3 +1==4 AND 4 < 5 returns 1

append Appends an element to a list or vector.


append((List, Element)

or

append(Vector, Element)

Example:
append([1,2,3],4) gives [1,2,3,4]

apply Returns a vector or matrix containing the results of applying a


function to the elements in the vector or matrix.
apply(Var→f(Var), Vector) or apply(Var→f(Var),
Matrix)

Example:
apply(x→x^3,[1 2 3]) gives [1 8 27]

assume Used in programming to state an assumption about a


variable.
assume(Var,Expr)

Example:
assume(n, integer)

basis Given a matrix, returns the basis of the linear subspace


defined by the set of vectors in the matrix.
basis(Matrix))

Example:
basis([[1,2,3],[4,5,6],[7,8,9],[10,11,12]])
gives [[-3,0,3],[0,-3,-6]]

bounded_function Argument returned by the limit command, indicating that the


function is bounded.

breakpoint Used in programming to insert an intentional stopping or


pausing point.

176 Functions and commands


canonical_form Returns a second degree trinomial in canonical form.
canonical_form(Trinomial,[Var])

Example:
canonical_form(2*x^2-12*x+1) gives 2*(x-3)^2-
17

cat Evaluates the objects in a sequence, then returns them


concatenated as a string.
cat(Object1, Object2,…)

Example:
cat("aaa",c,12*3) gives "aaac36"

cFactor Returns an expression factorized over the complex field (on


Gaussian integers if there are more than two ).
cfactor(Expr)

Example:
cFactor(x^2*y+y) gives (x+i)*(x-i)*y

charpoly Returns the coefficients of the characteristic polynomial of a


matrix. With only one argument, the variable used in the
polynomial is x. With a variable as second argument, the
polynomial returned is in terms of that variable.
charpoly(Matrix,[Var])

Example:

charpoly([[1,2],[3,4]], z) returns z^2-5*z-


2

chrem Returns a vector containing the Chinese remainders for two


sets of integers, contained in either two vectors or two lists.
chrem(List1, List2) or chrem(Vector1, Vector2)

Example:
chrem([2,3],[7,5]) returns [-12,35]

col Given a matrix and an integer n, returns the nth column of the
matrix as a vector.
col(Matrix, Integer)

Functions and commands 177


Example:

 1 2 3 
 
col  4 5 6 , 2 returns [2,5,8]
 
 7 8 9 

colDim Returns the number of columns of a matrix.


colDim(Matrix)

Example:

 1 2 3
colDim   returns 3
 4 5 6

comDenom Rewrites a sum of rational fractions as a one rational fraction.


The denominator of the one rational fraction is the common
denominator of the rational fractions in the original
expression. With a variable as second argument, the
numerator and denominator are developed according to it.
comDenom(Expr,[Var])

Example:
comDenom(1/x+1/y^2+1) gives (x*y^2+x+y^2)/
(x*y^2)

companion Returns the companion matrix of a polynomial.


companion(Poly,Var)

Example:

 
companion(x^2+5x-7,x) returns  0 7 
 1 –5 

compare Compares two objects and returns 1 if


type(Obj1)<type(Obj2) or if type(Obj1)=type(Obj2) and
Obj1<Obj2; otherwise, it returns 0.
compare(Obj1, Obj2)

Example:
compare(1,2) gives 1

complexroot With a polynomial and a real as its two arguments, returns a


matrix. Each row of the matrix contains either a complex root
of the polynomial with its multiplicity or an interval containing
such a root and its multiplicity. The interval defines a (possibly)
rectangular region in the complex plane where a complex
root lies.
178 Functions and commands
With two additional complex numbers as third and fourth
arguments, returns a matrix as described for two arguments,
but only for those roots lying in the rectangular region defined
by the diagonal created by the two complex numbers.
complexroot(Poly, Real, [Complex1], [Complex2])

Example:
complexroot(x^3+8, 0.01) returns
–2 1

1017 – 1782 ⋅ -i 1026


---------------------------------------- – 1773 ⋅ -i 1
----------------------------------------
1024 1024

1395 + 378 ⋅ i – 189 + 702 ⋅ i 1


-------------------------------------- ---------------------------------------
512 – 512 ⋅ i 256 + 256 ⋅ i

This matrix indicates there is 1 complex root at x=–2,


with another root between the two values in the second
row vector and a third root between the two values in the
third row vector.

contains Given a list or vector and an element, returns the index of the
first occurrence of the element in the list or vector; if the
element does not appear in the list or vector, returns 0.
contains((List, Element) or contains(Vector,
Element)

Example:
contains({0,1,2,3},2) returns 3

CopyVar Copies the first variable into the second variable without
evaluation.
CopyVar(Var1,Var2)

correlation Returns the correlation of the elements of a list or matrix.


correlation(List) or correlation(Matrix)

Example:

1 2
33
correlation 1 1 returns -------------------
6 ⋅ 31
4 7

count There are two uses for this function, in which first argument is
always a mapping of a variable onto an expression. If the
expression is a function of the variable, the function is applied
to each element in the vector or matrix (the second argument)
and the sum of the results is returned; if the expression is a

Functions and commands 179


Boolean test, each element in the vector or matrix is tested and
the number of elements that pass the test is returned.
count(Var → Function, Matrix) or count(Var → Test, Matrix)

Examples:
count(x→x2,[1 2 3]) returns 14

count(x→ x>1, [1 2 3]) returns 2

covariance Returns the covariance of the elements in a list or matrix.


covariance(List) or covariance(Matrix)

Example:

 1 2
  11
covariance  1 1  returns -------
  3
 4 7

covariance_ Returns a vector containing both the covariance and the


correlation correlation of the elements of a list or matrix.
covariance_correlation(List) or
covariance_correlation(Matrix)

Example:

 1 2
  11 33
covariance_correlation  1 1  returns ------- -------------------
  3 6 ⋅ 31
 4 7

cpartfrac Returns the result of partial fraction decomposition of a


rational fraction in the complex field.
cpartfrac(RatFrac)

Example:
1 1
x 
 --------------- --- ---
cpartfrac 
-
returns 2 -
2 - – ------------
2 – -----------
4 – x  x–2 x+2

crationalroot Returns the list of complex rational roots of a polynomial


without indicating the multiplicity.
crationalroot(Poly)

180 Functions and commands


Example:
crationalroot(2*x^3+(-5-7*i)*x^2+

(-4+14*i)*x+8-4*i) returns 3 +i
----------- 2 ⋅ i 1 + i
2

cumSum Accepts as argument either a list or a vector and returns a list


or vector whose elements are the cumulative sum of the
original argument.
cumSum(List) or cumSum(Vector)

Example:
cumSum([0,1,2,3,4]) returns [0,1,3,6,10]

delcols Given a matrix and an integer n, deletes the nth column from
the matrix and returns the result. If an interval of two integers
is used instead of a single integer, deletes all columns in the
interval and returns the result.
delcols(Matrix, Integer) or delcols(Matrix,
Intg1..Intg2)

Example:

 1 2 3  1 3
 
delcols  4 5 6 , 2 returns 4 6
 
 7 8 9  7 9

delrows Given a matrix and an integer n, deletes the nth row from the
matrix and returns the result. If an interval of two integers is
used instead of a single integer, deletes all rows in the interval
and returns the result.
delrows(Matrix, Integer) or delrows(Matrix,
Intg1..Intg2)

Example:

 1 2 3 
 
delrows  4 5 6 , 2..3 returns 1 2 3
 
 7 8 9 

deltalist Returns the list of the differences between consecutive terms in


the original list.
deltalist(Lst)

Example:
deltalist([1,4,8,9]) gives [3,4,1]

Functions and commands 181


Dirac Returns the value of the Dirac delta function for a real number.
Dirac(Real)

Example:
Dirac(1) gives 0

e Enters the mathematical constant e (Euler’s number).

egcd Given two polynomials, A and B, returns three polynomials U,


V and D such that:
U(x)*A(x)+V(x)*B(x)=D(x),

where D(x)=GCD(A(x),B(x)), the greatest common


divisor of polynomials A and B.
The polynomials can be provided in symbolic form or as lists
of coefficients in descending order.
Without a third argument, it is assumed that the polynomials
are expressions of x. With a variable as third argument, the
polynomials are expressions of it.
egcd((PolyA, PolyB, [Var]) or egcd(ListA,
ListB, [Var])

Example:
egcd((x-1)^2,x^3-1) gives [-x-2,1,3*x-3]

eigenvals Returns the sequence of eigenvalues of a matrix.


eigenvals(Matrix)

Example:

 –2 –2 1 
 
eigenvals  – 2 1 –2  returns [3 -3 -3]
 
 1 –2 –2 

eigenvects Returns the eigenvectors of a diagonalizable matrix.


eigenvects(Matrix)

Example:

 –2 –2 1  1 –3 –3
 
eigenvects  – 2 1 –2  returns – 2 0 – 3
 
 1 –2 –2  1 3 –3

182 Functions and commands


eigVl Returns the Jordan matrix associated with a matrix when the
eigenvalues are calculable.
eigVl(Matrix)

EVAL Evaluates an expression.


eval(Expr)

Example:
eval(2+3) returns 5

evalc Returns a complex expression written in the form


real+i*imag.
evalc(Expr)

Example:
1 x i⋅y
evalc  ------------------ returns ------------------
- – -------------------
x+y⋅i 2 2 2 2
x +y x +y

evalf Given an expression and a number of significant digits,


returns the numerical evaluation of the expression to the given
number of significant digits. With just an expression, returns
the numerical evaluation based on the CAS settings.
evalf(Expr,[Integer])

Example:
evalf(2/3) gives 0.666666666667

even Tests whether or not an integer is even. Returns 1 if it is and 0


if it is not.
Example:
even(1251) returns 0

exact Converts a decimal expression to a rational or real


expression.
exact(Expr)

Example:
exact(1.4141) gives 14141/10000

EXP Returns the solution to the mathematical constant e to the


power of an expression.
exp(Expr)

Example:
exp(0) gives 1

Functions and commands 183


exponential_ Given a set of points, returns a vector containing the
regression coefficients a and b of y=b*a^x, the exponential which best
fits the set of points. The points may be the elements in two
lists or the rows of a matrix.
exponential_regression(Matrix) or
exponential_regression(List1, List2)

Example:

 1.0 2.0 
 
exponential_regression  0.0 1.0  returns
 
 4.0 7.0 
1.60092225473,1.10008339351

EXPR Parses a string into a number or expression and returns the


result evaluated.
EXPR(String)

Examples:
expr("2+3") returns 5

expr("X+10") returns 100, if the variable X has the


value 90

ezgcd Uses the EZ GCD algorithm to return the greatest common


divisor of two polynomials with at least two variables.
ezgcd(Poly1,Poly2)

Example:
ezgcd(x^2-2*x-x*y+2*y,x^2-y^2) returns x-y

f2nd Returns a vector consisting of the numerator and denominator


of an irreducible form of a rational fraction.
f2nd(RatFrac)

Example:

 x 
f2nd  -------------- returns 1 x
x⋅ x
 

factorial Returns the factorial of an integer or the solution to the gamma


function for a non-integer. For an integer n, factorial(n)=n!. For
a non-integer real number a, factorial(a)=a! = Gamma(a + 1).
factorial(Integer) or factorial(Real)

184 Functions and commands


Examples:
factorial(4) returns 24

factorial(1.2) returns 1.10180249088

fMax Given an expression in x, returns the value of x for which the


expression has its maximum value. Given an expression and
a variable, returns the value of that variable for which the
expression has its maximum value.
fMax(Expr,[Var])

Example:
fMax(-x^2+2*x+1,x) gives 1

fMin Given an expression in x, returns the value of x for which the


expression has its minimum value. Given an expression and a
variable, returns the value of that variable for which the
expression has its minimum value.
fMin(Expr,[Var])

Example:
fMin(x^2-2*x+1,x) gives 1

format Returns a real number as a string with the indicated format


(f=float, s=scientific, e=engineering).
format(Real, String)

Example:
format(9.3456,"s3") returns 9.35

fracmod For a given integer n (representing a fraction) and an integer


p (the modulus), returns the fraction a/b such that n=a/b(mod
p).
fracmod(Integern, Integerp)

Example:
fracmod(41,121) gives 2/3

froot Returns a vector containing the roots and poles of a rational


polynomial. Each root or pole is followed by its multiplicity.
froot(RatPoly)

Example:

 5 4 3
froot  x--------------------------------------
– 2 ⋅ x + x - returns [0 3 1 2 3 -1]

 x–3 

Functions and commands 185


fsolve Returns the numerical solution of an equation or a system of
equations. With the optional third argument you can specify
a guess for the solution or an interval within which it is
expected that the solution will occur. With the optional fourth
argument you can name the iterative algorithm to be used by
the solver.
fsolve(Expr,Var,[Guess or Interval],[Method])

Example:
fsolve(cos(x)=x,x,-1..1,bisection_solver)
gives [0.739085133215]

function_diff Returns the derivative function of a function (as a mapping).


function_diff(Fnc)

Example:
function_diff(sin) gives (_x)→cos(_x)

gauss Given an expression followed by a vector of variables, uses


the Gauss algorithm to return the quadratic form of the
expression written as a sum or difference of squares of the
variables given in the vector.
gauss(Expr,VectVar)

Example:
gauss(x^2+2*a*x*y,[x,y]) gives (a*y+x)^2+(-
y^2)*a^2

GF Creates a Galois Field of characteristic p with p^n elements.


GF(Integerp, Integern)

Example:
GF(5,9) gives GF(5,k^9-k^8+2*k^7+2*k^5-k^2+2*k-
2,[k,K,g],undef)

gramschmidt Given a basis of a vector subspace, and a function that


defines a scalar product on this vector subspace, returns an
orthonormal basis for that function.
gramschmidt(Vector, Function)

186 Functions and commands


Example:

 1 
 
gramschmidt  1 1 + x , ( p, q ) → p ⋅ q dx
   returns
 –1 

1 1+x–1
------- ----------------------
2 6
-------
3

halftan2hypexp Returns an expression with sine, cosine, and tangent rewritten


in terms of half-tangent, and sinh, cosh, and tanh rewritten in
terms of the natural exponential.
halftan_hyp2exp(ExprTrig)

Example:
halftan_hyp2exp(sin(x)+sinh(x)) returns
x 1
2 ⋅ tan  --- exp ( x ) – -----------------
 2 exp ( x )-
-------------------------------- + -----------------------------------------
x 2 2
tan  --- + 1
 2

halt Used in programming to go into step-by-step debugging


mode.

hamdist Returns the Hamming distance between two integers.


hamdist(Integer1, Integer2)

Example:
hamdist(0x12,0x38) gives 3

has Returns 1 if a variable is in an expression, and returns 0


otherwise.
has(Expr,Var)

Example:
has(x+y,x) gives 1

head Returns the first element of a given vector, sequence or string.


head(Vector) or head(String) or
head(Obj1, Obj2,…)

Example:
head(1,2,3) gives 1

Functions and commands 187


Heaviside Returns the value of the Heaviside function for a given real
number (i.e. 1 if x>=0, and 0 if x<0).
Heaviside(Real)

Example:
Heaviside(1) gives 1

hyp2exp Returns an expression with hyperbolic terms rewritten as


exponentials.
hyp2exp(Expr)

Example:
1
exp ( x ) + -----------------
exp ( x )-
hyp2exp(cosh(x)) returns -----------------------------------------
2

iabcuv Returns [u,v] such that au+bv=c for three integers a, b, and c.
Note that c must be a multiple of the greatest common divisor
of a and b for there to be a solution.
iabcuv(Intgra, Intgrb, Intgrc)

Example:
iabcuv(21,28,7) gives [-1,1]

ibasis Given two matrices, interprets them as two vector spaces and
returns the vector basis of their intersection.
ibasis(Matrix1, Matrix2)

Example:

 
ibasis  1 0 0 , 1 1 1  returns [-1,-1,0]
 0 1 0 0 0 1

icontent Returns the greatest common divisor of the integer coefficients


of a polynomial.
icontent(Poly,[Var])

Example:
icontent(24x^3+6x^2-12x+18) gives 6

id Returns a vector containing the solution to the identity function


for the argument(s).
id(Object1, [Object2,…])

Example:
id([1 2], 3, 4) returns [[1 2] 3 4]

188 Functions and commands


identity Given an integer n, returns the identity matrix of dimension n.
identity(Integer)

Example:

1 0 0
identity(3) returns 0 1 0
0 0 1

iegcd Returns the extended greatest common divisor of two integers.


iegcd(Integer1, Integer2)

Example:
iegcd(14, 21) returns [-1, 1, 7]

igcd Returns the greatest common divisor of two integers or two


rational numbers or two polynomials of several variables.
igcd((Integer1, Integer2) or
igcd(Ratnl1, Ratnl2) or
igcd(Poly1, Poly2)

Examples:
igcd(24, 36) returns 12

igcd(2/3,3/4) returns 1/12

interval2center Returns the center of an interval.


interval2center(Interval)

Example:
interval2center(2..5) returns 7/2

inv Returns the inverse of an expression or matrix.


inv(Expr) or inv(Matrix)

Example:
inv(9/5) returns 5/9

iPart Returns a real number without its fractional part or a list of real
numbers each without its fractional part.
iPart(Real) or iPart(List)

Example:
iPart(4.3) returns 4

Functions and commands 189


iquorem Returns the Euclidean quotient and remainder of two integers.
iquorem(Integer1, Integer2)

Example:
iquorem(63, 23) returns [2, 17]

jacobi_symbol Returns the Jacobi symbol of the given integers.


jacobi_symbol(Integer1, Integer2)

Example:
jacobi_symbol(132,5) gives -1

laplacian Returns the Laplacian of an expression with respect to a vector


of variables.
laplacian(Expr, Vector)

Example:
laplacian(exp(z)*cos(x*y),[x,y,z]) returns
–x^2*cos(x*y)*exp(z)-
y^2*cos(x*y)*exp(z)+cos(x*y)*exp(z)

lcoeff Returns the coefficient of the term of highest degree of a


polynomial. The polynomial can be expressed in symbolic
form or as a list.
lcoeff(Poly) or lcoeff(List) or lcoeff(Vector)

Example:
lcoeff(-2*x^3+x^2+7*x) returns -2

legendre_symbol With a single integer n, returns the Legendre polynomial of


degree n. With two integers, returns the Legendre symbol of
the second integer, using the Legendre polynomial whose
degree is the first integer.
legendre_symbol(Integer1, [Integer2])

Example:
legendre(4) gives 35*x^4/8+-15*x^2/4+3/8 while
legendre(4,2) returns 443/8 after simplification

length Returns the length of a list, string or set of objects.


length(List) or length(String) or
length(Object1, Object2,…)

Example:
length([1,2,3]) gives 3

190 Functions and commands


lgcd Returns the greatest common divisor of a set of integers or
polynomials, contained in a list, a vector, or just entered
directly as arguments.
lgcd(List) or lgcd(Vector) or lgcd(Integer1,
Integer2, …) or lgcd(Poly1, Poly2, …)

Example:
lgcd([45,75,20,15]) gives 5

lin Returns an expression with the exponentials linearized.


lin(Expr)

Example:
lin((exp(x)^3+exp(x))^2) gives
exp(6*x)+2*exp(4*x)+exp(2*x)

linear_interpolate Takes a regular sample from a polygonal line defined by a


matrix of two rows.
linear_interpolate(Matrix,Xmin,Xmax,Xstep)

Example:
linear_interpolate([[1,2,6,9],[3,4,6,7]],1,9,
1) returns
[[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0],
[3.0,4.0,4.5,5.0,5.5,6.0,6.33333333333,6.6666
6666667,7.0]

linear_regression Given a set of points, returns a vector containing the


coefficients a and b of y=a*x+b, the linear which best fits the
set of points. The points may be the elements in two lists or the
rows of a matrix.
linear_regression(Matrix) or
linear_regression(List1, List2)

Example:

 1.0 2.0 
 
linear_regression  0.0 1.0  returns [1.53…, 0.769…]
 
 4.0 7.0 

list2mat Returns a matrix of n columns made by splitting a list into


rows, each containing n terms. If the number of elements in
the list is not divisible by n, then the matrix is completed with
zeros.
list2mat(List, Integer)

Functions and commands 191


Example:

1
list2mat({1,8,4,9},1) returns 8
4
9

lname Returns a list of the variables in an expression.


lname(Expr)

Example:
lname(exp(x)*2*sin(y)) gives [x,y]

lnexpand Returns the expanded form of a logarithmic expression.


lnexpand(Expr)

Example:
lnexpand(ln(3*x)) gives ln(3)+ln(x)

logarithmic_ Given a set of points, returns a vector containing the


regression coefficients a and b of y=a*ln(x)+b, the natural logarithmic
function which best fits the set of points. The points may be the
elements in two lists or the rows of a matrix.
logarithmic_regression(Matrix) or
logarithmic_regression(List1, List2)

Example:
1.0 1.0
logarithmic_regression 2.0 4.0 returns
3.0 9.0
4.0 9.0
[6.3299…, 0.7207…]

logb Returns the logarithm of base b of a.


logb(a,b)

Example:
logb(5,2) gives ln(5)/ln(2) which is approximately
2.32192809489

logistic_ Returns y, y', C, y'max, xmax, and R, where y is a logistic


regression function (the solution of y'/y=a*y+b), such that y(x0)=y0 and
where [y'(x0),y'(x0+1)...] is the best approximation of the line
formed by the elements in the list L.
logistic_regression(Lst(L),Real(x0),Real(y0))

192 Functions and commands


Example:
logistic_regression([0.0,1.0,2.0,3.0,4.0],0.0
,1.0) gives [-17.77/(1+exp(-
0.496893925384*x+2.82232341488+3.14159265359*
i)),-2.48542227469/(1+cosh(-
0.496893925384*x+2.82232341488+3.14159265359*
i))]

lvar Given an expression, returns a list of the functions of the


expression which utilize variables, including occurrences of
the variables themselves.
lvar(Expr)

Example:
lvar(e^(x)*2*sin(y) + ln(x)) returns [e^(x)
sin(y) ln(x)]

map There are two uses for this function, in which the second
argument is always a mapping of a variable onto an
expression. If the expression is a function of the variable, the
function is applied to each element in the vector or matrix (the
first argument) and the resulting vector or matrix is returned; if
the expression is a Boolean test, each element in the vector or
matrix is tested and the results are returned as a vector or
matrix. Each test returns either 0 (fail) or 1 (pass).
map(Matrix, Var → Function) or map(Matrix, Var → Test)

Examples:
map([1 2 3], x→x3) returns [1 8 27]

map([1 2 3], x→ x>1) returns [0 1 1]

mat2list Returns a vector containing the elements of a matrix.


mat2list(Matrix)

Example:
mat2list([[1 8],[4 9]]) gives [1 8 4 9]

matpow Given a matrix and an integer n, returns the nth power of the
matrix by jordanization.
matpow(Matrix, Integer)

Functions and commands 193


Example:
matpow([[1,2],[3,4]],n) gives [[(sqrt(33)-
3)*((sqrt(33)+5)/2)^n*-6/(-12*sqrt(33))+(-
(sqrt(33))-3)*((-(sqrt(33))+5)/2)^n*6/(-
12*sqrt(33)),(sqrt(33)-3)*((sqrt(33)+5)/
2)^n*(-(sqrt(33))-3)/(-12*sqrt(33))+(-
(sqrt(33))-3)*((-(sqrt(33))+5)/2)^n*(-
(sqrt(33))+3)/(-
12*sqrt(33))],[6*((sqrt(33)+5)/2)^n*-6/(-
12*sqrt(33))+6*((-(sqrt(33))+5)/2)^n*6/(-
12*sqrt(33)),6*((sqrt(33)+5)/2)^n*(-
(sqrt(33))-3)/(-12*sqrt(33))+6*((-
(sqrt(33))+5)/2)^n*(-(sqrt(33))+3)/(-
12*sqrt(33))]]

MAXREAL Returns the maximum real number that the HP Prime calculator
is capable of representing in Home and CAS views:
In the CAS, MAXREAL=1.79769313486*10308
In Home view, MAXREAL=9.99999999999E499

mean Returns the arithmetic mean of a list (with an optional list as a


list of weights). With a matrix as argument, returns the mean
of the columns.
mean(List1, [List2]) or mean(Matrix)

Example:
mean([1,2,3],[1,2,3]) gives 7/3

median Returns the median of a list (with an optional list as a list of


weights). With a matrix as argument, returns the median of
the columns.
median(List1, [List2]) or median(Matrix)

Example:
median([1,2,3,5,10,4]) gives 3.0

member Given a list or vector and an element, returns the index of the
first occurrence of the element in the list or vector; if the
element does not appear in the list or vector, returns 0. Similar
to contains, except that the element comes first in the
argument order.
member(( Element, List) or contains(Element,
Vector)

Example:
member(2, {0,1,2,3}) returns 3

194 Functions and commands


MINREAL Returns the minimum real number (closest to zero) that the HP
Prime calculator is capable of representing in Home and CAS
views:
In the CAS, MINREAL=2.22507385851*10 -308
In Home view, MINREAL=1 E-499

modgcd Uses the modular algorithm to return the greatest common


divisor of two polynomials.
modgcd(Poly1,Poly2)

Example:
modgcd(x^4-1,(x-1)^2) gives x-1

mRow Given an expression, a matrix, and an integer n, multiplies


row n of the matrix by the expression.
mRow(Expr, Matrix, Integer)

Example:

 1 2  12 24
 
mRow  12, 3 4 , 1 returns 3 4
 
 5 6  5 6

mult_c_conjugate If the given complex expression has a complex denominator,


returns the expression after both the numerator and the
denominator have been multiplied by the complex conjugate
of the denominator. If the given complex expression does not
have a complex denominator, returns the expression after
both the numerator and the denominator have been
multiplied by the complex conjugate of the numerator.
mult_c_conjugate(Expr)

Example:
1 1 ⋅ ( 3 + 2 ⋅ –i )
mult_c_conjugate  ------------------- returns ---------------------------------------------------------
3+2⋅i ( 3 + 2 ⋅ i ) ⋅ ( 3 + 2 ⋅ –i )

mult_conjugate Takes an expression in which the numerator or the


denominator contains a square root. If the denominator
contains a square root, returns the expression after both the
numerator and the denominator have been multiplied by the
conjugate of the denominator. If the denominator does not
contain a square root, returns the expression after both the
numerator and the denominator have been multiplied by the
conjugate of the numerator.
mult_conjugate(Expr)

Functions and commands 195


Example:
( 3 – 2) ⋅ ( 3 + 2)
mult_conjugate ( 3 – 2 ) returns ----------------------------------------------------------
3+ 2

nDeriv Given an expression, a variable of differentiation, and a real


number h, returns an approximate value of the derivative of
the expression, using f’(x)=(f(x+h)–f(x+h))/(2*h).
Without a third argument, the value of h is set to 0.001; with
a real as third argument, it is the value of h. With a variable
as the third argument, returns the expression above with that
variable in place of h.
nDeriv(Expr,Var, Real) or
nDeriv(Expr, Var1, Var2)

Example:
nDeriv(f(x),x,h) returns (f(x+h)-(f(x-h)))*0.5/h

NEG Unary minus. Enters the negative sign.

normal Returns the expanded irreducible form of an expression.


normal(Expr)

Example:
normal(2*x*2) gives 4*x

normalize Given a vector, returns it divided by its l2 norm (where the l2


norm is the square root of the sum of the squares of the
vector’s coordinates).
Given a complex number, returns it divided by its modulus.
normalize(Vector) or normalize(Complex)

Example:
normalize(3+4*i) gives (3+4*i)/5

NOT Returns the logical inverse of a Boolean expression.


not(Expr)

odd Returns 1 if a given integer is odd, and returns 0 otherwise.


odd(Integer)

Example:
odd(6) gives 0

196 Functions and commands


OR Logical Or. Returns 1 if either or both sides evaluates to true
and 0 otherwise.
Expr1 OR Expr2

Example:
3 +1==4 OR 8 < 5 returns 1

order_size Returns the remainder (O term) of a series expansion:


limit(x^a*order_size(x),x=0)=0 if a>0.
order_size(Expr)

pa2b2 Takes a prime integer n congruent to 1 modulo 4 and returns


[a,b] such that a^2+b^2=n.
pa2b2(Integer)

Example:
pa2b2(17) gives [4 1]

pade Returns the Pade approximation of an expression, i.e. a


rational fraction P/Q such that P/Q=Expr mod x^(n+1) or
mod N with degree(P)<p.
pade(Expr, Var, Integern, Integerp)

Example:
2
– 3 ⋅ x – 24 ⋅ x – 60
pade(exp(x), x, 5, 3) returns ------------------------------------------------------------
3 2
-
x – 9 ⋅ x + 36 ⋅ x – 60

PI Inserts π.

PIECEWISE Used to define a piecewise-defined function. Takes as


arguments pairs consisting of a condition and an expression.
Each of these pairs defines a sub-function of the piecewise
function and the domain over which it is active.

 Case1 if Test1

PIECEWISE  Case2 if Test2

 ...

Example:

 – x if x < 0
PIECEWISE  2
 x if x ≥ 0

Note that the syntax varies if the Entry setting is not set to
Textbook:
PIECEWISE(Case1, Test1, ...[ Casen, Testn])

Functions and commands 197


plotinequation
Shows the graph of the solution of inequations with 2
variables.
plotinequation(Expr,[x=xrange,y=yrange],[xste
p],[ystep])

polar_point Given the radius and angle of a point in polar form, returns
the point with rectangular coordinates in complex form.
polar_point(Radius, Angle)

Example:

polar_point(2, π/3) returns point  2 ⋅  1 i ⋅ 3 


--- + -------------
2 2 

pole Given a circle and a line, returns the point for which the line
is polar with respect to the circle.
pole(Crcle,Line)

Example:
pole(circle(0, 1), line(1+i, 2)) returns
point(1/2,1/2)

POLYCOEF Returns the coefficients of a polynomial with roots given in the


vector or list argument.
POLYCOEF(Vector) or POLYCOEF(List)

Example:
POLYCOEF({-1, 1}) returns {1, 0, -1}

POLYEVAL Given a vector or list of coefficients and a value, evaluates the


polynomial given by those coefficients at the given value.
POLYEVAL(Vector, Value) or POLYEVAL(List,
Value)

Example:
POLYEVAL({1,0,-1},3) returns 8

polygon Draws the polygon whose vertices are elements in a list.


polygon(Point1, Point2, …, Pointn)

Example:
polygon(GA,GB,GD) draws ΔABD

198 Functions and commands


polygonplot Used in the Geometry app Symbolic view. Given an n × m
matrix, draws and connects the points (xk, yk), where xk is the
element in row k and column 1, and yk is the element in row
k and column j (with j fixed for k=1 to n rows). Thus, each
column pairing generates its own figure, resulting in m–1
figures.
polygonplot(Matrix)

Example:

 1 2 3
 
polygonplot  2 0 1  draws two figures, each with three
 
 –1 2 3 
points connected by segments.

polygonscatterplot Used in the Geometry app Symbolic view. Given an n × m matrix,


draws and connects the points (xk, yk), where xk is the element in
row k and column 1, and yk is the element in row k and column j
(with j fixed for k=1 to n rows). Thus, each column pairing
generates its own figure, resulting in m-– figures.
polygonscatterplot(Matrix)

Example:

 1 2 3
 
polygonscatterplot  2 0 1  draws two figures, each
 
 –1 2 3 
with three points connected by segments.

polynomial_ Given a set of points defined by two lists, and a positive


regression integer n, returns a vector containing the coefficients (an, an–1
... a0) of y = an*xn + an–1xn–1+ ... a1*x + a0), the nth order
polynomial which best approximates the given points.
polynomial_regression(List1, List2, Integer)

Example:
polynomial_regression({1, 2, 3, 4}, {1, 4, 9,
16},3) returns [0 1 0 0]

POLYROOT Returns the zeros of the polynomial given as a vector of


coefficients.
POLYROOT(Vector)

Example:
POLYROOT([1 0 -1]) returns {-1, 1}

Functions and commands 199


potential Returns a function whose gradient is the vector field defined
by a vector and a vector of variables.
potential(Vector1, Vector2)

Example:
potential([2*x*y+3,x^2-4*z,-4*y],[x,y,z])
returns x2*y+3*x-4*y*z

power_regression Given a set of points defined by two lists, returns a vector


containing the coefficients m and b of y=b*x^m, the
monomial which best approximates the given points.
power_regression(List1, List2)

Example:
power_regression({1, 2, 3, 4}, {1, 4, 9, 16})
returns [2 1]

powerpc Given a circle and a point, returns the real number d2–r2,
where d is the distance between the point and the center of
the circle, and r is the radius of the circle.
powerpc(Circle, Point)

Example:
powerpc(circle(0,1+i),3+i) gives 8

prepend Adds an element to the beginning of a list or vector.


prepend(List, Element) or
prepend(Vector, Element)

Example:
prepend([1,2],3) gives [3,1,2]

primpart Returns a polynomial divided by the greatest common divisor


of its coefficients.
primpart(Poly,[Var])

Example:
primpart(2x^2+10x+6) gives x^2+5*x+3

product With an expression as the first argument, returns the product


of solutions when the variable in the expression goes from a
minimum value to a maximum value by a given step. If no step
is provided, it is taken as 1.
With a list as the first argument, returns the product of the
values in the list.

200 Functions and commands


With a matrix as the first argument, returns the element-by-
element product of the matrix.
product(Expr, Var, Min, Max, Step) or
product(List) or product(Matrix)

Example:
product(n,n,1,10,2) gives 945

propfrac Returns a fraction or rational fraction A/B simplified to Q+r/


B, where R<B or the degree of R is less than the degree of B.
propfrac(Fraction) or propfrac(RatFrac)

Example:
propfrac(28/12) gives 2+1/3

ptayl Given a polynomial P and a value a, returns the Taylor


polynomial Q such that P(x)=Q(x – a).
ptayl(Poly, Value, [Var])

Example:
ptayl(x^2+2*x+1,1) gives x^2+4*x+4

purge Unassigns a variable name.


purge(Var)

q2a Given a quadratic form and a vector of variables, returns the


matrix of the quadratic form with respect to the given
variables.
q2a(Expr, Vector)

Example:

q2a(x^2+2*x*y+2*y^2,[x,y]) returns 1 1
1 2

quantile Given a list or vector, and a quantile value between 0 and 1,


returns the corresponding quantile of the elements of the list
or vector.
quantile(List, Value) or
quantile(Vector, Value)

Example:
quantile([0,1,3,4,2,5,6],0.25) returns 1

Functions and commands 201


quartile1 Given a list or vector, returns the first quartile of the elements
of the list or vector. Given a matrix, returns the first quartile of
the columns of the matrix.
quartile1(List) or quartile1(Vector) or
quartile1(Matrix)

Example:
quartile1([1,2,3,5,10,4]) gives 2

quartile3 Given a list or vector, returns the third quartile of the elements
of the list or vector. Given a matrix, returns the third quartile
of the columns of the matrix.
quartile3(List) or quartile3(Vector) or
quartile3(Matrix)

Example:
quartile3([1,2,3,5,10,4]) returns 5

quartiles Returns a matrix containing the minimum, first quartile,


median, third quartile, and maximum of the elements of a list
or vector. With a matrix as argument, returns the 5-number
summary of the columns of the matrix.
quartiles(List) or quartiles(Vector) or
quartiles(Matrix)

Example:
1
2
quartiles([1,2,3,5,10,4]) returns 3
5
10

quorem Returns the Euclidean quotient and remainder of the quotient


of two polynomials, each expressed either in symbolic form
directly or as a vector of coefficients. If the polynomials are
expressed as vectors of their coefficients, this command
returns a similar vector of the quotient and a vector of the
remainder.
quorem(Poly1, Poly2) or quorem(Vector1,
Vector2)

Examples:
quorem(x^3+2*x^2+3*x+4,-x+2) returns [-x^2-4*x-
11, 26]

quorem([1,2,3,4],[-1,2]) returns [[-1, -4, -11]


[26]]

202 Functions and commands


QUOTE Returns an expression unevaluated.
quote(Expr)

randexp Given a positive real number, returns a random real number


according to the exponential distribution with real a>0.
randexp(Real)

randperm Given a positive integer, returns a random permutation of


[0,1,2,...,n–1].
randperm(Intg(n))

Example:
randperm(4) returns a random permutation of the elements of
the vector [0 1 2 3]

ratnormal Rewrites an expression as an irreducible rational fraction.


ratnormal(Expr)

Example:

x –1  2  x+1
- returns -------------------------
ratnormal  ---------------
3  x – 1 2
x +x+1

rectangular_ Given a vector containing the polar coordinates of a point,


coordinate returns a vector containing the rectangular coordinates of the
point.
rectangular_coordinates(Vector)

Example:

2 -------
rectangular_coordinates([1, π/4]) returns ------- 2
2 2

reduced_conic Takes a conic expression and returns a vector with the


following items:
• The origin of the conic
• The matrix of a basis in which the conic is reduced
• 0 or 1 (0 if the conic is degenerate)
• The reduced equation of the conic
• A vector of the conic’s parametric equations
reduced_conic(Expr, [Vector])

Functions and commands 203


Example:
reduced_conic(x^2+2*x-2*y+1) returns

[[− 1 0]] 
0 1 2   1  2  −1  
 1 y + 2 ⋅ x − 1 + −i ⋅  − 2 ⋅ x ⋅ x + i ⋅ x  x − 4 4 0.1 x + 2 ⋅ x − 2 ⋅ y + 1 − 1 + ( −i ) ⋅  2 ⋅ x ⋅ x + (i ) ⋅ x  
 − 1 0      

ref Performs Gaussian reduction of a matrix.


ref(Matrix)

Example:

1 2
--- –
ref 3 1 – 2 returns 1 3 3
------
3 2 2
0 1 2

remove Given a vector or list, removes the occurrences of Value or


removes the values that make Test true and returns the
resulting vector or list.
remove(Value, List) or remove(Test, List)

Examples:
remove(5,{1,2,5,6,7,5}) returns {1,2,6,7}

remove(x→x≥5, [1 2 5 6 7 5]) returns [1 2]

reorder Given an expression and a vector of variables, reorders the


variables in the expression according to the order given in the
vector.
reorder(Expr, Vector)

Example:
reorder(x2+2*x+y2,[y,x]) gives y2+x2+2*x

residue Returns the residue of an expression at a value.


residue(Expr, Var, Value)

Example:
residue(1/z,z,0) returns 1

restart Purges all the variables.


restart(NULL)

resultant Returns the resultant (i.e. the determinant of the Sylvester


matrix) of two polynomials.
resultant(Poly1, Poly2, Var)

204 Functions and commands


Example:
resultant(x^3+x+1, x^2-x-2,x) returns -11

revlist Reverses the order of the elements in a list or vector.


revlist(List) or revlist(Vector)

Example:
revlist([1,2,3]) returns [3,2,1]

romberg Uses Romberg’s method to return the approximate value of a


definite integral.
romberg(Expr, Var, Val1, Val2)

Example:
romberg(exp(x^2),x,0,1) gives 1.46265174591

row Given a matrix and an integer n, returns the row n of the


matrix. Given a matrix and an interval, returns a vector
containing the rows of the matrix indicated by the interval.
row(Matrix, Integer) or row(Matrix, Interval)

Example:

 1 2 3 
 
row  4 5 6 , 2 returns [4 5 6]
 
 7 8 9 

rowAdd Given a matrix and two integers, returns the matrix obtained
from the given matrix after the row indicated by the second
integer is replaced by the sum of the rows indicated by the
two integers.
rowAdd(Matrix, Integer1, Integer2)

Example:

 1 2  1 2
 
rowAdd  3 4 , 1, 2 returns 4 6
 
 5 6  5 6

rowDim Returns the number of rows of a matrix.


rowDim(Matrix)

Example:
 
rowDim  1 2 3  gives 2
 4 5 6

Functions and commands 205


rowSwap Given a matrix and two integers, returns the matrix obtained
from the given matrix after swapping the two rows indicated
by the two integers.
rowSwap(Matrix,Integer1,Integer2)

Example:

 1 2  3 4
 
rowSwap  3 4 , 1, 2 returns 1 2
 
 5 6  5 6

rsolve Given an expression defining a recurrence relation, a


variable, and an initial condition, returns the closed form
solution (if possible) of the recurrent sequence. Given three
lists, each containing multiple items of the above nature,
solves the system of recurrent sequences.
rsolve(Expr, Var, Condition) or rsolve(List1,
List2, List3)

Example:
rsolve(u(n+1)=2*u(n)+n,u(n),u(0)=1) returns
[-n+2*2n-1]

select Given a test expression in a single variable and a list or


vector, tests each element in the list or vector and returns a list
or vector containing the elements that satisfy the test.
select(Test, List) or select(Test, Vector)

Example:
select(x→x>=5,[1,2,6,7]) returns [6,7]

seq Given an expression, a variable defined over an interval, and


a step value, returns a vector containing the sequence
obtained when the expression is evaluated within the given
interval using the given step. If no step is provided, the step
used is 1.
seq(Expr, Var=Interval, [Step])

Example:
seq(2k,k=0..8) gives [1,2,4,8,16,32,64,128,256]

seqsolve Similar to rsolve. Given an expression defining a recurrence


relation in terms of n and/or the previous term (x), followed
by a vector of variables and an initial condition for x (the 0th
term), returns the closed form solution (if possible) for the
recurrent sequence. Given three lists, each containing multiple

206 Functions and commands


items of the above nature, solves the system of recurrent
sequences.
seqsolve(Expr, Vector, Condition) or
seqsolve(List1, List2, List3)

Example:
seqsolve(2x+n,[x,n],1) gives -n-1+2*2n

shift_phase Returns the result of applying a phase shift of pi/2 to a


trigonometric expression.
shift_phase(Expr)

Example:
shift_phase(sin(x)) gives -cos((pi+2*x)/2)

signature Returns the signature of a permutation.


signature(Vector)

Example:
signature([2 1 4 5 3]) returns –1

simult Returns the solution to a system of linear equations or several


systems of linear equations presented in matrix form. In the
case of one system of linear equations, takes a matrix of
coefficients and a column matrix of constants, and returns the
column matrix of the solution.
simult(Matrix1, Matrix2)

Example:

 
simult  3 1 , – 2  returns – 2
 3 2 2  4

sincos Returns an expression with the complex exponentials rewritten


in terms of sin and cos.
sincos(Expr)

Example:
sincos(exp(i*x)) gives cos(x)+(i)*sin(x)

Functions and commands 207


spline Given two lists or vectors (one for the x-values and one for the
y-values), as well as a variable and an integer degree, returns
the natural spline through the points given by the two lists. The
polynomials in the spline are in terms of the given variable and
are of the given degree.
spline(ListX, ListY, Var, Integer) or
spline(VectorX, VectorY, Var, Integer)

Example:
spline({0,1,2},{1,3,0},x,3) returns
5 3 13
–------ 5 3
--- ⋅ ( x – 1 ) + –
15- 2 1
⋅ x + ------- ⋅ x + 1 --------- ⋅ ( x – 1 ) – --- ⋅ ( x – 1 ) + 3
4 4 4 4 2

sqrt Returns the square root of an expression.


sqrt(Expr)

Example:
sqrt(50) gives 5*sqrt(2)

stddev Returns the standard deviation of the elements of a list or a list


of the standard deviations of the columns of a matrix. The
optional second list is a list of weights.
stddev(List1, [List2]) or
stddev(Vector1, [Vector2]) or stddev(Matrix)

Example:

6
stddev({1,2,3}) returns -------
3

stddevp Returns the population standard deviation of the elements of a list


or a list of the population standard deviations of the columns of a
matrix. The optional second list is a list of weights.
stddevp(List1, [List2]) or
stddevp(Vector1, [Vector2]) or
stddevp(Matrix)

Example:
stddevp({1,2,3}) gives 1

sto Stores a real or string in a variable.


sto((Real or Str),Var)

sturmseq Returns the Sturm sequence for a polynomial or a rational


fraction.
sturmseq(Poly,[Var])

208 Functions and commands


Example:
sturmseq(x^3-1,x) gives [1 [[1 0 0 -1] [3 0 0] 9] 1]

subMat Extracts from a matrix a sub matrix whose diagonal is defined


by four integers. The first two integers define the row and
column of the first element and the last two integers define the
row and column of the last element of the sub matrix.
subMat(Matrix, Int1, Int2, Int3, Int4)

Example:

 1 2 
 
subMat  3 4 , 2, 1, 3, 2 returns 3 4
  5 6
 5 6 

suppress Given a list and an element, deletes the first occurrence of the
element in the list (if there is one) and returns the result.
suppress(List, Element)

Example:
suppress([0 1 2 3 2],2) returns [0 1 3 2]

surd Given an expression and an integer n, returns the expression


raised to the power 1/n.
surd(Expr, Integer)

Example:
surd(8,3) gives 2

sylvester Returns the Sylvester matrix of two polynomials.


sylvester(Poly1, Poly2, Var)

Example:

1 0 –1 0 0
0 1 0 –1 0
sylvester(x2-1,x3-1,x) gives 0 0 1 0 –1
1 0 0 –1 0
0 1 0 0 –1

table Defines an array where the indexes are strings or real


numbers.
table(SeqEqual(index_name=element_value))

Functions and commands 209


tail Given a list, string, or sequence of objects, returns a vector
with the first element deleted.
tail(List) or tail(Vector) or tail(String) or
tail(Obj1, Obj2,…)

Example:
tail([3 2 4 1 0]) gives [2 4 1 0]

tan2cossin2 Returns an expression with tan(x) rewritten as (1–cos(2*x))/


sin(2*x).
tan2cossin2(Expr)

Example:
tan2cossin2(tan(x)) gives (1-cos(2*x))/sin(2*x)

tan2sincos2 Returns an expression with tan(x) rewritten as sin(2*x)/


(1+cos(2*x)).
tan2sincos2(Expr)

Example:
tan2sincos2(tan(x)) gives sin(2*x)/(1+cos(2*x)

transpose Returns a matrix transposed (without conjugation).


transpose(Matrix)

Example:

 
transpose  1 2  returns 1 3
 3 4 2 4

trunc Given a value or list of values, as well as an integer n, returns


the value or list truncated to n decimal places. If n is not
provided, it is taken as 0. Accepts complex numbers.
trunc(Real, Integer) or trunc(List, Integer)

Example:
trunc(4.3) gives 4

tsimplify Returns an expression with transcendentals rewritten as


complex exponentials.
tsimplify(Expr)

Example:
tsimplify(exp(2*x)+exp(x)) gives
exp(x)^2+exp(x)

210 Functions and commands


type Returns the type of an expression (e.g. list, string).
type(Expr)

Example:
type("abc") gives DOM_STRING

unapply Returns the function defined by an expression and a variable.


unapply(Expr,Var)

Example:
unapply(2*x^2,x) gives (x)→2*x^2

valuation Returns the valuation (degree of the term of lowest degree) of


a polynomial. With only a polynomial as argument, the
valuation returned is for x. With a variable as second
argument, the valuation is performed for it.
valuation(Poly,[Var])

Example:
valuation(x^4+x^3) gives 3

variance Returns the variance of a list or the list of variances of the


columns of a matrix. The optional second list is a list of
weights.
variance(List1, [List2]) or variance(Matrix)

Example:
variance({3, 4, 2}) returns 2/3

vpotential Given a vector V and a vector of variables, returns the vector


U such that curl(U)=V.
vpotential(Vector1, Vector2)

Example:
vpotential([2*x*y+3,x2-4*z,-2*y*z],[x,y,z])
1 3
returns 0 –2 ⋅ x ⋅ y ⋅ z 4 ⋅ x ⋅ z – --- ⋅ x + 3 ⋅ y
3

when Used to introduce a conditional statement.

XOR Exclusive or. Returns 1 if the first expression is true and the
second expression is false or if the first expression is false and
the second expression is true. Returns 0 otherwise.
Expr1 XOR Expr2

Functions and commands 211


Example:
0 XOR 1 returns 1

zip Applies a bivariate function to the elements of two lists or


vectors and returns the results in a vector. Without the default
value the length of the vector is the minimum of the lengths of
the two lists; with the default value, the shorter list is padded
with the default value.
zip(‘function’List1, List2, Default) or
zip(‘function’, Vector1, Vector2, Default)

Example:
zip('+',[a,b,c,d], [1,2,3,4]) returns [a+1 b+2
c+3 d+4]

| Inserts a template for substituting a value for a variable in an


expression.
Expr|Var1=Val1, [Var2=Val2, …]
2
Returns the square of an expression.
(Expr)2

π Inserts pi.

∂ Inserts a template for a partial derivative expression.

Σ Inserts a template for a summation expression.

− Inserts a minus sign.

√ Inserts a square root sign.

 Inserts a template for an antiderivative expression.

≠ Inequality test. Returns 1 if the left and right sides are not
equal and 0 if they are equal.

≤ Less than or equal inequality test. Returns 1 if the left side of


the inequality is less than the right side or if the two sides are
equal, and 0 otherwise.

≥ Greater than or equal inequality test. Returns 1 if the left side


of the inequality is greater than the right side or if the two
sides are equal, and 0 otherwise.

 Evaluates the expression then stores the result in variable var.


Note that  cannot be used with the graphics G0–G9. See the
command BLIT.

212 Functions and commands


expression  var

i Inserts the imaginary number i.


–1
Returns the inverse of an expression.
(Expr)–1

Creating your own functions


You can create your own function by writing a program (see
chapter 5) or by using the simpler DEFINE functionality.
Functions you create yourself appear on the User menu (one
of the Toolbox menus).

Suppose you wanted to create the function


SINCOS(A,B)=SIN(A)+COS(B)+C.

1. Press Sd (Define).
2. In the Name field, enter
a name for the
function—for example,
SINCOS—and tap
.
3. In the Function field,
enter the function.
eAA>+fAB>AC
New fields appear
below your function, one
for each variable used in
defining it. You need to
decide which ones are
to be input arguments
for your functions and
which ones are global
variables whose values
are not input within the function. In this example, we’ll
make A and B input variables, so our new function takes
two arguments. The value of C will be provided by global
variable C (which by default is zero).
4. Make sure that A and B are selected and C is not.

Functions and commands 213


5. Tap .
You can run your function by entering it on the entry line
in Home view, or be selecting it from the USER menu. You
enter the value for each variable you chose to be a
parameter. In this example. we chose A and B to be
parameters. Thus you might enter SINCOS(0.5, 0.75).
With C=0 and in radians mode, this would return
1.211…

214 Functions and commands


4

Variables
Variables are objects that have names and contain data.
They are used to store data, either for later use or to
control settings in the Prime system. There are four types of
variables, all of which can be found in the Vars menu by
pressing a:
• Home variables
• CAS variables
• App variables
• User variables
The Home and app
variables all have names
reserved for them. They
are also typed; that is, they can contain only certain types
of objects. For example, the Home variable A can only
contain a real number. You use Home variables to store
data that is important to you, such as matrices, lists, real
numbers, etc. You use app variables to store data in apps
or to change app settings. You can accomplish these
same tasks via the user interface of an app, but app
variables give you a quick way of doing these tasks, either
from Home or within a program. For example, you can
store the expression “SIN(X)” in the Function app
variable F1 in Home View, or you could open the Function
app, navigate to F1(X), and enter SIN(X) in that field.
CAS and user variables can be created by the user and
they have no particular type. Their names may be of any
length as well. Thus, diff(t2,t) returns 2*t and
diff((bt)2, bt) returns 2*bt for the CAS variables
t and bt. Further evaluation of 2*bt will only return
2*bt, unless an object has been stored in bt. For
example, if you enter bt:={1,2,3} and then enter
diff((bt)2, bt), the CAS will still return 2*bt. But if

Variables 215
you evaluate that result (using the EVAL command), the
CAS will now return {2,4,6}.
User variables are explicitly created by the user. You
create user variables either in a program or by assignment
in Home view. User variables created in a program are
either declared as local or exported as global. User
variables created by assignment or exported from a
program will show up in the Vars User menu. Local
variables exist only within their own program.
The following sections describe the various processes
associated with variables, such as creating them, storing
objects in them, and retrieving their contents. The rest of
the chapter contains tables that list all the Home and app
variable names.

Working Example 1: Assign π2 to the Home variable A and then


with Home calculate 5*A.
variables 1. Press H to display Home view.
2. Assign π2 to A:
Szj AaE
The result is written
to history.
3. Multiply A by 5:
5s
AaE
This example illustrates
the process for storing
and using any Home variable, not just the Real Home
variables A–Z. It is important to match the object you want
to store to the correct type of Home variable. See “Home
variables” on page 220 for details.

216 Variables
Working Example 2: Create a variable called ME and assign π2
with user to it.
variables 1. Press H to display Home view.
2. Assign π2 to ME:
Szj AQAcE
3. A message appears asking if you want to create a
variable called ME. Tap or press E to
confirm your intention.
You can now use that variable in subsequent
calculations: ME*3 will yield 29.6…, for example.
Example 3: You can also store objects in variables
using the assignment operator: Name:=Object. In this
example, we’ll store {1,2,3} in the user variable YOU.
1. Assign the list to the variable using the assignment
operator:=.
AAxotwAS.
Sq 1o 2 o3 E
2. A message appears asking if you want to create a
variable called YOU. Tap or press E to
confirm your intention.
The variable YOU is created and contains the list
{1,2,3}. You can now use that variable in
subsequent calculations: For example, YOU+60 will
return {61,62,63}.

Working Just as you can assign values to Home and user variables,
with app you can assign values to app variables. You can modify
variables Home settings on the Home Settings screen (SH).
But you can also modify a Home setting from Home view
by assigning a value to the variable that represents that
setting. For example, entering Base:=0 E in Home
view forces the Home settings field Integer (for the
integer base) to binary. A value of 1 would force it to
octal, 2 to decimal, and 3 to hex. Another example: you
can change the angle measure setting from radians to
degrees by entering HAngle :=1 E in Home view.

Variables 217
Entering HAngle:=0 E forces the setting to return
to radians.
You can see what value has been assigned to a
variable—whether Home, app, or user—by entering its
name in Home view and pressing E. You can enter
the name letter by letter, or choose the variable from the
Variables menu by pressing a.

More about Besides the four variable menus, the Vars menu contains
the Vars a toggle. If you want the value of a variable instead of its
menu name when you choose it from the Vars menu, tap
. A white dot will appear next to the menu button
label to indicate that it is active and that variable values
rather than names will be returned upon selection.
For the Home and app variables, use the Vars menu to
get help on the purpose of any of these variables. Select
the variable of interest and press W. Suppose, for
example, that you wanted to get help on the Function app
variable GridDots:
1. Press a to open the Vars menu.
2. Tap to open
the app variables
menu. (If you were
interested in a Home
variable instead, you
would tap
instead.)
3. Use the cursor keys
to navigate to the variable of interest.
4. Press W to see the
help about that
variable.
5. Tap to exit or
J to return to the
current Vars
submenu.

218 Variables
Qualifying variables
Some app variable names are shared by multiple apps.
For example, the Function app has a variable named
Xmin, but so too does the Polar app, the Parametric app,
the Sequence app, and the Solve app. Although named
identically, these variables usually hold different values. If
you attempt to retrieve the contents of a variable that is
used in more than one app by entering just its name in
Home view, you will get the contents of that version of the
variable in the current app. For example, if the Function
app is active and you enter Xmin in Home view, you will
get the value of Xmin from the Function app. If you want
the value of Xmin from, say, the Sequence app, you must
qualify the variable name. Enter Sequence.Xmin to
retrieve the value of Xmin from the Sequence app.
In the figure to the right,
the value of Xmin from
the Function app was
retrieved first (–10.4…).
The qualified variable
name entered second
retrieved the value of
Xmin from the Sequence
app (–1.8).
Note the syntax required: app_name.variable_name.
The app can be any of the 18 HP apps, or one you have
created based on a built-in app. The name of the app
variable must match a name listed in the app variables
tables below. Spaces are not allowed in an app name
and must be represented by the underscore character:
SX.
Tip Non-standard characters in variables name—such as Σ
and σ—can be entered by selecting them from the special
symbols palette (Sr) or from the characters menu
(Sa ).

Variables 219
Home variables
The Home variables are accessed by pressing a and
tapping .

Category Names

Real A to Z and θ
For example, 7.45 A

Complex Z0 to Z9
For example, 2+3×i Z1 or
(2,3) Z1 (depending on your
Complex number settings)

List L0 to L9
For example, {1,2,3} L1.

Matrix M0 to M9
Store matrices and vectors in these
variables.
For example, [[1,2],[3,4]] M1.

Graphics G0 to G9

Settings HAngle
HFormat
HDigits
HComplex
Date
Time
Language
Entry
Integer
Base
Bits
Signed

220 Variables
App variables
The app variables are accessed by pressing a and
tapping . They are grouped below by app.
Note that if you have customized a built-in app, your app
will appear on the App variables menu under the name you
gave it. You access the variables in a customized app in the
same way that you access the variables in built-in apps.

Function app variables

Category Names

Results SignedArea Root


[explained Extremum Slope
below] Isect

Symbolic F1 F6
F2 F7
F3 F8
F4 F9
F5 F0

Plot Axes Xmin


Cursor Xtick
GridDots Xzoom
GridLines Ymax
Labels Ymin
Method Ytick
Recenter Yzoom
Xmax

Numeric NumStart NumType


NumStep NumZoom
NumIndep

Modes AAngle ADigits


AComplex AFormat

Results variables
Extremum Contains the value from the last use of the Extremum
function from the menu in the Plot view of the

Variables 221
Function app. The app function EXTREMUM does not store
results to this variable.

Isect Contains the value from the last use of the Isect function
from the menu in the Plot view of the Function app.
The app function ISECT does not store results to this
variable.

Root Contains the value from the last use of the Root function
from the menu in the Plot view of the Function app.
The app function ROOT does not store results to this
variable.

SignedArea Contains the value from the last use of the Signed Area
function from the menu in the Plot view of the
Function app. The app function AREA does not store
results to this variable.

Slope Contains the value from the last use of the Slope function
from the menu in the Plot view of the Function app.
The app function SLOPE does not store results to this
variable.

Geometry app variables


Category Names

Plot Axes GridDots


GridLines Labels
PixSize ScrollText
Xmax Xmin
Ymax Ymin
XTick YTick

Modes AAngle ADigits


AComplex AFormat

222 Variables
Spreadsheet app variables
Category Names

Numeric ColWidth RowHeight


Row Col
Cell

Modes AAngle ADigits


AComplex AFormat

Solve app variables


Category Names

Symbolic E1 E6
E2 E7
E3 E8
E4 E9
E5 E0

Plot Axes Xmin


Cursor Xtick
GridDots Xzoom
GridLines Ymax
Labels Ymin
Method Ytick
Recenter Yzoom
Xmax

Modes AAngle ADigits


AComplex AFormat

Variables 223
Advanced Graphing app variables
Category Names

Symbolic V1 V6
V2 V7
V3 V8
V4 V9
V5 V0

Plot Axes Xmin


Cursor Xtick
GridDots Xzoom
GridLines Ymax
Labels Ymin
Recenter Ytick
Xmax Yzoom

Numeric NumXStart NumIndep


NumYStart NumType
NumXStep NumXZoom
NumYStep NumYZoom

Modes AAngle ADigits


AComplex AFormat

224 Variables
Statistics 1Var app variables
Category Names

Results NbItem ΣX
MinVal ΣX2
[explained
below] Q1 MeanX
MedVal sX
Q3 σX
MaxVal serrX

Symbolic H1 H1Type
H2 H2Type
H3 H3Type
H4 H4Type
H5 H5Type

Plot Axes Xmax


Cursor Xmin
GridDots Xtick
GridLines Xzoom
Hmin Ymax
Hmax Ymin
Hwidth Ytick
Labels Yzoom
Recenter

Numeric D1 D6
D2 D7
D3 D8
D4 D9
D5 D0

Modes AAngle ADigits


AComplex AFormat

Variables 225
Results
NbItem Contains the number of data points in the current 1-
variable analysis (H1-H5).

MinVal Contains the minimum value of the data set in the current
1-variable analysis (H1-H5).

Q1 Contains the value of the first quartile in the current 1-


variable analysis (H1-H5).

MedVal Contains the median in the current 1-variable analysis


(H1-H5).

Q3 Contains the value of the third quartile in the current 1-


variable analysis (H1-H5).

MaxVal Contains the maximum value in the current 1-variable


analysis (H1-H5).

ΣX Contains the sum of the data set in the current 1-variable


analysis (H1-H5).

ΣX2 Contains the sum of the squares of the data set in the
current 1-variable analysis (H1-H5).

MeanX Contains the mean of the data set in the current 1-variable
analysis (H1-H5).

sX Contains the sample standard deviation of the data set in


the current 1-variable analysis (H1-H5).

σX Contains the population standard deviation of the data set


in the current 1-variable analysis (H1-H5).

serrX Contains the standard error of the data set in the current
1-variable analysis (H1-H5).

226 Variables
Statistics 2Var app variables
Category Names

Results NbItem sX
[explained Corr σX
below] CoefDet serrX
sCov MeanY
σCov ΣY
ΣXY ΣY2
MeanX sY
ΣX σY
ΣX2 serrY

Symbolic S1 S1Type
S2 S2Type
S3 S3Type
S4 S4Type
S5 S5Type

Plot Axes Xmin


Cursor Xtick
GridDots Xzoom
GridLines Ymax
Labels Ymin
Method Ytick
Recenter Yzoom
Xmax

Numeric C1 C6
C2 C7
C3 C8
C4 C9
C5 C0

Modes AAngle ADigits


AComplex AFormat

Variables 227
Results
NbItem Contains the number of data points in the current 2-
variable analysis (S1-S5).

Corr Contains the correlation coefficient from the latest


calculation of summary statistics. This value is based on
the linear fit only, regardless of the fit type chosen.

CoefDet Contains the coefficient of determination from the latest


calculation of summary statistics. This value is based on
the fit type chosen.

sCov Contains the sample covariance of the current 2-variable


statistical analysis (S1-S5).

σCov Contains the population covariance of the current 2-


variable statistical analysis (S1-S5).

ΣXY Contains the sum of the X·Y products for the current 2-
variable statistical analysis (S1-S5).

MeanX Contains the mean of the independent values (X) of the


current 2-variable statistical analysis (S1-S5).

ΣX Contains the sum of the independent values (X) of the


current 2-variable statistical analysis (S1-S5).

ΣX2 Contains the sum of the squares of the independent values


(X) of the current 2-variable statistical analysis (S1-S5).

sX Contains the sample standard deviation of the


independent values (X) of the current 2-variable statistical
analysis (S1-S5).

σX Contains the population standard deviation of the


independent values (X) of the current 2-variable statistical
analysis (S1-S5).

serrX Contains the standard error of the independent values (X)


of the current 2-variable statistical analysis (S1-S5).

MeanY Contains the mean of the dependent values (Y) of the


current 2-variable statistical analysis (S1-S5).

228 Variables
ΣY Contains the sum of the dependent values (Y) of the
current 2-variable statistical analysis (S1-S5).

ΣY2 Contains the sum of the squares of the dependent values


(Y) of the current 2-variable statistical analysis (S1-S5).

sY Contains the sample standard deviation of the dependent


values (Y) of the current 2-variable statistical analysis (S1-
S5).

σY Contains the population standard deviation of the


dependent values (Y) of the current 2-variable statistical
analysis (S1-S5).

serrY Contains the standard error of the dependent values (Y) of


the current 2-variable statistical analysis (S1-S5).

Inference app variables


Category Names

Results ContribList ContribMat


[explained Slope Inter
below] Corr CoefDet
serrLine serrSlope
serrInter Yval
serrY CritScore
Result CritVal1
TestScore CritVal2
TestValue DF
Prob

Symbolic AltHyp InfType


Method

Variables 229
Category Names

Numeric Alpha Pooled


Conf s1
ExpList s2
Mean1 σ1
Mean2 σ2
n1 x1
n2 x2
μ0 Xlist
π0 Ylist
ObsList Xval
ObsMat

Modes AAngle ADigits


AComplex AFormat

230 Variables
Results
CoefDet Contains the value of the coefficient of determination.

ContribList Contains a list of the chi-square contributions by category


for the chi-square goodness of fit test.

ContribMat Contains a matrix of the chi-square contributions by


category for the chi-square two-way test.

Corr Contains the value of the correlation coefficient.

CritScore Contains the value of the Z- or t-distribution associated


with the input α-value

CritVal1 Contains the lower critical value of the experimental


variable associated with the negative TestScore value
which was calculated from the input α-level.

CritVal2 Contains the upper critical value of the experimental


variable associated with the positive TestScore value
which was calculated from the input α-level.

DF Contains the degrees of freedom for the t-tests.

ExpList Contains a list of the expected counts by category for the


chi-square goodness of fit test.

ExpMat Contains the matrix of expected counts by category for the


chi-square two-way test.

Inter Contains the value of the intercept of the regression line


for either the linear t-test or the confidence interval for the
intercept

Prob Contains the probability associated with the TestScore


value.

Result For hypothesis tests, contains 0 or 1 to indicate rejection


or failure to reject the null hypothesis.

serrInter Contains the standard error of the intercept for either the
linear t-test or the confidence interval for the intercept.

Variables 231
serrLine Contains the standard error of the line for the linear t-test.

serrSlope Contains the standard error of the slope for either the
linear t-test or the confidence interval for slope.

serrY Contains the standard error of ŷ for either the confidence


interval for a mean response or the prediction interval for
a future response.

Slope Contains the value of the slope of the regression line for
either the linear t-test or the confidence interval for slope.

TestScore Contains the Z- or t-distribution value calculated from the


hypothesis test or confidence interval inputs.

TestValue Contains the value of the experimental variable


associated with the TestScore.

Yval Contains the value of ŷ for either the confidence interval


for a mean response or the prediction interval for a future
response.

232 Variables
Parametric app variables
Category Names

Symbolic X1 X6
Y1 Y6
X2 X7
Y2 Y7
X3 X8
Y3 Y8
X4 X9
Y4 Y9
X5 X0
Y5 Y0

Plot Axes Tstep


Cursor Xmax
GridDots Xmin
GridLines Xtick
Labels Xzoom
Method Ymax
Recenter Ymin
Tmin Ytick
Tmax Yzoom

Numeric NumStart NumType


NumStep NumZoom

Modes AAngle ADigits


AComplex AFormat

Variables 233
Polar app variables
Category Names

Symbolic R1 R6
R2 R7
R3 R8
R4 R9
R5 R0

Plot θmin Recenter


θmax Xmax
θstep Xmin
Axes Xtick
Cursor Xzoom
GridDots Ymax
GridLines Ymin
Labels Ytick
Method Yzoom

Numeric NumIndep NumType


NumStart NumZoom
NumStep

Modes AAngle ADigits


AComplex AFormat

Finance app variables

Category Names

Numeric CPYR NbPmt


BEG PMT
FV PPYR
IPYR PV
GSize

Modes AAngle ADigits


AComplex AFormat

234 Variables
Linear Solver app variables

Category Names

Numeric LSystem LSolutiona

Modes AAngle ADigits


AComplex AFormat

a. Contains a vector with the last solution found by the Linear Solver
app.

Triangle Solver app variables

Category Names

Numeric SideA AngleA


SideB AngleB
SideC AngleC
Rect

Modes AAngle ADigits


AComplex AFormat

Linear Explorer app variables

Category Names

Modes AAngle ADigits


AComplex AFormat

Quadratic Explorer app variables

Category Names

Modes AAngle ADigits


AComplex AFormat

Variables 235
Trig Explorer app variables

Category Names

Modes AAngle ADigits


AComplex AFormat

Sequence app variables


Category Names

Symbolic U1 U6
U2 U7
U3 U8
U4 U9
U5 U0

Plot Axes Xmax


Cursor Xmin
GridDots Xtick
GridLines Xzoom
Labels Ymax
Nmin Ymin
Nmax Ytick
Recenter Yzoom

Numeric NumIndep NumType


NumStart NumZoom
NumStep

Modes AAngle ADigits


AComplex AFormat

236 Variables
5

Programming in HP PPL
This chapter describes the HP Prime Programming
Language (HP PPL). In this chapter you’ll learn about:
• programming commands
• writing functions in programs
• using variables in programs
• executing programs
• debugging programs
• creating programs for building custom apps
• sending a program to another HP Prime

HP Prime An HP Prime program contains a sequence of commands


Programs that execute automatically to perform a task.

Command Commands are separated by a semicolon ( ; ).


Structure Commands that take multiple arguments have those
arguments enclosed in parentheses and separated by a
comma( , ). For example,

PIXON (xposition, yposition);

Sometimes, arguments to a command are optional. If an


argument is omitted, a default value is used in its place. In
the case of the PIXON command, a third argument could
be used that specifies the color of the pixel:

PIXON (xposition, yposition [,color]);

In this manual, optional arguments to commands appear


inside square brackets, as shown above. In the PIXON
example, a graphics variable (G) could be specified as
the first argument. The default is G0, which always
contains the currently displayed screen. Thus, the full
syntax for the PIXON command is:

PIXON([G,] xposition, yposition [ ,color]);

Programming in HP PPL 237


Some built-in commands employ an alternative syntax
whereby function arguments do not appear in
parentheses. Examples include RETURN and RANDOM.

Program Programs can contain any number of subroutines (each of


Structure which is a function or procedure). Subroutines start with a
heading consisting of the name, followed by parentheses
that contain a list of parameters or arguments, separated
by commas. The body of a subroutine is a sequence of
statements enclosed within a BEGIN–END; pair. For
example, the body of a simple program, called
MYPROGRAM, could look like this:
EXPORT MYPROGAM()
BEGIN
PIXON(1,1);
END;

Comments When a line of a program begins with two forward


slashes, //, the rest of the line will be ignored. This
enables you to insert comments in the program:
EXPORT MYPROGAM()
BEGIN
PIXON(1,1);
//This line is just a comment.
END;

The Program Catalog


The Program Catalog is where you run and debug
programs, and send programs to another HP Prime. You
can also rename and remove programs, and it is where
you start the Program Editor. The Program Editor is where
you create and edit programs. Programs can also be run
from Home view or from other programs.

238 Programming in HP PPL


Open the Press Sx
Program (Program) to open the
Catalog Program Catalog.
The Program Catalog
displays a list of program
names. The first item in
the Program Catalog is a
built-in entry that has the
same name as the active app. This entry is the app
program for the active app, if such a program exists. See
“App programs” on page 260 for more information.

Program Catalog: buttons and keys

Button or Key Purpose

Opens the highlighted


program for editing.

Prompts for a new


program name, then
opens the Program
Editor.

Opens further menu


options for the selected
program:
• Save
• Rename
• Sort
• Delete
• Clear
These options are
described immediately
below.
To redisplay the initial
menu, press O or
J.

Programming in HP PPL 239


Button or Key Purpose (Continued)

Save creates a copy of


the selected program
with a new name you are
prompted to give.
Rename renames the
selected program.
Sort sorts the list of
programs. (Sort options
are alphabetical and
chronological).
Delete deletes the
selected program.
Clear deletes all
programs.

Transmits the highlighted


program to another HP
Prime.

Debugs the selected


program.

Runs the highlighted


program.

S= or S\ Moves to the beginning


or end of the Program
Catalog.

C Deletes the selected


program.

SJ Deletes all programs.

240 Programming in HP PPL


Creating a new program
In the following few sections, we will create a simple
program that counts to three as an introduction to using
the Program editor and its menus.
1. Open the Program
Catalog and start a
new program.
Sx (Program)

2. Enter a name for the


program.
AA (to lock
alpha mode)
MYPROGRAM
.

3. Press again.
A template for your
program is then
automatically
created. The
template consists of
a heading for a
function with the
same name as the program, EXPORT
MYPROGRAM(), and a BEGIN–END; pair that will
enclose the statements for the function.

Tip A program name can contain only alphanumeric


characters (letters and numbers) and the underscore
character. The first character must be a letter. For
example, GOOD_NAME and Spin2 are valid program
names, while HOT STUFF (contains a space) and
2Cool! (starts with number and includes !) are not valid.

Programming in HP PPL 241


The Program Editor
Until you become familiar with the HP Prime commands,
the easiest way to enter commands is to select them from
the Catalog menu (D ), or from the Commands
menu in the Program Editor ( ). To enter variables,
symbols, mathematical functions, units, or characters, use
the keyboard keys.

Program Editor: The buttons and keys in the Program Editor are:
buttons and keys

Button or Key Meaning

Checks the current program


for errors.

If your program goes beyond


or one screen, you can quickly
jump from screen to screen by
S= and tapping either side of this
S\ button. Tap the left side of the
button to display the previous
page; tap the right side to
display the next page. (The
left tap will be inactive if you
have the first page of the
program displayed.)

Opens a menu from which you


can choose from common
programming commands. The
commands are grouped under
the options:
• Strings
• Drawing
• Matrix
• App Functions
• Integer
• I/O
• More

242 Programming in HP PPL


Button or Key Meaning (Continued)

Press J to return to the


main menu.
The commands in this menu
are described in “Commands
under the Cmds menu”,
beginning on page 274.

Opens a menu from which you


can select common
programming commands. The
commands are grouped under
the options:
• Block
• Branch
• Loop
• Variable
• Function
Press J to return to the
main menu.
The commands in this menu
are described in “Commands
under the Tmplt menu”,
beginning on page 268.

a Displays menus for selecting


variable names and values.

Sa Displays a palette of
(Chars) characters. If you display this
palette while a program is
open, you can choose a
character and it will be be
added to your program at the
cursor point. To add one
character, highlight it and tap
or press E. To
add a character without
closing the characters palette,
select it and tap .

Programming in HP PPL 243


Button or Key Meaning (Continued)

S> and Moves the cursor to the end


S< (or beginning) of the current
line. You can also swipe the
screen.

S= and Moves the cursor to the start


S\ (or end) of the program. You
can also swipe the screen.

A> and Moves the cursor one screen


A< right (or left). You can also
swipe the screen.

E Starts a new line.

C Deletes the character to the


left of the cursor.

SC Deletes the character to the


right of the cursor.

SJ Deletes the entire program.

1. To continue the
MYPROGRAM
example (which we
began on page
241), use the cursor
keys to position the
cursor where you
want to insert a
command or just tap on the desired location. In this
example, you need to position the cursor between
BEGIN and END.
2. Tap to open
the menu of common
programming
commands for
blocking, branching,
looping, variables,
and functions.

244 Programming in HP PPL


In this example we’ll select a LOOP command from
the menu.
3. Select Loop and
then select FOR from
the sub-menu.

Notice that a
FOR_FROM_TO_DO
_ template is
inserted. All you
need do is fill in the
missing information.

4. Using the cursor keys


and keyboard, fill in
the missing parts of
the command. In this
case, make the
statement match the
following:
FOR N FROM 1 TO
3 DO
5. Move the cursor to a blank line below the FOR
statement.
6. Tap to open the menu of common
programming commands.
7. Select I/O and then
select MSGBOX from
the sub-menu.

Programming in HP PPL 245


8. Fill in the arguments
of the MSGBOX
command, and type
a semicolon at the
end of the command
(S+).

9. Tap to check the syntax of your program.


10. When you are finished, press Sx to return to
the Program Catalog or H to go to Home view.
You are ready now to execute the program.

Run a From Home view, enter the name of the program. If the
Program program takes parameters, enter a pair of parentheses
after the program name with the parameters inside them
each separated by a comma. To run the program, press
E.
From the Program Catalog, highlight the program you
want to run and tap . When a program is executed
from the catalog, the system looks for a function named
START() (no parameters).
You can also run a
program from the USER
menu (one of the Toolbox
menus):
1. Press D and tap
.
2. Tap MYPROGRAM >
to expand the menu
and select MYPROGRAM.
MYPROGRAM appears on the entry line.
3. Tap E and the program executes, displaying a
message box.

246 Programming in HP PPL


4. Tap three
times to step through
the FOR loop. Notice
that the number
shown increments by
1 each time.
After the program
terminates, you can
resume any other activity with the HP Prime.
If a program has arguments, when you press a
screen appears prompting you to enter the program
parameters.

Multi-function If there is more than one EXPORT function in a program,


programs when is tapped a list appears for you to choose
which function to run. To see this feature, create a program
with the text:
EXPORT NAME1( )
BEGIN

END;
EXPORT NAME2( )
BEGIN

END;
Now note that when you select your program from the
Program Catalog and tap or , a list with
NAME1 and NAME2 appears.

Debug a You cannot run a program that contains syntax errors. If


Program the program does not do what you expect it to do, or if
there is a run-time error detected by the system, you can
execute the program step by step, and look at the values
of local variables.
Let’s debug the program created above: MYPROGRAM.

Programming in HP PPL 247


1. In the Program
Catalog, select
MYPROGRAM.
Sx
Select
MYPROGRAM

2. Tap .
If there is more than
one EXPORT function
in a file, a list
appears for you to
choose which
function to debug.
While debugging a
program, the title of the program or intra-program
function appears at the top of the display. Below that
is the current line of the program being debugged.
The current value of each variable is visible in the
main body of the screen. The following menu buttons
are available in the debugger:
: Skips to the next line or block of the program

: Executes the current line


: Opens a menu of variables. You can select
one and add it to the list of variables so you can see
how it changes as you step through the program.
: Closes the debugger
: Continues program execution without
debugging
3. Execute the FOR loop command.

The FOR loop starts and the top of the display shows
the next line of the program (the MSGBOX
command).
4. Execute the MSGBOX command.

248 Programming in HP PPL


The message box appears. Note that when each
message box is displayed, you still have to dismiss it
by tapping or pressing E.
Tap and press E repeatedly to execute
the program step-by-step.
Tap to close the debugger at the current line of the
program, or tap to run the rest of the program
without using the debugger.

Edit a You edit a program using the Program Editor, which is


program accessible from the Program Catalog.
1. Open the Program
Catalog.
Sx
2. Tap the program you
want to edit (or use
the arrow keys to
highlight it and press
E).
The HP Prime opens the Program Editor. The name of
your program appears in the title bar of the display.
The buttons and keys you can use to edit your
program are listed in “Program Editor: buttons and
keys” on page 242.

Copy a You can use the global Copy and Paste commands to
program or copy part or all of a program. The following steps illustrate
part of a the process:

program 1. Open the Program Catalog.


Sx
2. Tap the program that has the code you want to copy.
3. Press SV (Copy).
The menu buttons change to give you options for
copying:
: Marks where the copying or cutting is to begin.
: Marks where the copying or cutting is to end.
: Select the entire program.

Programming in HP PPL 249


: Cut the selection.
: Copy the selection.
4. Select what you want to copy or cut (using the options
listed immediately above).
5. Tap or .
6. Return to the Program Catalog and open the target
program.
7. Move the cursor to where you want to insert the
copied or cut code.
8. Press SZ (Paste). The clipboard opens. What
you most recently copied or cut will be first in the list
and highlighted already, so just tap . The code
will be pasted into the program, beginning at the
cursor location.

Delete a To delete a program:


program 1. Open the Program Catalog.
Sx
2. Highlight a program to delete and press C.
3. At the prompt, tap to delete the program or
to cancel.

Delete all To delete all programs at once:


programs 1. Open the Program Catalog.
Sx
2. Press SJ (Clear).
3. At the prompt, tap to delete all programs or
to cancel.

Delete the You can clear the contents of a program without deleting
contents of a the program. The program then just has a name and
program nothing else.
1. Open the Program Catalog.
Sx
2. Tap the program to open it.
3. Press SJ (Clear).

250 Programming in HP PPL


To share a You can send programs between calculators just as you
program can send apps, notes, matrices, and lists.

The HP Prime programming language


The HP Prime programming language allows you to
extend the capabilities of the HP Prime by adding
programs, functions and variables to the system. The
programs you write can be either standalone or attached
to an app. The functions and variables you create can be
either local or global. If they are declared to be global,
then they appear in the User menu when you press D
or a. In the following sections, we discuss variables
and functions, then create a set of short programs to
illustrate the various techniques for creating programs,
functions, and variables.

Variables Variables in an HP Prime program can be used to store


and visibility numbers, lists, matrices, graphics objects, and strings. The
name of a variable must be a sequence of alphanumeric
characters (letters and numbers), starting with a letter.
Names are case-sensitive, so the variables named
MaxTemp and maxTemp are different.
The HP Prime has built-in variables of various types, visible
globally (that is, visible wherever you are in the
calculator). For example, the built-in variables A to Z can
be used to store real numbers, Z0 to Z9 can be used to
store complex numbers, M0 to M9 can be used to store
matrices and vectors, and so on. These names are
reserved. You cannot use them for other data. For
example, you cannot name a program M1, or store a real
number in a variable named Z8. In addition to these
reserved variables, each HP app has its own reserved
variables. Some examples are Root, Xmin, and
Numstart. Most of these app variables are local to their
app, though a few are global by design. For example, C1
is used by the Statistics 2Var app to store statistical data.
This variable is global so that you can access that data
from anywhere in the system. Again, these names cannot
be used to name a program or store data of a type other
than their design allows. (A full list of system and app

Programming in HP PPL 251


variables is given in chapter 4, “Variables”, beginning on
page 215.)
In a program you can declare variables for use only within
a particular function. This is done using a LOCAL
declaration. The use of local variables enables you to
declare and use variables that will not affect the rest of the
calculator. Local variables are not bound to a particular
type; that is, you can store floating-point numbers,
integers, lists, matrices, and symbolic expressions in a
variable with any local name. Although the system will
allow you to store different types in the same local
variable, this is poor programming practice and should
be avoided.
Variables declared in a program should have descriptive
names. For example, a variable used to store the radius of
a circle is better named RADIUS than VGFTRFG. You are
more likely to remember what the variable is used for if its
name matches its purpose.
If a variable is needed after the program executes, it can
be exported from the program using the EXPORT
command. To do this, the first command in the program
(that is, on a line above the program name) would be
EXPORT RADIUS. Then, if a value is assigned to
RADIUS, the name appears on the variables menu (a)
and is visible globally. This feature allows for extensive
and powerful interactivity among different environments in
the HP Prime. Note that if another program exports a
variable with the same name, the most recently exported
version will be active.
The program below prompts the user for the value of
RADIUS, and exports the variable for use outside the
program.
EXPORT RADIUS;
EXPORT GETRADIUS()
BEGIN
INPUT(RADIUS);
END;

252 Programming in HP PPL


Note that EXPORT
command for the
variable RADIUS
appears before the
heading of the function
where RADIUS is
assigned. After you
execute this program, a
new variable named RADIUS appears on the USER
GETRADIUS section of the Variables menu.

Qualifying The HP Prime has many system variables with names that
the name of a are apparently the same. For example, the Function app
variable has a variable named Xmin, but so too does the Polar
app, the Parametric app, the Sequence app, and the
Solve app. In a program, and in the Home view, you can
refer to a particular version of these variables by
qualifying its name. This is done by entering the name of
the app (or program) that the variable belongs to,
followed by a dot (.), and then the actual variable name.
For example, the qualified variable Function.Xmin
refers to the value of Xmin within the Function app.
Similarly, the qualified variable Parametric.Xmin
refers to the value of Xmin in the Parametric app. Despite
having the same name—Xmin—the variables could have
different values. You do likewise to use a local variable in
a program: specify the name of the program, followed by
the dot, and then the variable name.

Functions, You can define your own functions in a program, and data
their can be passed to a function using parameters. Functions
arguments, can return a value (using the RETURN statement) or not.
When a program is executed from Home view, the
and program will return the value returned by the last statement
parameters that was executed.
Furthermore, functions can be defined in a program and
exported for use by other programs, in much the same
way that variables can be defined and used elsewhere.
In this section, we will create a small set of programs, each
illustrating some aspect of programming in the HP Prime.
Each program will be used as a building block for a
custom app described in the next section, App Programs.

Programming in HP PPL 253


Program ROLLDIE We’ll first create a program called ROLLDIE. It simulates
the rolling of a single die, returning a random integer
between 1 and whatever number is passed into the
function.
In the Program Catalog create a new program named
ROLLDIE. (For help, see page 241.) Then enter the code
in the Program Editor.

EXPORT ROLLDIE(N)
BEGIN
RETURN 1+RANDINT(N-1);
END;
The first line is the heading of the function. Execution of the
RETURN statement causes a random integer from 1 to N
to be calculated and returned as the result of the function.
Note that the RETURN command causes the execution of
the function to terminate. Thus any statements between the
RETURN statement and END are ignored.
In Home view (in fact, anywhere in the calculator where a
number can be used), you can enter ROLLDIE(6) and a
random integer between 1 and 6 inclusive will be
returned.

Program Because of the EXPORT command in ROLLDIE, another


ROLLMANY program could use the ROLLDIE function and generate n rolls
of a die with any number of sides. In the following program,
the ROLLDIE function is used to generate n rolls of two dice,
each with the number of sides given by the local variable
sides. The results are stored in list L2, so that L2(1) shows
the number of times the dies came up with a combined total
of 1, L2(2) shows the number of times the dies came up with
a combined total of 2, etc. L2(1) should be 0 (since the sum
of the numbers on 2 dice must be at least 2).
EXPORT ROLLMANY(n,sides)
BEGIN
LOCAL k,roll;
// initialize list of frequencies
MAKELIST(0,X,1,2*sides,1) ▶ L2;
FOR k FROM 1 TO n DO
ROLLDIE(sides)+ROLLDIE(sides) ▶ roll;

254 Programming in HP PPL


L2(roll)+1 ▶ L2(roll);
END;
END;
By omitting the EXPORT command when a function is
declared, its visibility can be restricted to the program
within which it is defined. For example, you could define the
ROLLDIE function inside the ROLLMANY program like this:
ROLLDIE();
EXPORT ROLLMANY(n,sides)
BEGIN
LOCAL k,roll;
// initialize list of frequencies
MAKELIST(0,X,1,2*sides,1) ▶ L2;
FOR k FROM 1 TO n DO
ROLLDIE(sides)+ROLLDIE(sides) ▶ roll;
L2(roll)+1 ▶ L2(roll);
END;
END;
ROLLDIE(n)
BEGIN
RETURN 1+RANDINT(n-1);
END;
In the second version of the ROLLMANY program, there is
no ROLLDIE function exported from another program.
Instead, ROLLDIE is visible only to ROLLMANY. The
ROLLDIE function must be declared before it is called.
The first line of the program above contains the
declaration of the ROLLDIE function. The definition of the
ROLLDIE function is located at the end of the program.
Finally, the list of results could be returned as the result of
calling ROLLMANY instead of being stored directly in the
global list variable, L2. This way, if the user wanted to
store the results elsewhere, it could be done easily.
ROLLDIE();
EXPORT ROLLMANY(n,sides)
BEGIN
LOCAL k,roll,results;
// initialize list of frequencies
MAKELIST(0,X,1,2*sides,1) ▶ results;

Programming in HP PPL 255


FOR k FROM 1 TO n DO
ROLLDIE(sides)+ROLLDIE(sides) ▶ roll;
results(roll)+1 ▶ results(roll);
END;
RETURN results;
END;
ROLLDIE(N)
BEGIN
RETURN 1+RANDINT(N-1);
END;

In Home view you would enter ROLLMANY(100,6) L5


and the results of the simulation of 100 rolls of two six-
sided dice would be stored in list L5.

The User Keyboard: Customizing key presses


You can assign alternative functionality to any key on the
keyboard, including to the functionality provided by the
shift and alpha keys. This enables you to customize the
keyboard to your particular needs. For example, you
could assign e to a function that is multi-nested on a
menu and thus difficult to get to on a menu (such as
ALOG).
A customized keyboard is called the user keyboard and
you activate it when you go into user mode.

User mode There are two user modes:


• Temporary user mode: the next key press, and only
the next, enters the object you have assigned to that
key. After entering that object, the keyboard
automatically returns to its default operation.
To activate temporary user mode, press SW
(User). Notice that 1U appears in the title bar. The 1
will remind you that the user keyboard will be active
for just one key press.
• Persistent user mode: each key press from now until
you turn off user mode will enter whatever object you
have assigned to a key.

256 Programming in HP PPL


To activate persistent user mode, press
SWSW. Notice that U appears in the
title bar. The user keyboard will now remain active
until you press SW again.
If you are in user mode and press a key that hasn’t been
re-assigned, the key’s standard operation is performed.

Re-assigning Suppose you want to


keys assign a commonly used
function—such as
ALOG—to its own key on
the keyboard. Simply
create a new program
that mimics the syntax in
the image at the right.
The first line of the program specifies the key to be
reassigned using its internal name. (The names of all the
keys are given in “Key names” on page 258. They are
case-sensitive.)
On line 3, enter the text you want produced when the key
being re-assigned is pressed. This text must be enclosed in
quote marks.
The next time you want to insert ALOG at the position of
your cursor, you just press SWe.
You can enter any string you like in the RETURN line of
your program. For example, if you enter “Newton”, that
text will be returned when you press the re-assigned key.
You can even get the program to return user-defined
functions as well as system functions, and user-defined
variables as well as system variables.
You can also re-assign a shifted key combination. So, for
example, ASn could be re-assigned to produce
SLOPE(F1(X),3) rather than the lowercase t. Then if
ASn is entered in Home view and E
pressed, the gradient at X = 3 of whatever function is
currently defined as F1(X) in the Function app would be
returned.

Programming in HP PPL 257


Tip A quick way to write a program to re-assign a key is to
press Z and select Create user key when you are
in the Program Editor. You will then be asked to press the
key (or key combination) you want to re-assign. A
program template appears, with the internal name of the
key (or key combination) added automatically.

Key names The first line of a program that re-assigns a key must
specify the key to be reassigned using its internal name.
The table below gives the internal name for each key.
Note that key names are case-sensitive.

Internal name of keys and key states

Key Name S A AS
+ key + key + key

N K_0 KS_0 KA_0 KSA_0

x K_1 KS_1 KA_1 KSA_1

y K_2 KS_2 KA_2 KSA_2

z K_3 KS_3 KA_2 KSA_2

t K_4 KS_4 KA_4 KSA_4

u K_5 KS_5 KA_5 KSA_5

v K_6 KS_6 KA_6 KSA_6

p K_7 KS_7 KA_7 KSA_7

q K_8 KS_8 KA_8 KSA_8

r K_9 KS_9 KA_9 KSA_9

c K_Abc KS_Abc KA_Abc KSA_Abc

A K_Alpha KS_Alpha KA_Alpha KSA_Alpha

I K_Apps KS_Apps KA_Apps KSA_Apps

C K_Bksp KS_Bksp KA_Bksp KSA_Bksp

o K_Comma KS_Comma KA_Comma KSA_Comma

f K_Cos KS_Cos KA_Cos KSA_Cos

n K_Div KS_Div KA_Div KSA_Div

258 Programming in HP PPL


Internal name of keys and key states

Key Name S A AS
+ key + key
+ key

. K_Dot KS_Dot KA_Dot KSA_Dot

\ K_Down KS_Down KA_Down KSA_Down

E K_Enter KS_Enter KA_Enter KSA_Enter

H K_Home KS_Home KA_Home KSA_Home

,< K_Left KS_Left KA_Left KSA_Left

,> K_Right KS_Right KA_Right KSA_Right

h K_Ln KS_Ln KA_Ln KSA_Ln

i K_Log KS_Log KA_Log KSA_Log

w K_Minus KS_Minus KA_Minus KSA_Minus

Q K_Neg KS_Neg KA_Neg KSA_Neg

M K_Num KS_Num KA_Num KSA_Num

O K_On – KA_On KSA_On

P K_Plot KS_Plot KA_Plot KSA_Plot

+ K_Plus KS_Plus KA_Plus KSA_Plus

k K_Power KS_Power KA_Power KSA_Power

e K_Sin KS_Sin KA_Sin KSA_Sin

j K_Sq KS_Sq KA_Sq KSA_Sq

Y K_Symb KS_Symb KA_Symb KSA_Symb

g K_Tan KS_Tan KA_Tan KSA_Tan

= K_Up KS_Up KA_Up KSA_Up

a K_Vars KS_Vars KA_Vars KSA_Vars

V K_View KS_View KA_View KSA_View

d K_Xttn KS_Xttn KA_Xttn KSA_Xttn

W K_Help – KA_Help KSA_Help

Z K_Menu KS_Menu KA_Menu KSA_Menu

Programming in HP PPL 259


Internal name of keys and key states

Key Name S A AS
+ key + key
+ key

J K_Esc KS_Esc KA_Esc KSA_Esc

K K_Cas KS_Cas KA_Cas KSA_Cas

D K_Math KS_Math KA_Math KSA_Math

F K_Templ KS_Templ KA_Templ KSA_Templ

R K_Paren KS_Paren KA_Paren KSA_Paren

B K_Eex KS_Eex KA_Eex KSA_Eex

s K_Mul KS_Mul KA_Mul KSA_Mul

S – – – –

X K_Space KS_Space KA_Space KSA_Space

App programs
An app is a unified collection of views, programs, notes,
and associated data. Creating an app program allows
you to redefine the app’s views and how a user will
interact with those views. This is done with (a) dedicated
program functions with special names and (b) by
redefining the views in the View menu.

260 Programming in HP PPL


Using There are nine dedicated program function names, as
dedicated shown in the table below. These functions are called when
program the corresponding keys shown in the table are pressed.
These functions are designed to be written into a program
functions that controls an app and used in the context of that app.

Program Name Equivalent


Keystrokes

Symb Symbolic view Y


SymbSetup Symbolic Setup SY
Plot Plot view P
PlotSetup Plot Setup SP
Num Numeric view M
NumSetup Numeric Setup SM
Info Info view SI
START Starts an app

RESET Resets or
initializes an app

Redefining The View menu allows any app to define views in addition
the View to the standard seven views shown in the table above. By
menu default, each HP app has its own set of additional views
contained in this menu. The VIEW command allows you to
redefine these views to run programs you have created for
an app. The syntax for the VIEW command is:
VIEW "text", function()
By adding VIEW "text", function() before the
declaration of a function, you will override the list of views for
the app. For example, if your app program defines three
views—"SetSides", "RollDice" and "PlotResults"—when you
press V you will see SetSides, RollDice, and PlotResults
instead of the app’s default view list.

Programming in HP PPL 261


Customizing When an app is active, its associated program appears
an app as the first item in the Program Catalog. It is within this
program that you put functions to create a custom app. A
useful procedure for customizing an app is illustrated
below:
1. Decide on the HP app that you want to customize.
The customized app inherits all the properties of the
HP app.
2. Go to the Applications Library (I), highlight the
HP app, tap and save the app with a unique
name.
3. Customize the new app if you need to (for example,
by configuring the axes or angle measure settings).
4. Open the Program Catalog, select your new app
program, and tap .
5. Develop the functions to work with your customized
app. When you develop the functions, use the app
naming conventions described above.
6. Put the VIEW command in your program to modify
the app's View menu.
7. Decide if your app will create new global variables. If
so, you should EXPORT them from a separate user
program that is called from the Start() function in
the app program. This way they will not have their
values lost.
8. Test the app and debug the associated programs.
It is possible to link more than one app via programs. For
example, a program associated with the Function app
could execute a command to start the Statistics 1Var app,
and a program associated with the Statistics 1Var app
could return to the Function app (or launch any other app).

Example The following example illustrates the process of creating a


custom app. The app is based on the built-in Statistics
1Var app. It simulates the rolling of a pair of dice, each
with a number of sides specified by the user. The results
are tabulated, and can be viewed either in a table or
graphically.

262 Programming in HP PPL


1. In the Application
Librray, select the
Statistics 1Var app
but don’t open it.
I Select
Statistics
1Var.
2. Tap .
3. Enter a name for the new app (such as
DiceSimulation.)
4. Tap twice.
The new app appears in the Application Library.
5. Open the Program Catalog.
Sx
6. Tap the program to
open it.
Each customised
app has one
program associated
with it. Initially, this
program is empty.
You customize the
app by entering functions into that program.
At this point you decide how you want the user to interact
with the app. In this example, we will want the user to be
able to:
• start and initialize the app, and display a short note
• specify the number of sides (that is, faces) on each
die
• specify the number of times to roll the dice
• graphically display the results of the simulation
• numerically display the results of the simulation.
With that in mind, we will create the following views:
START, ROLL DICE, SET SIDES, and SET ROLLS.
The START option will initialize the app and display a note
that gives the user instructions. The user will also interact
with the app through the Numeric view and the Plot view.

Programming in HP PPL 263


These views will be activated by pressing M and P,
but the function Plot() in our app program will actually
launch the latter view after doing some configuration.
Before entering the
following program, press
S I to open the
Info editor and enter the
text shown in the figure.
This note will be
attached to the app and
will be displayed when
the user selects the Start option from the View menu (or
presses S I).
The program discussed earlier in this chapter to get the
number of sides for a dice is expanded here, so that the
possible sums of two such die are stored in dataset D1.
Enter the following sub-routines into the program for the
DiceSimulation app.

The DiceSimulation DICESIMVARS();


program ROLLDIE();
EXPORT SIDES,ROLLS;
EXPORT DiceSimulation()
BEGIN
END;
VIEW "Start",START()
BEGIN
D1:={};
D2:={};
SetSample(H1,D1);
SetFreq(H1,D2);
H1Type:=1;
STARTVIEW(6,1);
END;
VIEW "Roll Dice",ROLLMANY()
BEGIN
LOCAL k,roll;
D1:= MAKELIST(X+1,X,1,2*SIDES-1,1);
D2:= MAKELIST(0,X,1,2*SIDES-1,1);

264 Programming in HP PPL


FOR k FROM 1 TO ROLLS DO
roll:=ROLLDIE(SIDES)+ROLLDIE
(SIDES);
D2(roll-1):= D2(roll-1)+1;
END;
Xmin:= -0.1;
Xmax:= MAX(D1)+1;
Ymin:= −0.1;
Ymax:= MAX(D2)+1;
STARTVIEW(1,1);
END;
VIEW "Set Sides",SETSIDES()
BEGIN
REPEAT
INPUT(SIDES,"Die
Sides","N=","Enter# of sides",2);
SIDES:= FLOOR(SIDES);
IF SIDES<2 THEN
MSGBOX("# of sides must be >= 4");
END;
UNTIL SIDES >=4;
STARTVIEW(7,1);
END;

VIEW "Set Rolls",SETROLLS()


BEGIN
REPEAT
INPUT(ROLLS,"Num of
rolls","N=","Enter# of rolls",25);
ROLLS:= FLOOR(ROLLS);
IF ROLLS<1 THEN
MSGBOX("You must enter a num
>=1");
END;
UNTIL ROLLS>=1;
STARTVIEW(7,1);
END;
Plot()

Programming in HP PPL 265


BEGIN
Xmin:=-0.1;
Xmax:= MAX(D1)+1;
Ymin:= −0.1;
Ymax:= MAX(D2)+1;
STARTVIEW(1,1);
END;
Symb()
BEGIN
SetSample(H1,D1);
SetFreq(H1,D2);
H1Type:=1;
STARTVIEW(0,1);
END;

The ROLLMANY() routine is an adaptation of the program


presented earlier in this chapter. Since you cannot pass
parameters to a program called through a selection from
a custom View menu, the exported variables SIDES and
ROLLS are used in place of the parameters that were used
in the previous versions.
The program above calls two other user programs:
ROLLDIE() and DICESIMVARS(). ROLLDIE()
appears earlier in this chapter. Here is DICESIMVARS.
Create a program with that name and enter the following
code.

The program EXPORT ROLLS,SIDES;


DICESIMVARS EXPORT DICESIMVARS()
BEGIN
10 ▶ ROLLS;
6 ▶ SIDES;
END;
1. Press I, and open DiceSimulation. The note
will appear explaining how the app works.

266 Programming in HP PPL


2. Press V to see the
custom app menu.
Here you can reset
the app (Start), set
the number of sides
of the dice, the
number of rolls, and
execute a simulation.
3. Select Set Rolls and enter 100.
4. Select Set Sides and enter 6.
5. Select Roll Dice.
You will see a
histogram similar to
the own shown in
the figure.
6. Press M to see the
data and P to
return to the
histogram.
7. To run another simulation, press V and select
Roll Dice.

Program commands
This section describes each program command. The
commands under the menu are described first. The
commands under the menu are described in
“Commands under the Cmds menu” on page 274.

Programming in HP PPL 267


Commands under the Tmplt menu

Block
The block commands determine the beginning and end of
a sub-routine or function. There is also a Return
command to recall results from sub-routines or functions.

BEGIN END Syntax: BEGIN command1; command2;…;


commandN; END;
Defines a command or set of commands to be executed
together. In the simple program:
EXPORT SQM1(X)
BEGIN
RETURN X^2-1;
END;
the block is the single RETURN command.
If you entered SQM1(8) in Home view, the result returned
would be 63.

RETURN Syntax: RETURN expression;


Returns the current value of expression.

KILL Syntax: KILL;


Stops the step-by-step execution of the current program
(with debug).

Branch
In what follows, the plural word commands refers to both
a single command or a set of commands.

IF THEN Syntax: IF test THEN commands END;


Evaluate test. If test is true (not 0), executes commands.
Otherwise, nothing happens.

IF THEN ELSE Syntax: IF test THEN commands1 ELSE commands 2


END;
Evaluate test. If test is true (non 0), executes commands 1,
otherwise, executes commands 2

268 Programming in HP PPL


CASE Syntax:
CASE
IF test1 THEN commands1 END;
IF test2 THEN commands2 END;

[DEFAULT commands]
END;
Evaluates test1. If true, executes commands1 and ends the
CASE. Otherwise, evaluates test2. If true, executes
commands2 and ends the CASE. Continues evaluating
tests until a true is found. If no true test is found, executes
default commands, if provided.
Example:
CASE
IF x < 0 THEN RETURN "negative"; END;
IF x < 1 THEN RETURN "small"; END;
DEFAULT RETURN "large";
END;

IFERR IFERR commands1 THEN commands2 END;


Executes sequence of commands1. If an error occurs
during execution of commands1, executes sequence of
commands2.

IFERR ELSE IFERR commands1 THEN commands2 ELSE


commands3 END;
Executes sequence of commands1. If an error occurs
during execution of commands1, executes sequence of
commands2. Otherwise, execute sequence of
commands3.

Loop
FOR Syntax: FOR var FROM start TO finish DO commands END;
Sets variable var to start, and for as long as this variable
is less than or equal to finish, executes the sequence of
commands, and then adds 1 (increment) to var.

Programming in HP PPL 269


Example 1: This program determines which integer from 2
to N has the greatest number of factors.
EXPORT MAXFACTORS(N)
BEGIN
LOCAL cur,max,k,result;
1 ▶ max;1 ▶ result;
FOR k FROM 2 TO N DO
SIZE(CAS.idivis(k)) ▶ cur;
IF cur(1) > max THEN
cur(1) ▶ max;
k ▶ result;
END;
END;
MSGBOX("Max of "+ max +" factors for
"+result);
END;
In Home, enter
MAXFACTORS(100).

FOR STEP Syntax: FOR var FROM start TO finish [STEP increment]
DO commands END;
Sets variable var to start, and for as long as this variable
is less than or equal to finish, executes the sequence of
commands, and then adds increment to var.
Example 2: This program
draws an interesting
pattern on the screen.
EXPORT
DRAWPATTERN()
BEGIN
LOCAL
xincr,yincr,co
lor;
STARTAPP("Function");

270 Programming in HP PPL


RECT();
xincr := (Xmax - Xmin)/318;
yincr := (Ymax - Ymin)/218;
FOR X FROM Xmin TO Xmax STEP xincr DO
FOR Y FROM Ymin TO Ymax STEP yincr DO
color := RGB(X^3 MOD 255,Y^3 MOD 255,
TAN(0.1*(X^3+Y^3)) MOD 255);
PIXON(X,Y,color);
END;
END;
WAIT;
END;

FOR DOWN Syntax: FOR var FROM start DOWNTO finish DO commands
END;
Sets variable var to start, and for as long as this variable
is more than or equal to finish, executes the sequence of
commands, and then subtracts 1 (decrement) from var.

FOR DOWN STEP Syntax: FOR var FROM start DOWNTO finish [STEP
increment] DO commands END;
Sets variable var to start, and for as long as this variable
is more than or equal to finish, executes the sequence of
commands, and then subtracts increment from var.

WHILE Syntax: WHILE test DO commands END;


Evaluates test. If result is true (not 0), executes the
commands, and repeats.
Example: A perfect number is one that is equal to the sum
of all its proper divisors. For example, 6 is a perfect
number because 6 = 1+2+3. The example below returns
true when its argument is a perfect number.
EXPORT ISPERFECT(n)
BEGIN
LOCAL d, sum;
2 ▶ d;
1 ▶ sum;
WHILE sum <= n AND d < n DO
IF irem(n,d)==0 THEN
sum+d ▶ sum;

Programming in HP PPL 271


END;
d+1▶ d;
END;
RETURN sum==n;
END;
The following program displays all the perfect numbers up
to 1000:
EXPORT PERFECTNUMS()
BEGIN
LOCAL k;
FOR k FROM 2 TO 1000 DO
IF ISPERFECT(k) THEN
MSGBOX(k+" is perfect, press OK");
END;
END;
END;

REPEAT Syntax: REPEAT commands UNTIL test;


Repeats the sequence of commands until test is true (not
0).
The example below prompts for a positive value for SIDES,
modifying an earlier program in this chapter:
EXPORT SIDES;
EXPORT GETSIDES()
BEGIN
REPEAT
INPUT(SIDES,"Die Sides","N = ","Enter
num sides",2);
UNTIL SIDES>0;
END;

BREAK Syntax: BREAK(n)


Exits from loops by breaking out of n loop levels.
Execution picks up with the first statement after the loop.
With no argument, exits from a single loop.

CONTINUE Syntax: CONTINUE


Transfers execution to the start of the next iteration of a
loop.

272 Programming in HP PPL


Variable
These commands enable you to control the visibility of a
user-defined variable.

LOCAL Local.
Syntax: LOCAL var1,var2,…varn;
Makes the variables var1, var2, etc. local to the program
in which they are found.

EXPORT Syntax: EXPORT var1, var2, …, varn;


Exports the variables var1, var2, etc. so they are globally
available and appear on the User menu when you press
a and select .

Function
These commands enable you to control the visibility of a
user-defined function.

EXPORT Export.
Syntax: EXPORT FunctionName(Parameters) or
Export Var{:=Val) or Export Var1[:=Val1],
Var2[:=Val2], ...)
In a program, declares the functions or variables to export
globally. The exported functions appear in the Toolbox
User menu and the exported variables appear in the Vars
CAS, App, and User menus.
For an exported function, there are two uses of EXPORT.
Forward function declaration:
EXPORT function(params);
Normal function declaration:
EXPORT function[(params)]
BEGIN
//Function definition goes here
END;
Examples:
EXPORT X2M1(X);
EXPORT ratio:=0.15;

Programming in HP PPL 273


Export X2M1(X)
BEGIN
RETURN X^2-1;
END;

VIEW Syntax: VIEW “text”, functionname();


Replaces the View menu of the current app and adds an
entry with “text”. If “text” is selected and the user
presses or E , then functionname() is
called.

KEY A prefix to a key name when creating a user keyboard.


See “The User Keyboard: Customizing key presses” on
page 256.

Commands under the Cmds menu

Strings
A string is a sequence of characters enclosed in double
quotes (""). To put a double quote in a string, use two
consecutive double quotes. The \ character starts an
escape sequence, and the character(s) immediately
following are interpreted specially. \n inserts a new line
and two backslashes insert a single backslash. To put a
new line into the string, press E to wrap the text at
that point.

ASC Syntax: ASC (string)


Returns a list containing the ASCII codes of string.
Example: ASC("AB") returns [65,66]

CHAR Syntax: CHAR(vector) or CHAR(integer)


Returns the string corresponding to the character codes in
vector, or the single code of integer.

Examples: CHAR(65) returns "A"


CHAR([82,77,72]) returns "RMH"

DIM Syntax: DIM(string)

274 Programming in HP PPL


Returns the number of characters in string.
Example: DIM("12345") returns 5, DIM("""") and
DIM("\n") return 1. (Notice the use of the two double
quotes and the escape sequence.)

STRING Syntax: STRING (object);


Returns a string representation of object. The result varies
depending on the type of object.
Examples:

String Result

string(F1), when F1(X) "COS(X)"


= COS(X)

STRING(2/3) 0.666666666667

string(L1) when L1 = "{1,2,3}"


{1,2,3}

string(M1) when M1 = "[[1,2,3],[4,5,6]]"


1 2 3
4 5 6

INSTRING Syntax: INSTRING (str1,str2)


Returns the index of the first occurrence of str2 in str1.
Returns 0 if str2 is not present in str1. Note that the first
character in a string is position 1.
Examples:
INSTRING("vanilla","van") returns 1
INSTRING ("banana","na") returns 3
INSTRING("ab","abc") returns 0

LEFT Syntax: LEFT (str,n)


Return the first n characters of string str. If n ≥ DIM(str) or
n < 0, returns str. If n == 0 returns the string.
Example: LEFT("MOMOGUMBO",3) returns "MOM"

RIGHT Syntax: RIGHT(str,n)

Programming in HP PPL 275


Returns the last n characters of string str. If n <= 0, returns
empty string. If n > DIM(str), returns str
Example: RIGHT("MOMOGUMBO",5) returns
"GUMBO"

MID Syntax: MID(str,pos, [n])


Extracts n characters from string str starting at index pos.
n is optional, if not specified, extracts all the remainder of
the string.
Example: MID("MOMOGUMBO",3,5) returns
"MOGUM", MID("PUDGE",4) returns "GE"

ROTATE Syntax: ROTATE(str,n)


Permutation of characters in string str. If 0 <=n < DIM(str),
shifts n places to left. If –DIM(str) < n <= –1, shifts n spaces
to right. If n > DIM(str) or n < –DIM(str), returns str.
Examples:
ROTATE("12345",2) returns "34512"
ROTATE("12345",-1) returns "51234"
ROTATE("12345",6) returns "12345"

STRINGFROMID Syntax: STRINGFROMID(integer)


Returns, in the current language, the built-in string
associated in the internal string table with the specified
integer.
Examples:
STRINGFROMID(56) returns “Complex”
STRINGFROMID(202) returns “Real”

REPLACE Syntax: REPLACE(object1, start, object2)


Replaces part of object1 with object2 beginning at start.
The objects can be matrices, vectors, or stings.
Example:
REPLACE("12345",”3”,”99”) returns "12995"

276 Programming in HP PPL


Drawing
There are 10 built-in graphics variables in the HP Prime,
called G0–G9. G0 is always the current screen graphic.
G1 to G9 can be used to store temporary graphic objects
(called GROBs for short) when programming applications
that use graphics. They are temporary and thus cleared
when the calculator turns off.
Twenty-six functions can be used to modify graphics
variables. Thirteen of them work with Cartesian
coordinates using the Cartesian plane defined in the
current app by the variables Xmin, Xmax, Ymin, and
Ymax.
The remaining thirteen work with pixel coordinates where
the pixel 0,0 is the top left pixel of the GROB, and 320,
240 is the bottom right. Functions in this second set have
a _P suffix to the function name.

C→PX Converts from Cartesian coordinates to screen coordinates.


Syntax: C→PX(x,y) or C→PX({x,y})

DRAWMENU Syntax: DRAWMENU(string1, string2,…


string6)
Draws a six-button menu at the bottom of the display, with
labels string1, string2, …, string6.
Example:
DRAWMENU("ABC", "", "DEF") creates a menu with
the first and third buttons labelled ABC and DEF,
respectively. The other four menu keys are blank.

FREEZE Syntax: FREEZE


Pauses program execution until a key is pressed. This
prevents the screen from being redrawn after the end of
the program execution, leaving the modified display on
the screen for the user to see.

PX→C Converts from screen coordinates to Cartesian


coordinates.

RGB Syntax: RGB(R, G, B, [A])

Programming in HP PPL 277


Returns an integer number that can be used as the color
parameter for a drawing function, based on Red-, Green-
and Blue-component values (each 0 to 255).
If Alpha is greater than 128, returns the color flagged as
transparent. There is no alpha channel blending on Prime.
Examples:
RGB(255,0,128) returns 16711808
RECT(RGB(0,0,255)) makes a blue screen
LINE(0,0,8,8,RGB(0,255,0)) draws a green line

Pixels and Cartesian


ARC_P

ARC Syntax; ARC(G, x, y, r [ , a1, a2, c])


ARC_P(G, x, y, r [ , a1, a2, c])
Draws an arc or circle on G, centered on point x,y, with
radius r and color c starting at angle a1 and ending on
angle a2.
G can be any of the graphics variables and is optional.
The default is G0
r is given in pixels.
c is optional and if not specified black is used. It should
be specified in this way: #RRGGBB (in the same way as
a color is specified in HTML).
a1 and a2 follow the current angle mode and are
optional. The default is a full circle.
Example:
ARC(0,0,60,0,π,RGB(255,0,0)) draws a red
semicircle with center at (0,0)—using the current Plot
Setup window—and with a radius of 60 pixels. The
semicircle is drawn counterclockwise from 0 to π.

BLIT_P

BLIT Syntax: BLIT([trgtGRB, dx1, dy1, dx2, dy2],


srcGRB [ ,sx1, sy1, sx2, sy2, c])
BLIT_P ([trgtGRB, dx1, dy1, dx2, dy2],
srcGRB [ ,sx1, sy1, sx2, sy2, c])

278 Programming in HP PPL


Copies the region of srcGRB between point sx1, sy1 and
sx2, sy2 into the region of trgtGRB between points dx1,
dy1 and dx2, dy2. Do not copy pixels from srcGRB that
are color c.
trgtGRB can be any of the graphics variables and is
optional. The default is G0.
srcGRB can be any of the graphics variables.
dx2, dy2 are optional and if not specified will be
calculated so that the destination area is the same size as
the source area.
sx2, sy2 are optional and if not specified will be the
bottom right of the srcGRB.
sx1, sy1 are optional and if not specified will be the top
left of srcGRB.
dx1, dy1 are optional and if not specified will be the top
left of trgtGRB.
c can be any color specified as #RRGGBB. If it is not
specified, all pixels from srcGRB will be copied.
Note Using the same variable for trgtGRB and srcGRB can be
unpredictable when the source and destination overlap.

DIMGROB_P

DIMGROB Syntax: DIMGROB_P(G, w, h, [color]) or


DIMGROB_P(G, w, h, list)
DIMGROB(G, w, h, [color]) or
DIMGROB(G, w, h, list)
Sets the dimensions of GROB G to w × h. Initializes the
graphic G with color or with the graphic data provided in
list. If the graphic is initialized using graphic data, then list
is a list of integers. Each integer, as seen in base 16,
describes one color every 16 bits.
Colors are in A1R5G5B5 format (that is,1 bit for the alpha
channel, and 5 bits for R, G, and B).

Programming in HP PPL 279


FILLPOLY_P

FILLPOLY Syntax: FILLPOLY_P([G],{(x1, y1), (x2, y2),…(xn, yn)},


Color, [Alpha])
FILLPOLY([G],{(x1, y1), (x2, y2),…(xn, yn)},
Color, [Alpha])
For the polygon defined by the list of points, fills the
polygon with the color defined by the RGB number Color.
If Alpha is provided as an integer between 0 and 255
inclusive, the polygon is drawn with the corresponding
transparency level. You can use a vector of points instead
of a list; in this case, the points can be expressed as
complex numbers.
Example:
FILLPOLY_P({(20,20), (100, 20), (100,
100), (20, 100)}, #FF, 128) draws a square, 80
pixels on a side, near the upper left of the display, using
the color purple and transparency level 128.

GETPIX_P

GETPIX Syntax: GETPIX([G], x, y)


GETPIX_P([G], x, y)
Returns the color of the pixel G with coordinates x,y.
G can be any of the graphics variables and is optional.
The default is G0, the current graphic.

GROBH_P

GROBH Syntax: GROBH(G)


GROBH_P(G)
Returns the height of G.
G can be any of the graphics variables and is optional.
The default is G0.

280 Programming in HP PPL


GROBW_P

GROBW Syntax: GROBW(G)


GROBW_P(G)
Returns the width of G.
G can be any of the graphics variables and is optional.
The default is G0.

INVERT_P

INVERT Syntax: INVERT([G, x1, y1, x2, y2])


INVERT_P([G, x1, y1, x2, y2])
Executes a reverse video of the selected region. G can be
any of the graphics variables and is optional. The default
is G0.
x2, y2 are optional and if not specified will be the bottom
right of the graphic.
x1, y1 are optional and if not specified will be the top left
of the graphic. If only one x,y pair is specified, it refers to
the top left.

LINE_P

LINE Syntax: LINE_P([G], x1, y1, x2, y2, [color])


LINE_P([G],points_definition, lines_definitions,
otation_matrix or {rotation_matrix or -1, ["N"],
[{eye_x, eye_y, eye_z} or -1], [{3Dxmin, 3Dxmax,
3Dymin, 3Dymax, 3Dzmin, 3Dzmax}]}, [zstring])
LINE_P([G],pre_rotated_points, line_definitions,
[zstring])
LINE([G], x1, y1, x2, y2, [color])
LINE([G],points_definition, lines_definitions,
otation_matrix or {rotation_matrix or -1, ["N"],
[{eye_x, eye_y, eye_z} or -1], [{3Dxmin, 3Dxmax,
3Dymin, 3Dymax, 3Dzmin, 3Dzmax}]}, [zstring])
LINE([G],pre_rotated_points, line_definitions,
[zstring])
The basic form of LINE_P draws one line between
specified pixel coordinates in the graphic using the
specified color.

Programming in HP PPL 281


The advanced form of LINE_P allows the multiple lines to
be rendered at the same time with a potential 3D
transformation of the triangle’s vertices.
This is mostly used if you have a set of vertices and lines
and want to display them all at once (faster).
points_definition is either a list or a matrix of point
definitions. Each point is defined by two to four numbers:
x, y, z, and color. A valid point definition can have
multiple forms. Here are some examples: [x, y, z, c], {x, y,
z, c}, {x, y, #c}, {(x, y), c}, (x,y). You can use a vector of
points instead of a list; in this case, the points can be
expressed as complex numbers.
line_ definitions is either a list or a matrix of line
definitions. Each line is defined by two to four numbers:
p1, p2, color and alpha. p1 and p2 are the index in the
points_definition of the two points that define the line.
Color is used to override the per point color definition. If
you need to provide an Alpha, but not a color, use -1 for
the color.
Note that {Color, [Alpha], line_1, ..., line_n} is also a valid
form to avoid respecifying the same color for each line.
rotation_matrix is a matrix between the sizes 2*2 to 3*4
that specifies the rotation and translation of the point using
usual 3D or 4D geometry.
{eye_x, eye_y, eye_z} defines the eye position
(projection).
{3Dxmin, 3Dxmax, 3Dymin, 3Dymax, 3Dzmin, 3Dzmax}
is used to perform 3D clipping on the pretransformed
objects.
Each point is rotated and translated through a
multiplication by the rotation_matrix. It is then projected
on the view plan using the eye position calculated by the
following equation: x=eye_z/z*x-eye_x and y=eye_z/
z*y-eye_y.
Each line is clipped in 3D, if 3D clipping data is provided.
If "N" is specified, the Z coordinates are normalized
between 0 and 255 after rotation, providing easier
zClipping.

282 Programming in HP PPL


If zstring is provided, per pixel z clipping happens using
the z value string (see the following).
LINE_P returns a string that contains all the transformed
points. If you plan to call TRIANGLE or LINE multiple times
in a row using the same points and transformation, you
can do so by replacing the points_definition with this
string and omitting the transformation definition in
subsequent calls to TRIANGLE and LINE.
About zstring:
TRIANGLE_P([G]) returns a string adapted for z clipping.
To use z clipping, call TRIANGLE_P to create a z clipping
string (initialized at 255 for each pixels). You can then call
LINE_P with appropriate z (0-255) values for each of the
triangle vertices and LINE_P will not draw pixels farther
than the already drawn pixels. ZString is automatically
updated as appropriate.

PIXOFF_P

PIXOFF Syntax: PIXOFF([G], x, y)


PIXOFF_P([G], x, y)
Sets the color of the pixel G with coordinates x,y to white.
G can be any of the graphics variables and is optional.
The default is G0, the current graphic

PIXON_P

PIXON Syntax: PIXON([G], x, y [ ,color])


PIXON_P([G], x, y [ ,color])
Sets the color of the pixel G with coordinates x,y to color.
G can be any of the graphics variables and is optional.
The default is G0, the current graphic. Color can be any
color specified as #RRGGBB. The default is black.

RECT_P

RECT Syntax: RECT([G, x1, y1, x2, y2, edgecolor, fillcolor])


RECT_P([G, x1, y1, x2, y2, edgecolor, fillcolor])
Draws a rectangle on G between points x1,y1 and x2,y2
using edgecolor for the perimeter and fillcolor for the
inside.

Programming in HP PPL 283


G can be any of the graphics variables and is optional.
The default is G0, the current graphic.
x1, y1 are optional. The default values represent the top
left of the graphic.
x2, y2 are optional. The default values represent the
bottom right of the graphic.
edgecolor and fillcolor can be any color specified as
#RRGGBB. Both are optional, and fillcolor defaults to
edgecolor if not specified.
To erase a GROB, execute RECT(G). To clear the screen
execute RECT().
When optional arguments are provided in a command
with multiple optional parameters (like RECT), the
arguments provided correspond to the leftmost parameters
first. For example, in the program below, the arguments
40 and 90 in the RECT_P command correspond to x1
and y1. The argument #000000 corresponds to
edgecolor, since there is only the one additional
argument. If there had been two additional arguments,
they would have referred to x2 and y2 rather than
edgecolor and fillcolor. The program produces a
rectangle with a black edge and black fill.
EXPORT BOX()
BEGIN
RECT();
RECT_P(40,90,#0
00000);
WAIT;
END;

The program below also uses the RECT_P command. In


this case, the pair of arguments 320 and 240 correspond
to x2 and y2. The program produces are rectangle with
a black edge and a red fill.

284 Programming in HP PPL


EXPORT BOX()
BEGIN
RECT();
RECT_P(40,90,32
0,240,#000000,#
FF0000);
WAIT;
END;

SUBGROB_P

SUBGROB Syntax: SUBGROB(srcGRB [ ,x1, y1, x2, y2], trgtGRB)


SUBGROB_P(srcGRB [ ,x1, y1, x2, y2], trgtGRB)
Sets trgtGRB to be a copy of the area of srcGRB between
points x1,y1 and x2,y2.
srcGRB can be any of the graphics variables and is
optional. The default is G0.
trgtGRB can be any of the graphics variables except G0.
x2, y2 are optional and if not specified will be the bottom
right of srcGRB.
x1, y1 are optional and if not specified will be the top left
of srcGRB.

Example: SUBGROB(G1, G4) will copy G1 in G4.

TEXTOUT_P

TEXTOUT Syntax: TEXTOUT(text [ ,G], x, y [ ,font, c1, width, c2])


TEXTOUT_P(text [ ,G], x, y [ ,font, c1, width,
c2])
Draws text using color c1 on graphic G at position x, y
using font. Do not draw text more than width pixels wide
and erase the background before drawing the text using
color c2. G can be any of the graphics variables and is
optional. The default is G0.
Font can be:
0: current font selected on the Homes Settings screen, 1:
small font 2: large font. Font is optional and if not
specified is the current font selected on the Homes Settings
screen.

Programming in HP PPL 285


c1 can be any color specified as #RRGGBB. The default is
black (#000000).
width is optional and if not specified, no clipping is
performed.
c2 can be any color specified as #RRGGBB. c2 is
optional. If not specified the background is not erased.
Example:
The following program displays the successive
approximations for π using the series for the arctangent(1).
Note that a color for the text, and for background, has
been specified (with the width of the text being limited to
100 pixels).
EXPORT PISERIES()
BEGIN
LOCAL sign;
K:=2;
A:=4;
sign:=−1;
RECT();
TEXTOUT_P("N=",0,0);
TEXTOUT_P("PI APPROX=",0,30);
REPEAT
A+sign*4/(2*K-1) ▶ A;
TEXTOUT_P(K ,35,0,2,#FFFFFF,
100,#333399);
TEXTOUT_P(A ,90,30,2,#000000,100,
#99CC33);
sign*-1 ▶ sign;
K+1 ▶ K;
UNTIL 0;
END;
END;
The program executes
until the user presses
O to terminate.

286 Programming in HP PPL


TRIANGLE_P

TRIANGLE Syntax: TRIANGLE_P([G], x1, y1, x2, y2, x3, y3, c1,
[c2, c3], [Alpha], ["ZString", z1, z2, z3])
TRIANGLE_P([G], {x1, y1, [c1], [z1]}, {x2, y2,
[c2], [z2]},{x3, y3, [c3], [z3]}, ["ZString"])
TRIANGLE_P([G],points_definition,
triangle_definitions, rotation_matrix or
{rotation_matrix or -1, ["N"], [{eye_x, eye_y,
eye_z} or -1], [{3Dxmin, 3Dxmax, 3Dymin,
3Dymax, 3Dzmin, 3Dzmax}]}, [zstring])
TRIANGLE_P([G],pre_rotated_points,
triangle_definitions, [zstring])
TRIANGLE_P([G])
The basic form of TRIANGLE draws one triangle between
the specified pixel coordinates in the graphic using the
specified color and transparency (0 ≤ Alpha ≤ 255). If
three colors are specified, it blends the colors in between
the vertices.
The advanced form of TRIANGLE_P allows multiple
triangles to be rendered at the same time with a potential
3D transformation of the triangles’ vertices.
This is mostly used if you have a set of vertices and
triangles and want to display them all at once (faster).
points_definition is either a list or a matrix of point
definition. Each point is defined by two to four numbers:
x, y, z, and color. A valid point definition can have
multiple forms. Here are a couple of example: [x, y, z, c],
{x, y, z, c}, {x, y, #c}, {(x, y), c}, (x,y)... You can use a
vector of points instead of a list; in this case, the points can
be expressed as complex numbers.
triangle_ definitions is either a list or a matrix of triangle
definitions. Each triangle is defined by three to five
numbers: p1, p2, p3, color and alpha. p1, p2 and p3 are
the index in the points_definition of the 3 points that
define the triangle. Color is used to override the per point
color definition. If you need to provide an Alpha, but not
a color, use -1 for the color.

Programming in HP PPL 287


Note that {Color, [Alpha], triangle_1, ..., triangle_n} is
also a valid form to avoid respecifying the same color for
each triangle.
rotation_matrix is a matrix between sizes 2*2 to 3*4 that
specifies the rotation and translation of the point using
usual 3D and 4D geometry.
{eye_x, eye_y, eye_z} defines the eye position
(projection).
{3Dxmin, 3Dxmax, 3Dymin, 3Dymax, 3Dzmin, 3Dzmax}
is used to perform 3D clipping on the pretransformed
objects.
Each point is rotated and translated through a
multiplication by the rotation_matrix. It is then projected
on the view plan using the eye position calculated by the
following equation: x=eye_z/z*x-eye_x and y=eye_z/
z*y-eye_y.
Each triangle is clipped in 3D, if 3D clipping data is
provided.
If "N" is specified, the Z coordinates are normalized
between 0 and 255 after rotation, providing easier
zClipping.
If zstring is provided, per pixel z clipping happens using
the z value string (see the following).
TRIANGLE_P returns a string which contains all the
transformed points. If you plan to call TRIANGLE or LINE
multiple times in a row using the same points and
transformation, you can do so by replacing the
points_definition with this string and omitting the
transformation definition in subsequent calls to TRIANGLE
and LINE.
About zstring:
TRIANGLE_P([G]) returns a string adapted for z clipping.
To use z clipping, call TRIANGLE_P to create a z clipping
string (initialized at 255 for each pixels). You can then call
TRIANGLE_P with appropriate z (0-255) values for each
of the triangle vertices and TRIANGLE_P will not draw
pixels farther than the already drawn pixels. ZString is
automatically updated as appropriate.

288 Programming in HP PPL


Matrix
Some matrix commands take as their argument the matrix
variable name on which the command is applied. Valid
names are the global variables M0–M9 or a local
variable that contains a matrix.

ADDCOL Syntax: ADDCOL(matrix, vector,


column_number)
Inserts the values in vector into a new column inserted
before column_number in the specified matrix. The
number of values in the vector must be the same as the
number of rows in the matrix.

ADDROW Syntax: ADDROW(matrix, vector, row_number)


Inserts the values in vector into a new row inserted
before row_number in the specified matrix. The number
of values in the vector must be the same as the number of
columns in the matrix.

DELCOL Syntax: DELCOL(matrix,column_number)


Deletes column column_number from the matrix.

DELROW Syntax: DELROW(matrix,row_number)


Deletes row row_number from the matrix.

EDITMAT Syntax: EDITMAT(matrix)


Starts the Matrix Editor and displays the specified matrix.
If used in programming, returns to the program when user
presses . Even though this command returns the
matrix that was edited, EDITMAT cannot be used as an
argument in other matrix commands.

REDIM Syntax: REDIM(matrix, size)


Redimensions the specified matrix or vector to size. For a
matrix, size is a list of two integers (n1,n2). For a vector,
size is a list containing one integer (n). Existing values in
the matrix are preserved. Fill values will be 0.

REPLACE Syntax: REPLACE(matrix, start, object)


Replaces portion of a matrix or vector stored in matrix with
an object starting at position start. Start for a matrix is a
list containing two numbers; for a vector, it is a single

Programming in HP PPL 289


number. REPLACE also works with lists, graphics, and
strings. For example, REPLACE("123456", 2, "GRM") ->
"1GRM56"

SCALE Syntax: SCALE(matrix, value, rownumber)


Multiplies the specified row_number of the specified
matrix by value.

SCALEADD Syntax: SCALEADD (matrix, value, row1, row2)


Multiplies the specified row1 of the matrix by value,
then adds this result to the second specified row2 of the
matrix and replaces row1 with the result.

SUB Syntax: SUB (matrix, start, end)


Extracts a sub-object—a portion of a list, matrix, or
graphic—and stores it in matrix. Start and end are each
specified using a list with two numbers for a matrix, a
number for vector or lists, or an ordered pair, (X,Y), for
graphics: SUB(M1{1,2},{2,2})

SWAPCOL Syntax: SWAPCOL (matrix, column1, column2)


Swaps column1 and column2 of the specified matrix.

SWAPROW Syntax: SWAPROW(matrix, row1, row2)


Swaps row1 and row2 in the specified matrix.

App Functions
These commands allow you to launch any HP app, bring
up any view of the current app, and change the options in
the View menu.

STARTAPP Syntax: STARTAPP("name")

Starts the app with name. This will cause the app
program’s START function to be run, if it is present. The
app’s default view will be started. Note that the START
function is always executed when the user taps in
the Application Library. This also works for user-defined
apps.
Example: STARTAPP("Function") launches the Function
app.

STARTVIEW Syntax: STARTVIEW( n [,draw?])

290 Programming in HP PPL


Starts the nth view of the current app. If draw? is true (that
is, not 0), it will force an immediate redrawing of the
screen for that view.
The view numbers (n) are as follows:
Symbolic:0
Plot:1
Numeric:2
Symbolic Setup:3
Plot Setup:4
Numeric Setup:5
App Info: 6
View Menu:7
First special view (Split Screen Plot Detail):8
Second special view (Split Screen Plot Table):9
Third special view (Autoscale):10
Fourth special view (Decimal):11
Fifth special view (Integer):12
Sixth special view (Trig):13

The special views in parentheses refer to the Function app,


and may differ in other apps. The number of a special
view corresponds to its position in the View menu for that
app. The first special view is launched by
STARTVIEW(8), the second with STARTVIEW(9), and
so on.
You can also launch views that are not specific to an app
by specifying a value for n that is less than 0:
Home Screen:-1
Home Settings:-2
Memory Manager:-3
Applications Library:-4
Matrix Catalog:-5
List Catalog:-6
Program Catalog:-7
Notes Catalog:-8

VIEW Syntax: VIEW ("string"[,program_name])


BEGIN
Commands;
END;

Programming in HP PPL 291


Adds a custom option to the View menu. When string
is selected, runs program_name. See “The
DiceSimulation program” on page 264.

Integer
BITAND Syntax: BITAND(int1, int2, … intn)
Returns the bitwise logical AND of the specified integers.
Example: BITAND(20,13) returns 4.

BITNOT Syntax: BITNOT(int)


Returns the bitwise logical NOT of the specified integer.
Example: BITNOT(47) returns 549755813840.

BITOR Syntax: BITOR(int1, int2, … intn)


Returns the bitwise logical OR of the specified integers.
Example: BITOR(9,26) returns 27.

BITSL Syntax: BITSL(int1 [,int2])


Bitwise Shift Left. Takes one or two integers as input and
returns the result of shifting the bits in the first integer to the
left by the number places indicated by the second integer.
If there is no second integer, the bits are shifted to the left
by one place.
Examples:
BITSL(28,2) returns 112
BITSL(5) returns 10.

BITSR Syntax: BITRL(int1 [,int2])


Bitwise Shift Right. Takes one or two integers as input and
returns the result of shifting the bits in the first integer to the
right by the number places indicated by the second
integer. If there is no second integer, the bits are shifted to
the right by one place.
Examples:
BITSR(112,2) returns 28
BITSR(10) returns 5.

BITXOR Syntax: BITXOR(int1, int2, … intn)

292 Programming in HP PPL


Returns the bitwise logical exclusive OR of the specified
integers.
Example: BITXOR(9,26) returns 19.

B→R Syntax: B→R(#integerm)


Converts an integer in base m to a decimal integer (base
10). The base marker m can be b (for binary), o (for
octal), or h (for hexadecimal).
Example: B→R(#1101b) returns 13

GETBASE Syntax: GETBASE(#integer[m])


Returns the base for the specified integer (in whatever is
the current default base): 0 = default, 1 = binary, 2 =
octal, 3 = hexadecimal.
Examples: GETBASE(#1101b) returns #1h (if the
default base is hexadecimal) while GETBASE (#1101)
returns #0h.

GETBITS Syntax: GETBITS(#integer)


Returns the number of bits used by integer, expressed in
the default base.
Example: GETBITS(#22122) returns #20h or 32

R→B Syntax: R→B(integer)


Converts a decimal integer (base 10) to an integer in the
default base.
Example: R→B(13) returns #1101b (if the default base is
binary) or #Dh (if the default base is hexadecimal).

SETBITS Syntax: SETBITS(#integer[m] [,bits])


Sets the number of bits to represent integer. Valid values
are in the range –64 to 65. If m or bits is omitted, the
default value is used.
Example: SETBITS(#1111b, 15) returns #1111:b15

SETBASE Syntax: SETBASE(#integer[m][c])


Displays integer expressed in base m in whatever base is
indicated by c, where c can be 1 (for binary), 2 (for
octal), or 3 (for hexadecimal). Parameter m can be b (for
binary), d (for decimal), o (for octal), or h (for
hexadecimal). If m is omitted, the input is assumed to be
in the default base. Likewise, if c is omitted, the output is
displayed in the default base.

Programming in HP PPL 293


Examples: SETBASE (#34o,1) returns #11100b while
SETBASE (#1101) returns #0h ((if the default base is
hexadecimal).

I/O
I/O commands are used for inputting data into a
program, and for outputting data from a program. They
allow users to interact with programs.

CHOOSE Syntax: CHOOSE(var, "title", "item1",


"item2",…,"itemn")
Displays a choose box with the title and containing the
choose items. If the user selects an object, the variable
whose name is provided will be updated to contain the
number of the selected object (an integer, 1, 2, 3, …) or
0 if the user taps .
Returns true (not zero) if the user selects an object;
otherwise, returns false (0).
Example:
CHOOSE
(N,"PickHero",
"Euler","Gauss
","Newton");
IF N==1 THEN
PRINT("You
picked
Euler"); ELSE
IF N==2 THEN PRINT("You picked
Gauss");ELSE PRINT("You picked
Newton");
END;
END;
After execution of CHOOSE, the value of N will be updated
to contain 0, 1, 2, or 3. The IF THEN ELSE command
causes the name of the selected person to be printed to
the terminal.

294 Programming in HP PPL


EDITLIST Syntax: EDITLIST(listvar)
Starts the List Editor loading listvar and displays the
specified list. If used in programming, returns to the
program when user taps .
Example: EDITLIST(L1) edits list L1.

EDITMAT Syntax: EDITMAT(matrixvar)


Starts the Matrix Editor and displays the specified matrix.
If used in programming, returns to the program when user
taps .
Example: EDITMAT(M1) edits matrix M1.

GETKEY Syntax: GETKEY


Returns the ID of the first key in the keyboard buffer, or –1
if no key was pressed since the last call to GETKEY. Key
IDs are integers from 0 to 50, numbered from top left (key
0) to bottom right (key 50) as shown in figure 5-1.

0 1 3 4

Keys 0–13
{ 5
6

11
7
2

12
8 9

13
10

Keys 14–19

Keys 20–25

Keys 26–30

Keys 31–35

Keys 36–40

Keys 41–45

Keys 46–50

Figure 5-1: Numbers of the keys

Programming in HP PPL 295


INPUT Syntax: INPUT(var,[“title”], [“label”], [“help”],
[reset_value][initial_value])
INPUT({vars},[“title”], [{“labels”}], [{“help”}],
[{reset_values}], [{initial_values}])
The simpler form of this command opens a dialog box
with the given title and one field named label, displaying
help at the bottom. The dialog box includes the CANCEL
and OK menu keys. The user can enter a value in the
labeled field. If the user presses the OK menu key, the
variable var is updated with the entered value and 1 is
returned. If the user presses the CANCEL menu key, the
variable is not updated and 0 is returned.

In the more complex form of the command, lists are used


to create a multi-field dialog box. If var is a list, each
element can be either a variable name or a list using the
following syntax.

• {var_name, real, [{pos}]} to create a check box


control. If real is >1, this check box gets pooled with
the next n -1 check boxes in a radio group (that is,
only one of the n check boxes can be checked at any
time)
• {var_name, [allowed_types_matrix] , [{pos}]} to
create an edit field. [allowed_types_matrix] lists all
the allowed types ([-1] stands for all types allowed). If
the only allowed type is a string, the edition hides the
double quotes.
• {var_name, {Choose items}, [{pos}]} to create a
choose field.
If pos is specified, it is a list of the form {field start in screen
%, field width in screen%, line(starts at 0)}. This allows you
to control the precise position and size of your fields. Note
that you have to specify pos for either none or all fields in
the dialog box.
There is a maximum of seven lines of controls per page.
Controls with more than seven lines are placed in
subsequent pages. If more than one page is created,
["title"] can be a list of titles.

296 Programming in HP PPL


ISKEYDOWN Syntax: ISKEYDOWN(key_id);
Returns true (non-zero) if the key whose key_id is provided
is currently pressed, and false (0) if it is not.

MOUSE Syntax: MOUSE[(index)]


Returns two lists describing the current location of each
potential pointer (or empty lists if the pointers are not
used). The output is {x , y, original z, original y, type}
where type is 0 (for new), 1 (for completed), 2 (for drag),
3 (for stretch), 4 (for rotate), and 5 (for long click).
The optional parameter index is the nth element that
would have been returned—x, y, original x, etc.—had the
parameter been omitted (or –1 if no pointer activity had
occurred).

MSGBOX Syntax: MSGBOX(expression or string [ ,ok_cancel?]);


Displays a message box with the value of the given
expression or string.
If ok_cancel? is true, displays the and
buttons, otherwise only displays the button. Default
value for ok_cancel is false.
Returns true (non-zero) if the user taps , false (0) if
the user presses .

EXPORT AREACALC()
BEGIN
LOCAL radius;
INPUT(radius, "Radius of Circle","r =
","Enter radius",1);
MSGBOX("The area is " +π*radius^2);
END;
If the user enters 10 for
the radius, the message
box shows this:

Programming in HP PPL 297


PRINT Syntax: PRINT(expression or string);
Prints the result of expression or string to the terminal.
The terminal is a program text output viewing mechanism
which is displayed only when PRINT commands are
executed. When visible, you can press \ or = to view
the text, Cto erase the text and any other key to hide
the terminal. Pressing O stops the interaction with the
terminal. PRINT with no argument clears the terminal.
There are also commands for outputting data in the
Graphics section. In particular, the commands TEXTOUT
and TEXTOUT_P can be used for text output.
This example prompts the user to enter a value for the
radius of a circle, and prints the area of the circle on the
terminal.
EXPORT AREACALC()
BEGIN
LOCAL radius;
INPUT(radius,
"Radius of
Circle","r =
","Enter
radius",1);

PRINT("The
area is "
+π*radius^2);
END;

Notice the use of the


LOCAL variable for the
radius, and the naming
convention that uses lower case letters for the local
variable. Adhering to such a convention will improve the
readability of your programs.

WAIT Syntax: WAIT(n);


Pauses program execution for n seconds. With no
argument or with n = 0, pauses program execution for one
minute.

298 Programming in HP PPL


More
%CHANGE Syntax: %CHANGE(x,y)
The percentage change in going from x to y.
Example: %CHANGE(20,50) returns 150.

%TOTAL Syntax: %TOTAL(x,y)


The percentage of x that is y.
Example: %TOTAL(20,50) returns 250.

CAS Syntax: CAS.function() or CAS.variable


Executes the function or returns the variable using the
CAS.

EVALLIST Syntax: EVALLIST({list})


Evaluates the content of each element in a list and returns
an evaluated list.

EXECON Syntax: EXECON(&expr, List1, [List2,…])


Creates a new list based on the elements in one or more
lists by iteratively modifying each element according to an
expression that contains the ampersand character (&).
Examples:
EXECON("&+1",{1,2,3}) returns {2,3,4}

Where the & is followed directly by a number, the position


in the list is indicated. For example:
EXECON("&2–&1",{1, 4, 3, 5}" returns {3, –1,
2}

In the example above, &2 indicates the second element


and &1 the first element in each pair of elements. The
minus operator between them subtracts the first from the
second in each pair until there are no more pairs. In this
case (with just a single list), the numbers appended to &
can only be from 1 to 9 inclusive.
EXECON can also operate on more than one list. For
example:
EXECON("&1+&2",{1,2,3},{4,5,6}) returns
{5,7,9}

In the example above, &1 indicates an element in the first


list and &2 indicates the corresponding element in the

Programming in HP PPL 299


second list. The plus operator between them adds the two
elements until there are no more pairs. With two lists, the
numbers appended to & can have two digits; in this case,
the first digit refers to the list number (in order from left to
right) and the second digit can still only be from 1 to 9
inclusive.
EXECON can also begin operating on a specified
element in a specified list. For example:
EXECON("&23+&1",{1,5,16},{4,5,6,7}) returns
{7,12}

In the example above, &23 indicates that operations are


to begin on the second list and with the third element. To
that element is added the first element in the first list. The
process continues until there are no more pairs.

→HMS Syntax: →HMS(value)


Converts a decimal value to hexagesimal format; that is,
in units subdivided into groups of 60. This includes
degrees, minutes, and seconds as well as hours, minutes,
and seconds.
Example: →HMS(54.8763) returns 54°52′34.68″

HMS→ Syntax: HMS→(value)


Converts a value expressed in hexagesimal format to
decimal format.
Example: HMS→(54°52′34.68″) returns 54.8763

ITERATE Syntax: ITERATE(expr, var, ivalue, #times)


For #times, recursively evaluates expr in terms of var
beginning with var = ivalue.
Example: ITERATE(X^2, X, 2, 3) returns 256

TICKS Syntax: TICKS


Returns the internal clock value in milliseconds.

TIME Syntax: TIME(program_name)


Returns the time in milliseconds required to execute the
program program_name. The results are stored in the
variable TIME. The variable TICKS is similar. It contains
the number of milliseconds since boot up.

300 Programming in HP PPL


TYPE Syntax: TYPE(object)
Returns the type of the object:
0: Real
1: Integer
2: String
3: Complex
4: Matrix
5: Error
6: List
8: Function
9: Unit
14.?: cas object. The fractional part is the cas type.

Variables and Programs


The HP Prime has four types of variables: Home variables,
App variables, CAS variables, and User variables. You
can retrieve these variables from the Variable menu (a).

The names of Home variables are reserved; that is, they


cannot be deleted from the system and cannot be used to
store objects of any other type than that for which they
were designed. For example, A–Z and θ are reserved to
store real numbers, Z0–Z9 are reserved to store complex
numbers, and L0–L9 are reserved to store lists, etc. As a
result, you cannot store a matrix in L8 or a list in Z.
Home variables keep the same value in Home and in
apps; that is, they are global variables common to the
system. They can be used in programs with that
understanding.

App variable names are also reserved, though a number


of apps may share the same app variable name. In any of
these cases, the name of the app variable must be
qualified if that variable is not from the current app. For
example, if the current app is the Function app, Xmin will
return the minimum x-value in the Plot view of the Function
app. If you want the minimum value in the Plot view of the
Polar app, then you must enter Polar.Xmin. App

Programming in HP PPL 301


variables represent the definitions and settings you make
when working with apps interactively. As you work
through an app, the app functions may store results in app
variables as well. In a program, app variables are used to
edit an app’s data to customize it and to retrieve results
from the app’s operation.

CAS variables are similar to the Home real variables A–Z,


except that they are lowercase and designed to be used
in CAS view and not Home view. Another difference is
that Home and App variables always contain values,
while CAS variables can be simply symbolic and not
contain any particular value. The CAS variables are not
typed like the Home and App variables. For example, the
CAS variable t may contain a real number, a list, or a
vector, etc. If a CAS variable has a value stored in it,
calling it from Home view will return its contents.

User variables are variables created by the user, either


directly or exported from a user program. They provide
one of several mechanisms to allow programs to
communicate with the rest of the calculator and with other
programs. User variables created in a program may be
either local to that program or global. Once a variable
has been exported from a program, it will appear among
the user variables in the Variables menu, next to the
program that exported it. User variables may be multi-
character, but must follow certain rules; see “Variables
and visibility” on page 251 for details.
User variables, like CAS variables, are not typed and thus
may contain objects of different types.
The following sections deal with using app variables in
programs, providing descriptions of each app variable by
name and its possible contents. For a list of all the Home
and app variables, see chapter 4, “Variables”, beginning
on page 215. For user variables in programs, see “The HP
Prime programming language”, beginning on page 251.

302 Programming in HP PPL


App Not all app variables are used in every app. S1Fit, for
variables example, is only used in the Statistics 2Var app. However,
many of the variables are common to the Function,
Advanced Graphing, Parametric, Polar, Sequence, Solve,
Statistics 1Var, and Statistics 2Var apps. If a variable is
not available in all of these apps, or is available only in
some of these apps (or some other app), then a list of the
apps where the variable can be used appears under the
variable name.
The following sections list the app variables by the view in
which they are used. To see the variables listed by the
categories in which they appear on the Variables menu
see “App variables”, beginning on page 221.

Plot view variables


Axes Turns axes on or off.
In Plot Setup view, check (or uncheck) AXES.
In a program, type:
0  Axes—to turn axes on.
1  Axes—to turn axes off.

Cursor Sets the type of cursor. (Inverted or blinking is useful if the


background is solid).
In Plot Setup view, choose Cursor.
In a program, type:
0  Cursor—for solid crosshairs (default)
1  Cursor—to invert the crosshairs
2  Cursor—for blinking crosshairs.

GridDots Turns the background dot grid in Plot view on or off.


In Plot Setup view, check (or uncheck) GRID DOTS.
In a program, type:
0  GridDots—to turn the grid dots on (default).
1  GridDots—to turn the grid dots off.

Programming in HP PPL 303


GridLines Turns the background line grid in Plot View on or off.
In Plot Setup view, check (or uncheck) GRID LINES.
In a program, type:
0  GridLines—to turn the grid lines on (default).
1  GridLines—to turn the grid lines off.

Hmin/Hmax Defines the minimum and maximum values for histogram


Statistics 1Var bars.
In Plot Setup view for one-variable statistics, set values for
HRNG.
In a program, type:
n 1  Hmin
n 2  Hmax
where n 1 < n 2

Hwidth Sets the width of histogram bars.


Statistics 1Var In Plot Setup view for one-variable statistics, set a value for
Hwidth.
In a program, type:
n  Hwidth where n > 0

Labels Draws labels in Plot View showing X and Y ranges.


In Plot Setup View, check (or uncheck) Labels.
In a program, type:
1  Labels—to turn labels on (default)
0  Labels—to turn labels off.

Method Defines the graphing method: adaptive, fixed-step


Function, Solve, segments, or fixed-step dots.
Parametric, Polar, In a program, type:
Statistics 2Var
0  Method—select adaptive
1  Method—select fixed-step segments
2  Method—select fixed-step dots

304 Programming in HP PPL


Nmin/Nmax Defines the minimum and maximum values for the
Sequence independent variable.
Appears as the N RNG fields in the Plot Setup view. In Plot
Setup view, enter values for N Rng.
In a program, type:
n1  Nmin
n2  Nmax
where n 1 < n 2

PixSize Sets the dimensions of each square pixel in the Geometry


Geometry app. In Plot view, enter a positive value in Pixel Size.
Or enter PixSize:=n, where n>0.

Recenter Recenters at the cursor when zooming.


From Plot-Zoom-Set Factors, check (or uncheck)
Recenter.
In a program, type:
0  Recenter— to turn recenter on (default).
1  Recenter— to turn recenter off.

S1mark-S5mark Sets the mark to use for scatter plots.


Statistics 2Var In Plot Setup view for two-variable statistics, select one of
S1 Mark-S Mark.

ScrollText Determines whether the current command in Plot view


Geometry scrolls automatically or manually. In Plot view, select or
clear Scroll Text.
You can also enter ScrollText:=0 to scroll manually or
ScrollText:=1 to scroll automatically.

SeqPlot Enables you to choose between a Stairstep or a Cobweb


Sequence plot.
In Plot Setup view, select SeqPlot, then choose
Stairstep or Cobweb.
In a program, type:
0  SeqPlot—for Stairstep.
1  SeqPlot—for Cobweb.

Programming in HP PPL 305


θmin/θmax Sets the minimum and maximum independent values.
Polar In Plot Setup view enter values for θ Rng.
In a program, type:
n 1  θ min
n 2  θ max
where n 1 < n 2

θstep Sets the step size for the independent variable.


Polar In Plot Setup view, enter a value for θ Step.
In a program, type:
n  θ step
where n > 0

Tmin/Tmax Sets the minimum and maximum independent variable values.


Parametric In Plot Setup view, enter values for T Rng.
In a program, type:
n1  Tmin
n2  Tmax
where n 1 < n 2

Tstep Sets the step size for the independent variable.


Parametric In Plot Setup view, enter a value for T Step.
In a program, type
n  Tstep
where n > 0

Xtick Sets the distance between tick marks for the horizontal axis.
In Plot Setup view, enter a value for X Tick.
In a program, type:
n  Xtick where n > 0

Ytick Sets the distance between tick marks on the vertical axis.
In Plot Setup view, enter a value for Y Tick.
In a program, type:
n  Ytick where n > 0

306 Programming in HP PPL


Xmin/Xmax Sets the minimum and maximum horizontal values of the
plot screen.
In Plot Setup view, enter values for X Rng.
In a program, type:
n1  Xmin
n2  Xmax
where n 1 < n 2

Ymin/Ymax Sets the minimum and maximum vertical values of the plot
screen.
In Plot Setup view, enter the values for Y Rng.
In a program, type:
n1  Ymin
n2  Ymax
where n 1 < n 2

Xzoom Sets the horizontal zoom factor.


In Plot View, press then . Scroll to Set
Factors,select it and tap . Enter the value for X
Zoom and tap .
In a program, type:
n  Xzoom
where n > 0
The default value is 4.

Yzoom In Plot View, tap then . Scroll to Set


Factors and tap . Enter the value for Y Zoom
and tap .
Or, in a program, type:
n  Yzoom where n > 0
The default value is 4.

Programming in HP PPL 307


Symbolic view variables
AltHyp Determines the alternative hypothesis used for hypothesis
Inference testing.
In Symbolic View, select an option for Alt Hypoth.
In a program, type:
0  AltHyp—for μ < μ 0
1  AltHyp—for μ > μ 0
2  AltHyp—for μ ≠ μ 0

E0...E9 Contains an equation or expression. In Symbolic view,


Solve select one of E0 through E9 and enter an expression or
equation. The independent variable is selected by
highlighting it in Numeric view.
In a program, type (for example):
X+Y*X-2=Y▶ E1

F0...F9 Contains an expression in X. In Symbolic View, select one


Function of F0 through F9 and enter an expression.
In a program, type (for example):
SIN(X) ▶ F1

H1...H5 Contains a list of the dataset(s) that define a 1-variable


Statistics 1Var statistical analysis. The first column in the list is the
independent column and the second (if any) specifies the
column used for the frequencies. For example, H1 by
default returns {D1, “”}, where D1 is the default
independent column and “” indicates that there is no
column used for frequencies. In Symbolic view, select one
of H1 through H5 and enter an independent column and
an optional frequency column.

308 Programming in HP PPL


H1Type...H5Type Sets the type of plot used to graphically represent the
Statistics 1Var statistical analyses H1 through H5. In Symbolic View,
specify the type of plot in the field for Plot1, Plot2, etc.
Or in a program, store one of the following constant
integers or names into the variables H1Type, H2Type,
etc.
1 Histogram (default)
2 Box and Whisker
3 Normal Probability
4 Line
5 Bar
6 Pareto
Example:
2H3Type

Method Determines whether the Inference app is set to calculate


Inference hypothesis test results or confidence intervals. In Symbolic
view, make a selection for Method.
In a program, type:
0  Method—for Hypothesis Test
1  Method—for Confidence Interval
2  Method—for Chi-Square
3  Method—for Regression

R0...R9 Contains an expression in θ . In Symbolic view, select one


Polar of R0 through R9 and enter an expression.
In a program, type (for example):
SIN( θ )  R1

S1...S5 Contains a list that defines a 2-variable statistical analysis.


Statistics 2Var Returns a list containing the independent column name,
the dependent column name and the fit equation (if any).

Programming in HP PPL 309


S1Type...S5Type Sets the type of fit to be used by the FIT operation in
Statistics 2Var drawing the regression line. From Symbolic view, specify
the fit in the field for Type1,Type2, etc.
In a program, store one of the following constant integers
into a variable S1Type,S2Type, etc.
1 Linear
2 Logarithmic
3 Exponential
4 Power
5 Exponent
6 Inverse
7 Logistic
8 Quadratic
9 Cubic
10 Quartic
11 User Defined
Example:
3  S2Type

InfType Determines the type of hypothesis test or confidence


Inference interval. Depends upon the value of the variable Method.
From Symbolic View, make a selection for Type.
Or, in a program, store the constant number from the list
below into the variable Type. With Method=0, the
constant values and their meanings are as follows:
0 Z-Test:1 μ
1 Z-Test: μ 1 – μ 2
2 Z-Test:1 π
3 Z-Test: π 1 – π 2
4 T-Test:1 μ
5 T-Test: μ 1 – μ 2

310 Programming in HP PPL


With Method=1, the constants and their meanings are as
follows:
0 Z-Int:1 μ
1 Z-Int: μ 1 – μ 2
2 Z-Int:1 π
3 Z-Int: π 1 – π 2
4 T-Int:1 μ
5 T-Int: μ 1 – μ 2
With Method=2, the constants and their meanings are as
follows:
0 Chi-square goodness of fit test
1 Chi-square two-way test
With Method=3, the constants and their meanings are as
follows:
0 Linear t-test
1 Interval: Slope
2 Interval: Intercept
3 Interval: Mean Response
4 Prediction Interval

X0, Y0...X9,Y9 Contains two expressions in T: X(T) and Y(T). In


Parametric Symbolic view, select any of X0–Y0 through X9–Y9 and
enter expressions in T.
In a program, store expressions in T in Xn and Yn, where
n is an integer from 0 to 9.
Example:
SIN(4*T) Y1;2*SIN(6*T) X1

U0...U9 Contains an expression in N. In Symbolic view, select any


Sequence of U0 through U9 and enter an expression in N, Un(N-1),
or Un(N-2).
In a program, use the RECURSE command to store the
expression in Un, where n is an integer from 0 to 9.
Example:
RECURSE (U,U(N-1)*N,1,2)  U1

Programming in HP PPL 311


Numeric view variables
C0...C9 Contain lists of numerical data. In Numeric view, enter
Statistics 2Var numerical data in C0 through C9.
In a program, type:
LIST  Cn
where n = 0 , 1, 2, 3 ... 9 and LIST is either a list or the
name of a list.

D0...D9 Contain lists of numerical data. In Numeric view, enter


Statistics 1Var numerical data in D0 through D9.
In a program, type:
LIST  Dn
where n = 0 , 1, 2, 3 ... 9 and LIST is either a list or the
name of a list.

NumIndep Specifies the list of independent values (or two-value sets


Function of independent values) to be used by Build Your Own
Parametric Table. Enter your values one-by-one in the Numeric view.
Polar In a program, type:
Sequence
Advanced LIST  NumIndep
Graphing List can be either a list itself or the name of a list. In the
case of the Advanced Graphing app, the list will be a list of
pairs (a list of 2-element vectors) rather than a list of numbers.
NumStart Sets the starting value for a table in Numeric view.
Function
From Numeric Setup view, enter a value for NUMSTART.
Parametric
Polar In a program, type:
Sequence n  NumStart

NumXStart Sets the starting number for the X-values in a table in


Advanced Graphing Numeric view.
From Numeric Setup view, enter a value for NUMXSTART.
In a program, type:
n  NumXStart

312 Programming in HP PPL


NumYStart Sets the starting value for the Y-values in a table in
Advanced Graphing Numeric view.
From Numeric Setup view, enter a value for NUMYSTART.
In a program, type:
n  NumYStart
NumStep Sets the step size (increment value) for the independent
Function variable in Numeric view.
Parametric From Numeric Setup view, enter a value for NUMSTEP.
Polar
Sequence In a program, type:
n  NumStep
where n > 0
NumXStep Sets the step size (increment value) for the independent X
Advanced Graphing variable in Numeric view.
From Numeric Setup view, enter a value for NUMXSTEP.
In a program, type:
n  NumXStep
where n > 0
NumYStep Sets the step size (increment value) for the independent Y
Advanced Graphing variable in Numeric view.
From Numeric Setup view, enter a value for NUMYSTEP.
In a program, type:
n  NumYStep
where n > 0
NumType Sets the table format.
Function
In Numeric Setup view, make a selection for Num Type.
Parametric
Polar In a program, type:
Sequence 0  NumType—for Automatic (default).
Advanced Graphing
1  NumType—for BuildYourOwn.

NumZoom Sets the zoom factor in the Numeric view.


Function From Numeric Setup view, type in a value for NUMZOOM.
Parametric
Polar In a program, type:
Sequence n  NumZoom
where n > 0

Programming in HP PPL 313


NumXZoom Sets the zoom factor for the values in the X column in the
Advanced Graphing Numeric view.
From Numeric Setup view, type in a value for NUMXZOOM.
In a program, type:
n  NumXZoom
where n > 0
NumYZoom Sets the zoom factor for the values in the Y column in the
Advanced Graphing Numeric view.
From Numeric Setup view, type in a value for NUMYZOOM.
In a program, type:
n  NumYZoom
where n > 0

Inference The following variables are used by the Inference app.


app They correspond to fields in the Inference app Numeric
view. The set of variables shown in this view depends on
variables the hypothesis test or the confidence interval selected in
the Symbolic view.

Alpha Sets the alpha level for the hypothesis test. From the
Numeric view, set the value of Alpha.
In a program, type:
n  Alpha
where 0 < n < 1

Conf Sets the confidence level for the confidence interval. From
Numeric view, set the value of C.
In a program, type:
n  Conf
where 0 < n < 1

ExpList Contains the expected counts by category for the chi-


square goodness of fit test. In the Symbolic view field
Expected, select Count. Then, in Numeric view, enter the
data in ExpList.

314 Programming in HP PPL


Mean1 Sets the value of the mean of a sample for a 1-mean
hypothesis test or confidence interval. For a 2-mean test or
interval, sets the value of the mean of the first sample.
From Numeric view, set the value of x or x 1 .
In a program, type:
n  Mean1

Mean2 For a 2-mean test or interval, sets the value of the mean of
the second sample. From Numeric view, set the value of
x2 .
In a program, type:
n  Mean2

μ0 Sets the assumed value of the population mean for a


hypothesis test. From the Numeric view, set the value of μ0.
In a program, type:
n  μ0
where 0 < μ0 < 1

n1 Sets the size of the sample for a hypothesis test or


confidence interval. For a test or interval involving the
difference of two means or two proportions, sets the size
of the first sample. From the Numeric view, set the value of
n1.
In a program, type:
n  n1

n2 For a test or interval involving the difference of two means


or two proportions, sets the size of the second sample.
From the Numeric view, set the value of n2.
In a program, type:
n  n2

ObsList Contains the observed count data for the chi-square


goodness of fit test. In Numeric view, enter your data in
ObsList.

ObsMat Contains the observed counts by category for the chi-


square two-way test. In Numeric view, enter your data in
ObsMat.

Programming in HP PPL 315


π0 Sets the assumed proportion of successes for the One-
proportion Z-test. From the Numeric view, set the value of
π0.
In a program, type:
n  π0
where 0 < π0 < 1

Pooled Determine whether or not the samples are pooled for tests
or intervals using the Student’s T-distribution involving two
means. From the Numeric view, set the value of Pooled.
In a program, type:
0  Pooled—for not pooled (default).
1  Pooled—for pooled.

ProbList Contains the expected probabilities by category for the


chi-square goodness of fit test. In the Symbolic view, in the
Expected box, select Probability. Then, in Numeric
view, enter the data in ProbList.

s1 Sets the sample standard deviation for a hypothesis test or


confidence interval. For a test or interval involving the
difference of two means or two proportions, sets the
sample standard deviation of the first sample. From the
Numeric view, set the value of s1.
In a program, type:
n  s1

s2 For a test or interval involving the difference of two means


or two proportions, sets the sample standard deviation of
the second sample. From the Numeric view, set the value
of s2.
In a program, type:
n  s2

316 Programming in HP PPL


σ1 Sets the population standard deviation for a hypothesis
test or confidence interval. For a test or interval involving
the difference of two means or two proportions, sets the
population standard deviation of the first sample. From the
Numeric view, set the value of σ1.
In a program, type:
n  σ1

σ2 For a test or interval involving the difference of two means


or two proportions, sets the population standard deviation
of the second sample. From the Numeric view, set the
value of σ2.
In a program, type:
n  σ2

x1 Sets the number of successes for a one-proportion


hypothesis test or confidence interval. For a test or interval
involving the difference of two proportions, sets the
number of successes of the first sample. From the Numeric
view, set the value of x1.
In a program, type:
n  x1

x2 For a test or interval involving the difference of two


proportions, sets the number of successes of the second
sample. From the Numeric view, set the value of x2.
In a program, type:
n  x2

Xlist Contains the list of explanatory data (X) for the regression
tests and intervals. In Numeric view, enter your data in
Xlist.

Xval For the confidence interval for the mean response and
prediction interval for a future response, contains the value
of the explanatory variable (X) under scrutiny. Enter a
value when prompted by the wizard.

Ylist Contains the list of response data (Y) for the regression
tests and intervals. In Numeric view, enter your data in
Ylist.

Programming in HP PPL 317


Finance app The following variables are used by the Finance app. They
variables correspond to the fields in the Finance app Numeric view.

CPYR Compounding periods per year. Sets the number of


compounding periods per year for a cash flow
calculation. From the Numeric view of the Finance app,
enter a value for C/YR.
In a program, type:
n CPYR
where n > 0

BEG Determines whether interest is compounded at the


beginning or end of the compounding period. From the
Numeric view of the Finance app, check or uncheck End.
In a program, type:
1BEG—for compounding at the end of the period
(Default)
0BEG—for compounding at the beginning of the period

FV Future value. Sets the future value of an investment. From


the Numeric view of the Finance app, enter a value for FV.
In a program, type:
n FV
Positive values represent return on an investment or loan.

IPYR Interest per year. Sets the annual interest rate for a cash
flow. From the Numeric view of the Finance app, enter a
value for I%YR.
In a program, type:
n IPYR
where n > 0

NbPmt Number of payments. Sets the number of payments for a


cash flow. From the Numeric view of the Finance app,
enter a value for N.
In a program, type:
n NbPmt
where n > 0

318 Programming in HP PPL


PMT Payment value. Sets the value of each payment in a cash
flow. From the Numeric view of the Finance app, enter a
value for PMT.
In a program, type:
n PMT
Note that payment values are negative if you are making
the payment and positive if you are receiving the payment.

PPYR Payments per year. Sets the number of payments made


per year for a cash flow calculation. From the Numeric
view of the Finance app, enter a value for P/YR.
In a program, type:
n PPYR
where n > 0

PV Present value. Sets the present value of an investment.


From the Numeric view of the Finance app, enter a value
for PV.
In a program, type:
n PV
Note: negative values represent an investment or loan.

GSize Group size. Sets the size of each group for the
amortization table. From the Numeric view of the Finance
app, enter a value for Group Size.
In a program, type:
n GSize

Linear Solver The following variables are used by the Linear Solver app.
app They correspond to the fields in the app's Numeric view.
variables
LSystem Contains a 2x3 or 3x4 matrix which represents a 2x2 or
3x3 linear system. From the Numeric view of the Linear
Solver app, enter the coefficients and constants of the
linear system.
In a program, type:
matrixLSystem

Programming in HP PPL 319


where matrix is either a matrix or the name of one of the
matrix variables M0-M9.

Triangle The following variables are used by the Triangle Solver


Solver app app. They correspond to the fields in the app's Numeric
variables view.

SideA The length of Side a. Sets the length of the side opposite
the angle A. From the Triangle Solver Numeric view, enter
a positive value for a.
In a program, type:
n SideA
where n > 0

SideB The length of Side b. Sets the length of the side opposite
the angle B. From the Triangle Solver Numeric view, enter
a positive value for b.
In a program, type:
n SideB
where n > 0

SideC The length of Side c. Sets the length of the side opposite
the angle C. From the Triangle Solver Numeric view, enter
a positive value for c.
In a program, type:
n SideC
where n > 0

AngleA The measure of angle A. Sets the measure of angle A. The


value of this variable will be interpreted according to the
angle mode setting (Degrees or Radians). From the
Triangle Solver Numeric view, enter a positive value for
angle A.
In a program, type:
n AngleA
where n > 0

AngleB The measure of angle B. Sets the measure of angle B.

320 Programming in HP PPL


The value of this variable will be interpreted according to
the angle mode setting (Degrees or Radians). From the
Triangle Solver Numeric view, enter a positive value for
angle B.
In a program, type:
n AngleB
where n > 0

AngleC The measure of angle C. Sets the measure of angle C.


The value of this variable will be interpreted according to
the angle mode setting (Degrees or Radians). From the
Triangle Solver Numeric view, enter a positive value for
angle C.
In a program, type:
n AngleC
where n > 0

Programming in HP PPL 321


RECT Corresponds to the status of in the Numeric view
of the Triangle Solver app. Determines whether a general
triangle solver or a right triangle solver is used. From the
Triangle Solver view, tap .
In a program, type:
0RECT—for the general Triangle Solver
1RECT—for the right Triangle Solver

Home The following variables (except Ans) are found in Home


Settings Settings. The first four can all be over-written in an app's
variables Symbolic Setup view.

Ans Contains the last result calculated in the Home view.

HAngle Sets the angle format for the Home view. In Home
Settings, choose Degrees or Radians for angle
measure.
In a program, type:
0  HAngle—for Degrees.
1  HAngle—for Radians.

HDigits Sets the number of digits for a number format other than
Standard in the Home view. In Home Settings, enter a
value in the second field of Number Format.
In a program, type:
n  HDigits, where 0 < n < 11 .

HFormat Sets the number display format used in the Home view. In
Home Settings, choose Standard, Fixed,
Scientific, or Engineering in the Number
Format field.
In a program, store one of the following the constant
numbers (or its name) into the variable HFormat:
0 Standard
1 Fixed
2 Scientific
3 Engineering

322 Programming in HP PPL


HComplex Sets the complex number mode for the Home view. In
Home Settings, check or uncheck the Complex field.
Or, in a program, type:
0  HComplex—for OFF.
1  HComplex—for ON.

Date Contains the system date. The format is YYYY.MMDD. This


format is used irrespective of the format set on the Home
Settings screen. On page 2 of Home Settings, enter
values for Date.
In a program, type:
YYYY.MMDD ► Date, where YYYY are the four digits of
the year, MM are the two digits of the month, and DD are
the two digits of the day.

Time Contains the system time. The format is HH°MM’SS’’,


with the hours in 24-hour format. This format is used
irrespective of the format set on the Home Settings
screen. On page 2 of Home Settings, enter values for
Time.
In a program, type:
HH°MM’SS’’ ► Time, where HH are the two digits of the
hour (0≤HH<24), MM are the two digits of the minutes,
and SS are the two digits of the seconds.

Language Contains an integer indicating the system language. From


Home Settings, choose a language for the Language
field.
In a program, store one of the following constant numbers
into the variable Language:
1  Language (English)
2  Language (Chinese)
3  Language (French)
4  Language (German)
5  Language (Spanish)
6  Language (Dutch)
7  Language (Portuguese)

Programming in HP PPL 323


Entry Contains an integer that indicates the entry mode. In
Home Settings, select an option for Entry.
In a program, enter:
0  Entry—for Textbook
1  Entry—for Algebraic
2  Entry—for RPN

Integer

Base Returns or sets the integer base. In Home Settings, select


an option for the first field next to Integers. In a program,
enter:
0  Base—for Binary
1  Base—for Octal
2  Base—for Decimal
3  Base—for Hexadecimal

Bits Returns or sets the number of bits for representing integers.


In Home Settings, enter a value for the second field next
to Integers. In a program, enter:
n  Bits where n is the number of bits.

Signed Returns the status of, or sets a flag, indicating that the
integer wordsize is signed or not. In Home Settings,
check or uncheck the ± field to the right of Integers. In a
program, enter:
0  Signed—for unsigned
1  Signed—for signed

324 Programming in HP PPL


Symbolic The following variables are found in the Symbolic setup of
Setup an app. They can be used to overwrite the value of the
variables corresponding variable in Home Settings.

AAngle Sets the angle mode.


From Symbolic setup, choose System, Degrees, or
Radians for angle measure. System (default) will force
the angle measure to agree with that in Home Settings.
In a program, type:
0  AAngle—for System (default).
1  AAngle—for Radians.
2  AAngle—for Degrees.

AComplex Sets the complex number mode.


From Symbolic setup, choose System, ON, or OFF.
System (default) will force the complex number mode to
agree with the corresponding setting in Home Settings.
In a program, type:
0  AComplex—for System (default).
1  AComplex—for ON.
2  AComplex—for OFF.

ADigits Contains the number of decimal places to use for the


Fixed, Scientific, or Engineering number formats in the
app’s Symbolic Setup.
From Symbolic setup, enter a value in the second field of
Number Format.
In a program, type:
n  ADigits
where 0 < n < 11

Programming in HP PPL 325


AFormat Defines the number display format used for number
display in the Home view and to label axes in the Plot
view.
From Symbolic setup, choose Standard, Fixed,
Scientific, or Engineering in the Number Format
field.
In a program, store the constant number into the variable
AFormat.
0 System
1 Standard
2 Fixed
3 Scientific
4 Engineering
Example:
3  AFormat

Results The Function, Statistics 1Var, Statistics 2Var, and Inference


variables apps offer functions that generate results that can be re-
used outside those apps (such as in a program). For
example, the Function app can find a root of a function,
and that root is written to a variable called Root. That
variable can then be used elsewhere.
The results variables are listed with the apps that generate
them. See “App variables” on page 221.

326 Programming in HP PPL


Index coding See programming
commands
app 290
branch 301
definition of 290
A
geometric 39–68
Advanced Graphing app
See also functions
variables, summary of 224
structure in programming 237
algebra functions 116–117
variable 273
alternative hypothesis 72
commenting code 238
antilogarithm
complex numbers
common 102
functions for 107–108
natural 102
complex variables 220
app
confidence intervals 84–88, 161–162
commands 290
copying
creating 262
programs 249
customizing See app, creating
critical values 73
programs 260
curves 28
variables 221–236, 303–326
custom apps 262
See also variables
custom functions 213
App menu 99
apps
Geometry 5–68
D
Inference 69–88 debugging programs 247
arithmetic functions 106–108 deleting
programs 240
dilation 35
B
drawing commands 277–286
block commands 268
branch commands 268, 301
E
editing
C
programs 238
calculations
CAS 116–??
confidence intervals 84
F
geometric 20 Finance app
in Home view 101–115 functions 166–168
calculus functions 118–122 variables
CAS Numeric 318–319
calculations using 116–?? summary of 234
functions Function app
algebra 116–117 functions 139
calculus 118–122 variables
integer 129–131 results 326
plot 138–?? summary of 221
polynomial 131–137 functions
rewrite 124–129 algebra 116–117
solve 122–124 apps 138–172
menu 116–?? arithmetic 106–108
Catlg menu 172–213 calculus 118–122

Index 327
common 171 I
creating your own 213 I/O commands, programming 292,
Finance app 166–168 294
Function app 139 inference
geometric 39–68 confidence intervals 84–88
hyperbolic 109 hypothesis tests 77–83
Inference app 157–162 One-Proportion Z-Interval 85
integer 129–131 One-Proportion Z-Test 79
keyboard 101–104 One-Sample T-Interval 87
Linear Explorer 170 One-Sample T-Test 81
Linear Solver 168 One-Sample Z-Interval 84
number 105–106 One-Sample Z-Test 77
plot 138–?? Two-Proportion Z-Interval 86
polynomial 131–137 Two-Proportion Z-Test 80
probability 109–114 Two-Sample T-Interval 87
rewrite 124–129 Two-Sample T-Test 82
solve 122–124 Two-Sample Z Test 78
Solve app 140 Two-Sample Z-Interval 84
spreadsheet 140–154 Inference app 69–88
Statistics 1Var 154–155 confidence intervals 84–88
Statistics 2Var 156–157 functions 157–162
Triangle Solver 168–170 hypothesis tests 77–83
importing statistics 74
G variables
geometric objects ??–30 Numeric 314
geometric transformations 33–37 Results 231
Geometry app 5–68 summary of 229
commands 39–68 integer commands, programming 292
creating objects integer functions 129–131
in Plot view 12
in Symbolic view 19 K
functions 39–68 keyboard
objects, types of ??–30 customizing 256
Plot view, menu buttons 16 functions on 101–104
transforming objects 33–37 keys
variables, summary of 222 internal name of 258
global variables 252 user defined 256
graphics
storing and recalling 277
L
variables 220
Linear Explorer app
functions 170
H Linear Solver
Home settings 220 functions 168
hyperbolic functions 109 variables
hypothesis tests 71, 77–83, 157–160 Numeric 319
hypothesis, alternative 72 summary of 235
lines 25
lists

328 Index
variables 220 defined in Geometry app 30
local variables 252 functions 138–??
logarithmic Plot view
functions 102 in Geometry app 12
loop commands 269, 270–272 menu buttons 16
variables 303–307
M points 24
Math menu 105–115 Polar app
matrices variables 234
commands 289–290 polygons 26
swap row 290 polynomial functions 131–137
variables 220 probability functions 109–114
menu program
App 99 commands
CAS 116–?? app functions 290
Catlg 172–213 block 268
Math 105–115 branch 268
User 99 drawing 277–286
menu buttons function 273
in Plot view I/O 292, 294
Geometry app 16 integer 292
menus loop 269
display format of 100 matrix 289
mode other 299–301
user 256 strings 274
variable 273
N commenting in 238
names, in Geometry app 13 create 241
natural logarithm 102 debug 247
negation 104 run 246
Normal Z-distribution, confidence inter- samples 254–256, 264–267
vals 84 structure of 238
number functions 105–106 programming 237–326
projection 35
O
objects
Q
geometric ??–30 qualify, variables 253
One-Proportion Z-Interval 85 quotes in strings 274
One-Proportion Z-Test 79
One-Sample T-Interval 87 R
One-Sample T-Test 81 real variables 220
One-Sample Z-Interval 84 rewrite functions 124–129
One-Sample Z-Test 77
S
P sample programs 254–256, 264–267
Parametric app Sequence app
variables 233 variables 236
plot settings 220

Index 329
Solve app Finance app 234
functions 140 Function app 221
variables, summary of 223 Geometry 222
solve functions 122–124 global 252
Spreadsheet app graphics 220
functions 140–154 Home 220
variables 223 Home settings 220
Statistics 1Var in programming 301
functions 154–155 Inference app 229
variables, summary of 225 Linear Solver 235
Statistics 2Var list 220
functions 156–157 local 252
variables, summary of 227 matrix 220
Symbolic view Numeric view 312
in Geometry app 19 Parametric app 233
system-wide settings 220 Plot view 303
Polar app 234
T qualifying 253
Toolbox menus 99 real 220
transformations, geometric 33–37 Sequence apps 236
Triangle Solver app Solve app 223
functions 168–170 Spreadsheet app 223
variables Statistics 1Var 225
Numeric 320 Statistics 2Var 227
summary of 235 Symbolic view 308–311
trigonometric Triangle Solver 235
functions 108 types of in programming 301
Two-Proportion Z-Interval 86 Views menu 261
Two-Proportion Z-Test 80
Two-Sample T-Interval 87 Z
Two-Sample T-test 82 Z-Intervals 84–86
Two-Sample Z-Interval 84
Two-Sample Z-Test 78

U
Upper-Tail Chi-Square probability 111
user defined
keys 256
variables 253
user keyboard 256
User menu 99
user modes 256

V
variables
Advanced Graphing app 224
app 303–326
complex 220

330 Index

You might also like