Can you make the code for tangent line and normal line of implicit algebraic curve cu
more concise than mine?
The code for tangent line at {x,y}={8,7}
is:
D[cu, {{x, y}}] . {a - x, b - y} /. {x -> 8, y -> 7} /. {a -> x, b -> y} // Expand
The code for normal line at {x,y}={8,7}
is:
D[cu, {{y, x}}] . {a - x, -b + y} /. {x -> 8, y -> 7} /. {a -> x, b -> y} // Expand
What I do not like about my code is that it uses two Rule
's and two temporary and meaningless variables a, b
.
cu = 3 x^2 + 5 y^2 - 7 x y + 2 x - 9 y + 2;
cu == 0 /. {x -> 8, y -> 7}
D[cu, {{x, y}}] . {a - x, b - y} /. {x -> 8, y -> 7} /. {a -> x,
b -> y} // Expand
D[cu, {{y, x}}] . {a - x, -b + y} /. {x -> 8, y -> 7} /. {a -> x,
b -> y} // Expand
ContourPlot[{cu == 0, %% == 0, % == 0}, {x, -2, 10}, {y, 0, 8},
Epilog -> {Point[{8, 7}]}, AspectRatio -> Automatic]
Clear[cu]
(* True *)
(* -43 + x + 5 y *)
(* -33 + 5 x - y *)
{x,y}
is on the curvecu
and{X,Y}
is on the tangen line.D[cu, {{x, y}}] . ({X, Y} - {x, y}) /. {x -> 8, y -> 7} // Expand
$\endgroup$X, Y
which you have to replace by another rule to have it in desiredx, y
variables. $\endgroup$Y==((f[x]-f[x0])/(x-x0))*(X-x0)+f[x0]
to express a line which passes through the point{x0,f[x0]}
and{x,f[x]}
.{x,y}
is on the curve{x,f[x]}
and{X,Y}
is on the line. $\endgroup$