1

I used ContourPlot to plot the graph of x Sin[Pi y] - y Cos[Pi x] == 1 with the following input:

eqn[x_, y_] := (x Sin[Pi y] - y Cos[Pi x] )== 1
ContourPlot[Evaluate[eqn[x, y]], {x, 0, Pi}, {y, 0, Pi}]

To find $dy/dx$ I used the following code:

yprimeEq = D[eqn[x, y[x]], x];
sol = Solve[yprimeEq, y'[x]] // Simplify;
dydx = y'[x] /. First[sol] /. y[x] -> y;

I am stuck on finding the slope of the tangent line to the graph at $(2/3,2)$. I know I have to just plug in $2/3$ for $x$ and $2$ for $y$ but I don't know how to write it in Mathematica.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
ppkjref
  • 51
  • 1
  • 5

2 Answers2

2

Differentiate your equation :

exp00= Dt /@ (x Sin[Pi y] - y Cos[Pi x] == 1) 

 (* -Cos[π x] Dt[y] + π x Cos[π y] Dt[y] + π y Dt[
   x] Sin[π x] + Dt[x] Sin[π y]==0 *)

( = $-\text{Cos}[\pi x] \text{Dt}[y]+\pi x \text{Cos}[\pi y] \text{Dt}[y]+\pi y \text{Dt}[x] \text{Sin}[\pi x]+\text{Dt}[x] \text{Sin}[\pi y]==0$)

replace Dt[x] by for example dx, idem for y

 exp01 = exp00 /. {Dt[y] -> dy, Dt[x] -> dx}  

(* -dy Cos[π x] + dy π x Cos[π y] + dx π y Sin[π x] +
   dx Sin[π y] == 0 *)

( = $-\text{dy} \text{Cos}[\pi x]+\text{dy} \pi x \text{Cos}[\pi y]+\text{dx} \pi y \text{Sin}[\pi x]+\text{dx} \text{Sin}[\pi y]==0$)

The reason for doing this is that if we gives yet numerical values to x and y, Dt[x] and Dt[y] will become null (may be useless here, as we give values at the very end).

Solve dy function of dx :

derivative00=dy/dx /. Solve[exp01 ,{dy}][[1]]

(* (-dx π y Sin[π x] - 
 dx Sin[π y])/(dx (-Cos[π x] + π x Cos[π y])) *)

( = $\frac{-\text{dx} \pi y \text{Sin}[\pi x]-\text{dx} \text{Sin}[\pi y]}{\text{dx} (-\text{Cos}[\pi x]+\pi x \text{Cos}[\pi y])}$)

Cancel dx which is common to numerator and denominator :

derivative01=Cancel[derivative00]

(* (π y Sin[π x] + Sin[π y])/(Cos[π x] - π x Cos[π y]) *)

( = $\frac{\pi y \text{Sin}[\pi x]+\text{Sin}[\pi y]}{\text{Cos}[\pi x]-\pi x \text{Cos}[\pi y]}$ )

Apply the numeric values :

derivative02=derivative01 /. {x -> 2/3, y -> 2}

resultat : (Sqrt[3] π)/(-(1/2) - (2 π)/3)

( = $\frac{\sqrt{3} \pi }{-\frac{1}{2}-\frac{2 \pi }{3}}$)

verification :

ContourPlot[Evaluate[eqn[x, y]], {x, 0, Pi}, {y, 0, Pi},
 Epilog -> {
   PointSize[0.03],
   Point[{2/3, 2}],
   Text[Style["{2/3,2}", FontSize -> 12], {2/3, 2}, {1, 1.5}],
   Line[{{2/3 - 1, 
      2 - (Sqrt[3] π)/(-(1/2) - (2 π)/3)}, {2/3 + 1, 
      2 + (Sqrt[3] π)/(-(1/2) - (2 π)/3)}}]
   }]

enter image description here

LCarvalho
  • 9,233
  • 4
  • 40
  • 96
andre314
  • 18,474
  • 1
  • 36
  • 69
1

Just change the last command to

dydx[x_, y_] = (y'[x] /. First[sol] /. y[x] -> y);
Spawn1701D
  • 1,871
  • 13
  • 14