Been awhile; I'm a little rusty. Anyway, here's a math lesson along with a small program to accompany it.

## Background InformationEdit

In calculus and physics classes you learn that:

distance = velocity x time

Knowing this, if you were to graph a velocity vs time function, say, y=x, the distance can be found by finding the area between the line and the x axis. This is shown by this silly little graph I've drawn on MS Paint to the right.

Unfortunately, math is never as simple as finding the area of green triangles. Many calculus graphs have bumps and curves in all sorts of shapes and styles. I'm sure there's a formulaic method for figuring the area out, but all I've been taught in my modest public high school education is something called the TRAPEZOID RULE.

I'm assuming most people interested in calculator programming already know this but I feel obligated to keep explaining.

## Trapezoid RuleEdit

Basically, in order to find out the area under a curve, I've been taught to break the area into small trapezoid sections. Hold on...I'll draw a quick diagram:

Okay so here, in this curvy diagram, the area has been broken up into more modest sized groups, artfully labeled 1, 2, 3, and 4. It's incredibly tedious to hand-calculate all of this. But that's where my TI-84 came in handy.

I created a program that allows you to calculate the displacement of any function from any starting point to any ending point in the time-frame. And the program also allows for the user to choose the sizes of the trapezoids (the smaller the trapezoids, the more accurate the area)

## The ProgramEdit

The inputs are:

BASE FUNCTION: which prompts you for the function of velocity with respect to time. This can be any function.

RANGE START: asks for where in time you are beginning your search for area. In the graphs above, this value was 0.

RANGE END: asks where what value of time you want the calculation of displacement to stop.

TOLERANCE: asks for the width of the trapezoids. Okay, the only part you care about:

:ClrHome :Input "BASE FUNCTION?: ",Str1 //one space for my ocd :Str1→Y1 //this is in VARS>Y-VARS :Input "RANGE START: ",A //4 spaces :Input "RANGE END: ",B //6 spaces :Input "TOLERANCE: ",C //6 spaces :Disp "Calculating..." :A→X :1→L :{0}→L1 :iPart((A+B)/C)+1→dim(L1) :While X<b :If (X+C)>(B) :If(X+C)>(A+B) :A+B-x→C :(1/2)(Y1(X)+Y1(X+C))C→D //Y1 is the function, NOT Y times 1 :D→L1(L) :L+1→L:X+C→X :End :0→F :For(E,1,dim(L1) :L1(E)+F→F :End :Disp F :If (X+C)>

Some trims can be made, and the While() can be turned into a For() but the program works flawlessly for me so I'm not to worry about it. So for anyone in Cal or Physics this is a useful tool!