2
$\begingroup$

I'm trying to do part a) of this calculus 1 problem in Mathematica V9:

http://tutorial.math.lamar.edu/Classes/CalcI/RelatedRates.aspx#Deriv_Rates_Ex4

Warning noob code below!

st = 5/14 == r/h; (* 1. Similiar triangles to relate radius and height *)
radius = Solve[st, r][[1]]; (* 2. Get radius in terms of height *)
dr = Dt[radius]; (* 3. Get dr in terms of dh *)
dv = Dt[v == (1/3) r^2 h]; (* 4. Implicitly diff the volume of our leaky cone *)
dv /. { Dt[v] -> -2, dr[[1]], radius[[1]], h -> 6 } (* replace unknowns with knowns *)

My problem is in the last line above. There's still an h remaining. Why didn't it get replaced? If I could properly replace it, I can then take one more step and solve this related rates problem by solving for Dt[h].

$\endgroup$
1
  • $\begingroup$ BTW I'ts nice to see students trying to think out of the box $\endgroup$ Jan 25, 2013 at 7:09

1 Answer 1

5
$\begingroup$

We usually don't answer homework related problems directly, but you was almost there. Your code has three problems:

1) You forgot a factor Pi in the volume
2) Look at the "speed" replacement in the code below. It is needed because Dt[6] is ... zero
3) (and most important) you need to Solve for the speed

st = 5/14 == r/h;
radius = Solve[st, r][[1]];
dr = Dt[radius];
dv = Dt[v == (1/3) Pi r^2 h];
eq = dv /. {Dt[v] -> -2, dr[[1]], radius[[1]]} /. Dt[h] -> speed /. h -> 6

Solve[eq, speed]

-2 == (225 Pi speed)/49
{{speed -> -(98/(225 Pi))}}

Edit 1

If you care about code compactness:

con = 5/14 == r/h;
Solve[Dt[v == 1/3 Pi r^2 h] /.Solve[con, r] /.{Dt[h] -> s, h -> 6, Dt[v] -> -2}, s]

Edit 2

Regarding your original problem, to make your replacement for h you need to use ReplaceAllRepeated[] instead of ReplaceAll[] because

x /. {x -> y, y -> z}

y

but:

x //. {x -> y, y -> z}

z

but don't bother fixing it since it will fail because you'll find yourself calculating Dt[6], which as I already said, is zero.

$\endgroup$
4
  • $\begingroup$ Wow, your awesome; you went above and beyond my expectations, I love you. You answered the question, improved my PoC to a legit answer, showed me a more idiomatic concise way of solving problems such as these, and then you answered my original query even though I was actually asking more, and I didn't even realize it. $\endgroup$ Jan 25, 2013 at 8:13
  • $\begingroup$ @AdamDreaver Well, I have to confess: I'm green, I've blue feathers attached to my ears, and I don't speak, but growl. Do you still love me? $\endgroup$ Jan 25, 2013 at 8:30
  • $\begingroup$ @AdamDreaver And let me say that we need more curious students like you lurking on this site $\endgroup$ Jan 25, 2013 at 8:32
  • $\begingroup$ I'd still love you if were a rock; you're so amazing I could just make a multiple choice question and answer and I bet you would break symmetry and roll onto the right answer; that's how much you rock! $\endgroup$ Jan 25, 2013 at 8:40

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.