Idiomatic use of Reduce in a physics problem
- To: mathgroup at smc.vnet.net
- Subject: [mg114670] Idiomatic use of Reduce in a physics problem
- From: Eduardo Cavazos <wayo.cavazos at gmail.com>
- Date: Sun, 12 Dec 2010 05:45:43 -0500 (EST)
Hello, Let's use Mathematica to solve a basic projectile motion problem. Yes, Mathematica is basically overkill for such a problem, but it does illustrate some Mathematica techniques. A home run is hit in such a way that the baseball just clears a wall 21.0 m high, located 130 m from home plate. The ball is hit at an angle of 35.0° to the horizon- tal, and air resistance is negligible. Find (a) the initial speed of the ball, (b) the time it takes the ball to reach the wall, and (c) the velocity components and the speed of the ball when it reaches the wall. (Assume the ball is hit at a height of 1.00 m above the ground.) This is problem 4.49 from Physics for Scientists and Engineers by Serway and Jewett. As usual, there are a bunch of ways to go about expressing the solution in Mathematica. Below is one way using Reduce and Notation (to provide something similar to traditional vector notation). My question is, is this idiomatic use of Mathematica? I'm a Mathematica beginner and I'm venturing into somewhat more esotetic features like Notation. My approach in the solution is to provide one big expression to Reduce such that all the answers "pop out" in one step. Why the Reduce chain at the end? Sometimes when using Reduce, I have to go through a trial and error discovery of which vars will yield a result such that the answers are not in terms of other variables. Chaining Reduce seems to be easier. If this is a bad idea, let me know. (Yeah, it looks a little sloppy, but it's so convenient. :-) Finally, I apologize for including the output in the complex looking Cell Expression format; plain old Copy/Paste didn't seem to work in this example. If you paste the expression below into Mathematica, it should look better. Thanks for any suggestions. Ed { Cell[BoxData[{ RowBox[{"<<", "Notation`"}], "\[IndentingNewLine]", RowBox[{"Notation", "[", RowBox[{ TemplateBox[{OverscriptBox["v_", "\[RightVector]"]}, "NotationTemplateTag"], " ", "\[DoubleLongLeftRightArrow]", " ", TemplateBox[{RowBox[{"{", RowBox[{ SubscriptBox["v_", "x"], ",", SubscriptBox["v_", "y"]}], "}"}]}, "NotationTemplateTag"]}], "]"}]}], "Input"], Cell[BoxData[{ RowBox[{ RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{ OverscriptBox[ SubscriptBox["v", "f"], "\[RightVector]"], "\[Equal]", RowBox[{ OverscriptBox[ SubscriptBox["v", "i"], "\[RightVector]"], "+", RowBox[{ OverscriptBox["a", "\[RightVector]"], "*", "t"}]}]}], ",", "\[IndentingNewLine]", RowBox[{ OverscriptBox[ SubscriptBox["r", "f"], "\[RightVector]"], "\[Equal]", RowBox[{ OverscriptBox[ SubscriptBox["r", "i"], "\[RightVector]"], "+", RowBox[{ OverscriptBox[ SubscriptBox["v", "i"], "\[RightVector]"], "*", "t"}], "+", RowBox[{ RowBox[{"1", "/", "2"}], "*", OverscriptBox["a", "\[RightVector]"], "*", SuperscriptBox["t", "2"]}]}]}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ OverscriptBox[ SubscriptBox["r", "i"], "\[RightVector]"], "\[Equal]", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ SubscriptBox[ SubscriptBox["v", "i"], "x"], ">", "0"}], ",", RowBox[{ SubscriptBox[ SubscriptBox["v", "i"], "y"], ">", "0"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"Tan", "[", RowBox[{"\[Theta]", " ", "Degree"}], "]"}], "\[Equal]", RowBox[{ SubscriptBox[ SubscriptBox["v", "i"], "y"], "/", SubscriptBox[ SubscriptBox["v", "i"], "x"]}]}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"\[Theta]", "\[Equal]", "35"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"t", ">", "0"}], ",", " ", RowBox[{ OverscriptBox["a", "\[RightVector]"], "\[Equal]", RowBox[{"{", RowBox[{"0", ",", RowBox[{"-", "9.8"}]}], "}"}]}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ OverscriptBox[ SubscriptBox["r", "f"], "\[RightVector]"], "\[Equal]", RowBox[{"{", RowBox[{"130", ",", "21"}], "}"}]}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ SubscriptBox[ SubscriptBox["v", "f"], "x"], "\[Equal]", SubscriptBox[ SubscriptBox["v", "i"], "x"]}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"initialSpeed", "\[Equal]", RowBox[{"Norm", "[", OverscriptBox[ SubscriptBox["v", "i"], "\[RightVector]"], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"finalSpeed", "\[Equal]", RowBox[{"Norm", "[", OverscriptBox[ SubscriptBox["v", "f"], "\[RightVector]"], "]"}]}]}], "\[IndentingNewLine]", "}"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Reduce", "[", "%", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Reduce", "[", "%", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{"Reduce", "[", "%", "]"}]}], "Input", CellChangeTimes->{{3.5011213954975023`*^9, 3.501121396167547*^9}, { 3.501121440011367*^9, 3.5011216827801943`*^9}, { 3.501121724501215*^9, 3.501121727215644*^9}, {3.501121802386731*^9, 3.5011219002852173`*^9}, {3.501121959426733*^9, 3.5011219697977962`*^9}, {3.501122004292712*^9, 3.501122017755189*^9}}] }