Here I go again.
My knowledge of V4 is shooting me in the foot at every turn,
as I attempt things that were so easy and elegant in V4
and now, despite my best efforts unobtainable (the
same way) in V12.
Here is another, almost spooky example.
Consider the following setup for another simple problem in Newtonian Mechanics:
m = Quantity[200, "Kilograms"];
g = Quantity[9.8, ("Meters")/("Seconds")^2];
Fw = m*g;
F1Vec = AngleVector[{F1, 0 Degree}];
FwVec = AngleVector[{Fw, 270 Degree}];
FnVec = AngleVector[{Fw, 90 Degree}];
RVec = F1Vec + FwVec + FnVec;
UnitSimplify[{m, g, Fw, FwVec, F1, F1Vec, FnVec, RVec}] // N
Now add to this, a position vector that changes as a function of time
rVec = {Quantity[1.2, ("Meters")/("Seconds")^2] t^2 -
Quantity[0.2, ("Meters")/("Seconds")^3] t^3, Quantity[0, "Meters"]}
Now, this definition of the rVec seems reasonable, as it will return both correct magnitudes, as well as, correct units:
rVec /. t -> Quantity[3, "Seconds"]
Which correctly produces the following output:
{Quantity[5.4, "Meters"], Quantity[0, "Meters"]}
So far, so good.
Now, let's take a couple derivatives of rVec to obtain aVec:
vVec = D[rVec, t];
aVec = D[vVec, t];
Now we immediately see a major problem, if we compare rVec to aVec.
The "units" for the y-component of rVec have been deleted by the Derivative function, which makes mathematical sense, but causes problems later. The Derivative of "0 m" is and should be "0", without units. And this at least, is what happens.
And although zero oranges fills one's hand in the exact same way as zero apples, the y-component of aVec would almost seem to need to be in units of m/s^2, to create a "0 m/s^2" value in the second derivative of the position vector rVec. I realize that this makes only partial sense, but consider, Quantity[0, "Meters"] returns "0 m", which is also kind of meaningless. But as we can see, now after taking the derivative of rVec all units for the y-components of vVec and aVec have disappeared.
rVec
vVec
aVec
Which now equal, the following respectively:
{t^3 (Quantity[-0.2, ("Meters")/("Seconds")^3]) +
t^2 (Quantity[1.2, ("Meters")/("Seconds")^2]),
Quantity[0, "Meters"]}
{t^2 (Quantity[-0.6, ("Meters")/("Seconds")^3]) +
t (Quantity[2.4, ("Meters")/("Seconds")^2]), 0}
{t (Quantity[-1.2, ("Meters")/("Seconds")^3]) +
Quantity[2.4, ("Meters")/("Seconds")^2], 0}
Now, the first thing we notice is that there are no units for the y-component of vVec and aVec,
which is mathematically correct, I believe. However, that lack of units in aVec will easily break Solve/NSolve as I will show in a moment.
The second odd thing is that the derivative of the x-components of vVec and aVec look correct.
I note that when differentiating the x-component of rVec, the units never changed in the x-component, only the magnitude of the Quantities change, as does the variable "t". All
correctly, I believe.
And of course, the goal was to use Newton's Second Law to determine the F1 scalar defined above.
But now, with no units in the y-component of aVec, when I multiply aVec times the scalar mass Quantity "m", I get a really squirrelly result:
m * aVec
Produces the following nonsense:
{(t (Quantity[-1.2, ("Meters")/("Seconds")^3]) +
Quantity[2.4, ("Meters")/("Seconds")^2]) (Quantity[200,
"Kilograms"]), Quantity[0, "Kilograms"]}
Which will of course make Solve/NSolve explode (and for good reason).
This approach, which worked so elegantly in V4 and is mathematically correct in it's basic design, is junk code in V12.
As always, any help or syntax corrections would be appreciated.
Regards,
- Joe