Example: Compute Kinetic Energy
The kinetic energy of a mass in motion is given by where m
is the mass and v
is the velocity. In this example the mass is 2.4 pounds and the velocity is 6.7 meters per second. The infix operators defined by Physical
automatically handle the unit convertions and computes the current units for the result.
using System;
using Imsl.Math;
public class PhysicalEx1
{
public static void Main(String[] args)
{
Physical mass = new Physical(2.4, "pound");
Physical velocity = new Physical(6.7, "m/s");
Physical energy = 0.5*mass*velocity*velocity;
Console.Out.WriteLine("Kinetic energy is " + energy);
}
}
Output
Kinetic energy is 24.43411378716 m^2*kg/s^2
Link to C# source.