acceleration
average and instantaneous acceleration of an object
Interface
#include <codecogs/physics/kinematics/acceleration.h>
using namespace Physics::Kinematics;
inline double acceleration_avg(double vf, double tf, double v0 = 0, double t0 = 0)inline double acceleration_ins(double (*v)(double), double t, double eps = 1E-6)inline std::vector<double> acceleration_ins(double (*v)(double), std::vector<double> &t, double eps = 1E-6)inline double acceleration_ins_space(double (*x)(double), double t, double eps = 1E-5)inline std::vector<double> acceleration_ins_space(double (*x)(double), std::vector<double> &t, double eps = 1E-5)
Overview
This module computes the average and instantaneous acceleration of a moving object at given moments of time.
FUNCTION
acceleration_avg
This function computes the average acceleration of a moving object, given the initial and final velocities, and also the total time spent. Considering is the initial velocity at time
and
is the final velocity at time
, the average acceleration
is given by the following simple formula:
Example 1
#include <codecogs/physics/kinematics/acceleration.h>
#include <iostream>
int main()
{
// final velocity and time
double v = 200, t = 15.7;
std::cout << std::endl;
std::cout << " Final velocity = " << v << " m/s" << std::endl;
std::cout << " Time spent = " << t << " s" << std::endl;
std::cout << std::endl;
// assuming initial velocity and initial time are null,
// display the average acceleration of the object
std::cout << "Average acceleration = " <<
Physics::Kinematics::acceleration_avg(v, t);
std::cout << " m/s^2" << std::endl;
return 0;
}Output
Final velocity = 200 m/s
Time spent = 15.7 s
Average acceleration = 12.7389 m/s^2Parameters
Returns
Interactive Calculator
Computing…
Set a range above first to export a graph.
FUNCTION
acceleration_ins
This function returns the instantaneous acceleration of a moving object at a certain moment of time t, given a function v which describes the velocity of the object at any moment of time. It is based on the fact that the instantaneous acceleration function is given by the derivative of the velocity function
with respect to time, i.e.
Since this function uses numerical differentiation to compute the above derivative, an optional parameter eps is available to specify the precision of numerical computations.
Example 1
#include <codecogs/physics/kinematics/acceleration.h>
#include <iostream>
// function defining the velocity at any moment of time t;
// in this case velocity(t) = t^2/2
double velocity(double t)
{
return t*t/2;
}
int main()
{
// time at which to calculate instantaneous acceleration
double t = 11.43;
std::cout << std::endl;
std::cout << "Velocity = " << velocity(t);
std::cout << " m/s" << std::endl;
std::cout << " Time = " << t;
std::cout << " s" << std::endl;
std::cout << std::endl;
// display instantaneous acceleration at time t
std::cout << "Instantaneous acceleration = " <<
Physics::Kinematics::acceleration_ins(velocity, t);
std::cout << " m/s^2" << std::endl;
return 0;
}Output
Velocity = 65.3225 m/s
Time = 11.43 s
Instantaneous acceleration = 11.43 m/s^2Parameters
Returns
FUNCTION
acceleration_ins
This function is based on the same equation as the previous one, only that it is able to compute the instantaneous acceleration values at several moments of time and return the results in the form of an array.
Notice the example code below which shows exactly how this is a generalisation of the previous overloaded function.
Example 1
#include <codecogs/physics/kinematics/acceleration.h>
#include <iostream>
// function defining the velocity at any moment of time t;
// in this case velocity(t) = t^2/2
double speed(double t)
{
return t*t/2;
}
int main()
{
// moments of time at which to evaluate
// the instantaneous acceleration of the object
double t[10] = {
11.40, 11.41, 11.42, 11.43, 11.44,
11.45, 11.46, 11.47, 11.48, 11.49
};
// compute the instantaneous acceleration values
std::vector<double> time(t, t+10),
acceleration = Physics::Kinematics::acceleration_ins(speed, time);
// display the time, the velocity
// and the instantaneous acceleration
std::cout << std::endl;
for (int i = 0; i < 10; i++)
{
std::cout << "Time = " << time[i] << " s";
std::cout << "\tVelocity = " << speed(time[i]) << " m/s";
std::cout << "\tAcceleration = " << acceleration[i] << " m/s^2";
std::cout << std::endl;
}
return 0;
}Output
Time = 11.4 s Velocity = 64.98 m/s Acceleration = 11.4 m/s^2
Time = 11.41 s Velocity = 65.094 m/s Acceleration = 11.41 m/s^2
Time = 11.42 s Velocity = 65.2082 m/s Acceleration = 11.42 m/s^2
Time = 11.43 s Velocity = 65.3225 m/s Acceleration = 11.43 m/s^2
Time = 11.44 s Velocity = 65.4368 m/s Acceleration = 11.44 m/s^2
Time = 11.45 s Velocity = 65.5512 m/s Acceleration = 11.45 m/s^2
Time = 11.46 s Velocity = 65.6658 m/s Acceleration = 11.46 m/s^2
Time = 11.47 s Velocity = 65.7805 m/s Acceleration = 11.47 m/s^2
Time = 11.48 s Velocity = 65.8952 m/s Acceleration = 11.48 m/s^2
Time = 11.49 s Velocity = 66.0101 m/s Acceleration = 11.49 m/s^2Parameters
Returns
FUNCTION
acceleration_ins_space
This function returns the instantaneous acceleration of a moving object at a certain moment of time t, given a function x which determines the position of the object at any moment of time on a fixed axis. It is based on the fact that the instantaneous acceleration function is given by the second order derivative of the position function
with respect to time, i.e.
Since this function uses numerical differentiation to compute the above second order derivative, an optional parameter eps is available to specify the precision of numerical computations.
Example 1
#include <codecogs/physics/kinematics/acceleration.h>
#include <iostream>
// function defining the position at any moment of time t;
// in this case space(t) = t^3
double pos(double t)
{
return t*t*t;
}
int main()
{
// time at which to calculate instantaneous acceleration
double t = 11.43;
std::cout << std::endl;
std::cout << "Position = " << space(t);
std::cout << " m" << std::endl;
std::cout << " Time = " << t;
std::cout << " s" << std::endl;
std::cout << std::endl;
// display instantaneous acceleration at time t
std::cout << "Instantaneous acceleration = " <<
Physics::Kinematics::acceleration_ins_space(space, t);
std::cout << " m/s^2" << std::endl;
return 0;
}Output
Position = 1493.27 m
Time = 11.43 s
Instantaneous acceleration = 68.5782 m/s^2Parameters
Returns
FUNCTION
acceleration_ins_space
This function is based on the same equation as the previous one, only that it is able to compute the instantaneous acceleration values at several moments of time and return the results in the form of an array.
Notice the example code below which shows how this is a generalisation of the previous overloaded function.
Example 1
#include <codecogs/physics/kinematics/acceleration.h>
#include <iostream>
// function defining the position at any moment of time t;
// in this case pos(t) = t^3
double pos(double t)
{
return t*t*t;
}
int main()
{
// moments of time at which to evaluate
// the instantaneous acceleration of the object
double t[10] = {
11.40, 11.41, 11.42, 11.43, 11.44,
11.45, 11.46, 11.47, 11.48, 11.49
};
// compute the instantaneous acceleration values
std::vector<double> time(t, t+10),
acceleration = Physics::Kinematics::acceleration_ins_space(distance, time);
// display the time, the position
// and the instantaneous acceleration values
std::cout << std::endl;
for (int i = 0; i < 10; i++)
{
std::cout << "Time = " << time[i] << " s";
std::cout << "\tPosition = " << distance(time[i]) << " m";
std::cout << "\tAcceleration = " << acceleration[i] << " m/s^2";
std::cout << std::endl;
}
return 0;
}Output
Time = 11.4 s Position = 1481.54 m Acceleration = 68.3985 m/s^2
Time = 11.41 s Position = 1485.45 m Acceleration = 68.4599 m/s^2
Time = 11.42 s Position = 1489.36 m Acceleration = 68.5168 m/s^2
Time = 11.43 s Position = 1493.27 m Acceleration = 68.5782 m/s^2
Time = 11.44 s Position = 1497.19 m Acceleration = 68.6396 m/s^2
Time = 11.45 s Position = 1501.12 m Acceleration = 68.6987 m/s^2
Time = 11.46 s Position = 1505.06 m Acceleration = 68.7601 m/s^2
Time = 11.47 s Position = 1509 m Acceleration = 68.8237 m/s^2
Time = 11.48 s Position = 1512.95 m Acceleration = 68.8829 m/s^2
Time = 11.49 s Position = 1516.91 m Acceleration = 68.9397 m/s^2