Group Abstract Group Abstract

Message Boards Message Boards

0
|
102 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Determining whether a line is tangent to a curve

Posted 3 days ago

The equations of the line and the curve are as follows:

line = 2 x - 1
eq = Sin[x + 2 y] == 2 x - y;

I solved the problem using the following Mathematica code—does anyone have a better (or simply different) approach?

F[x_, y_] := Sin[x + 2 y] - 2 x + y;
dydx[x_, y_] = -D[F[x, y], x]/D[F[x, y], y] // Simplify
eqs = {F[x, y] == 0, dydx[x, y] == 2  };
sol = NSolve[eqs, {x, y}, Reals]
POSTED BY: Wen Dao
2 Replies

Set up:

  • equations for the points of intersection
  • differential equations for tangency
  • Dt[x] != 0 so that dy/dx is defined

Code:

line = y == 2 x - 1;
curve = Sin[x + 2 y] == 2 x - y;
tangentSystem = Flatten[
   {#,     (* equations *)
    Dt@#,  (* differentials *)
    Dt[x] != 0}] &@ {line, curve}
Reduce[tangentSystem, 
   {Dt[x], Dt[y]}] (* if solution(s), then tangent;
                      if False, then not tangent;
                      if Reduce[...], then the problem has not been solved *)
tangentPoints = {x, y} /. Solve[ (* bound to find explicit solutions *)
   Flatten[{tangentSystem, -10 < y < 10, -10 < x < 10}],
   {Dt[x], Dt[y], x, y}]
POSTED BY: Michael Rogers

I assume that your line has equation y == 2 x - 1. You have forgotten to include the equation of the line into your eqs, which brings spurious points:

ContourPlot[{Sin[x + 2 y] - 2 x + y == 0, y == 2 x - 1},
 {x, -2, 10}, {y, -2, 10},
 Epilog -> {PointSize[Large],
   Point[NSolveValues[Append[eqs, 0 < x < Pi], {x, y}, Reals]]}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard