Here is how I used to do this in V4. I can not find an equivalent way in V12. Any ideas would be appreciated.

enter image description here

  • 2
    $\begingroup$ Here is how you used to do.... what? 1) please describe your problem in more detail; 2) post code as text so we can copy and paste it, rather than pictures of code. $\endgroup$
    – MarcoB
    Commented Nov 29, 2020 at 23:27
  • $\begingroup$ Nothing in this code looks like it wouldn't work in any version of mathematica greater than version 4. Beyond using Quantities...so `Quantity[1, "Second"] would be for units... $\endgroup$ Commented Nov 29, 2020 at 23:43
  • $\begingroup$ Thanks. That is my conclusion too. The code that I wrote 15 years ago and worked perfectly in V4, now no longer works. So much for backward compatibility. And unfortunately, as demonstrated earlier today in my original post, the Quantity issue is a show stopper. I would love to find a working copy of V4. $\endgroup$ Commented Nov 30, 2020 at 0:02

2 Answers 2


The following seems to reproduce what you have in MMA 12 using the Quantity framework. Not that I am a huge fan of its implementation, but one can make it work.



r0Vec = {Quantity[0, "Meters"], Quantity[0, "Meters"]};
v0 = Quantity[37, "Meters"/"Seconds"];
v0Vec = AngleVector[{v0, 53.1 Degree}];
aVec = {Quantity[0, "Meters"/"Seconds"^2], 
        Quantity[-9.8, "Meters"/"Seconds"^2]};

Find the position of the baseball at $t=2s$:

r0Vec + 
  Integrate[v0Vec, Quantity[t, "Seconds"]] + 
    Integrate[aVec, Quantity[t, "Seconds"], Quantity[t, "Seconds"]] /. t -> 2

(* Out {Quantity[44.4311, "Meters"], Quantity[39.5767, "Meters"]} *)

Find the magnitude and direction of the ball's velocity at $t=2s$

Here we must work around the known fact that ArcTan does not work with quantity objects. Definitely an annoying oversight, but fixable:

arctan[x_, y_] /; QuantityUnit[x] == QuantityUnit[y] := 
  ArcTan[x, y] /. QuantityUnit[x] -> 1;
arctan[x_, y_] := ArcTan[x, y];

{Norm[##], arctan[#1, #2]/Degree} & @@ 
  (v0Vec + Integrate[aVec, Quantity[t, "Seconds"]] /. t -> 2)

(* Out: {Quantity[22.2155, "Meters"/"Seconds"], 24.2092}*)

What is the highest point and when does this happen?

r1Vec = {x, y};
v1Vec = {v1x, Quantity[0, "Meters"/"Seconds"]};
  {r1Vec == 
     r0Vec + Integrate[v0Vec, Quantity[t, "Seconds"]] + 
       Integrate[aVec, Quantity[t, "Seconds"], Quantity[t, "Seconds"]],
   v1Vec == v0Vec + Integrate[aVec, Quantity[t, "Seconds"]]},
  {x, y, t, v1x}

(* Out:
   {{  x -> Quantity[67.0736, "Meters"],
       y -> Quantity[44.6668, "Meters"], 
       t -> 3.01922, 
     v1x -> Quantity[22.2155, ("Meters")/("Seconds")]}} 

When does the ball touch the ground and how far has it travelled horizontally?

r1Vec = {x, Quantity[0, "Meters"]};
v1Vec = {v1x, v1y};
   r1Vec == 
    r0Vec + Integrate[v0Vec, Quantity[t, "Seconds"]] + 
     Integrate[aVec, Quantity[t, "Seconds"], Quantity[t, "Seconds"]],
   v1Vec == v0Vec + Integrate[aVec, Quantity[t, "Seconds"]]},
  {x, t, v1x, v1y}

(* Out: 
{  x -> Quantity[134.147, "Meters"], 
   t -> 6.03844, 
 v1x -> Quantity[22.2155, ("Meters")/("Seconds")], 
 v1y -> Quantity[-29.5883, ("Meters")/("Seconds")]}

Hopefully this reproduces most of what you had from the otherwise hopelessly obsolete V4.


I think the only real problem keeping you from using the more modern Quantities framework is the fact that Integrate[a0, t, t] and a0 Integrate[1, t, t] are not equivalent if one or more accelerations in a0 are zero. In the first case we get {0 m/s^2, -4.9 t^2 m/s^2} and in the second case we get {t^2 (0 m/s^2), t^2 (-4.9 m/s^2)}. Since we're integrating constants, we can pull the constants out of the integral and put them in front. I've done it for both v0 and a0, though it was only absolutely necessary for a0. Unfortunately, because of the way the replacement works, Mathematica will print a warning that m/s and m are incompatible units, then the substitution happens and it realizes the units are fine.

vectorDirection[vec_] := ArcTan[vec[[2]]/vec[[1]]]*180/\[Pi]

r0 = Quantity[{0, 0}, "Meters"];
s0 = Quantity[37, "Meters"/"Seconds"];
v0 = AngleVector[s0, 53.1 Degree]
a0 = Quantity[{0, -9.8}, "Meters"/"Seconds"^2];

r0 + v0 Integrate[1, t] + a0 Integrate[1, t, t] /. 
 t -> Quantity[2, "Seconds"]

  v0 + a0 Integrate[1, t] /. t -> Quantity[2, "Seconds"]], 
  v0 + a0 Integrate[1, t] /. t -> Quantity[2, "Seconds"]]}

r1 = {x, y};
v1 = {v1x, Quantity[0, ("Meters")/("Seconds")]};
Solve[{r1 == r0 + v0 Integrate[1, t] + a0 Integrate[1, t, t], 
  v1 == v0 + a0 Integrate[1, t]}, {x, y, t, v1x}]

r1 = {x, Quantity[0, "Meters"]};
v1 = {v1x, v1y};
Last@Solve[{r1 == r0 + v0 Integrate[1, t] + a0 Integrate[1, t, t], 
   v1 == v0 + a0 Integrate[1, t]}, {x, t, v1x, v1y}]

Of course all the quantities and integrals can be entered in the more traditional format when using Mathematica, but it doesn't translate well to StackExchange. I do think it's a bit strange to carry around all these integrals and repeatedly solve the same equations over and over. My usual process would be to solve the integral once, if possible, and then be done with it. Perhaps you have a reason you want to keep the integrals, but I think it's cleaner without. With the initial values defined as above:

pos = Integrate[a, t, t, GeneratedParameters -> C] /. {C[1] -> r0, C[2] -> v0,  a -> a0}
pos /. t -> Quantity[2, "Seconds"]
{Norm[#], vectorDirection[#]} &@(D[pos, t] /. 
   t -> Quantity[2, "Seconds"])
Solve[{{x, y} == pos, {v1x, Quantity[0, ("Meters")/("Seconds")]} == 
   D[pos, t]}, {x, y, t, v1x}]
Last@Solve[{{x, Quantity[0, "Meters"]} == pos, {v1x, v1y} == 
    D[pos, t]}, {x, t, v1x, v1y}]

If we were using the derivative of the position a lot, we could also just define a new equation like vel = D[pos, t]. I also switched the definition of position here. From a physics perspective, I don't think the original definition is quite right. It gets the same answer, but a double indefinite integral should have two unknowns (initial velocity and initial position, here). When using the double integral, we're really solving the differential equation r''[t] == a and integrating both sides twice to get r[t] = 1/2 a t^2 + v0 t + r0, so we don't need the definition to contain 3 separate parts.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.