Guest User

Untitled

a guest
Jan 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. ContourPlot[ (x^2 + y^2 - 4) *( y - x^2 + 2 x - 1) == 0, {x, -4, 4}, {y, -4, 4} , ContourStyle -> {Thick, Magenta},
  2. GridLines -> Automatic]
  3.  
  4. fi = FindInstance[(x^2 + y^2 - 4) == 0 && (y - x^2 + 2 x - 1) ==
  5. 0, {x, y}, Reals, 2] // N
  6.  
  7. {*
  8. {x -> -0.399864, y -> 1.95962}, {x -> 1.85894, y -> 0.737785}
  9. *}
  10.  
  11. ContourPlot[(x^2 + y^2 - 4)*(y - x^2 + 2 x - 1) == 0, {x, -4,
  12. 4}, {y, -4, 4}, ContourStyle -> {Thick, Blue},
  13. GridLines -> Automatic,
  14. Epilog -> {Red, PointSize[Large], Point[{x, y}] /. fi}]
  15.  
  16. nsol = NSolve[{(x^2 + y^2 - 4) == 0, (y - x^2 + 2 x - 1) == 0}, {x,
  17. y}, Reals]
  18.  
  19. {*
  20. {x -> -0.399864, y -> 1.95962}, {x -> 1.85894, y -> 0.737785}
  21. *}
  22.  
  23. fi == nsol
  24. (*
  25. True
  26. *)
  27.  
  28. f[x_, y_] := (x^2 + y^2 - 4)
  29. g[x_, y_] := (y - x^2 + 2 x - 1)
  30.  
  31. pts = FindAllCrossings2D[{f[x, y], g[x, y]}, {x, -7/2, 4}, {y, -9/5,
  32. 21/5}, Method -> {"Newton", "StepControl" -> "LineSearch"},
  33. PlotPoints -> 85, WorkingPrecision -> 20] // Chop;
  34.  
  35. pl=ContourPlot[{f[x, y], g[x, y]}, {x, -7/2, 4}, {y, -9/5, 21/5},
  36. Contours -> {0}, ContourShading -> False,
  37. Epilog -> {AbsolutePointSize[6], Red, Point /@ pts}]
  38.  
  39. NSolve[{(x^2 + y^2 - 4) == 0, (y - x^2 + 2 x - 1) == 0}, {x,y}, Reals]
  40.  
  41. Show[pl,
  42. Graphics[{AbsolutePointSize[12], Purple,
  43. Point[{x, y}] /.
  44. NSolve[{(x^2 + y^2 - 4) == 0, (y - x^2 + 2 x - 1) == 0}, {x, y}, Reals]}]]
  45.  
  46. f[x_, y_] := (x^2 + y^2 - 4)
  47. g[x_, y_] := (y - x^2 + 2 x - 1)
  48.  
  49. ContourPlot[{f[x, y], g[x, y]}, {x, -7/2, 4}, {y, -9/5, 21/5},
  50. Contours -> {0}, ContourShading -> False, BaseStyle -> Thick,
  51. MeshFunctions -> {g[#, #2] - f[#, #2] &},
  52. Mesh -> {{{0, Directive[Red, PointSize[Large]]}}}]
  53.  
  54. Graphics`Mesh`MeshInit[];
  55. cp = ContourPlot[{f[x, y], g[x, y]}, {x, -7/2, 4}, {y, -9/5, 21/5},
  56. Contours -> {0}, ContourShading -> False, BaseStyle -> Thick];
  57.  
  58. Show[cp, Epilog -> {Red, PointSize[.03],
  59. Point[Graphics`Mesh`FindIntersections[Normal @ cp]]}]
Add Comment
Please, Sign In to add comment