Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Here's a homework problem from the Coursera course Calculus: Single Variable by Robert Ghrist

Find the derivative $\frac{dy}{dx}$ from the equation $x \tan y - y^2 \ln x=4$

I wanted to check my work using Mathematica so I tried this:

Dt[x Tan[y] - y^2 Log[x] == 4];
% /. {Dt[y] -> dy, Dt[x] -> dx};
Reduce[{%, dy/dx == z}, z]

On my system (Mathematica 9, Windows 7), this computation seems to hang.

Does anyone have a suggestion on how to solve this?

Edit:

I'm also interested in why Reduce doesn't handle the problem well when used as above whereas Solve handles it just fine (see answers).

share|improve this question
add comment

3 Answers

up vote 7 down vote accepted

The command Dt accepts a second argument that specifies what symbol corresponds to the independent variable in the differentiation. In your case, that's x. The derivative you're looking for would then be written Dt[y, x].

So you just need to do this:

Solve[Dt[x Tan[y] - y^2 Log[x] == 4, x], Dt[y, x]]

(*
==> {{Dt[y, x] -> (y^2 - x Tan[y])/(
   x (-2 y Log[x] + x Sec[y]^2))}}
*)
share|improve this answer
    
Thank you Jens. –  dharmatech Aug 3 '13 at 23:38
add comment

You can also use D directly but define y as y[x] and solve for y'[x] as follows.

Solve[D[x Tan[y[x]] - y[x]^2 Log[x] == 4, x], y'[x]]
{{y'[x] -> (-x Tan[y[x]] + y[x]^2)/(
   x (x Sec[y[x]]^2 - 2 Log[x] y[x]))}}

And if you want the answer without the y[x] appearing you can use a replacement rule:

Solve[D[x Tan[y[x]] - y[x]^2 Log[x] == 4, x], y'[x]] /. y[x] -> y
{{y'[x] -> (y^2 - x Tan[y])/(
   x (-2 y Log[x] + x Sec[y]^2))}}
share|improve this answer
add comment

Just as you started:

 expr1 = Dt[x Tan[y] - y^2 Log[x] == 4]

(* -((y^2 Dt[x])/x) - 2 y Dt[y] Log[x] + x Dt[y] Sec[y]^2 + 
  Dt[x] Tan[y] == 0  *)

Divide the both parts by Dt[x]:

    expr2 = Map[Divide[#, Dt[x]] &, expr1] // Apart

(* (-y^2 Dt[x] - 2 x y Dt[y] Log[x] + x^2 Dt[y] Sec[y]^2)/(x Dt[x]) + Tan[y] == 0 *)

Replace Dt[y]/Dt[x] by z:

 expr3 = expr2 /. Dt[y] -> z*Dt[x] // Simplify

  (*  x z Sec[y]^2 + Tan[y] == (y (y + 2 x z Log[x]))/x *)

Now find z:

    Solve[expr3, z]

(*  {{z -> (y^2 - x Tan[y])/(x (-2 y Log[x] + x Sec[y]^2))}}  *)

Done.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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