Download as pdf or txt
Download as pdf or txt
You are on page 1of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

HP Prime Advanced Workshop


Introduction
The HP Prime Advanced Workshop Series provide in-depth understanding of and experience with the advanced
features of the HP Prime Graphing Calculator. This workshop focuses on the HP Prime Wireless Classroom
Network, the Advanced Graphing App, the new version 1.1 of the Geometry App, Statistics on the HP Prime, and
programming the HP Prime using HP PPL (HP Prime Programming Language). In this workshop you will learn
about custom HP Prime content, especially customized HP Apps. As you learn about custom HP Prime content,
you will also become familiar with the HP Prime Wireless Classroom Network, which will be used to distribute and
share example content. The HP Classroom Network will also be used to survey the participants and share their
thoughts, display a participants Prime display for discussion purposes, and cover various other tasks.

HP Prime Content
HP Prime was designed to be a customizable and extensible system for solving problems and learning
mathematics. You customize and extend your HP Prime as you use it by saving data in variables, creating
programs, and customizing the HP apps in the App Library.

Programs
An HP Prime program is a set of instructions in HP PPL designed to complete a task. A program can be as simple
as a user-defined function or much more complicated. Like notes, programs can stand alone in the Program
Catalog or they can be attached to custom apps.

Custom HP Apps
You customize any HP App in the Apps Library simply by using it, storing data in it, and then saving it under a new
name. You can then attach a note to your new app, customizing it further. Finally, each app has a program
attached to it. Initially, this program is empty. But you can use this program to extend your custom app even
further. An app program can contain sub-routines; if it contains a sub-routine named Plot for example, then this
sub-routine is called when the user presses P while in the custom app. In fact, the app program can even take
the user to another app and then return. Using programs to customize HP apps is the second major focus of this
workshop.

Notes
You can create as many notes as you like, subject to memory restrictions. You can keep your notes in the Note
Catalog or you can attach them to custom apps as you create them. Notes have formatting capability to give them
structure and make them easier to read.

2014 by HP Calculators

Last Updated August 22, 2014

Page 1 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Identities, Domains, and Conditions


This activity is based on a talk Mark Howell did at NCTM 2014 in New Orleans, USA.
The HP Prime graphing calculator, with its Advanced Graphing app, provides new opportunities to visualize
identities and make conjectures involving mathematical statements and their domains.

Visualizing an identity
What does the graph of an identity look like?
Consider the identity:

X Y X Y
.
3
3 3

1.

Press I and select the Advanced


Graphing app.

2.

Enter

3.

Press P to see the graph.

X Y X Y
in V1.
3
3 3

The graph produced by the Advanced Graphing app


is shown to the right. Students must correctly
interpret this graph to mean that the statement
seems true for all (X, Y) ordered pairs.
Many students have probably never seen the graph
of an identity in this way, so it is worth discussing
with them that this graph is saying the equation is
true for all (x, y) ordered pairs. However, by itself,
the graph is not a proof of the identity.

Example: Is

X 2 X an identity?

4.

Press Y to return to Symbolic view.

5.
6.

Enter X X in V1.
Press P to see the graph.
2

The graph is shown to the right. Clearly, the


statement is not an identity. Students may
recognize the graph as that of the inequality X0.
In other words,

X 2 X if and only if X0.

This is a new and different way of using the power


of visualization.

2014 by HP Calculators

Last Updated August 22, 2014

Page 2 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Example: If X 2 Y 2 then does X=Y?


1.

Press @ to return to Symbolic view.

2.
3.

Enter X Y in V1.
Press P to see the graph.
2

The graph is shown to the right. What does this


graph say to students? It seems that there are 2
possibilities and only one of them is that X=Y.
Students must recognize the other solution branch
as X= -Y.
If X Y then either X=Y or X= -Y.
2

Getting students to make formal conjectures based


on graphs develops their ability to carry on
mathematical discourse.
This graphing technique can be used to dispel
common student misconceptions as well. How
about my old favorite? Is the following statement an
identity?

X 2 Y2 X Y
In the graph to the right, the axes have been turned
off. Clearly, the statement is not an identity, but it is
sometimes true.
If Y=0, then the statement reduces to our old friend

X 2 X , which we now know to be true if X0.


Conversely, if X=0, then the result is Y Y ,
which would be true for Y0. So we cannot say it is
never true. But it is only true for the trivial cases in
which either X or Y is equal to zero and the other is
not negative.
2

X 2 Y 2 X Y if X=0 and Y0 or if Y=0 and


X0.
You can extend this example to examine what needs to be true about f(x) for f(x)=f(y) to imply that x=y. This is an
important new way to approach the nature of a 1:1 function.
The HP Prime Advanced Graphing app takes the power of visualization to a whole new level, allowing students to
test all sorts of mathematical statements and make conjectures based on their graphs.

2014 by HP Calculators

Last Updated August 22, 2014

Page 3 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

An Introduction to Solving Trigonometric Equations


In this activity, we look at introducing students to the topic of solving trigonometric equations. As an example, we
take the equation

sin( x)

3
. If we use this equation as an example to introduce students to the notion of
2

solving trigonometric equations, what do we want them to notice from the very outset? First and foremost, there
are three important aspects to the solution set:
1. There are an infinite number of solutions
2. These solutions are composed of two branches
3. There is a conventional way of expressing these two branches of infinite solutions in a succinct way
1.

Press I and tap on the Advanced


Graphing app icon; the app opens in
Symbolic view.

Here, you can enter up to 10 equations or


inequalities.

sin( x)

3
2

2.

In V1, enter

3.

Press P to see the graph.

The graph appears to consist of a set of vertical


lines. The vertical lines suggest solutions of the
form x=c, where c is a real number. The lines are
arranged in pairs, suggesting two sets of solutions.
You can pinch with your fingers to zoom in or out.
Zooming out shows more and more of these pairs of
lines, suggesting there are an infinite number of
solutions. So far, this graphical representation has
done a good job of fulfilling our first two
requirements.
The tracer is on the first vertical line to the right of
the y-axis and reads x=1.047 or x=/3.

2014 by HP Calculators

Last Updated August 22, 2014

Page 4 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

We will now train the tracer to jump from one xintercept to the next.

2014 by HP Calculators

Last Updated August 22, 2014

Page 5 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

A Rose For You


In this activity, we discuss how to use the HP Prime Advanced Graphing app to teach students about
transformations in the plane, including translations and reflections. But instead of a geometric approach, the app
allows us to take an algebraic approach. We start with a generic shape, which we then transform in various ways
to build a picture of a rose. The HP App Rose4You already has V1 defined as per Steps 1-3 below. It also has a
page of notes to get the student started.
If you do not have the HP App Rose4You, then start
by defining our generic shape, a filled ellipse, given
by x y x y 1 0 .
2

1.
2.
3.
4.
5.

Press I and tap the Advanced Graphing


icon
Enter the expression above into V1, using
and
to help you
Tap on the color picker for V1 and choose
purple
Press P to see the graph of our ellipse.
Press + to zoom in. This is the first
petal of our rose.

If you have the HP App Rose4You, then Steps 1-3


are already done for you. Also, Press S I (Info)
to see notes on how to translate, reflect, and dilate
V1.
A reflection over the vertical line x=-1 is a mapping
such that x-2-x and yy. So we define V2 to be
V1(-2-x, y), as shown in the figure to the right. We
use the same color (purple) for our reflection.

Press P to see the second petal; tap and drag to


scroll the view.

2014 by HP Calculators

Last Updated August 22, 2014

Page 6 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

We need a stem for our rose. Creating a stem takes


some experimentation. Students will learn to
stretch the base shape first, then translate it into its
final position. We defined V3 to be
V1(10*(X+1),0.3*(Y+4)), as shown to the right. Do
not forget to change the color to dark green!

Again, press P to see the rose starting to take


shape. Press w to zoom out and drag to scroll
until you get the view you want.

Next, we add some leaves. For the first leaf (in V4),
we experiment as we did for the stem, first dilating
and then translating to get what we want. Then the
second leaf is the reflection of the first leaf, using
the same method we used for the petals. We chose
light green as the color for both leaves.

And now you have a simple rose!

For extra credit, we added two fancy petals and


some thorns. The expressions are shown on the
next page in case you want to work them out for
yourself first!

If you did not start with the HP App Rose4You, be sure to save your new app. Press I to go to the App Library;
the Advanced Graphing app should already be highlighted. Tap
, enter a name for your new app (we used
Rose4You), and tap
twice. The new app now appears in your App Library.

2014 by HP Calculators

Last Updated August 22, 2014

Page 7 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Getting the most out of your HP Prime Virtual Calculator for the PC
If you are using the HP Virtual Prime for the PC (it is on the product CD that came with your HP Prime), you can just
copy and paste the expressions below into the virtual calculator. Then you can send the app from the virtual
calculator to your physical HP Prime. The steps are listed below.

Advanced Graphing app expressions for the rose


V1: X^2+Y^2-X*Y-1<0
V2: V1(-2-X,Y)
V3: V1(10*(X+1),.3*(Y+4))
V4: V1(2*(X+.5),2*(Y+4))
V5: V4(-2-X,Y)
V6: Y+1>(X+1)^2 AND Y<1+COS(2*X+3)
V7: V6(-2-X,Y)
V8: V1(20*(X+.8),10*(Y+3))
V9: V8(-2-X,Y)

To copy the rose expressions to your HP Prime Virtual Calculator


1.
2.
3.
4.
5.

Select and copy the expression named V1. Note: select and copy everything after V1:
On the HP Prime Virtual Calculator, go to the Rose app Symbolic view and select the field V1
In the menu bar, click on Edit and select Paste. The expression will be pasted into the V1 field.
Tap
to accept the expression. It will now graph properly.
Repeat Steps 2-4 for the other expressions (V2-V9)

To send the Advanced Graphing app from your virtual calculator to a physical HP Prime
1.
2.
3.
4.
5.

Connect your physical HP Prime to your PC using the USB cable


Turn on your HP Prime and launch the HP Prime Virtual Calculator for the PC
On the virtual Prime menu bar, click Calculator, then click Connect To and select your physical Prime
Go to the App Library, select the Rose app, and tap
The Rose app is now on your physical Prime and ready for viewing!

2014 by HP Calculators

Last Updated August 22, 2014

Page 8 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Dampened Oscillations
In this experiment, an accelerometer is used to track the dampened oscillations of a wooden or aluminum stick.
Then the data is sent to the Statistics 2Var app, where a user-defined fit is designed.

Accelerometer

SS410

Table

Stick or Ruler

The Materials

HP Prime graphing calculator


HP StreamSmart 410 and USB cable
Fourier accelerometer and sensor cable
A ruler or flat stick (wooden or aluminum)
A clamp
A thick rubber band

The Setup
1.
2.
3.
4.

Attach the accelerometer to the ruler using


the rubber band
Clamp the ruler to the edge of the table
with the ruler extending out over the edge
Connect the accelerometer to the HP
StreaSmart 410 using a sensor cable
Connect the HP StreamSmart 410 to the HP
Prime using the USB cable

Select the DataStreamer App

The Procedure
1.

2.
3.

Turn on the HP Prime; press ! to open


the Apps Library and tap the DataStreamer
icon to open the app.
Tap
and then twang the ruler once
or twice to set it vibrating.
Tap
once you see a good set of
oscillations.

Oscillations in the default window

HP Calculators

Last Revised August 21, 2014

Page 9 of 45

HP Prime
4.
5.

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Move the tracer to the middle of the set of


oscillations.
Tap
twice to change it to
.
Use the right direction key to zoom in on
your data. The dampened oscillations
should appear as shown to the right.

6.

Tap
to start the process of selecting
your final data set and exporting it to the
Statistics 2Var app.

7.

Tap
and use the direction pad to
crop unwanted data from the left. Then tap
and use the direction pad to crop
data from the right. Your data set may not
contain all the maxima and minima, but get
as many as you can. Also try to make sure
that your first data point is a relative
maximum. The screen capture to the right
shows a good representative sample.

8.

9.

Tap
to move to the second page of
menu items and tap
. In the Export
to Statistics window, tap
again to
accept the default values.
The Numeric view of the Statistics 2Var app
will open, where you can see your new
data.

If your first data point is not a relative maximum,


then delete the first few data points until the first
one is a relative maximum. Also, we wish the time
data to start at time t=0. In Home view, enter C1C1(1)C1 (tap
to get the character). This
will subtract the first value in C1 from all the data
points in C1. Our final data set appears to the right.

HP Calculators

Last Revised August 21, 2014

Page 10 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

10. Press V and select Autoscale. The Plot


view will open with a scatter plot of your
data as well as a default linear fit. Ignore
the fit for now.
We wish to define our own fit, a combination of
exponential and trigonometric functions. The fit is
of the form a*cos(b*X), where a is itself an
exponential function of the form c*e-d*X. Note that
the value of c can be estimated from the first data
point. The value of d can be arrived at empirically.
11. Press @ to enter Symbolic view. By
default, S1 uses C1 for the independent
data and C2 for the dependent data, as we
wish. Tap on the field Fit1 and enter your
decreasing exponential function for the
diminishing amplitude of the oscillations. In
2.1 X

the example here, we used 1.16 e


.
Note that the fit type automatically
changes to User Defined.
12. Press P to return to Plot view. Adjust the
parameters of the exponential until the
graph is as close as possible to the set of
maxima, as shown to the right.
13. Now we will add the cos(b*X) part of the fit.
Press @ to return to Symbolic view.
Select Fit1 and tap
. Again, you
will have to experiment to get the period as
close as possible. In the figure to the right,
we used b=214.

In this experiment, students were challenged to find their own fit equation for a dampened oscillation, based on
their understanding of exponential and trigonometric functions. The HP Prime DataStreamer app easily produces
stunningly beautiful data to drive the challenge!

HP Calculators

Last Revised August 21, 2014

Page 11 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

China GDP: More about the Statistics 2Var App


The table to the right shows the gross domestic
product (GDP) of China for the years 2002-2011, in
millions of CNY. In this activity, we explore the data
using the Statistics 2Var app on HP Prime.
For the purposes of our exploration, we will let
X=the number of years since 2000. Thus, our first
data point has X=2. We will then let Y=the GDP in
millions of CNY for year X.
1.
2.

Year
2002
2003
2004
2005
2006

GDP in
millions CNY
12,033,269
13,582,276
15,987,834
18,493,737
21,631,443

Year
2007
2008
2009
2010
2011

GDP in
millions CNY
26,581,031
31,404,543
34,090,281
40,151,280
47,156,370

Press ! to open the Apps Library and


select the Statistics 2Var app.
The app opens in Numeric view. In column
C1, enter the years, 2-11. In C2, enter the
GDP values. The complete data set is
shown to the right.

Suppose we wish to test the suitability of an


exponential model. We may first want to plot the
natural log of the Y-values against the X-values and
examine the linearity of the scatter plot.
3.

4.

Press @ to open Symbolic view. By


default, S1 is already set up to use C1 for
the independent variable. But instead of
using C2 for the dependent variable, we
wish to use LN(C2).
Tap the second field under S1 to select it.
Press j. The command line opens with
LN(). Tap
, enter 2, and tap
.
The completed S1 is shown to the right.

The scatter plot in Plot view will now plot the


natural log of the values in C2 against the
corresponding values in C1. There is no need to
create C3=LN(C2) and then plot C3 against C1. Of
course, you could achieve the same results that
way. The advantages to our method are two-fold:
The raw data remains the raw data- no
extra columns of manipulated data
The definition of S1 remains clearly
expressed in Symbolic view- no need to
remember what was plotted
5.

Press V and select Autoscale to see


the scatter plot and the default linear fit.
The scatter plot does appear to be linear.

HP Calculators

Last Revised August 21, 2014

Page 12 of 45

HP Prime
6.

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Press N to return to Numeric view and


tap
. The value of the correlation
coefficient (r) is quite close to one,
indicating a high degree of linearity.

Note the white dot in


, indicating that this
option is active. There are two other options as well,
and
. Each of these displays statistics
associated with their respective variables.
7.

8.

Tap
to leave the Stats window and
return to Numeric view. Press @ to return
to Symbolic view. Tap the check box for S1
and tap
to deselect it. In S2, use C1
for the independent data and C2 for the
dependent data. For the fit type in Type2,
select Exponential. The completed
Symbolic view is shown to the right.
Press V and select Autoscale to see
the scatter plot and the exponential fit. To
see the expression for the fit, press D to
move from the scatter plot to the fit graph,
then tap
. The fit expression
is

8,699,346.07 e0.15430241 X .

How does this exponential fit compare to our linear


fit in S1? They both have the same value for M, the
coefficient of X. The only question is how close is
e15.9787584 to 8,699,346.07? The difference is less
than 1 CNY, as shown below.

The Statistics 2Var App makes it easy to explore bivariate data and make conjectures. And with the Symbolic
view, you can always see any modifications or transformations that were made to the raw data.

HP Calculators

Last Revised August 21, 2014

Page 13 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Anscombe's Quartet
Anscombe's Quartet refers to four datasets with almost exactly the same statistical measures but very different
graphical properties. Devised by Francis Anscombe in 1973, the quartet stresses the importance of examining a
graphical representation of your data before analyzing it! In this activity, the data from the quartet is already
loaded into an app called AnscombeQuartet.
1.

Press ! and scroll down to the


AnscombeQuartet app. Tap
to start
the app. The app opens in Numeric view. C1
contains the common x-variable data for
the first three datasets. C2, C3, and C4 each
contain a different y-variable dataset for
the common x-variable dataset. Not shown
are C5 and C6, the fourth dataset.

We will begin by comparing the summary statistics


for the datasets.
2.

Press @ to open Symbolic view and


checkS1 through S4, as shown in the figure
to the right.

As you can see, S1 has already been configured to


use C1 as the independent variable and C2 as the
dependent variable. Likewise, S2 uses C1 for the
independent variable but uses C3 for the dependent
variable. Finally, S3 uses the common C1 for the
independent variable and C4 for the dependent
variable. Not shown is S4, which uses C5 and C6.
3.

4.

Press N to return to Numeric view and


tap
. The summary statistics are
displayed, as shown to the right. As you can
see, the correlation (r) for all the datasets
are almost identical in value.
Tap
to see summary statistics for
the independent variable and tap
to
see similar statistics for the dependent
variable. They are remarkably close for all
three datasets. Tap
when you are
done.

HP Calculators

Last Revised August 21, 2014

Page 14 of 45

HP Prime
5.

Advanced Workshop: The HP Prime Wireless Classroom Network

6.

Press @ to return to Symbolic view.


Uncheck S2, S3, and S4, leaving only S1
checked.
Press V and select Autoscale. The

7.

scatter plot of S1 is displayed. Tap


to open the Plot view menu and tap
.
The linear fit will be drawn along with the
scatter plot.
Press D to move the tracer from the

Version 1.2

scatter plot to the fit line. Tap


to
see the linear expression in X: S1=0.5*X+3.
Repeat Steps 5-7, checking S2, S3, and S4, one at a
time, to see their scatter plots and fit lines. In each
case, the fit line is 0.50*X+3.00, to the nearest
hundredth.

S1 and S3 both appear to be linear relationships,


although S3 is clearly a different linear relationship
that is influenced by an outlier. S2 and S4 are clearly
not linear relationships. S2 has a clear relationship,
but it is not linear. S4 shows that an outlier can
generate a high correlation value even though the
relationship is simply not linear.
8.

Press H to enter Home view. Type C1L1


and press E. Type C2L2 and press
E. We will use this dataset in our next
exercise.

The first dataset appears to be a simple linear relationship. In the next activity, we examine that relationship
using the Inference app.

HP Calculators

Last Revised August 21, 2014

Page 15 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Inference for Regression


In the last activity, we saw that the linear fit was y=0.5*x+3, with a correlation of r=0.816. In this activity, we use
the Inference app to perform a linear t-test and to construct a confidence interval for the slope.
The Inference app supports the following inferential methods:
Test hypotheses using the Normal or Student's t distributions
Construct confidence intervals using the Normal or Student's t distributions

Test hypotheses about categorical data using the 2 (Chi-Square) distribution

Make inferences involving linear regression using Student's t-distribution

1.

Press ! and scroll down to the Inference


app. Tap
to start the app. The app
opens in Symbolic view. Tap on the

2.
3.

4.

Method field and then use


to select
Regression.
For Type, select Linear t test.
For the alternative hypothesis, select 1>0.
The completed Symbolic view is shown to
the right.
Press N to open Numeric view. This is
where you enter your x- and y-datasets. By
default, this view is empty. Enter the x-data
in Xlist and the y-data in Ylist.

We want to use the first of Anscombe's datasets


from the previous example. We could type it in again
here, but instead we will use a trick. Remember that
we stored C1 in L1 and C2 in L2 at the end of the last
exercise.
5.

Press H for Home view, type L1Xlist


and press E. Now type L2Ylist and
press E. To get Xlist and Ylist, you can
either type them in letter-by-letter or use
the Vars menu. Press a, select
Inference, then Numeric, and scroll
down to Xlist and Ylist.

Now when you return to Numeric view, you will see


the Anscombe data.

HP Calculators

Last Revised August 21, 2014

Page 16 of 45

HP Prime
6.

7.

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Press N to return to Numeric view. The


data has been copied from L1 into Xlist and
L2 into Ylist.
Tap
to execute the linear t-test.

The value of t is returned, along with the associated


probability, based on the alternative hypothesis
being tested and the degrees of freedom used
(which is also reported).
After these three, the values of the intercept and
slope are returned, followed by the standard errors
of the line, the slope, and the intercept.
Finally, the correlation (r) and the coefficient of
determination are reported last.
Each is labeled and the label is expanded in the
command line if selected. In the example to the
right, 1 is selected and the expanded text explains
that this is the calculated value of the slope of the
line.
8.

Tap

when you are done.

We will now calculate the 99% confidence interval


for the slope.
9.

Press @ to return to Symbolic view. In


the Type field, select Interval:
Slope.
10. Press N to return to Numeric view. Tap
to calculate the 99% confidence
interval. You will be prompted for the Cvalue; enter 0.99 and tap
.
The confidence level, the associated critical value of
t, and the degrees of freedom are all displayed.
Below these are the slope and the standard error of
the slope. At the bottom of the list are the endpoints
of the confidence interval. Note that the
components needed to calculate the interval (the
critical value of t, the slope, and the standard error
of the slope) are all displayed with the confidence
interval for pedagogical purposes.
The last three activities illustrate how well the statistical apps on the HP Prime work together to explore
mathematics and solve problems.

HP Calculators

Last Revised August 21, 2014

Page 17 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

The Spreadsheet App and the CAS


The Spreadsheet app can be used in conjunction with the CAS to enable visualization tools in the symbolic realm,
where students can look for patterns and make conjectures about symbolic operations.
For our first example, we will use a single command
to populate the first column with the square roots
of the positive integers. In fact, the command is
simply

Row , where Row is a variable that refers

to the row number of each row in the spreadsheet.


1.

2.

Press ! to open the Apps Library and tap


on the Spreadsheet app icon. The app
opens in Numeric view. Tap on the column
header for Column A to select the entire
column.
Press S = to start our formula. Press
S l to enter the square root operator.
Press a, tap
, tap
Spreadsheet, Numeric, and select
Row. Press E when you are done. The
finished definition and its result are shown
in the figure to the right.

Imagine asking students to look for patterns here! Some integers have square roots that are also integers; others
do not. Of the ones that do not, some seem to simplify while others do not. What are the rules here?
The spreadsheet shown to the right was created
with just two commands. Imagine introducing
binomial operations to students using visualization
tools like these!
Let's look at the commands used to create this
spreadsheet. The first column contains powers of
the binomial x+1, starting at the first power. In fact,
the formula for this column is simply (x+1)Row,
where Row is a variable that indicates the row
number.
3.

Press S & to clear the Spreadsheet


app. You will be prompted to proceed; tap
. Tap on the column header for
Column A to select the entire column.

HP Calculators

Last Revised August 21, 2014

Page 18 of 45

HP Prime
4.

5.

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Press S = to start our formula. Press


n to enter parentheses. Between the
parentheses, enter x+1. To get the lowercase x, press A S *. Move outside
the parentheses and press f to insert a
power. Get the variable Row as in Step 2 of
the previous example. Press E when
you are done.
Let's tidy up a bit. Tap on the HP icon in the
upper right corner to select the entire
spreadsheet. Tap
, scroll down to
Textbook, and select Yes. Tap
again and select Row. In the Row input

6.

7.

form, enter 30 and tap


. Your
Column A should now look like the one in
the figure.
The second column definition is much like
the first, except that it starts with the CAS
command expand. Tap on the column
header for Column B to select the entire
column. Press S = to start our
formula. Press b to open the Toolbox
menus, tap
, Algebra, and select
expand. Continue as you did for the first
column definition and press E when
you are done.
Select one of the rows of expanded
binomial powers in Column B and un-pinch
(spread) two fingers horizontally to
increase the width of the row.

The result is a great visualization of Pascal's


Triangle!
Speaking of which, the figure to the right shows a
way of creating Pascal's Triangle with a single
command.

With the Spreadsheet app and the CAS at your service, you can open up a whole new realm of visualization for
your students.

HP Calculators

Last Revised August 21, 2014

Page 19 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

The Sierpinski Triangle


The Sierpinski Triangle is a geometric fractal that starts with an equilateral triangle, which we will call our Stage
0. In Stage 1, the midpoints of the sides of the original triangle are joined to form another equilateral triangle, and
this triangle is removed from the figure- resulting in three equilateral triangles. Stage 2 continues the process on
each of these three new triangles. Stages 1 and 2 are shown below, along with an advanced stage created by the
IFSFractal app.

Stage 1

Stage 2

After many iterations

What can we say about the area of the final Sierpinski Triangle? In this activity, we examine the area of the figure
at each of the first few stages and then examine its limiting value.
We know that the formula for finding the area of an
equilateral triangle whose sides each have length s
is A

s2 3
. Since we will be using the
4

equilateral triangle area formula repeatedly, we will


create a user-defined function based on this
formula.
1.

Press H for Home view. Then press S


d (Define) to open the Define input form.
For the name, enter TA (for Triangle Area).
In the Function field, enter the formula.
The field for S appears after the formula is
parsed and it will be checked by default to
indicate that it will be an input variable for
this function. The finished definition
appears to the right. Tap
when you
are done.

HP Calculators

Last Revised August 21, 2014

Page 20 of 45

HP Prime
2.

3.

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Press S C (CAS Settings) and set the


value of the field Simplify to Maximum.
Highlight the field value and tap
to
make a selection, or use + and - to
move through the list of options.
Let's test our new user-defined function
TA(S). Press C to open CAS view. Press
b to open the Toolbox menus. Tap
, User Functions, and select
TA. The command line will show TA(), with
the cursor positioned between the
parentheses. Let's assume that the original
equilateral triangle at Stage 0 has a side
length of 1. Enter 1 between the
parentheses and press E.

The result,

3
, is returned simplified as shown in
4

the figure to the right. In Stage 1, we subtract the


area of the central triangle, whose sides are each of
length 1/2.
4.

Press - and the command line will show


Ans-. This means that whatever we enter
now will be subtracted from the previous
answer. Enter TA(1/2) and press E.

The result is
5.

6.

3 3
.
16

At Stage 2, we need to subtract the area of


three triangles, each of which has sides of
length 1/4. Tap on the previous input and
tap
to copy it to the command line.
Insert 3* in front of TA and change the 2 in
1/2 to a 4 and press E.
At Stage 3, we need to subtract the area of
9 triangles, each with side length 1/8. The
results are shown to the right.

We note that the area values all have powers of 4 in the denominator and powers of 3 in the numerator. The
n

3
3n 3
3
general formula for the area at Stage n seems to be A(n) n 1 or A(n)
. Clearly, this
4
4
4
quantity goes to zero as n. Let's see if the CAS agrees.

HP Calculators

Last Revised August 21, 2014

Page 21 of 45

HP Prime
7.

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

In CAS view, press c to open the


Template menu and select the limit
template. Fill out the template as shown to
the right. You can find the symbol by
pressing S 9. As you can see from
the figure, the limit is indeed zero.

It is not accurate to say that the area of the


Sierpinski Triangle is zero, as it is not a 2dimensional object. Its Hausdorff dimension has
been established to be less than 2 but greater than
1. Such a figure cannot be said to have an area in the
first place.
HP Prime significantly extends the sets of problems and visualizations that are now accessible to your students.

HP Calculators

Last Revised August 21, 2014

Page 22 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

The Geometry App, Version 1.1


Introduction
The Geometry app has a new version 1.1. Improvements of note to version 1.1 include tests on geometric objects,
slider bars, animations, the ability to quickly select and move objects, and a whole set of plot types.
1.

Press I and tap on the icon for the


Geometry app

The app opens in Plot view. Press P at any time to


return to this view. There are shortcuts for basic
objects and operations, as shown in the table below:
Key
A
C
I
L
P
S
T
2.

3.

4.
5.

Tool
Toggle axes off and on
Circle
Find the intersection(s) of two objects
Line
Point
Segment
Triangle
Press n, the shortcut for the Triangle
command. The bottom of the display now
has two lines: the top line shows help for
the current command and the bottom line
contains the Commands menu (Cmds) as
well as the current cursor coordinates.
Press E to select the current cursor
coordinates as the first vertex of the
triangle.
Tap at another location and press E
again.
Repeat Step 4 to create your triangle

The Triangle command remains in effect. Press J


to clear it.
Note that the bottom right corner of the screen
displays the names of all objects near the cursor; in
this case, C and D. The cursor is near Point C and
ABC, which is the geometric object named D. These
objects also are colored red to show they are
currently selectable or moveable.
There is a new menu key:
. This menu
contains options for the selected object(s). In the
figure to the right, Hide label was selected to
hide the name of the triangle (D). Note the other
options; these are available as well by pressing Z.

HP Calculators

Last Revised August 21, 2014

Page 23 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Geometric Tests: The Midpoint Quadrilateral App


To get started and examine geometric tests, we will use the HP Prime Wireless Classroom Network to send a
customized version of the Geometry app called the MidpointQuad app.
1.

Press I and tap on the icon for the


MidpointQuad app

The app opens in Plot view. Press P at any time to


return to this view. The green quadrilateral ABCD is
the basis of the construction. The blue quadrilateral
KLMN is formed by connecting the midpoints of the
sides of ABCD. The diagonals AC and BD are also
drawn to aid in conjecture and proof. At the top of
the view is a test for whether or not KLMN is a
parallelogram.

Two ways to move objects


2.

Tap at point D to move the cursor there.

Once you see the cursor near point D, it will be


shown among the list of objects near the cursor; this
list is displayed at the bottom right of the screen,
and the objects named are colored red for
identification.
3.

Now tap at point D and drag it.

Point D will move according to the direction and


length of your drag. This is a quick move.
4.

Press E to select point D. It will turn


light blue to show that it has been selected.

Now you can drag point D around OR use the arrow


keys to move it one pixel at a time. Press E
again to de-select point D.
Selected objects stay selected until you deselect
them. You can select multiple objects as well, either
individually or by tap-and-hold, then drag to create
a selection rectangle. Everything touching the
selection rectangle is selected. Press J to
deselect everything.

Geometric Tests
At the top of the screen is a parallelogram test for KLMN. This test consists of the test itself and its label. The
label was edited to make it more readable for students. The Geometry app has a number of tests available to
support student conjecture and proofs. These geometric tests can be created in either the Plot or Numeric views.

HP Calculators

Last Revised August 21, 2014

Page 24 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

The parallelogram test can return any of the following five values:
0: KLMN is not a parallelogram
1: KLMN is a parallelogram
2: KLMN is a rhombus
3: KLMN is a rectangle
4: KLMN is a square
Take a moment and experiment with the construction by moving points A, B, C, or D. You will see that the test
never returns zero. Even if you make ABCD concave, the test will continue to return a value of at least one. This
leads us to our first conjecture, usually known as Varignon's Theorem:
The quadrilateral formed by the midpoints of the sides of any quadrilateral is a parallelogram.

The Technique
Let's make ABCD a rectangle.
5.

6.

Move points A, B, C, and D so that they


appear to form something close to a
rectangle. In the figure to the right, the
opposite sides of ABCD appear to be
roughly equal in length and consecutive
sides appear perpendicular.
Press Y to open the Symbolic view of the
app and observe the definitions of points A,
B, C, and D.

We shall edit the coordinates of these points so that


they are more exactly the coordinates of a
parallelogram. Specifically, in our case (but not
necessarily yours), we will make the following
changes:
GA: point(-1, -6)
GB: point(-1, 1)
GC: point(10, 1)
GD: point(10, -6)
7.
8.
9.

Tap on the definition of GA to select it.


Tap
to edit the definition
Delete the current coordinates and enter
your own. Press E or tap
when you are done.

In the figure to the right, the coordinates of point A


are being changed to (-1, -6).
10. Repeat Steps 7-9 with points B, C, and D

HP Calculators

Last Revised August 21, 2014

Page 25 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Return to Plot view after editing the coordinates of


points A, B, C, and D.
11. Press P to return to Plot view to see
what has changed.
In this case, the test result has changed to 2,
indicating that KLMN is a rhombus. Making ABCD a
rectangle seems to make KLMN a rhombus. We will
now change ABCD, but keep it a rectangle and see
how the test behaves.
12. Tap on segment AD, between point N and
point D, and press E to select it. A
pop-up box will appear; make sure
segment AD (object J) is selected and any
others de-selected; then tap
.
13. You can now use the up- or down-direction
keys to move the segment, maintaining
ABCD as a rectangle.
You will note that the test continues to return a
value of 2, indicating that if ABCD is a rectangle,
then KLMN is a rhombus. This example was used to
illustrate the technique involved:

In Plot view, move A, B, C, or D to form what


appears to be a special quadrilateral
Go to Symbolic view and edit the definitions
to make the coordinates exact
Return to Plot view to see the effects on
the test results
Manipulate ABCD, keeping its properties
intact and see if the test result changes

We can make ABCD a kite, a rhombus, a rectangle, a


square, or a trapezoid. For each quadrilateral type,
we can make a conjecture about KLMN.

Try it yourself
Make ABCD a kite, following the procedure outlined
above. Once it is a kite, select one of the vertices
and press E to select it. Now you can move
the vertex carefully using the directional pad, one
pixel at a time. Move the vertex so that ABCD
continues to be a kite. In the figure to the right, you
could move A or C horizontally. Keep your eye on the
test results as you move A or C.

HP Calculators

Last Revised August 21, 2014

Page 26 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Creating a geometric test


We will now recreate the parallelogram test to illustrate the technique.
1.

Press Y to go to Symbolic view and


identify the name of the quadrilateral
KLMN. The figure to the right shows that
KLMN is the geometric object named GO.

The Symbolic view shows the definition of every


geometric object in Plot view, whether visible or not.
Those that are checked are visible; those that are
not checked are hidden. You can easily see how any
construction was created and the order in which the
objects were created. You can also choose the color
of each object in Symbolic view.
2.

Press M to go to Numeric view. The first


line contains our current parallelogram
test. Select this entry to see the definition
of the test at the bottom of the screen:
is_parallelogram(GO)

Tap
to edit the definition or
the label.

to edit

We will now recreate the test.


3. Tap on the second entry line to select it and
tap
4.
5.

6.
7.

8.

Tap
, select Tests, and choose
Parallelogram
The command is pasted to the command
line. Tap
, scroll down and select GO
(or type the name using the Alpha shift).
Tap
to enter the new test.
Tap
to edit the test label. Enter a
more descriptive text label. We used "Is
KLMN a parallelogram?".
Tap
when your label is done.

Objects in Numeric view that are checked appear


docked to the top left in Plot view; objects that are
not checked in Numeric view are not visible in Plot
view.

HP Calculators

Last Revised August 21, 2014

Page 27 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Return to Plot view.


9.

Press P to see our duplicate test in Plot


view.
10. Tap on the duplicate. Now drag it to the
bottom of the screen, as shown in the
figure to the right. We now have the
original test docked at the top left and our
duplicate undocked at the bottom of the
screen.
11. Pinch to zoom out. You will see that the
undocked test changes both size and
position with the zoom, while the docked
test remains the same.
12. Tap and hold on the undocked test. The
menu keys change and the label edit box
opens.
The cursor appears at the end of the current label.
Delete or edit the text as you see fit.
The table below lists the other operations you can
perform with the new menu keys.
Menu Key

Purpose
Re-dock the measurement or test
Delete the measurement or test
Select a color for the test and its
label
Cancel label editing and return to
the main menu
Accept label editing and return to
the main menu

Since we do not need it anymore, tap


delete the duplicate test.

to

The Geometry app has an entire set of tests like the parallelogram test. Tap
whole list. There are an additional 7 tests in the Catalog.

and select Tests to see the

Testing geometric objects for their properties allows students to make conjectures and pursue proofs. Having
dedicated Numeric and Symbolic views helps students and their teachers see how the app was created and how it
works.

HP Calculators

Last Revised August 21, 2014

Page 28 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Elements, animations and function plots: the SlopeFunction App


We will now use the HP Prime Wireless Classroom Network to send you an app called SlopeFunction. We will use
this app to investigate the element command and creating animations. Along the way, we will discover one of
many plot types.
1.

Press I and tap on the icon for the


SlopeFunction app

The app opens in Plot view. Press P at any time to


return to this view. The plot of a cubic function is
shown in blue, with a green tangent line through a
point B on the function. There is an orange point D
as well. At the top of the display are the coordinates
of point D as well as a measurement named B that
shows a current value of -0.5.
2.

Press Y to enter Symbolic view. There


are 5 objects defined here:
GA: the plot of a cubic function

o
, Plot, Function
GB: a point on the function
o
, Point, Point On
GC: the tangent to the function through
the point B
o
, Line, Tangent
GD: a point whose abscissa is the same
as the abscissa of point B and whose
ordinate is the same as the slope of the
tangent line
o
, Point, Point
GE: the locus of point D as point GB
moves along the function GA
o

, Curve, Locus

The Plot view only showed us 5 of the 6 objects.


Note that GE is not checked in Symbolic view, so it is
not visible in Plot view.
3.

Press M to enter Numeric view. There are


two measurements defined here:
The coordinates of point D

o
, Cartesian, Coordinates
The equation of the locus GE
o

, Cartesian, Equation of

Only the coordinates of point D are checked to be


visible in Plot view. The equation of the slope
function is hidden.

HP Calculators

Last Revised August 21, 2014

Page 29 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

The definition of point D places it on the slope


function for the function defined in GA. Also, since
its x-coordinate is the same as that of point B, you
can control point D by moving point B.
4.

5.

Tap on point B and move it anywhere along


the function plot. You will see point D move
and the coordinates of point D will update
accordingly.
Tap on point D. The menu key
appears. Tap on it and select Trace. Now
move point B again. As point D moves, it
traces its path.

The path of point D appears to be parabolic. We can


now make the locus and its equation visible.
6.

7.

8.

Press Y to return to Symbolic view and


check GE, the locus, so it is visible in Plot
view.
Press M to return to Numeric view and
check the equation so it, too, is visible in
Plot view.
Press P to return to Plot view to see our
new additions.

The locus is shown in orange and its formula

3 2
x x 1 is displayed as well.
2
You can now edit the function GA in Symbolic view
and the Plot view will change accordingly. In other
words, you now have a way to visualize the slope
function of any function, either one point at a time,
or via its trace or locus. The choice is yours.

Elements and Animations


A word about the elements command is in order. In
Symbolic view, the definition of GB is:
GB:=element(GA, -0.5)
This amounts to saying that point B is a point on GA
(the function plot) whose initial x-coordinate is -0.5.
When you create an element (a point on an object),
the x-coordinate is shown in Plot view as a
measurement. This measurement is actually a slider
bar, and the slider bar can be used to control an
animation.

HP Calculators

Last Revised August 21, 2014

Page 30 of 45

HP Prime
9.

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Tap and hold the measurement labeled B. A


slider bar appears. You can now move the
slider left and right, either with your finger
or with the left- and right-direction keys.

Notice the new menu key:


. Press this menu
key to define the slider bar and any animation
associated with it precisely.
10. Press
. In the figure to the right, the
minimum and maximum values have been
set to correspond roughly with the Plot
view visible domain of GA, with a step of
0.025 (the current pixel width in Plot view).
11. Tap on the Animation field. You can
choose either a Loop or a Back and
Forth animation. Select the Back and
forth option.
12. Tap

to create the animation.

Note that you can control the relative speed of an


animation as well as the length of the pause before
the animation repeats. Here we kept the default
values.
Since the slider was selected when we edited it, the
slider is still selected when we tap
.
13. Press J to deselect the slider bar and the
animation will start.
14. In general, you start, stop, and restart an
animation by pressing
and tapping
Animation. It is a toggle. A check mark
will show that it is active and will be cleared
when it is inactive.

With slider bars and animations, you can create any number of interesting simulations and explorations. The next
app we study will feature another use of slider bars as well.

HP Calculators

Last Revised August 21, 2014

Page 31 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

More on slider bars and plot types: the Iterations App


We will now use the HP Prime Wireless Classroom Network to send you an app called Iterations. We will use this
app to learn more about the element command. Along the way, we will discover one more plot type.
1.

Press I and tap on the icon for the


Iterations app

The app opens in Plot view. Press P at any time to


return to this view. The plot of a quadratic function
and the line y=x are shown in blue, with a green
point D as well. At the top of the display are three
measurements or calculations, two of which are
slider bars.
2.

Press Y to enter Symbolic view. There


are 5 objects defined here:
GA: a slider bar for a parameter value

o
, Curve, Slider
GB: a variable named f that contains a
quadratic function defined in terms of
the slider GA
o Just type it in
GC: a line defined by y=0

o
, Line, Line
GD: a point on the line y=0

o
, Point, Point On
GE: a sequence plot of GB, using the
abscissa of point D as the initial value
o

, Plot, Sequence

The plotseq command has the following syntax:


Plotseq(function in x, {starting value of x, xmin,
xmax}, number of iterations)
The Symbolic view only showed us 5 of the 6
objects.
3.

Press M to enter Numeric view. There is


one calculation defined here:
The 10th iteration on the quadratic
function, using the abscissa of point D
as initial value
o D,
, ITERATE

The ITERATE command has the following syntax:


ITERATE(function, variable, starting value, number
of iterations)

HP Calculators

Last Revised August 21, 2014

Page 32 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Note that GA uses the same element command that we used for a point on an object, but with a different syntax.
The command element(object, value) creates a point on an object at an initial value as well as a slider bar to
change that value. The command element(min, max, initial) create a slider bar with a given domain and a given
initial value, without creating a point on an object.
4.

Press P to return to Plot view. Tap and


drag point D along the x-axis. The 10th
iteration will change along with the value
shown.

As you know from the previous app, you can tap and
hold on the slider bar for D to open it and control the
position of point D that way as well.
5.
6.

Now tap and hold on A to open its slider bar


Use the left- and right-direction keys to
change the parameter value and observe
its effect on the sequence plot.

The value of the slider is shown at the bottom right


of the screen.
Of course, you can create an animation based on the
value of A, just as we did for the point D in the
previous app. You can also create an animation for
point D the same way. You can even run both
animations at the same time; though in this case,
the pedagogical value is dubious.

Edit the definition of the function f(x) in GB and you


can iterate on any function you please. In the figure
to the right, we edited GB so that f(x):=GA*cos(x).

With slider bars via the element command, and a whole set of plot types, the Geometry app is really about much
more than just Geometry.

HP Calculators

Last Revised August 21, 2014

Page 33 of 45

HP Prime

Advanced Workshop: The HP Prime Wireless Classroom Network

Version 1.2

Programming in HP PPL

The HP Prime Programming Language (HP PPL) was designed for general use. It is simple to get started with, but
powerful enough for a wide range of applications. HP PPL supports basic programming structures, such as loops
and branches of various sorts. It has an extensive set of graphical, input/output, string, matrix and other types of
commands. Within any program, you also have access to all the mathematical functions of your HP Prime. Finally,
you have access to any App Function from within a program.

Programming Options
You can create an HP PPL program using a number of methods, as shown in the table below. Each method has its
benefits and drawbacks. No matter which method you use, the HP Prime Connectivity Kit assures that you can
send your program to your HP Prime and your HP Prime Virtual Calculator.
Method
HP Prime

Benefits

HP Prime Virtual
Calculator

HP Prime
Connectivity Kit

Your Favorite Word


Processor

Mobility: work on your program anytime,


any place
Debug: use the built-in check and debugger
tools to check your program
Fast: use your PC keyboard to just type in
your program
Debug: use the built-in check and debugger
tools to check your program
Fast: use your PC keyboard to just type in
your program
Commands, strings, and comments are
color-coded for easy identification and
reading
Fast: use your PC keyboard to just type in
your program

Drawbacks

Must use menus to find and enter


commands-or use the alpha shift to enter a
command letter by letter

Must have access to your PC

No debugging tools
Must have access to your PC

Must copy and paste the program into the


virtual calculator or connectivity kit
No debugging tools
Must have access to your PC

HP Calculators

Last Revised August 21, 2014

Page 34 of 45

HP Prime

Advanced Workshop

Version 1.0

Getting started: user-defined functions


The simplest way of extending the capabilities of your HP Prime via programming is to create user-defined
functions. This can be done using two different methods, each with its own variiations. In the following examples,
we will explore creating, modifying, and deleting user-defined functions.
In the setting of a geometric random variable, each trial is independent and has probability of success p; the
probability density function for the distribution of such a variable computes the probability of the first success
occurring on the kth trial. The formula for the geometric probability density function is thus

P( X k ) 1 p

k 1

p . HP Prime has no built-in geometric probability density or cumulative density

functions. We shall create a user-defined geometric probability density function in two variables.

User-defined functions: geometric_pdf(p, k)


In this example, we use the Define dialog box to create a function named geometric_pdf.
1.
2.

Press H to go to the Home view


Press S d (Define) to open the Define
dialog box
3. The first field in the Define dialog box is for the
name of the function:
Press A S A to lock the lower-case
alpha shift
Enter geometric_pdf and tap
Note: press X to get the underscore character
4. Highlight the Function field and enter the
formula for the geometric probability density
function
Enter the formula as shown to the right
Tap
when you are finished
Note: We use upper-case letters for our
variables here
You will now see the two variables (P and K), with
check boxes beside each one. The left-to-right order
of the variables matches their order in the function;
that is our geometric probability density function is
actually geometric_pdf(P, K).
The check box beside each variable determines
whether or not the variable is an input variable. If
checked, a variable is an input variable and a value
for it must be supplied each time the function is
used. If unchecked, the variable is not an input
variable; instead of being required as input when the
function is used, the current value of the
corresponding home real number variable will be
used.

2014 by HP Calculators

Last Updated May 30, 2014

Page 35 of 45

HP Prime

Advanced Workshop

Version 1.0

If a coin is has equal probabilities for heads and


tails, then the probability of heads on the first toss
is 0.5. That is geometric_pdf(0.5, 1) should return
0.5.
1.

2.

To access our new function, press D to


open the Toolbox menus, tap
for
the User menu, tap User Functions, and
select geometric_pdf
Complete the command geometric_pdf(0.5,
1) and press E

The result is as expected. The screen shot also


shows what happens when you use a list for K.
Suppose that, in practice, we find that we rarely
change the value of P and do many calculations all
using the same P-value. We can edit the definition
of our function so that it takes its P-value from the
current value of the home variable P instead of
supplying that value each time we use the function.
1.
2.

3.
4.

Press S d (Define) to open the Define


dialog box
With the Name field highlighted, tap
and select geometrix_pdf; the current
definition populates the Define dialog box
Highlight the field for the variable P, tap
to uncheck it and tap
In the Home view, store the value 0.5 in P:
Type 0.5, tap
, press A B
(for P) and press E

Now our function is geometric_pdf( K) and takes its


probability from the value of the Home real variable
P. The figure to the right reprises the earlier
examples.
To delete a user-defined function, press D to
open the Toolbox menus, tap
for the User
menu, and use the cursor keys to navigate to the
function you want to delete. With the function
highlighted, press C.
In the next section, we will continue to examine user-defined functions, but this time we will use the Program
Catalog and Program Editor.

2014 by HP Calculators

Last Updated May 30, 2014

Page 36 of 45

HP Prime

Advanced Workshop

Version 1.0

Exported functions in a program: Geometric probability functions


The geometric probability cumulative density function calculates the probability that a success is generated by
the Kth trial, where each trial is independent and has an equal probability of success P. It is thus a sum whose
terms are each given by our geometric_pdf function. In this example, we will use the network to send you a
program named Geometric that contains both the probability density and cumulative density functions.
1.
2.

Press S x (Program) to open the


Program Catalog
Tap on the program name Geometric;
the Program Editor opens to allow you to
edit your new program

The program is shown in the figure to the right. It


has three parts:
The program name, followed by an empty
BEGINEND block structure (highlighted in
green)
The exported GEO_PDF function (in yellow)
The exported GEO_CDF function (in orange)

Let's take a look at each of these three parts in


detail.
Geometric()
BEGIN
END;

EXPORT GEO_PDF(P,X)
BEGIN
RETURN P*(1-P)^(X-1);
END;

EXPORT GEO_CDF(P,X)
BEGIN
V:=0;
FOR A FROM X DOWNTO 1 STEP 1 DO
V:=V+GEO_PDF(P,A);
END;
RETURN V;
END;

2014 by HP Calculators

This part is created automatically. We left the


BEGINEND block structure blank for the sake of
simplicity.

The EXPORT command makes the geometric


probability density function GEO_PDF(P,X) visible
outside of the program. The RETURN statement
within the BEGINEND block defines the function.

The cumulative probability function GEO_CDF(P, X)


initializes the variable V with a value of zero. The
FOREND loop computes the GEO_PDF value for
each possible X-value and adds it to V to get a
partial cumulative sum. Once the loop finishes, the
RETURN command returns the final sum in V.

Last Updated May 30, 2014

Page 37 of 45

HP Prime

Advanced Workshop

Version 1.0

Return to Home view to use our new functions.


1.
2.
3.

4.
5.

6.
7.

Press H to open Home view


Press D to open the Toolbox menus and
tap
Tap Geometric to see our two new
functions, as shown in the figure to the
right
Tap GEO_PDF; the command is pasted
into the Home view command line
Complete the command GEO_PDF(0.5, 3)
and press E; it returns the correct
result: 0.125
Repeat Steps 2 and 3, but this time select
GEO_CDF
Complete the command GEO_CDF(0.5, 3)
and press E; it returns the correct
result: 0.875

You have now learned two ways to create user-defined functions to extend the capabilities of your HP Prime.
Along the way, you have learned how to use the Program Catalog and Editor to create new programs to extend
your HP Prime. In the next example, we look at programming in a more general context.

Programming: The Sierpinski Triangle


The program Sierpinski uses the Chaos Game
approach to approximating the Sierpinski Triangle.
In the Chaos Game, one starts with the three
vertices of a triangle (named in order 1, 2, and 3)
and a point as initial condition. An integer from 1 to
3 is chosen at random. If 1 is chosen then a point is
plotted halfway between the initial condition and
Vertex 1. Similarly, you plot the point halfway from
the initial condition to Vertex 2 or Vertex 3 if a 2 or 3
were chosen. The new point is then made the initial
condition and the Chaos Gam continues. In our
program, we draw the first 10,000 points in a
matter of seconds. The earliest points are red and
they decrease in red and increase in blue as the
game proceeds.
We will now send you the Sierpinski program using the HP Connectivity Kit.

2014 by HP Calculators

Last Updated May 30, 2014

Page 38 of 45

HP Prime

Advanced Workshop

Version 1.0

Program Listing

Comments

local x1, x2, x3, y1, y2, y3, xn, yn;


local a, b, color;

Declare the coordinates of the triangle and the initial


condition as local variables. Also declare a, b, and color as
local variables (more on these later).

EXPORT Sierpinski()
BEGIN
x1:=160; x2:=299; x3:=21; xn:=160;
y1:=0; y2:=240; y3:=240; yn:=0;
RECT();
FOR a FROM 1 TO 10000 STEP 1 DO
b:=RANDINT(2)+1;
CASE
IF b=1 THEN xn:=(xn+x1)/2; yn:=(yn+y1)/2;END;
IF b=2 THEN xn:=(xn+x2)/2; yn:=(yn+y2)/2;END;
IF b=3 THEN xn:=(xn+x3)/2; yn:=(yn+y3)/2;END;
END;
color:=RGB(255-a/40,0,a/40);
PIXON_P(IP(xn),IP(yn),color);
END;
WAIT;
END;

Export the program so it appears in the Toolbox User


menu.
Declare values for the vertices and initial condition.
RECT() with no argument clears the graphics display.
Local variable a is used in a FORDOEND loop
Local variable b contains the Chaos Game random integer
The CASEEND structure defines the point to plot, based
on the random integer value.

The local variable color uses the RGB command to set a


color for the point.
Turn on the pixel for that point, using the value of color.
Pause when finished until a key is pressed.

Notes
We used physical screen coordinates rather than Plot view coordinates. The top left of the display is the point (0,
0) and the bottom right of the display is (320, 240). The point (x1, y1) is at the top middle of the display. The other
two points were chosen to be at the bottom of the display and to form a triangle that is close to equilateral. The
initial condition was chosen as the top vertex of the triangle.
The RANDINT(N) command generates integers from 0 to N, so we used RANDINT(2)+1 to generate 1, 2, or 3 and
store it in the local variable b.
The RGB command creates a single hexadecimal integer from three decimal integers from 0 to 255. The first
decimal integer is for the red component. Here we used 255-a/40 so that the red component would be strong at
first and gradually die off. We kept the green component zero. The blue component is the opposite of the red
component; it starts off close to zero and increases as the game continues. So early points are red, middle points
are purple, and later points are blue.
The command PIXON_P(x, y, color) uses the same physical coordinates that we used for the points. If you prefer
to use the Plot view coordinate system, use the command PIXON(x, y, color).
You can change the values of xn and yn to see that the initial condition really does not matter.

2014 by HP Calculators

Last Updated May 30, 2014

Page 39 of 45

HP Prime

Advanced Workshop

Version 1.0

Custom HP Apps with programs and notes: Sicherman Dice


Like regular dice, Sicherman dice are cubical in shape and numbered with positive integers. Unlike regular dice,
the first Sicherman dices is numbered 1, 2, 2, 3, 3, and 4, while the second Sicherman dice is numbered 1, 3, 4, 5,
6, 8. If 2 Sicherman dice are rolled repeatedly, what does the distribution of the sum of each roll look like?
To simulate rolling regular and Sicherman dice, we created an app called Sicherman that has a program attached
to it. Here is the process we followed to create the app:
1. Decide which HP App will be the basis of your new app
a. We chose the Statistics 1Var app because we wanted to display a histogram of the distribution
of the sums
2. Save the HP App under a new name and start it
a. We chose the name "Sicherman"
3. Open the Program Catalog. The Program Catalog always lists a program with the same name as the
current app. Open this program and edit it to add the functionality you need.
We will now send you the Sicherman App via the Prime Classroom Network. Then we will examine how it works
and what the program attached to it contains.
1.

Press I and tap on the icon for the


Sicherman app

The app is programmed to open in its Info view


(more on this later). Press S I (Info) at any
time to return to this view. This view describes the
app in general terms and directs the student to
press V to get started.
1.

2.

Press V and select Regular Dice.


You will be prompted to enter the number
of rolls. Type 5000 and press E.
The simulation will run and then the
histogram of the sums of the rolls will be
displayed.

As shown in the figure to the right, the distribution is


symmetric and centered at 7, as expected.

2014 by HP Calculators

Last Updated May 30, 2014

Page 40 of 45

HP Prime

3.

Advanced Workshop

Version 1.0

Press M to see the data.

Column D1 contains the possible sums (with 1


retained to make things easier). Column D2 contains
the frequencies corresponding to each sum in D1.
Columns D3 and D4 represent the two dice used in
the simulation.
4.

Now press V and select Sicherman


Dice. Run a simulation of 500 rolls with
these dice.

Are you surprised at the results? Look at Numeric


view and compare the data to what is shown for the
regular dice in the figure to the right.
We will now look at the Sicherman app program to see how it was constructed and how it behaves.
5. Press S x (Program) to open the Program Catalog
6. Tap on the program name Sicherman (App)
7. The Program Editor opens with the Sicherman program listing, shown on the next page with notes on
each section.

Program Listing
DOIT();
Plot();
EXPORT n, b, a;
VIEW "Sicherman Dice" Sich()
BEGIN
D3:={1,2,2,3,3,4};
D4:={1,3,4,5,6,8};
DOIT();
END;
VIEW "Regular Dice" Regu()
BEGIN
D3:={1,2,3,4,5,6}; D4:={1,2,3,4,5,6};
DOIT();
END;

2014 by HP Calculators

Comments
Declare two subroutines: DOIT() and Plot().
Export the variables n, b, and a outside of the program.
Add an option "Sicherman Dice" to the Views key menu
The program Sich() runs when this option is chosen. The
program defines columns D3 and D4 to be the two
Sicherman dice and then runs the program DOIT().

Add an option "Regular Dice" to the Views key menu


The program Regu() runs when this option is chosen. The
program defines columns D3 and D4 to be two regular
dice and then runs the subroutine DOIT().

Last Updated May 30, 2014

Page 41 of 45

HP Prime

Advanced Workshop

Version 1.0

Program Listing

Comments

DOIT()
BEGIN
D1:={1,2,3,4,5,6,7,8,9,10,11,12};
D2:={0,0,0,0,0,0,0,0,0,0,0,0};
INPUT(n,"Number of Rolls","Rolls","Enter
number of rolls",50,50);
FOR a FROM 1 TO n DO
b:=D3(RANDINT(5)+1)+D4(RANDINT(5)+1);
1+D2(b)D2(b);
END;
Plot();
END;
Plot()
BEGIN
SetSample(H1,D1);
SetFreq(H1,D2);
H1Type:=1;
Hwidth:=1;
Hmin:=0;
Hmax:=13;
Xmin:=-0.5;
Xmax:=14;
Ymin:=-0.5;
Ymax:=1.1*MAX(D2);
Xtick:=1;
IF n<50 THEN Ytick:=1 ELSE
Ytick:=IP(Ymax/100)*10;
END;
CHECK(1);
STARTVIEW(1,1);
STARTVIEW(1,1);
END;
START()
BEGIN
STARTVIEW(6, 1);
END;

The subroutine DOIT() defines D1 to be the possible sums


(including 1 for ease) and D2 to be the frequencies of the
corresponding sums in D1. Then an input form is created for n,
the number of rolls. The FORDOEnd loop defines b to be
the sum of two numbers chosen randomly, one from each die.
D2(b) is then incremented by one.

When the loop finishes, the Plot() subroutine runs.

The subroutine Plot() defines H1 in Symbolic view. It makes


D1 the sample data and D2 the frequencies.
It sets the plot type to histogram and the bin width to 1.
It sets the Plot view window and makes a guess about where
to put the ticks on the y-axis.

It makes sure H1 is checked (active) for graphing and then it


displays the histogram in Plot view.

The subroutine START() runs whenever the app is


started (by tapping its icon in the App Library or
selecting it and tapping
). It displays the Info
view.

Notes
The program Plot() actually runs not only whenever it is called as a subroutine, but also whenever you press P
while this app is running. Likewise, the program START() runs when the app is selected in the App Library and you
press
. The other app control keys ( Y, M, etc.) can be tied to subroutines in a similar fashion. This
gives you complete control over your custom app.
The VIEW command changes the options available when V is pressed. Each instance of the VIEW command
adds exactly one option to the Views menu, in the order in which they are encountered in the program listing. You
can reinstate standard Views options (Autoscale, etc.) as well, depending on the base HP app used.

2014 by HP Calculators

Last Updated May 30, 2014

Page 42 of 45

HP Prime

Advanced Workshop

Version 1.0

The STARTVIEW command is used to present any view of the current app. View 6 is the Info view.
You noticed that the Sicherman app had a note attached to it, which is displayed when the app starts. The note is
in the Info view of the app and is sent whenever the app is transmitted to another HP Prime.
When the Sicherman app is sent to an HP Prime, the Sicherman app program is sent along with it. You must open
the Sicherman program on the receiving HP Prime to activate the program.
Thus, all custom HP apps have three files associated with them:

The app file itself: Sicherman.hpapp


The app program file: Sicherman.hpappprgrm
The app note file: Sicherman.hpappnote

Usually, these three files are bundled in a single zip file that you drop into the Content Pane of HP Connectivity
Kit. Right-click on this zip file and select Send to send the app, along with its note and program, to all connected
HP Primes (or select a subset of the connected HP Primes in the Monitor pane and send to just those devices). Be
sure to open the zip file to see if there are instructions for the teacher or student, or if there is a short
introductory video.

Program Listings
You can use the following program listings to copy and paste the programs into your HP Prime Virtual Calculator.

Program: Geometric
Geometric()
BEGIN
END;
EXPORT GEO_PDF(P,X)
BEGIN
RETURN P*(1-P)^(X-1);
END;
EXPORT GEO_CDF(P,X)
BEGIN
V:=0;
FOR A FROM X DOWNTO 1 STEP 1 DO
V:=V+GEO_PDF(P,A);
END;
RETURN V;
END;

2014 by HP Calculators

Last Updated May 30, 2014

Page 43 of 45

HP Prime

Advanced Workshop

Version 1.0

Program: Sierpinski
local x1, x2, x3, y1, y2, y3, xn, yn;
local a, b, color;
EXPORT Sierpinski()
BEGIN
x1:=160; x2:=299; x3:=21; xn:=160;
y1:=0; y2:=240; y3:=240; yn:=0;
RECT();
FOR a FROM 1 TO 10000 STEP 1 DO
b:=RANDINT(2)+1;
CASE
IF b=1 THEN xn:=(xn+x1)/2; yn:=(yn+y1)/2;END;
IF b=2 THEN xn:=(xn+x2)/2; yn:=(yn+y2)/2;END;
IF b=3 THEN xn:=(xn+x3)/2; yn:=(yn+y3)/2;END;
END;
color:=RGB(255-a/40,0,a/40);
PIXON_P(IP(xn),IP(yn),color);
END;
WAIT;
END;

App Program: InferencePlus (based on the Inference App)


local p,k;
GEO_PDF(p,k);
GEO_CDF(p,k);
EXPORT InferencePlus()
BEGIN
END;
VIEW "Geometric PDF" GEO_PDF()
BEGIN
INPUT({p,k},"Geometric PDF",{"P", "K"},{"Enter the probability of success, P","Enter the number of trials,
K"},{0.5,1},{0.5,1});
MSGBOX("GEO_CDF("+p+","+k+")="+p*(1-p)^(k-1));
END;
VIEW "Geometric CDF" GEO_CDF()
BEGIN
V:=0;
INPUT({p, k},"Geometric CDF",{"P", "K"},{"Enter the probability of success, P","Enter the number of the successful
trial, K"},{0.5,1},{0.5,1});
FOR A FROM k DOWNTO 1 STEP 1 DO
V:=V+p*(1-p)^(A-1);
END;
MSGBOX("GEO_CDF("+p+","+k+")="+V);
END;

2014 by HP Calculators

Last Updated May 30, 2014

Page 44 of 45

HP Prime

Advanced Workshop

Version 1.0

App Program: Sicherman (based on the Statistics 1Var App)


DOIT();
Plot();
EXPORT n, b, a;
VIEW "Sicherman Dice" Sich()
BEGIN
D3:={1,2,2,3,3,4};
D4:={1,3,4,5,6,8};
DOIT();
END;
VIEW "Regular Dice" Regu()
BEGIN
D3:={1,2,3,4,5,6};
D4:={1,2,3,4,5,6};
DOIT();
END;
DOIT()
BEGIN
D1:={1,2,3,4,5,6,7,8,9,10,11,12};
D2:={0,0,0,0,0,0,0,0,0,0,0,0};
INPUT(n,"Number of Rolls","Rolls","Enter number of rolls",50,50);
FOR a FROM 1 TO n DO
b:=D3(RANDINT(5)+1)+D4(RANDINT(5)+1);
1+D2(b)D2(b);
END;
Plot();
END;
Plot()
BEGIN
SetSample(H1,D1);
SetFreq(H1,D2);
H1Type:=1;
Hwidth:=1;
Xmin:=-0.5;
Xmax:=14;
Ymin:=-0.5;
Ymax:=1.1*MAX(D2);
Xtick:=1;
IF n<50 THEN Ytick:=1 ELSE
Ytick:=IP(Ymax/100)*10;
END;
CHECK(1);
STARTVIEW(1,1);
STARTVIEW(1,1);
END;

2014 by HP Calculators

Last Updated May 30, 2014

Page 45 of 45

You might also like