Saturday, February 23, 2013

Greetings From Riverside! Mike Grigsby's Blog and an TI nSpire App Review

I am blogging today from Daily Brew Coffee House in Riverside, CA. Service here is excellent - very nice and friendly people.



Mike Grigsby

If you get a chance, please check out Mike Grigsby's blog at http://mikebibbygrigsby83.blogspot.com/?m=1. Mike has a Master's Degree in Mathematics from Cal Poly Pomona, and is the Social Media Administrator for the Riverside Astronomical Society. Later tonight I am going to meet with Mike to go their monthly meeting at La Sierra University in Riverside.

More information about the Society can be found here: http://www.rivastro.org/index.php.

Mike is a super duper awesome guy. Please check his blog out.


Quick Review: Texas Instruments TI-nSpire App for iPad

Platforms: iPad (iPad 2 and later, including the iPad Mini)
Cost: $29.99 (yes, this is very expensive for an app). There is a CAS and non-CAS version. I totally recommend that you get the CAS version. (CAS is the Computer Algebraic Version)
Version of nSpire: TI nSpire CX (the latest and the good one in my opinion)

Short and sweet, the nSpire app is everything the TI nSpire hardware is. Unlike most calculators, the nSpire operates as a computer software interface (think closer to Mathematica, Matlab, or Maple) than the traditional calculator. You work on documents which contains pages. Each page can be a mathematics page, graph page, a spreadsheet, geometry page, or a statistics page. Within the problems in the document, variables are linked. That is, you can create a variable in one page, and it is define throughout the documents. Programs work the same way.

Programs are in TI-Basic and can either be limited to the document or made global. The global feature is very useful when you are creating custom functions (like the gamma function). Programming on the nSpire is more strictly for the mathematical sense; so if you are looking to make video games, this app may not be what you are looking for.

The keyboard on the app is a pleasure to use. On the keyboard, you will note several keys having a blue bar over them. Holding the key down gives you additional options. For example:
Holding the r key gives you access to the θ variable.
The var key contains the STO> function.
The sin key expands to sin^-1, csc, and csc^-1.

The best part of the keyboard? The keys are big! Well, we are on an iPad here.

On the graph page, not only can you graph functions, polar functions, scatter plots, parametric functions, and inequalities, you can do it all one page if you want. This adds flexibility that is usually seen only on the Casio graphing calculators and somewhat on the HP 49g series. The graph page offers a geometric view or a 3D view for three-dimensional graphs. Pinch to zoom, hold on to drag the graph and any other text.

Here are the screenshots from the app. All the shots are from the CAS version.

I recommend getting this app. Now I realize that the $29.99 price tag is heavy in the market on apps, but this app has it all together in one package. However, in the market of complete mathematical software packages it is inexpensive. If you buy it, I recommend the CAS version.

This is also a great alternative to getting the hardware if you don't want and/or have $150 to spend but have an iPad ready. And the batteries last longer! At least with the app I don't have to constantly plug in my tangible nSpire CX almost every time I want to use it. And yes documents can be shared by email or downloaded to the computer for later use (including downloading it on the physical units).




That is all for today, please go check out Mike Grigsby's blog. I can't wait to meet with him tonight. Have a great day and weekend everyone.

Eddie


This blog is property of Edward Shore. 2013

Wednesday, February 20, 2013

TI-84+: Binary-Decimal Conversions

One of the missing features of the TI-82/83/84 family is the ability to convert between bases. Here are two programs in TI-Basic to help fill at least some of the gap.

It is very basic conversion, working only with positive integers up to 65,535 (16 ones as its binary representation).

Variables used:
N = number in decimal form
L1 = list representing the binary representation (1s and 0s)

The programs display the binary numbers as a solid number, rather by a list. This is accomplished by a For loop involving the Output command.

Access L1 by pressing [2nd], [ 1 ].

Examples: Decimal ← → Binary
27 ← → {0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1}
428 ← → {0,0,0,0,0,0,0,1,1,0,1,0,1,1,0,0}
3,245 ← → {0,0,0,0,1,1,0,0,1,0,1,0,1,1,0,1}

DEC2BIN
Decimal to Binary (N → L1)
This program works with any positive integer from 0 to 65,535 - 16 bits. No negative numbers. Note: ending quotes and parenthesis are left out to conserve space.
2/20/2013. 170 bytes.  (updated 7/5/2016)

: Input "N:",N
: If N<0 

: Then
: Pause "INVALID
: Stop
: End
: int(N→N
: N→D
: DelVar L1
: 16→dim(L1
: For(K,0,15
: If 2^(15-K)≤D
: Then
: 1→L1(K+1
: D-2^(15-K→D
: End
: End
: ClrHome
: Output(1,1,N
: Output(1,6,">BIN
: For(K,1,16
: Output(3,K,L1(K
: End
: Pause
: ClrHome


BIN2DEC
Binary to Decimal (L1 → N). Enter a list up to 16 zeroes and ones.
This program works with any positive integer from 0 to 65,535 - 16 bits. No negative numbers. Note: ending quotes and parenthesis are left out to conserve space.
2/20/2013. 160 bytes.


: Input "L1 UP TO 16 BITS:",L1
: If dim(L1)>16
: Then
: Pause "INVALID
: Stop
: End
: While dim(L1) < 16

: augment({0},L1→L1
: End
: 0→N
: For(K,0,15
: N+2^K*L1(16-K→N
: End
: ClrHome
: For(K,1,16
: Output(1,K,L1(K
: End
: Output(3,1,">DEC
: Output(3,6,N
: Pause
: ClrHome


** Edited 12/5/2013.  This is due to an error Stephanie Ison pointed out to me.  Many thanks! - Eddie 

Enjoy!

Eddie


This blog is property of Edward Shore. 2013




Saturday, February 16, 2013

Review: Programming the TI-83 Plus/TI-84 Plus by Christopher R. Mitchell

Continuing the Saturday night tour, I stopped by at another coffee place, the Swörk Urban Coffee Bar in Eagle Rock (Los Angeles).

Review: Programming the TI-83 Plus/TI-84 Plus - Christopher R. Mitchell

Author: Christopher R. Mitchell, his website is http://www.cemetech.net/.

To make this short and sweet, this book is an excellent reference book, for all levels. I have 22 years of calculator programming experience - starting from the TI-81 in 1991. However I am learning new tricks and techniques from this book.

The book aims towards the TI-83/TI-84 family and how to maximize programming efficiency. I focused on the later chapters of the book, where topics cover the GETKEY command, using the home and graph screen to efficiently display text and figures, and how to make programs interactive. There is also a chapter on how to optimize programs, such as taking advantage of implicit conditionals and use of the last answer (Ans) function. So far, the GETKEY is my favorite thing I am learning.

The list price is $29.99, which includes the book and electronic copies of the book (I have yet to download the electronic copy.) If you want to expand your programming skills, or develop them from the beginning - Go for it, I definitely recommend this book. Mitchell writes the book in a straight-forward manner.

P.S. I got to the mouse to eat 142 pieces of cheese. (See chapter 6 to see what I am taking about, readers).

Eddie




This blog is property of Edward Shore. 2013



a_(n+1) = a_n + n + C (from Stories Cafè in Echo Park in Los Angeles)

Good afternoon all! This is a Saturday Afternoon/Night blog post. On the menu: much needed delicious food from Stories Cafè in Los Angeles and some work with recurrence relations.

But first, an announcement! I am working on a short series of programming tutorials of the Hewlett Packard HP 39gii Calculator. Think of it as a short boot camp to get HP 39gii owners up and running.

An emulator for the HP 39gii can be found here: http://www.hp.com/sbso/product/calculators-emulators/graphic-calculator-emulators.html. The emulators are for Widows and probably Mac - not sure if they run on other operating systems. As of today, I am not aware if there are any iOS and/or Android apps for this. I aim to post this series in March 2013.

Now on to the math...

a_(n+1) = a_n + n + C

The goal is to find a general formula for

(I) a_(n+1) = a_n + n + C with the initial condition a_0 = A_0.

The type of recursion formula presented is polynomial recurring relation. A general polynomial recursion formula takes the form a_(n+1) = a_n + p(n).

The general formula for a_(n+1) = a_n + n + C takes the form:

(II) a_n = c_2 * n^2 + c_1 * n + c_0

Mainly, with recursion formula of polynomial type will require a formula of order n+1. There are n+2 constants to solve for.

Working with equation (II) above, we will need to solve for c_0, c_1, and c_2. It would be very difficult to work with only one equation. Luckily, we can turn this problem in to a system of three linear equations.

Starting with the initial condition a_0 = A_1, we can use the recursion formula for n=1 and n=2 to find a_1 and a_2. Then we get the system:

(III)
a_0 = c_0 (where n=0)
a_1 = c_0 + c_1 + c_2 (where n=1)
a_2 = c_0 + 2 * c_1 + 4 * c_2 (where n=2)

Putting (III) in matrix form we get:

(IV)
[ [1, 0, 0], [1, 1, 1], [1, 2, 4] ] * [ [c_0], [c_1], [c_2] ] = [ [a_0], [a_1], [a_2] ]

For the Hewlett Packard HP 50g calculator owners (others may have this function/program), you can get the matrix on the left hand side of equation (IV) by using the VANDERMONDE matrix function on the vector [0, 1, 2]. This function comes in handy for these types of problems.

Continuing with the ever handy HP 50g, solving for c_0, c_1, and c_2:

(V)
[ [c_0],[c_1],[c_2] ] = [ [1, 0, 0],[-3/2, 1, -1/2],[1/2, -1, 1/2] ] * [ [a_0], [a_1], [a_2] ]

And we finish with:
(VI)
c_0 = a_0
c_1 = -3/2 * a_0 + 2 * a_1 - 1/2 * a_2
c_2 = 1/2 * a_0 - a_1 + 1/2 * a_2


So in summary:
The general formula for the recursion formula

a_(n+1) = a_n + n + C is:

c_0 = a_0
c_1 = -3/2 * a_0 + 2 * a_1 - 1/2 * a_2
c_2 = 1/2 * a_0 - a_1 + 1/2 * a_2



A numerical example:

a_(n+1) = a_n + n - 2 with a_0=3

Prepare by finding a_0, a_1, and a_2:

a_0 = 3 (given)
a_1 = 3 + 1 - 2 = 2 (use n=1)
a_2 = 2 + 2 - 2 = 2 (use n=2)

Then:
c_0 = 3
c_1 = -3/2 * 2 + 2 * 2 - 1/2 * 2 = -3/2
c_2 = 1/2 * 2 - 2 + 1/2 * 2 = 1/2

Our general formula is:
a_n = 1/2 * n^2 - 3/2 * n + 3

Let's test it out.

With n=1:
a_1 = 1/2 - 3/2 + 3 = 2 (checks out)

With n=3
a_3 = 1/2 * 3^2 - 3/2 * 3 + 3 = 3

Observe from the recursion formula a_3 = 2 + 3 - 2 = 3. (Checks out)

With n=4
a_4 = 1/2 * 4^2 - 3/2 * 4 + 3 = 5


Warning: The above technique only works when the coefficient of a_n is 1. (See (I).)

I tried this technique with a_(n+1) = -3*a_n + 7*n - 1 with a_0 =1.

With a_1 = 5 and a_2 = 0 from the recursion formula, I came up with a_n = -9/2 * n^2 + 17/2 * n + 1. Using this formula I came up with a_3 = -14, when in reality a_3 = 22. Just a heads up.


I hope this weekend and all your future days are good to you.

Eddie


This blog is property of Edward Shore. 2013

Saturday, February 9, 2013

a_(n+1) = S * a_n + T

Hi everyone!


First a correction. In my Numerical CAS section, posted December 2012, I typed an extra quotation mark in the POLYBINE program for the Casio Prizm - that has been corrected. Much thanks to Ryan Maziarz who pointed that out to me.

Here is a link to the corrected post:
http://edspi31415.blogspot.com/2012/12/numeric-cas-part-2-binomial-expansion.html?m=1


Today we are finding the general formula for this recursion formula:

a_(n+1) = S * a_n + T

with the initial condition a_0 = A.

I could try using a characteristic polynomial, but with some observation we may be able to detected a pattern which leads us to a general formula.

Observe that:

a_0 = A

a_1 = S * a_0 + T
a_1 = S * A + T

a_2 = S * a_1 + T
a_2 = S * (S * A + T) + T
a_2 = S^2 * A + S * T + T
a_2 = S^2 * A + T * (S + 1)

a_3 = S * a_2 + T
a_3 = S * (S^2 * A + T * (S + 1)) + T
a_3 = S * A^3 + T * (S^2 + S + 1)

a_4 = S * a_3 + T
a_4 = S^4 * A + T * (S^3 + S^2 + S + 1)

From the pattern, observe that:

a_n = S^n * A + T * Σ(S^k, k=0, n-1)

With Σ(t^k, k=0, n-1) = (t^n - 1)/(t - 1) :

a_n = S^n * A + T * (S^n - S)/(S - 1)


An Example:

S = 3, T = 1, A = -2

Using the HP 39gii to generate the sequence (the 39gii uses a_1 as its initial term):


The general formula is:

a_n = (3^n) * (-2) + 1 * (3^n - 1)/(3 - 1)
a_n = (-2) * 3^n + (3^n - 1)/2
with a_0 = -2. (The 39gii has u_1 = a_0)

Example:

a_2 = u_3 = (3^2) * (-2) + (9 - 1)/2 = -14


That is all for now, see you next time!

Eddie

This blog is property of Edward Shore. 2013

5 blog entries away from the 200th blog entry.

Greetings From Monrovia! Finding a Formula to Generate the Fibonacci Sequence

Hi everyone. I am blogging from the Friends Café in downtown Monrovia, CA on a beautiful, chilly day.

Today's blog entry is about to the Fibonacci Sequence and how to find a general formula to generate a sequence.

The Fibonacci Sequence

The world famous Fibonacci Sequence, first introduced by Fibonacci's Liber Abaci, written in 1202, is:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 293, 377...

(Source: Pickover, Clifford. "The Math Book" Sterling Publishing, New York. 2009 - Eddie says: Go get this book - it's awesome!)

It is easy to build the sequence. Start with two entries of 1. Add them up to get the next term. Each subsequent term is the sum of the last two. 1+1=2, 1+2=3, 2+3=5, 3+5=8, 5+8=13, and so on.

We can use this recursion formula:

a_(n+2) = a_(n+1) + a_n

with the initial conditions a_0 = 1 and a_1 = 1.

We can generate a general formula for this.


Technique

Start with the recursion formula:

a_(n+2) = a_(n+1) + a_n

with the initial conditions a_0 = 1 and a_1 = 1.

This is a linear recursion formula. A way to find the general formula is to use a characteristic polynomial. The characteristic polynomial is formed by turning subscripts to exponents (and usually replacing a with another letter, such as x) and finding the roots of the polynomial.

The general formula will have the form

a_n = c_1 * (x_1)^n + c_2 * (x_2)^n + ...

Where n is the number of initial conditions.

In the case of the Fibonacci sequence, we have two initial conditions (a_0 = 1 and a_1 = 1). Hence n=2.

Then use the initial conditions to solve for the c_k constants.


Finding the General Formula

a_(n+2) = a_(n+1) + a_n
with the initial conditions a_0 = 1 and a_1 = 1.

The characteristic equation is:

x^(n+2) = x^(n+1) + x^n

Assuming x ≠ 0, divide both sides by x^n:

x^2 = x + 1

x^2 - x - 1 = 0

The roots of the polynomial are:

x_1 = (1 + √5)/2
x_2 = (1 - √5)/2

Then our general form has:

a_n = c_1 * ((1 + √5)/2)^n + c_2 * ((1 - √5)/2)^n

Our next step is to find c_1 and c_2.

Note when n = 0, a_0 = 1 and:

1 = c_1 + c_2

When n = 1, a_1 = 1 and:

1 = c_1 * (1 + √5)/2 + c_2 * (1 - √5)/2

Leaving us with the system of linear equations:

c_1 + c_2 = 1
c_1 * (1 + √5)/2 + c_2 * (1 - √5)/2 = 1

I like using matrices to solve systems of linear equations, you may a different preferred way, it's all good here:

[ [1, 1], [(1 + √5)/2, (1 - √5)/2] ] * [ [c_1], [c_2] ] = [ [ 1 ], [ 1 ] ]

[ [c_1], [c_2] ] = [ [1, 1], [(1 + √5)/2, (1 - √5)/2] ]^-1 * [ [ 1 ], [ 1 ] ]

[ [c_1], [c_2] ] = [ [(5 - √5)/10, √5/5], [(5 + √5)/10, -√5/5] ] * [ [ 1 ], [ 1 ] ]

which evaluates and simplifies to:

c_1 = (5 + √5)/10
c_2 = (5 - √5)/10

The general formula to generate the Fibonacci sequence is:

a_n = (5 + √5)/10 * ((1 + √5)/2)^n + (5 - √5)/10 * ((1 - √5)/2)^n


An approximate formula would be (8 digits):

a_n ≈ 0.72360680 * 1.6180339^n + 0.27639320 * (-0.6180339)^n

Round off when necessary.

Testing the general formula, find the 2nd and 6th term:

a_2 = (5 + √5)/10 * ((1 + √5)/2)^2 + (5 - √5)/10 * ((1 - √5)/2)^2
a_2 = (5 + √5)/5 + (5 - √5)/2
a_2 = 10/2 = 2

a_6 = (5 + √5)/10 * ((1 + √5)/2)^6 + (5 - √5)/10 * ((1 - √5)/2)^6
a_6 = (65 + 29 * √5)/10 + (65 - 29 * √5)/10
a_6 = 130/10 = 13


A Broader Problem

The technique applied can be applied to the general problem:

a_(n+2) = S * a_(n+1) + T * a_n

With initial conditions a_0 = A and a_1 = B.

Using the trusty HP 50g to assist me, I come up with the following:

a_n = c_1 * (x_1)^n + c_2 * (x_2)^n

where

x_1 = (S + √(S^2 + 4 * T))/2

x_2 = (S - √(S^2 + 4 * T))/2

c_1 = (B - A * x_2)/(x_1 - x_2)

c_2 = (A * x_1 - B)/(x_1 - x_2)


Next time, I am going to look at the general recursion formula:

a_(n+1) = S * a_n + T with the initial condition a_0 = A

I am working a basic programming series, which my target is with the HP 39gii calculator and the series would be posted in March 2013.

Thank you everyone who reads, follows, and comments on this blog. As always it is much appreciated.

Have a great day!

Eddie


This blog is property of Edward Shore. 2013

Friday, February 1, 2013

Balances and Recursion Formula - Part 2


To recap our scenario:

We have a loan with an initial balance $b, that has an annual interest rate of r%. We are making a monthly payment of $p every month. In Part 1, we were finding out how long to pay off the balance.

In Part 2, we asking the same question, but with an added component: this time assume that there is a monthly charge of $c to the balance. The charge stops when the balance is paid.


Variables:
b = a_0 = initial balance
p = monthly payment
r = annual rate
c = monthly additional charge
a_n = balance after n payments

Let the recursion formula be:

a_(n+1) = (a_n + c) + (a_n + c) × r/1200 - p
with the initial condition a_0 = b.

Let θ = r/1200, then:
a_(n+1) = (a_n + c) × (1 + θ) - p

Let's get a_1, a_2, and a_3 in terms of a_0.

a_1 = (a_0 + c) × (1 + θ) - p

a_2 = (a_1 + c) × (1 + θ) - p
a_2 = ((a_0 + c) × (1 + θ) - p + c) × (1 + θ) - p
a_2 = (a_0 + c) × (1 + θ)^2 - p × (1 + θ) + c × (1 + θ) - p

a_3 = (a_2 + c) × (1 + θ) - p
a_3 = a_2 × (1 + θ) + c × (1 + θ) - p
a_3 = ((a_0 + c) × (1 + θ)^2 - p × (1 + θ) + c × (1 + θ) - p) × (1 + θ) + c × (1 + θ) - p
a_3 = (a_0 + c) × (1 + θ)^3 - p × (1 + θ)^2 + c × (1 + θ)^2 - p × (1 + θ) + c × (1 + θ) - p

Noticing a pattern...

a_n = (a_0 + c) × (1 + θ)^n - p × Σ((1 + θ)^k, k=0, n-1) + c × Σ((1 + θ)^k, k=1, n-1)
a_n = (a_0 + c) × (1 + θ)^n - p × ((1 + θ)^n - 1)/θ + c × ((1 + θ)^n - (1 + θ))/θ

With a_0 = b:

a_n = (b + c) × (1 + θ)^n - p × ((1 + θ)^n - 1)/θ + c × ((1 + θ)^n - (1 + θ))/θ


Example 1:

Sandra has a credit card with a 15% APR. The initial balance is $1,500.00. Sandra uses a premium credit card that charges $20.00 each month there is a balance.

b = 1500.00
c = 20.00
r = 15%
p = 500.00

Then θ = 15/1200 = 1/80

The resulting sequence is:

a_0 = 1500.00
a_1 = 1039.00
a_2 = 572.23
a_3 = 99.64

In 3 payments , Sandra has knocked the balance to below the payment amount of $1,500.00. In month 4, the amount will be ($99.64 + $20.00) × (1 + 15/1200) = $121.14, and her debt will be over.

Example 2:
Greg has taken a payday loan, for the amount of $1,893.64. The interest rate is 14.99% and the loan incurs a $14.99 holding fee for each month the balance exists. Greg makes a $350.00 payment every month.

b = 1893.64
c = 14.99
r = 15.99%
p = 350.00

Then θ = 15.99/1200

The sequence generated is:

a_0 = 1893.64
a_1 = 1584.06
a_2 = 1270.36
a_3 = 952.48
a_4 = 630.36
a_5 = 303.95

At month 6, the final balance will be ($303.95 + $14.99) × (1 + 14.99/1200) = $322.92.


We can find out when the balance is zero by solving for n.

When a_n = 0:

n = ln((c × (1 + θ)/θ - p/θ) / (b + c - p/θ +c/θ)) × (ln (1 + θ))^(-1)

Then the integer part of n, int(n), is the nth payment when the balance is less than the payment amount.

Recalling our examples:

Example 1:

b = 1500.00
c = 20.00
r = 15%
p = 500.00

Then θ = 15/1200 = 1/80, and n ≈ 3.21

This means the balance is below the payment after then 3rd payment.

Example 2:

b = 1893.64
c = 14.99
r = 15.99%
p = 350.00

Then θ = 15.99/1200 and n ≈ 5.91

The balance becomes below the payment after the 5th payment.


Have a great day everyone!

Eddie

This blog is property of Edward Shore. 2013

Balances and Recursion Formula - Part 1

Greetings everyone coming to you from a Starbucks in Covina, CA! (on my way to seeing my mom and some friends for dinner).

1 month of 2013 is already in the books - hope everyone is getting February off to a great start!

The topic of this and the next post: using a recursion formula in financing.



The scenario: You have a loan that you make monthly payments. Interest accrues each month based on the loan's balance. The rate is stated as an annual rate. How many months will it take to pay off the loan?

For this, we are going to use a recursion formula to describe the balance at the end of each payment. We will then come up with a general formula which will allow us to find the balance at any month. Finally, use the general formula to find when the balance is zero (approximately).

Part 1 will deal with the scenario stated. On my next blog entry, I will consider paying the loan balance when a monthly charge is involved.


What is a recursion formula?

A recursion formula is a formula in which the result is based on previous results. To generate a sequence of answers, one or more initial conditions are required.

A simple example is:

a_(n+1) = 2 × a_n + 1 with the initial condition a_0 = 0.

In order to calculate a_(n+1), you will need the previous result, a_n.

Then: (a_n is in bold)

a_0 = 0 (start with the initial condition)
a_1 = 2 × 0 + 1 = 1
a_2 = 2 × 1 + 1 = 3
a_3 = 2 × 3 + 1 = 7
a_4 = 2 × 7 + 1 = 15
And so on...

Some recursion formulas can be transformed into general formulas, where any nth term can be found when only the initial conditions are known.

A famous recursion formula is the Fibonacci Sequence (1, 1, 2, 3, 5, 8, 13, 21, etc...)

a_(n+2) = a_(n+1) + a_n with the initial conditions a_0 = 1 and a_1 =1.


Back to our scenario: You have a loan that you make monthly payments. Interest accrues each month based on the loan's balance. The rate is stated as an annual rate. How many months will it take to pay off the loan?

Variables:
b = a_0 = initial balance
p = monthly payment
r = annual rate (if the rate is 10%, r = 10)
a_n = balance after n payments (after n months)

Let the recursion formula be:
a_(n+1) = a_n + a_n × r/1200 - p
with the initial condition a_0 = b

Let θ = r/1200. Then:

a_(n+1) = a_n × (1 + θ) - p

Note: we will stop when the balance sinks below the payment amount. At that point, the next payment is the balance, reducing the debt to 0.

Calculating the first few terms (balance after n payments) in terms of the initial balance (a_0):

a_1 = a_0 × (1 + θ) - p

a_2 = a_1 × (1 + θ) - p
a_2 = (a_0 × (1 + θ) - p) - p
a_2 = a_0 × (1 + θ)^2 - p × (1 + θ) - p

a_3 = a_2 × (1 + θ) - p
a_3 = (a_0 × (1 + θ)^2 - p × (1 + θ) - p) × (1 + θ) - p
a_3 = a_0 × (1 + θ)^3 - p × (1 + θ)^2 - p × (1 + θ) - p

Noticing the pattern...

a_n = a_0 × (1 + θ)^n - Σ( p × (1 + θ)^k, k=0, n-1)
a_n = a_0 × (1 + θ)^n - p × Σ( (1 + θ)^k, k=0, n-1)
a_n = a_0 × (1 + θ)^n - p × ((1 + θ)^n - 1)/(1 + θ - 1))

With a_0 = b:

a_n = b × (1 + θ)^n - p × ((1 + θ)^n - 1)/θ


Example 1:

A bank loan is made for $1,000, which has a 10% annual interest rate. The borrower plans to make monthly payments of $300.

r = 10%, b = 1000, p = 300
Then θ = 10/1200 = 1/120

The sequence generated is:

a_0 = 1000.00
a_1 = 708.33
a_2 = 414.23
a_3 = 117.68

Example 2:

The balance on a short term lease is currently $8,764.10. The lessor wants to make payments of $1,500 until the balance is fully paid. The lease carries an interest rate of 4.95%.

r = 4.95%, b = 8764.10, p = 1500.00
Then θ = 4.95/1200 = 33/8800

The sequence generated is:

a_0 = 8764.10
a_1 = 7300.25
a_2 = 5830.37
a_3 = 4354.42
a_4 = 2872.38
a_5 = 1384.27


When will the balance be fully paid?

Solving for n when a_n = 0:

0 = b × (1 + θ)^n - p × ((1 + θ)^n - 1)/θ
0 = (b - p/θ) × (1 + θ)^n + p/θ
-p/θ = (b - p/θ) × (1 + θ)^n
-[ (p/θ) / (b - p/θ) ] = (1 + θ)^n
[ (p/θ) / (p/θ - b) ] = (1 + θ)^n
ln [ (p/θ) / (p/θ - b) ] = n × ln (1 + θ)

n = ln [ (p/θ) / (p/θ - b) ] / ln (1 + θ)

Taking the integer portion of n, or int(n), gives the nth payment when the balance is less than the payment amount.


Continuing with our two examples from before:

Example 1:

r = 10%, b = 1000, p = 300
Then θ = 10/1200 = 1/120

n ≈ 3.3

After 3 payments, the balance is below the payment amount of $1,000.00.

Example 2:

r = 4.95%, b = 8764.10, p = 1500.00
Then θ = 4.95/1200 = 33/8800

n ≈ 5.9

After 5 payments, the balance is below the payment amount of $1,500.00.


Next time will be Part 2. Thanks as always!

Eddie


This blog is property of Edward Shore. 2013



P.S. To all those who are partaking in the Super Bowl festivities this Sunday: please be safe - and don't drink and drive! And have fun.

Saturday, January 26, 2013

Review: MyScript Calculator

MyScript Calculator Review

Available for: iOS, Android
Company: Vision Objects
Cost: Free
Latest Update: 12/19/2012 (iOS), 1/24/2013 (Android)


The program lets you literally write calculations with your finger or stylus. Results are calculated automatically. Up to three decimal places are shown for approximations. Expressions, which include fractions and square roots, are built dynamically. You can even insert characters or draw "scratches" to remove characters.

It has a learning curve, because the app has to recognize what you write. A suggestion is to go slow at first, and let the app recognize each character. Patience is needed. However, I now can fulfill my fantasy to write calculations and have them execute.

Order of operations are similar to graphing calculators. (Negation is low on the order of operations)

I don't think describing what this app does using words, does it justice. I definitely encourage you to download it and try it for yourself.

Both the iOS and Android version (Android as of today) have the following features:

* Arithmetic and Exponents
* Percent, and it works properly! (36 - 10% = 32.4)
* Square Root, which the surd expands to accommodate long expressions under the root
* Support for the constants π, e, and ϕ (the golden ratio)
* Logarithmic functions (log to any base, ln, e^x)
* Trigonometric functions
* Absolute value
* Parenthesis
* Ability to solve equations by use of the ? and = symbols
* Factorial
* Tweet, email, or post results on Facebook (and probably other social networks)

I am excited about the future of these type of this app.

What I like to see in future updates is:
* Ability to show answers beyond 3 decimals** (see below)
* Numerical calculus: derivatives and integrals
* Matrices and complex number support, I can see the potential

Rating: 5 stars out of 5

I'll leave you with some screenshots of the MyScript app.

** Alexander Oestert of HP Forum (HP Museum of Calculators) pointed out that in the Android version that you can have decimal settings up to 6 places. (1/27/2013)

Until next time,

Eddie


This blog is property of Edward Shore. 2013

Speed Test - Casio Calculators

Hi everyone! Today I am blogging from home.

Last time I posted a speed test for various Texas Instruments, which you can go to by clicking on this link.

For each calculator, I timed how long does the calculator take until it "counts down" from 2013 to 0. I ran the program on each calculator twice.

The Program TEST2013

TEST2013:
2013 → A
Lbl 1
A - 1 → A
A > 0 ⇒ Goto 1 : 1

The program returns 1 when completed.

For the Casio ClassPad 330, I had to modify the program a bit, as the ⇒ symbol means "store" (instead of "jump") for the ClassPad.

TEST2013 for ClassPad 330:
2013 ⇒ a
Lbl one
a
a - 1 ⇒ a
If a > 0
Then
Goto one
IfEnd

Results

I will start from the oldest made model. Thanks to rskey.org and Wikipedia for the dates.

fx-7000GA (1990): 31.11 sec, 30.89 sec
(The fx-7000GA is as close to the original 7000G as I will probably get).

fx-6300G (1991): 38.91 sec, 38.90 sec

CFX-9850G (1997): 28.58 sec, 28.00 sec

fx-9750G Plus (2002): 28.50 sec, 28.44 sec

fx-3650P (2002) Solar Powered: 3 min 6 sec, 3 min 6.31 sec

ClassPad 330, Operating System 3.04.4000 (2007): 35.89 sec, 36.01 sec

Prizm (fx-CG 10) (2010), Operating System 1.04.3200 : 9.53 sec, 9.44 sec
(I am very happy with this!)

Note that the fx-3650P is a solar powered-calcualtor. I had no idea that this model was released in 2002. I had to get it from eBay, as it is not sold in stores in the United States.

I did not test any of the modern fx-9860g family (GII, Slim, etc...), but I guess that these calculators are fast of the Prizm. From these results, it is apparent that Casio knows how to maximize their processor speed.

Next time I will review the calculator app MyScript. Until next time,

Eddie



This blog is property of Edward Shore. 2013

Thursday, January 24, 2013

TI-8x Speed Test - A slowdown for the TI-84+?

Here is a speed test between newer and older Texas Instruments calculators. Please keep in mind this is one way to compare speeds. I ran the program on each calculator listed twice. The test is to see how fast the calculator "counted" to 2013.

Appropriately, the test program is named TEST2013.

TEST2013:*

0 →A
ClrHome
Lbl 1
Output(1,1,A)
IS>(A,2013)
Goto 1

*The TI-81 does not have an Output command, so Disp A was used instead.


I will start with the oldest (made) calculator.

TI-81: 52.70 sec, 52.36 sec

TI-82: 38.73 sec, 38.78 sec

TI-83+ Silver Edition, Operating System 1.14:
17.92 sec, 17.96 sec

TI-85: 47.91 sec, 47.43 sec

TI-84+, Operating System 2.55MP, MathPrint Mode On:
1 min 20.03 sec, 1 min 19.91 sec
(yes, this is shocking)

TI-84+ Silver Edition running on a TI nSpire via TI-84+ Keypad, Operating System 2.54MP, MathPrint On:
46.93 sec, 46.15 sec
(a second faster than the TI-85)

I don't know why the tests ran slower on the 84+s. At first, guessed that it is that the MP 2 is more complex than MP 1 and requires a great deal of RAM to operate. If I recall correctly, almost all the TI-8x series run on a Zilog Z80 chip.

A post written in 2010 from ticalc.org stated that there have been reports that programs run slower on the TI-84+ with operating system 2.53MP (or greater). Kevin Ouellet responded that the slow down issue is resolved if MathPrint is turned off.

Source: TI-OS 2.53 Released for the TI-84+ Family, 2/15/2010, written by Nikky. Retrieved 1/23/2013.

Let's put that to the test. If you don't know, on the TI-84+, you can turn MathPrint on and off by pressing the MODE key, scroll up or down to the second page. Choose CLASSIC. In classic mode, the F1, F2, and F4 shortcut menus are still available, except all input is linear.

Running these tests yields these results:

TI-84+, Operating System 2.55MP, MathPrint Off (CLASSIC):
27.02 sec, 27.00 sec

TI-84+ Silver Edition running on a TI nSpire via TI-84+ Keypad, Operating System 2.54MP, MathPrint Off (CLASSIC):
31.03 sec, 31.00 sec

A significant difference for the TI-84+. To compare: 1 minute 20 seconds with MathPrint On, only 27 seconds with it off.

The motto of the story is, if you have a TI-84+ and want to run a program, consider turning MathPrint off, and set it in CLASSIC mode instead.

I am curious to see if TI addressed this issue with the new TI-84+ C Silver Edition coming out this Spring.

Next time, I will post speed times for a handful of Casio calculators.

This blog is property of Edward Shore. 2013


Sunday, January 20, 2013

Converting Polar Equations to Parametric Equations

Good Sunday!

This blog will show how to transform polar equations, in the form of r(θ) to a pair of parametric equations, x(t) and y(t).


Tools We Need

x = r * cos θ
y = r * sin θ

Let θ = t.


For each example, we will change each polar equation and display a graph for each form. The polar form, colored blue, is on top; the parametric form, in red, is on the bottom. (A TI nSpire-CX is used for the pictures)

Example (I):

r = 2*θ

Then θ = r/2 and let θ = t.

x = r * cos t
x = 2 * t * cos(r/2)
x = 2 * t * cos((2*t)/2)
x = 2 * t * cos t

Similarly,

y = r * sin t
y = 2 * t * sin(r/2)
y = 2 * t * sin t

To summarize:
r = 2*θ

is equivalent to

x = 2 * t * cos t
y = 2 * t * sin t

Example (II):

r = e^(2 * θ)

Then θ = 1/2 * ln r and let θ = t.

And...

x = r * cos t
x = e^(2*t) * cos(1/2 * ln r)
x = e^(2*t) * cos(1/2 * ln(e^(2*t)))
x = e^(2*t) * cos(1/2 * 2 * t)
x = e^(2*t) * cos t

y = r * sin t
y = e^(2*t) * sin(1/2 * ln r)
y = e^(2*t) * sin(1/2 * ln(e^(2*t)))
y = e^(2*t) * sin t



To summarize:
r = e^(2*θ)

is equivalent to:

x = e^(2*t) * cos t
y = e^(2*t) * sin t

Example (III):

r = 2 cos θ

Then:

θ = arccos(r/2) = cos⁻¹(r/2)

Then, with θ=t...

x = r * cos t
x = 2 * cos t * cos(cos⁻¹(r/2))
x = 2 * cos t * cos(cos⁻¹(2*cos(t)/2))
x = 2 * cos t * cos t
x = 2 * cos² t

And... (some trigonometric identities are required)

y = r * sin t
y = 2 * cos t * sin(cos⁻¹(r/2))

Note: sin(cos⁻¹ x) = √(1 - x²)

y = 2 * cos t * √((1 - (r/2)²)
y = 2 * cos t * √(1 - r²/4)
y = 2 * cos t * √(1 - (4 cos² t)/4)
y = 2 * cos t * √(1 - cos² t)

Note: sin² x + cos² x = 1

y = 2 * cos t * sin t

Note: sin(2*x) = 2 * cos x * sin x

y = sin (2*t)

To Summarize:
r = 2 cos θ

is equivalent to:

x = 2 * cos² t
y = sin (2*t)

Until next time, take care!

Eddie


This blog is property of Edward Shore. 2013

Wednesday, January 16, 2013

Length of a Polynomial Segment - Part 1; and the HP 50g Program MPFIT


The next two blog entries are going to deal with finding the length of a polynomial segment.

Polynomial Segments

What is a polynomial segment? I could not find a formal definition, so I'll describe it is this: similar to a line segment where a pair of points are connected with a line, a polynomial segment is a set of points that are connected by polynomial curve. The degree of the polynomial is determined by the number of points, less one. For instance, if we have 3 points, the polynomial that connects them the order 2 (quadratic). A cubic polynomial (order 3) is used to connect a set of 4 points.

The Goal

We have a set of points {(x0, y0), (x1, y1), (x2, y2),... (xn, yn)}. Connect the points using a polynomial. What is the length of that segment?

General Method

1. Find the polynomial to connect the set of points. Order of the elements is important. This is determined by using the matrix calculation (X^T X)^-1 (X^T y) to determine the coefficients. The resulting matrix contains the coefficients of the polynomial; with each term being a coefficient of x of increasing power, from 0 to n-1.

2. Use the arc length formula ∫ ( √ (1 + (f'(x))^2 ) dx, a, b) where a is the minimum of the x values and b is the maximum of the x values.

We recommend using a calculator or math software that can handle matrices and integrals for this procedure.

But what is X and y?

y represents a vector of y-values of the set of points.

X is a Vandermonde Matrix. A Vandermonde matrix is a n × n matrix is formed with each row containing a geometric progression of each term. The first column, each term is raised to the 0th power, the second column each term to the 1st, the third column each term is raised to the second power, and so on until the nth row where each term is raised to the n-1 power.

For instance, a Vandermonde matrix consisting of the set [a, b, c, d] would look like this:

Example 1

Find a polynomial segment that fits the points (0,0), (4,8), and (8,6). Find the length of that segment. (See the diagram above).

The x values are [0, 4, 8] with xmin = 0 and xmax = 8. The y values are [0, 8, 6]. Let X be the Vandermonde matrix with the set [0, 4, 8] and the vector y be represented by the corresponding y-values.

Now we need to calculate (X^T X)^-1 (X^T y).

Then:

The resulting matrix contains the coefficients of the required polynomial. Since the vector has 3 entries, the order of the polynomial is 3-1=2.

Going top-down:
0 is the constant (coefficient of x^0),
3.25 is the coefficient of x,
and -0.3125 is the coefficient of x^2.

Our polynomial is f(x) = 3.25x - 0.03125x^2.

To find the length, use the arc length formula using end points xmin = 0 and xmax = 8. We find that the length of the polynomial segment connecting (0,0), (4,8), and (8,6) is about 14.23920.

Example 2

What is the length of the polynomial segment connected with the points (-2,5), (0,-6), (3,2), and (4,1). We are working with 4 points, the required polynomial has the order 4-1=3. (Cubic polynomial)

The Vandermonde matrix X with the vector y are as follows:

Calculating (X^T X)^-1 (X^T y) yields (approximately):

[ [ -6 ]
[ 2.98333 ]
[ 2.725 ]
[ -0.75833 ] ]

To form the cubic polynomial:
-6 is the constant,
2.98333 is the coefficient of x,
2.725 is the coefficient of x^2, and
-0.75833 is the coefficient of x^3.

With xmin = -2 and xmax = 4, we find the length of this segment is approximately 32.60952. (See below).

HP50g Program MPFIT

The HP 50g program MPFIT fits a polynomial to the set of points {(x0, y0), (x1, y1), (x2, y2), ... , (x_(n-1), y_(n-1))}.

Input:
2: vector of x coordinates
1: vector of y coordinates

Output:
2: Coefficients in matrix form [ [a0] [a1] [a2] ... [a_(n-1)] ]
1: Polynomial of X in the form a0 + a1 * X + a2 * X^2 + ... + a_(n-1) * X^(n-1)

Program MPFIT (size 183.5 bytes)

<< DUP SIZE OBJ→ DROP → MX MY N
<< 'X' PURGE
MY OBJ→ 1 + →ARRY
MX VANDERMONDE
LSQ → MR
<< MR DUP
{1, 1} GET
2 N FOR K
MR K 1 2 →LIST GET
'X' K 1 - ^ * +
NEXT >> >> >>

Example:
Input:
2: [1, 3, 6]
1: [6, 3, 5]

Output:
2: [[8.8] [-3.23333333333] [0.43333333333]]
1: 8.8+-3.23333333333*X+0.43333333333*X^2

Which means the polynomial fit for the given points is (approximately):

8.8 - 3.23333x + 0.43333x^2

(Screen shots of this example are shown below)

To get the length of the segment with the HP 50g, first note the xmin and xmax values, which are 1 and 6, respectively. This keystroke (in RPN Mode) should do the trick:

[ ' ] [ X ] [ENTER]
[RS] [COS] ( δ )
[LS] [ √ ] (x²)
1 [ + ] [ √ ]
1 [ENTER]
6 [ENTER]
3 [LS] [EVAL] (PRG) [F1] (STACK) [NXT] [F1] (ROLL)
[ ' ] [ X ] [ENTER]
[RS] [TAN] ( ∫ )

Length = 7.75662832829



My next blog entry will contain programs for the TI-84+ and Casio Prizm (fx series) calculators.

Have a great day everyone,

Eddie


This blog is property of Edward Shore. 2013

Length of a Polynomial Segment - Part 2 (TI-84+/Casio); From Coffee Klatch in San Dimas

Today I am coming to you from Coffee Klatch in San Dimas, CA. This is one of my most favorite places to hang out, and have great coffee and food.

Today's blog is the second part of the polynomial segment blog. Here is a link to Part 1.


To Recall:

A polynomial segment is a set of points that is connected by a polynomial.

To find a perfectly fit polynomial to fit n points:

1. Let X be the Vandermonde matrix of order (n-1) × (n-1) for the following:

2. Let y be the vector of y values.
3. The coefficient matrix is calculated as (X^T X)^-1 (X^T y). The result is a vector of coefficients of x^k where k = 0 to n-1.

On most graphing (and some scientific calculators), you can accomplish this task in two ways:

1. Use matrix operations. This is good for any size polynomial.
2. Take advantage of the curve fitting functions LinReg (to fit 2 points), QuadReg (to fit 3 points), CubicReg (to fit 4 points), and QuartReg (to fit 5 points). *Regression models and names vary for each calculator.

Once the polynomial, f(x) is found, find the arc length is found by:

The limits of the integral are the minimum and maximum x values, respectively.




Here are two programs that accomplish the task of finding a polynomial fit for 3, 4, or 5 points for the TI-84+ (and its family), and the Casio Prizm (and its fx-9xxx family).


TI-84+

POLYARC
1/12/2013
Fit a polynomial to a set of three, four, or five points.
Find the arc length of the polynomial from the end points.

Example 1: (0,0), (4,8), (8,6)
Results: y = -0.3125x^2 + 3.25
Length = 14.23920

Example 2: (0,3), (2,-1), (4,2), (6,0)
Results: y = -0.25x^3 + 2.375x^2 - 5.75x + 3
Length = 12.46834

Example 3: (0,0), (1,1), (2,0), (3,-1), (4,0.5)
Results: y ≈ -0.02083333x^4 + 0.20833333x^3 - 1.77083333x^2 + 2.54166666x
Length = 6.36142413

Program POLYARC (327 bytes)
Input "NO OF PTS(3-5)", N
If N<3 or N>5
1/0
N → dim(L1)
N → dim(L2)
For(K,1,N)
Disp K
Input "X=", X
Input "Y=", Y
X → L1(K)
Y → L2(K)
End
If N=3
Then
QuadReg L1, L2
fnInt(√(1+(2aX+b)²),X,min(L1),max(L1)) → L
Pause {a, b, c}
End
If N=4
Then
CubicReg L1, L2
Pause {a, b, c, d}
fnInt(√(1+(3aX² + 2bX + c)²), X, min(L1), max(L1)) → L
End
If N=5
Then
QuartReg L1, L2
Pause {a, b, c, d, e}
fnInt(√(1 + (4aX³ + 3bX² + 2cX + d)² , X, min(L1), max(L2)) → L
End
Disp "LENGTH="
Pause L

Where to find:
a, b, c, d, e: VARS, 5 (Statistics), right, right, [2, 3, 4, 5, and 6 respectively]
You need the lower case a, b, c, d, and e!

Note: No "bending backwards" is allowed


Casio Prizm

POLYARC
1/12/2013
Fit a polynomial to a set of three or four points.
Find the arc length of the polynomial from the end points.

Example 1: (0,0), (4,8), (8,6)
Results: y = -0.3125x^2 + 3.25
Length = 14.23920

Example 2: (0,3), (2,-1), (4,2), (6,0)
Results: y = -0.25x^3 + 2.375x^2 - 5.75x + 3
Length = 12.46834

Example 3: (0,0), (1,1), (2,0), (3,-1), (4,0.5)
Results: y ≈ -0.02083333x^4 + 0.20833333x^3 - 1.77083333x^2 + 2.54166666x
Length = 6.36142413

Program POLYARC (352 bytes):
"NO. OF POINTS(3,4,5)"? → N
N<3 Or N>5 ⇒ 1 ÷ 0
N → Dim List 1
N → Dim List 2
For 1 → K To N
K ◢
"X"? → List 1[K]
"Y"? → List 2[K]
Next
If N = 3
Then QuadReg List 1, List 2
∫( √(1 + (2aX + b)² ), Min(List 1), Max(List 1)) → L
{a, b, c} ◢
EndIf
If N=4
Then CubicReg List 1, List 2
∫( √(1 + (3aX ² + 2bX + c)² ), Min(List 1), Max(List 1)) → L
{a, b, c, d} ◢
EndIf
If N=5
Then QuartReg List 1, List 2
∫ ( √(1 + (4aX^3 + 3bX ² + 2cX + d)² ), Min(List 1), Max(List 2)) → L
{a, b, c, d, e} ◢
EndIf
"LENGTH="
L

How to Access:
a, b, c, d, and e: VARS, STAT (F3), GRAPH (F3), F1 (F2, F3, F4, and F5 respectively)
QuadReg: back to default menu, MENU, STAT, CALC, X^2
CubicReg: back to default menu, MENU, STAT, CALC, X^3
QuartReg: back to default menu, MENU, STAT, CALC, X^4

Note: No "bending backwards" allowed



Enjoy the day and I'll talk to you soon!

Eddie


This blog is property of Edward Shore. 2013

Numworks (Python): Determining Earth’s Acceleration of Gravity

Numworks (Python): Determining Earth’s Acceleration of Gravity Introduction Note: We will only be using SI units on this blog en...