CrunchJr is an expression evaluator.
It evaluates the user's
input expression and tabulates the result and variable values for up to
three variables (each with one or more values).
200+ Constants (e.g., PI, SQRT2) and 300+ Functions
(e.g., Sqrt, Refinance, Cubic, Payoff, ComplexDiv, Ira, Integrate) are
available for use. Tapping
[Inputs] → {Functions}
or → {Constants} leads to detailed
information about the hundreds of available Functions and Constants.
Further, there are several advanced features,
including storing results
for later use, personalizing your environment, integration,
building user-defined functions, and input shortcuts.
There are several features which can make using the basic
functionality of expression (and equation) evaluation easier.
This list allows you to navigate quickly to get to the description for
these features.
An equation is a simple variable followed by "=" followed by an
expression. The expression may contain variables,
constants, and functions. The result of each expression
evaluation (one for each set of variable values) is saved in
the Store
under the left hand side variable name. When that
variable is next referenced in an expression, those saved values are
automatically loaded (although they are subject to user override).
Here is a simple sample of an equation:
omega = (rho-a)*sin((pi-rho)*(1-a));
For this sample, the user would be prompted for one or more values for
the variables rho and a. If the user entered two
values for one variable and three for the other, six values for
omega would be calculated and saved in
the Store.
When omega is later used in this or a future session,
these six values would be automatically loaded.
It is straightforward to load variable values directly into
the Store.
for use later in this or a future session. Tap
[Inputs] → {Variables}
→ (Edit) → Add
Variable, then enter the variable name and values (separate
multiple values with commas). Later you can use the variable
in an expression without needing to enter values. Here are some
examples:
e = enat
i = 1, 2,
3, 4
index = loop
1 17 2
beta = 5.103,
4.1219, pi, 2.171, sqrt3
xyz = interp
3 7 4
In these examples, values for e, i, index,
beta and xyz are placed in
the Store.
Enat, pi and sqrt3 are constants, and
loop and interp are special input shortcuts. The
values for index are 1, 3, 5, ..., 17. The values for
xyz are 3, 3.125, 3.25, ..., 3.875, 4. That is, seven
equally-spaced values are placed between 3 and 4, making nine values
total. Details about loop and interp can be
found below in the Input shortcuts section.
There are a variety of user-settable options and toggles which control
various operations, including displaying results and saving information
in the Store.
These options and toggles are most often employed by heavy-duty users
– the majority of users are comfortable with the default
settings.
Tap [Info] → {Show
Settings} to see the current status of these tunable parameters
(the tables below show the default settings).
Or, tap [Info] →
{Settings} to make changes.
A sample: By default,
values generated by a computation – the LHS (left-hand side) of
an equation evaluation – are automatically saved in
the Store
for later review or reuse,
but users may choose to disable this option (via the
Save LHS toggle).
Equations and expressions entered in the
[Expression] box
are saved in a history file which is available
for reference in this and future sessions.
Any of them can be recalled for review, editing, deletion
or resubmission.
Here is an abbreviated sample history view
(note the Key at the bottom which describes the various fields).
the Store
holds variables and user-defined functions. This
data is available in the current and future sessions.
Various usage statistics
are maintained for the data stored in the Store. The values of
variables are kept for future review and use. Variables and their
values are sent to the store as the result of Equation Evaluations
(when the SaveLHS option is On), when variables are
used in an expression while the SaveRHS option is On, and when direct
Store requests are made (e.g.,
[Inputs] → {Variables}
→ (Edit) →
Add Variable). By default,
SaveLHS = On and SaveRHS = Off. These options can
be changed via
[Info] → {Settings}.
There are multiple access paths for reviewing the contents of
the Store.
[Info] →
{The Store} leads to usage reports
Pick one of the reports from (1) above, and tap
{+Fav}. You can then
quickly access that report via
[Info] →
{(Favorite Screens)}.
[Inputs] →
{Variables} generates a list of the
variables – tap any variable to see its values, stats
etc.
When entering an expression with a variable which has saved data,
that data is automatically entered into the variable entry box.
This data can be modified or ignored (see next section).
Data in
the Store
is automatically used (although the user may override
some or all of the previous values). Here is a sample: Assume that
index is in
the Store
with nine values (1,3,5,...,17).
Then entering dist = index*(pi-theta) in the
[Expression]
box and tapping [Submit] would lead to:
dist = index*(PI-theta);
Enter value(s) for each variable
index
theta
The input values for index from
the Store
may be accepted, deleted, or overridden for this evaluation.
Input values may be integers, floating point values, or
CrunchJr-recognized constants (like pi or sqrt2).
Input values are separated by one or more commas and blanks.
Further, there are three special strings that
can be used with input values: Loop,
Interp, and Last
Loop: Use a set of values described by the 2 or 3
following values: FirstValue, LastValue,
Increment. When the optional Increment is
not supplied, either +1 or -1 is used.
Increment may be silently sign-corrected.
The values may be integers or floating point values.
No other values may appear on the input line. Note that
LastValue is not guaranteed to be included (see example 3).
Here are some examples:
Loop 1 10
Loop 1 10 2
Loop -0.5 pi .25
Loop 3 -10
Loop 100 80
which create 10, 5, 15, 14, and 21 values respectively.
Note that no variable may have more than 256 values.
Interp: Interpolate. This special format
indicates that n values are to be used (at equally-spaced
intervals)
between the FirstValue and LastValue. 3 other values must appear
on the input line. In this example
Interp 7.5 4 10
6 values are used: (7.5, 8, 8.5, 9, 9.5,
10). No other values may appear on the input
line. Since no variable may have more than 256 values, n
must be 254 or less.
Last: Use the result of the previous evaluation
of the expression (zero is used for the first
pass). "Last" must be a stand-alone value.
When you are entering data, tapping the
[calc] key switches to a
special-purpose keyboard (which includes a standard 789 numeric
keypad). Although
it appears similar to a calculator keyboard, it is more of a hybrid
– with some of the strengths of both a calculator and
CrunchJr. Unlike a calculator, when you tap
a function key (e.g., sin), those characters appear in the
[Expression] box; it does not force an
immediate computation. When you've built the expression
you want, tap the [Submit] button as usual.
Back-to-back keystrokes
can be used to build other functions. For example, a and
cos for acos(), sin and
h for sinh(); tan and d
for tand()†. (Note that the arcsine
function is asin(), not invsin().)
Altogether, 24 functions are quickly available.
acos()
atanh()
inv()
sinr()
acosh()
cos()
ln()
sqrt()
asin()
cosd()
log()
tan()
asinh()
cosh()
sin()
tand()
atan()
cosr()
sind()
tanh()
atan2()
exp()
sinh()
tanr()
Similarly, these 18 constants can be easily constructed.
EINV
LOG10E
SQRT5
LN10
PIINV
SQRT6
LN2
PIINVSQRT
SQRT7
LN3
SQRT10
SQRT8
LOG102
SQRT2
SQRTE
LOG103
SQRT3
SQRTPI
This keyboard may be most convenient when working with hexadecimal
numbers (all the entries are on the same keyboard). Further, the
15 letters represent about 85% of typical English text (by frequency).
Thus some users find it convenient to use this keyboard for
most of their input.
Users can copy the result from selected computations (by
tapping the
button), which places it in the pasteboard.
This value can then be pasted
into any CrunchJr input request, or used outside the
app. Further, an outside value can be carried into
CrunchJr and used just like any other value. To
enable this capability, set the Cut-and-Paste toggle (
[Info] → {Settings}
→ (Cut-and-Paste) to ON (it is OFF by default).
Although the pasteboard holds only one value, you can tap
[Info] → {Pasteboard
Contents} to review the most recent entries, and you may
place any one of these into the pasteboard.
CrunchJr provides three mechanisms to review some
simple statistics
about computed (and input) values.
When an equation is
used, statistics about the computed variable are saved in
the Store.
These simple stats (count, max, min, avg, stdev, median)
are available by tapping [Inputs] →
(Variables) → {the variable name}.
Maximum, minimum and median values are highlighted in
the standard output when more than two values are computed.
(When there are an even number of results, the median value is
computed.)
If the Show Stats option is
enabled, a small table of statistics is displayed below the computed
results. Here is a sample: Note that the (Min,Max,Mdn)
values are displayed independent of the status of the Show Stats
option.
CrunchJr provides a mechanism to create user-defined
functions, and use them in subsequent computations during the same
and future sessions. Each must have 1-3 arguments and
return a single value. Each argument must be used at least
once. User-defined function names follow the same rules
as variable names, and may not take on the name of an
existing CrunchJr function or constant.
A user-defined function
can be used just like any other function (e.g., it may have
constants, variables, and other single-valued functions as arguments;
it may be used in expressions and equations and as the arguments to
other functions), except that user-defined functions may not nest.
That is, a user-defined function may not be used
as an argument to a user-defined function.
To create a user-defined function:
[Inputs] → {User-Defined
Functions}→(Edit) →
{Add Function}, then enter the
New Function Prototype – e.g., cos2(a,b) – followed
by the New Function Definition –
pi*(a*cos(2*a+b) - b*cos(a-2*b))
The function definition must use each of the dummy
arguments at least once (no other variables are allowed), and may
also use numbers, CrunchJr constants, functions, and any
of the available mathematical operations (e.g., +,
–, *, etc). As with any other entry in the
[Expression] box, whitespace is ignored
and entries are case-insensitive.
Note that user functions are stored as complete parse-trees (not
symbolically). This means that it is not necessary
to encase the definition in parentheses. That is,
given a user function abc(x,y) → x - y
,
the expression r * abc(x,y) will always be evaluated
as r*(x-y), not as (r*x) - y.
A review of the current user functions and some information about each
is available in
the Store, or by
simply tapping its prototype in the User-Defined Functions screen.
User functions can not be overwritten nor deleted.
Here is some sample output from an equation which uses
both user functions mentioned above. Note that in this sample,
three of the four user function dummy arguments are populated by
constants and one is a variable (p). In fact, any dummy
argument in a user function may be replaced with a constant,
a simple variable, or an expression.
zippo = abc(6.733, pi)*cos2(p, 1.53)
One variable p with
values of "Loop 1.103, 1.83, 0.084" was used. Note that when
user-defined functions are employed in an expression, they are
always listed in green.
CrunchJr provides two functions to perform approximate integrations
{Integrate() and Quadrature()}. They use the
same numerical approximations to integrations, and produce the
same results. The only difference is that Quadrature()
always shows the convergence to the approximate solution, while
Integrate only displays convergence data when convergence has
not been achieved. Quadrature() is recommended.
Here is the definition:
Integrate( a, b, expr ): a∫b{expr(x)} dx. Approximate result of integrating the expression (expr) from a to b. a and b are the lower and upper bounds of the (dummy) variable in expr, and must be constants with (a ≠ b). The expression expr must have exactly one variable, must be single-valued, and may be a single user-defined function or an expression with no user-defined functions. The expression expr must be continuous over the specified range, and may include any single-valued function except Rand() and IRand(). Unpredictable results may occur when expr is not continuous or is otherwise ill-behaved.
Here are a sample of each:
CrunchJr checks input expressions for validity, and puts
out a message when it detects an anomaly (e.g., a non-standard
character, a parsing problem, mismatched parentheses, unrecognized
function names, et cetera). Here are some samples:
input error -- "sqrtt" at character
6 is not a recognized Function
1 Diagnostic: see input
equation below
bb =
sqrtt(time+0.2*penalty);
.....^
Note that if the toggle Input Info Panel
is ON (which it is by default), this error will be shown while
you are entering the line into the [Expression]
box.
When a run-time computational error is encountered,
CrunchJr highlights
the error and attempts to complete the other data sets.
No statistics are compiled when an error is encountered,
and data is not transferred into
the Store.
Here is a sample.
seabiscuit = sqrt(x-y)/(y-x)
Setting x = 3, 5, 9 and y = 1, 2, 5, 8 generates
these results:
seabiscuit
x
y
------------
---
---
1)
-0.7071068
3
1
2)
-1
3
2
NSqr
3)
???
3
5
NSqr
4)
???
3
8
5)
-0.5
5
1
6)
-0.5773503
5
2
ZDiv
7)
???
5
5
NSqr
8)
???
5
8
9)
-0.3535534
9
1
10)
-0.3779645
9
2
11)
-0.5
9
5
12)
-1
9
8
4 run-time errors:
1: ZDiv - Division by zero 3: NSqr - Square Root of a negative number
CrunchJr provides a variety of special purpose functions which
perform very specific computations (e.g., exploring Mortgage payoff
strategies, computing calories burned during a workout, computing
Body Mass Index (BMI), finding the day of the week of any date, finding
your target workout heartrate, integrating, exercising Ohm's Law,
counting the number of 1-bits in a word, solving quadratic,
cubic, and quartic equations, ...).
There are 130 Special Functions. Tap [Info]
→ (Details) → {Special Functions} for details.
When entering an equation or expression, CrunchJr allows
the user to try various expansion candidates, and thus save some
typing. At any time, the user can tap the
→ key, which will expand the rightmost token in the
expression box, and show other candidates (if any) in the panel right
below the expression box. The token must start with a letter
and be at least two characters. The expansion candidates are
selected from a list of all the CrunchJr Functions and
Constants. If there are no valid candidates, tapping the → key will do nothing. To accept a
particular expansion candidate, just continue typing. If the
current expansion candidate is not what you want, consecutive → key taps will cyle through all the
candidates. The last tap before restarting through the cycle
again will be the original text (i.e., as if you hadn't hit the → key).
For example, there are
12 functions which start with "pay" – by entering pay and
tapping the → key three times, you
will have "payoffbiweekly(" in the expression box. If you
now tap a key (building the first argument to PayoffBiweekly()), the
panel below the expression box will display the prototype (argument
list) for the function.