# Calculus 1 Related Rates -Total Derivative issues

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].

-
BTW I'ts nice to see students trying to think out of the box – Dr. belisarius Jan 25 '13 at 7:09

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;
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.

-
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. – Adam Dreaver Jan 25 '13 at 8:13
@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? – Dr. belisarius Jan 25 '13 at 8:30
@AdamDreaver And let me say that we need more curious students like you lurking on this site – Dr. belisarius Jan 25 '13 at 8:32
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! – Adam Dreaver Jan 25 '13 at 8:40