Lesson on Acceleration
How to Hand Calculate Acceleration
Acceleration is defined as the rate of change of velocity for an object. In its simplest form, the equation for acceleration is given as:
a = Δv⁄t
Where a is the acceleration of the object, Δv is the change in velocity, and t is the amount of time the change in velocity takes.
Of course, we do not always know the change in velocity and elapsed time, so we must sometimes use other equations to solve for acceleration. These equations are known as the kinematic equations. There are four kinematic equations, but only three of them can be used to solve for acceleration. After rearranging the terms in these three equations to solve for acceleration, they are given as:
1.) a = (v – v0)⁄t
2.) a = (v2 – v02)⁄2Δx
3.) a = 2(x – x0 – v0t)⁄t2
We choose a kinematic equation based on what parameters we already know. For example, if we are given the values for initial velocity (v0), final velocity (v), and distance (Δx), we would use equation 2. If we are given time instead of distance, we would use equation 1.
How the Calculator Works
When you click the “calculate” button, the acceleration function runs. This function utilizes all of the equations that were listed in the lesson above. It takes the inputted numbers, applies them to the applicable formula, then rounds the answer to the fifth decimal place. The function also takes care of all unit conversions for the inputs and output.
The code also contains logic for catching errors. If the solution is not a finite number, it will throw an error and ask the user to check their inputs. There are two main reasons for invalid inputs causing an error. The first is an input that results in dividing by zero during calculations. This situation will return infinity and throw an error. The second reason is an input that contains non-number characters such as a letter. This cannot be added, subtracted, multiplied, or divided with other numbers and therefore returns an error.