Tuesday, October 11, 2011

RPL Programming Tutorial - Part 6 - HP 49g+/50g: Algebra & Calculus

Algebra & Calculus

Welcome to Part 6. Today we are going to take a break from programming and learn more about some of the cool stuff we can do with algebraic objects. Part 5 gave an introduction to algebraic objects.

Recall that algebraic objects are functions or expressions that are enclosed in single quotes. Examples include:

'A=B+C'
'√5'
'SIN(X+π/2)'

Expressions can usually be entered in one of three ways:

1. As a string of RPN commands
2. As an algebraic expression entered between single quotes
3. From the Equation Writer ([RS] [ ' ] (EQW))

When programming, generally only the first two methods are available.

Set Up: ** HP 49g+ and 50g **

For Part 6, we will use X as the CAS variable. You can tell if it is by the 'X' indicator at the top of the screen. If it doesn't (i.e. it reads 'T' or 'N', or something else), follow the procedure below.

To set X as the CAS variable:
1. Press [MODE].
2. Press [F3] (CAS).
3. Type [ ' ] [big X] at the Indep Var prompt. Press [F6] (OK) twice.

To clear X:
1. Type [ ' ] [big X] [ENTER].
2. Press [TOOLS] [F5] (PURGE).

Now we're ready to go!

The important EVAL

The [EVAL] key simplifies expressions. Use this key to force the calculator to simplify the expressions (and make them look nice).

Comma

Sometimes commands have more than one argument. If you are entering commands with multiple required arguments, use a comma. The keystroke for a comma is [RS] [SPC] ( , ).

Note: [big X] is located on the 5th rows of keys up from the bottom. I will use this to distinguish the X character from the times key [ x ].

Some Common Algebra CAS Commands

EXPAND: Rewrites algebraic expressions by distributing powers over sums and multiplication over addition and subtraction.

Keystrokes: [SYMB] [F1] (ALG) [F1] (EXPAN)

Example: Expand (x + 2)^5.

By RPN Entry: [big X] [ENTER] 2 [ + ] 5 [y^x] [SYMB] [F1] (ALG) [F1] (EXPAN) [EVAL]

By Algebraic Object: [ ' ] [LS] [ - ] (parenthesis) [big X] [ + ] 2 [ &rarr ] [y^x] 5 [ENTER] [SYMB] [F1] (ALG) [F1] (EXPAN) [EVAL]

Result: x^5 + 10x^4 + 40x^3 + 80x^2 + 80x + 32
(Use [HIST] [F2] (VIEW) or [ &uarr ] [F2] (VIEW) to see the entire result as needed.)

FACTOR: Attempts to factor the expression.

Keystrokes: [SYMB] [F1] (ALG) [F2] (FACTO)

Example: Factor x^2 + 5x + 6.

By RPN Entry: [big X] [ENTER] [ENTER] [LS] [ √ ] (x^2) [LS] [ &rarr ] (SWAP) 5 [ x ] [ + ] 6 [ + ] [EVAL] [SYMB] [F1] (ALG) [F2] (FACTO)

By Algebraic Object: [ ' ] [big X] [y^x] 2 [ + ] 5 [ x ] [big X] [ + ] 6 [ENTER] [SYMB] [F1] (ALG) [F2] (FACTO)

Result: (x + 2)(x + 3)

SUBST: Substitutes an expression for a given variable.

Stack Setup:
Level 2: expression
Level 1: 'variable = value'

Keystrokes: [SYMB] [F1] (ALG) [F5] (SUBST)

Example: Given the function f(x) = x^2 + e^-x, find a numerical approximation of f(1). Remember, you find numeric approximations by the [RS] [ENTER] (&rarr NUM) sequence.

By RPN Entry: [big X] [LS] [ √ ] (x^2) [big X] [+/-] [LS] [y^x] (e^x) [ + ] [big X] [ENTER] 1 [RS] [+/-] (=) [SYMB] [F1] (ALG) [F5] (SUBST) [RS] [ENTER] (&rarr NUM)

By Algebriac Object: [ ' ] [big X] [y^x] 2 [ + ] [LS] [y^x] (e^x) [+/-] [big X] [ENTER]
[ ' ] [big X] [RS] [+/-] (=) 1 [ENTER] [SYMB] [F1] (ALG) [F5] (SUBST) [RS] [ENTER] (&rarr NUM)


Result: 1.36787944117

PROPFRAC: Gives the proper fraction of a rational expression p(x)/q(x). p(x) and q(x) are not necessarily polynomials.

Keystrokes: [SYMB] [F2] (ARITH) [F5] (PROPF)

Example: Find the proper fraction of (x^3 + 2x + 1)/(x - 5).

By RPN Entry: [big X] [ENTER] 3 [y^x] 2 [ENTER] [big X] [ x ] [ + ] 1 [ + ] * (numerator) [big X] [ENTER] 5 [ - ] * (demoniator) [ ÷ ] [SYMB] [F2] (ARITH) [F5] (PROPF)

By Algebriac Object:
Note: We can divide objects (and use other mathematical operators), so let's enter the numerator and denominator separately. Obviously, you can use parenthesis and enter the entire expression as one.
[ ' ] [big X] [y^x] 3 [ + ] 2 [ x ] [big X] [ + ] 1 [ENTER]
[ ' ] [big X] [ - ] 5 [ENTER]
[ ÷ ] [SYMB] [F2] (ARITH) [F5] (PROPF)


Result: x^2 + 5x + 27 + 136/(x-5)

Some Common Calculus CAS Commands

DERVX: First derivative of any expression where X is the independent variable (assumes you have X set up as the Independent Variable)

Keystrokes: [SYMB] [F3] (CALC) [F2] (DERVX)

Example: Find ∂/∂x sin(x^2 + 1)

By RPN: [big X] [LS] [ √ ] (x^2) 1 [ + ] [SIN] [SYMB] [F3] (CALC) [F2] (DERVX) [EVAL]

By Algebraic Object: [ ' ] [SIN] [big X] [y^x] 2 [ + ] 1 [ENTER] [SYMB] [F3] (CALC) [F2] (DERVX) [EVAL]

Result: 2x cos(x^2 + 1)

: First Derivative to any variable.

Stack Setup:
Level 2: Expression
Level 1: 'Variable'

Keystrokes: [RS] [COS] ( ∂ )

As an algebraic object: ' ∂variable(expression) ' Use [EVAL] to evaluate.

Example: Find ∂/∂T cos(T^2 + π/T)

Get the stack to read:
Level 2: 'COS(T^2+π/T)'
Level 1: 'T'

Press [RS] [COS] (∂) [EVAL]

Result: ((π - 2T^3)*sin((π + T^3)/T)/T^2

Alternatively:
Level 1: '∂T(COS(T^2+π/T))'
[RS] [COS] ( ∂ ) [EVAL]

INTVX: Symbolic indefinite integral of any expression where X is the independent variable (assumes you have X set up as the independent variable)

Keystrokes: [SYMB] [F3] (CALC) [F4] (INTVX)

Example: Find ∫ e^(-5x) dx.

By RPN: 5 [+/-] [ENTER] [big X] [ x ] [LS] [y^x] (e^x) [SYMB] [F3] (CALC) [F4] (INTVX)

By Algebraic Object: [ ' ] [LS] [y^x] (e^x) [+/-] 5 [ x ] [big X] [ENTER] [SYMB] [F3] (CALC) [F4] (INTVX)

Result: e^(-5x)/-5

: Integration using lower and upper limits. Use this when you want to execute definite integrals. You can use any variable of integration with ∫.

Stack Setup:
Level 4: lower limit
Level 3: upper limit
Level 2: integrand
Level 1: variable of integration

Keystrokes: [RS] [TAN] ( ∫ )

As an algebraic object: ' ∫(lower,upper,integrand,variable of integration) ' Use [EVAL] to evaluate.

Example: Find the definite integral of x^2 -2 from 0 to 2.

Get the stack to read:
4: 0
3: 2
2: 'X^2 - 2'
1: 'X'

Press [RS] [TAN] ( ∫ )

Result: -4/3

Alternatively:
1: ' ∫(0,2,X^2-2,X) '
[RS] [TAN] ( ∫ )

Sums and Roots

To alternate between Real and Complex Mode

Press and HOLD [LS], then press [TOOL]. A "R=" indicator states that you are operating in the Real mode. A "C=" indicator states that you are operating in the Complex mode.

You can also press [MODE] [F3] (CAS) and check (or uncheck) Complex and press [F6] (OK) twice.

The imaginary character has the sequence [LS] [TOOL] (i). You must put a multiplication sign between the imaginary part and i. Example: 5*i

ZEROS: Finds the roots of an expression in terms of any variable.

Stack Setup:
Level 2: 'expression (don't put an equals sign in it)'
Level 1: 'variable to solve for'

Here we are assuming that the expression equals 0.

Keystrokes: [SYMB] [F5] (SOLVE) [F6] (ZEROS)

Example: Find the roots of x^4 - 1.

Get the stack to read this:
Level 2: 'X^4-1'
Level 1: 'X'
Press [SYMB] [F5] (SOLVE) [F6] (ZEROS)

Result:
{-1, 1} in Real Mode
{i, -1, -i, 1} in Complex Mode

Possible set of keystrokes (by Algebraic Object): [ ' ] [big X] [y^x] 4 [ - ] 1 [ENTER] [ ' ] [big X] [ENTER] [SYMB] [F5] (SOLVE) [F6] (ZEROS)

SOLVEVX: Solves for X in any equation.

Keystrokes: [SYMB] [F5] (SOLVE) [F4] (1st SOLVE)

Example: Find the solution to 2√x + 3 = 5.

Possible set of keystrokes (by Algebraic Object): [ ' ] 2 [ x ] [ √ ] [big X] [ + ] 3 [RS] [+/-] (=) 5 [ENTER] [SYMB] [F5] (SOLVE) [F4] (1st SOLVE)

Result: 1

CAUTION: Not all equations can be solved this way.

SOLVE: Solves an equation for any variable.

Stack setup:
Level 2: equation
Level 1: 'variable'

Keystrokes: [SYMB] [F5] (SOLVE) [F5] (2nd SOLVE)

Try the above example using SOLVE.

: The Summation function. You can calculate finite sums and convergent infinite sums.

Stack Setup:
Level 1: variable (summation index, I recommend X)
Level 2: initial value
Level 3: final value
Level 4: summand, expression

Keystrokes: [RS] [SIN] ( ∑ )

To type infinity: [LS] 0 ( ∞ )

Alternatively: ' ∑(index=initial value,final value,expression) ' [EVAL] (or [RS] [ENTER] for a numerical approximation)

Example: Find the sum of the numbers from 1 to 25.

Get the stack to read this:
Level 1: 'X'
Level 2: 1
Level 3: 25
Level 4: 'X'
Press [RS] [SIN] ( ∑ )

Alternatively:
Level 1: ' ∑(X=1, 25, X)'
Press [RS] [SIN] ( ∑ )

Result: 325

This wraps up Part 6. We get back to programming in Part 7, where we invoke the solver. Thanks for reading, Eddie.


This tutorial is property of Edward Shore. Mass reproduction and distribution requires express permission of the author.

1 comment:


  1. Really its very useful information that you have shared and thanks for sharing the information with us.


    123.hp.com/setup 4530

    ReplyDelete

HP Prime and TI-84 Plus CE: Shallow Wave Analysis

HP Prime and TI-84 Plus CE:  Shallow Wave Analysis Introduction The program H2OWAVES calculates wave speed, impedance, and w...