Numerical Calculations with Units

The Wolfram Language's unit system utilizes various numerical methods, facilitating calculations using (RefLink[Quantity, paclet:ref/Quantity]) expressions within the Wolfram Language's numerical functions.

Numerical functions that operate on (RefLink[Quantity, paclet:ref/Quantity]) expressions.

(RefLink[N, paclet:ref/N])[quantity] gives you a numerical approximation of quantity:

N[Quantity[20+29(Sqrt[2]),"Feet"]]

For numerical functions like (RefLink[FindRoot, paclet:ref/FindRoot]) and (RefLink[FindMaximum, paclet:ref/FindMaximum]), if a variable is specified within a (RefLink[Quantity, paclet:ref/Quantity]) expression, then that variable is assumed to be a dimensionless value (representing the magnitude of its (RefLink[Quantity, paclet:ref/Quantity])). If no unit is specifically associated with a variable, these functions will attempt to automatically determine the units associated with the variable, based on the expression and any specified start values.

Specifying x within a (RefLink[Quantity, paclet:ref/Quantity]) indicates that x is a dimensionless value:

FindRoot[Quantity[Cos[x],"Amperes"]==Quantity[x,"Amperes"],{x,0}]

Find the time it takes for a falling body to hit the ground:

FindRoot[(1/2) ((t^2) ((QuantityUnit[(-9.8`)]))+(QuantityUnit[200])),{{t,Quantity[1,"Seconds"]}}]

Find a local maximum, starting the search at x=2:

FindMaximum[x*Quantity[Cos[x],"Miles"],{x,2}]

Find the peak height of a bullet fired from a rifle vertically, without dampening:

vel=Quantity[3000,"Feet"/"Seconds"];
grav=Quantity[1,"StandardAccelerationOfGravity"];

FindMaximum[vel*t+1/2(-grav)t^2,{{t,Quantity[1,"Seconds"]}}]

Find how long it takes the bullet to return to Earth:

NSolve[vel*t+1/2(-grav)t^2==0,t,Reals]

Find the maximum height of a body shot vertically upward, with dampening:

h=First[y[t]/.DSolve[{ y''[t]==-γ y'[t]-g,y[0]==Quantity[0,"Meters"],y'[0]==Quantity[10,"Meters"/"Seconds"]},y,t]]/.{γ->Quantity[1/10,1/"Seconds"],g->Quantity[9.8,"Meters"/"Seconds"^2]};

FindMaximum[h,{{t,Quantity[1,"Seconds"]}}]