P64 is a powerful math engine, with an easy-to-learn programming language.
Using an easy-to-learn coding language, write programs to compute mathematical expressions and save them for later use.
The examples below demonstrate the utility of P64 when solving problems in physics.
Let's say you are studying objects in uniform motion, motion under constant acceleration. You want to calculate the force required to stop a moving object in a given distance. The mass of the object and its speed are given.
To solve this problem, you use the equation of kinematics that defines velocity as a function of displacement, and then you solve that equation for the acceleration required to stop the object in the specified distance. Then you use Newton's second law to calculate the force required.
v2 - v2
0 = 2a(x - x0) ∴ a = (v2 - v2
0)/(2(x - x0)) ∴ a = ((v - v0)(v + v0))/(2(x - x0)) F = Ma
Finally, to compute the last two equations above, you would write the following P64 code.
$start {
let M = 2000.0 // kg - mass of the object
let v0 = 100.0 // m/s - inital speed
let v = 0.0 // m/s - final speed
let x0 = 0.0 // m - inital position
let x = 80.0 // m - final position, the stopping distance
// Acceleration
let a = ((v - v0) * (v + v0)) / (2.0 * (x - x0))
// Force required
let F = M * a
// Print
let os : OMLStream
let sp = {"_0.1"}
let F_unit = $M (variable, "N (Newtons)", "color FF0000")
os << "Force required to stop the object"
<< sp << "in" << sp << x << sp << "meters:"
os << F << sp << F_unit
}
334880 joules is required to boil 1 kg of water. How many kilowatt hours is that? 0.0930222 kwh
Use the following equation of heat transfer.
E = McΔT
Here is the P64 code for it.
$start {
// mass of 1.0 liters of water
let M = 1.0 // kg
// initial temperature of water
let T1 = 20.0 // degrees celcius
// final temperature
let T2 = 100.0 // degrees celcius
// specific heat of water
let c = 4186.0 // joules / (kg degrees celcius)
// increase in temperature
let DT = T2 - T1
// energy required - in joules
let E = M * c * DT
// Print...
let os : OMLStream
let sp = {"_0.3"}
os << E << sp << "joules"
<< sp << "is required to boil"
<< sp << M << sp << "kg of water"
// How many kilowatt hours is that?
let kw = 1000.0 // 1000 joules per second
let E_1_kw_hour = kw * 60.0 * 60.0 // joules
let E_kwh = E / E_1_kw_hour
os << "How many kilowatt hours is that?"
os << E_kwh << sp << "kwh"
}