Formula Examples

Please keep in mind that all the principles presented below for coding formulas also apply to any numerical expressions.

Example 1

Let us start with the complex expression you have already coded in the last example of the Tutorial:

F =

2*10(u + v − 2*x) + 10(u − x)

—————————————————————

10(u + v − 2*x) + 10(u − x) + 1

Hopefully, you managed to program it into the Calculator by following these instructions ("EN" means press of the "Enter" button):

2 EN u EN v + 2 EN x * - 10^x * u EN x - 10^x + u EN v + 2 EN x * - 10^x u EN x - 10^x + 1 + /

But how will you figure out the correct button presses when facing a new formula? In other words, how will you learn to "fly on your own"? Here is one golden piece of advice: facing one complex problem, break it into several simpler ones! The above formula is composed of the following "chunks" easily separated by the "+" and "/" operations:

    • A = 2*10(u + v − 2*x)
    • B = 10(u − x)
    • C = 10(u + v − 2*x)
    • D = 10(u − x)
    • 1

Once you figure out how to code A, B, C, and D, then you will have a much simpler problem to solve:

F =

A + B

————————

C + D + 1

It is easier to analyze it when the above is written in a single line of text:

F = (A + B) / (C + D + 1)

Here are some general principles to observe while programming formulas:

    • Enter variables and numbers from left to right - that part is easy.
    • Enter operations in order of their priority.

What exactly does it mean: "the order of priority"? First, the arithmetic operations follow the well known order of algebraic priorities: "^", "*", "/", "+", "-", meaning that, e.g., multiplication is executed before addition. The exponent expression in the element A may be used as a good example: "u + v - 2*x". Let's try entering it as a simple exercise. First goes the variable "u", followed by the "Enter" button, then "v" followed by the "+" operation:

u EN v +

So far so good, we get the "u + v" expression. What about the "- 2*x" part? How about this:

2 - x *

Nope, you get "(u + v - 2)*x". Why? This is because multiplication has a higher priority than either addition or subtraction - the entire left side will look like an operand to the "*" operation and will be wrapped in parenthesis. Hence, the "*" must be entered before the "-". So back off by hitting the "Undo" button four times until you will see just the original "u + v" expression. The "2" should still remain on the main display - this time hit the "Enter" button instead of "-". You should see the following: "u + v, 2". The comma character separating "u + v" and "2" really means "I will put an operation here at a later time". This is exactly what you want: hold the place for "-" until its ready to be entered! Isn't that cool? Now, follow up with "x * -". You will notice that the "-" operation "jumps" in the place of comma - exactly as intended. You have entered operations in order of their priority. The complete sequence for entering "u + v - 2*x" is therefore:

u EN v + 2 EN x * -

Going one step further, press the "10^x" button and the entire expression will become an exponent of the "10^" function, wrapped in parentheses: "10^(u + v - 2*x)". This just one small step away from the "A" piece defined above! What's missing is the "2*" multiplying the whole function in front. Press he "C" key to clear the top display and start anew:

2 EN

Hmmm, what should come next? "10^x"? Nope, this will produce "10^2" - not what you want. Simply, enter the next variable, "u", followed by "Enter":

2 EN u EN

Again, your good friend comma is separating "2" and "u" - yes, you will enter "*" in its place in an appropriate moment. Now, finish the construction of the "10^(u + v - 2*x)" expression as you did before:

v + 2 EN x * - 10^x

Did you notice something interesting? The last key press, the "10^x", wrapped only the part to the right of the comma, leaving the leftmost "2," intact! In general, commas may separate several independent "chunks" of your formula. Here are two more principles worthy of remembering:

    • Functions wrap the rightmost "chunk".
    • Operations replace the rightmost comma.

Time to finish entering A by entering the last multiplication:

*

At this moment you should see "2*10^(u + v - 2*x)" on the top display. If not, hit the "C" to clear everything and try again:

2 EN u EN v + 2 EN x * - 10^x *

The next piece, B, should now be easy:

u EN x - 10^x

You should see A and B separated by a comma - join these two pieces with a "+" operation:

+

and the display should now show "2*10^(u + v - 2*x) + 10^(u - x)". Pretty neat, eh? To enter the remaining pieces C, D, and 1, start with the first element of C, which is the variable "u":

u EN

Again, the comma should separate it from A + B. The rest of the sequence should now be obvious to you:

v + 2 EN x * - 10^x u EN x - 10^x + 1 +

These key presses should now produce the numerator and denominator of your formula separated by a comma: "2*10^(u + v - 2*x) + 10^(u - x), 10^(u + v - 2*x) + 10^(u - x) + 1". You are almost there! Finish it with the division operator and smile:

/

Example 2

A few days ago, in my professional work I came across a nice article filled with great, complicated formulas to further practice the Reverse Polish Notation on. OK, for the curious ones, here is the reference: [Golicnik M. "Explicit reformulations of time-dependent solution for a Michaelis-Menten enzyme reaction model." Analytical Biochemistry, 406 (2010) 94-96.] It mentions, among other things, approximate formulas to a very useful Lambert function. Winitzki approximation is the simplest one:

Let's program it in. What should you enter first? Stick to the principles outlined in Example 1 and programming this formula will come easy. Break the formula into manageable pieces and remember that:

    • Enter variables and numbers from left to right.
    • Functions wrap the rightmost "chunk".

Well, the first elements of the first piece are "1 + x"...

1 EN x +

and these compose an argument of the ln() function. (Press the "2nd" button to access it.)

ln

The result should be simply "ln(1 + x)". That's the first "chunk". The next one is simply a "1" from inside the curly brackets:

1 EN

This will lead to "ln(1 + x), 1". Time recall the next principle:

    • Enter operations in order of their priority.

Since division has higher priority than subtraction, you should leave the "1" alone and start entering next "chunks":

1 EN 1 EN x + ln + ln

and:

2 EN 1 EN x + ln +

Now you should have the following "chunks": "ln(1 + x), 1, ln(1 + ln(1 + x)), 2 + ln(1 + x)". The last step is to join these pieces together with appropriate operations while remembering that:

    • Operations replace the rightmost comma.

/ - *

Voila! This should complete your formula: "ln(1 + x)*(1 - ln(1 + ln(1 + x))/(2 + ln(1 + x)))". Curious how it's plot would look like? ;) Just remember that this approximation is valid only for x>0.

Example 3

Equation (4) in the mentioned article is quite nifty:

Here, it is expressed in terms of Calculator variables "u", "v", "w", and "x":

(1+(v/u)*(v/u+2))((1+v/u)/(2+v/u))*e−u*x/w

u*—————————————————————————————

(1+(v/u)*(v/u+2)*e−u*x/w)((1+v/u)/(2+v/u))

First, try entering it yourself. With minimum words, here are the steps to program it:

u EN 1 EN v EN u / v EN u / 2 + * +

This makes first two "chunks": "u, 1+(v/u)*(v/u+2)". Next:

1 EN v EN u / + 2 EN v EN u / + *

Result= "u, 1+(v/u)*(v/u+2), (1+v/u)*(2+v/u)". Next, add power operation:

^

leading to "u, (1+(v/u)*(v/u+2))^((1+v/u)*(2+v/u))". Next:

u EN +/- x * w / e^x *

Result= "u, (1+(v/u)*(v/u+2))^((1+v/u)*(2+v/u))*e^((-u)*x/w)". Next:

1 EN v EN u / v EN u / 2 + * u EN +/- x * w / e^x * +

Result= "u, (1+(v/u)*(v/u+2))^((1+v/u)*(2+v/u))*e^((-u)*x/w), 1+(v/u)*(v/u+2)*e^((-u)*x/w)". Next:

1 EN v EN u / + 2 EN v EN u / + * ^

Getting closer: "u, (1+(v/u)*(v/u+2))^((1+v/u)*(2+v/u))*e^((-u)*x/w), (1+(v/u)*(v/u+2)*e^((-u)*x/w))^((1+v/u)*(2+v/u))". Add finishing touches:

/ *

and the final result should be: "u*((1+(v/u)*(v/u+2))^((1+v/u)*(2+v/u))*e^((-u)*x/w))/((1+(v/u)*(v/u+2)*e^((-u)*x/w))^((1+v/u)*(2+v/u)))". Make sure there are no commas left :) (top display is scrollable).

Nothing can stop you now...

Example 4

Have you heard about continued fractions? They have a remarkable approximation properties with just a few elements. For example, a very good approximation of the number π consists of just 6 integers, organized into this continued fraction:

3 + 1/(7 + 1/(15 + 1/(1 + 1/(292 +1/2))))

Let's program this expression into the Calculator - it is remarkably simple:

3 EN 1 EN 7 EN 1 EN 15 EN 1 EN 1 EN 1 EN 292 EN 1 EN 2 / + / + / + / + / +

And the result is 3.14159265346744. Hmmm... Are you wondering how accurate it is? Let's add another operation:

π -

This subtracts Calculator's representation of π from its approximation. Look at the result: isn't it remarkable? Try other fractional expressions mentioned in the Wikipedia page.