HP 39gii Programming Tutorial - Part 8: Functions as Arguments

Apologies for the delay.

In part 8, I will show you several was you can use functions as arguments in programs. First, some pointers to help make the programming experience less daunting:

1. The HP 39gii is not a CAS machine. Everything must be evaluated to a number.

2. Functions are entered either as strings (expressions surrounded by quotation marks) or by the use of the QUOTE command. The QUOTE command can be found by pressing [Math], [ 1 ], [ 2 ]. It may help to store the required equation/function in E#/F# first before running the program, which is the case with PARTDER.

3. When using HP mathematical commands, you may have to store pass-through variables into global variables first. I am not sure why this is true for some commands but not for others.

4. The use of expressions and functions don't always work in programming. Use caution. I have particular trouble with SOLVE and FNROOT in this situation.

--------

Note: Recall there are two ways to store objects, one the store arrow ( →) and the assign operator ( := ). I usually code the latter, but for most applications, either way is acceptable. I use both methods in today's programming examples. And yes, we can use both methods in one program.

Hint: I often test commands and their usage at the Home screen to get a better understanding on how mathematical commands work. I also note their syntax by both using the command and accessing the help menu ([SHIFT] [Views]).

------

The Program PARTDER

PARTDER takes the partial derivatives of the function f(X,Y) at the point (x, y) and returns a list of the values {df/dx, df/dy}.

PARTDER takes two pass-through arguments:

x = value of x

y = value of y

Define f(X,Y) as a string into E0 outside the program.

EXPORT PARTDER(a,b)

BEGIN

a → A; b →Y; ∂(E0, X=A) → C;

b → B; a → X; ∂(E0, Y=B) → D;

RETURN {C, D};

END;

Examples:

"SIN(X*Y)+Y^2"→E0

PARTDER(π, 1) returns { -1, -1.14159265359 }

QUOTE(X^(2*Y+1))→E0

PARTDER(4,1) returns {48, 177.445678223}

Eddie

This blog is property of Edward Shore. 2013

A blog is that is all about mathematics and calculators, two of my passions in life.

## Tuesday, April 23, 2013

### HP 39gii Programming Tutorial - Part 8: Functions in Programs

### Numworks: Allowing Repeated Calculations in Python

Numworks: Allowing Repeated Calculations in Python Introduction Say we want the user to repeat a calculation or a routine for as lo...