Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Extr = {x /. #, y /. #} &;
- Att =
- Extr[
- NMinimize[{(x - #[[1]])^2 + (y - #[[2]])^2, x - x^3 + y^2 == 0}, {x, y}, AccuracyGoal -> 10, PrecisionGoal -> 8][[2]]] &;
- DynamicModule[{loc1 = {0, 0}, pt1 = {0, 0}, pt2 = {1, 0}, loc2 = {1, 0}, pt3= {-1, 0}},
- {
- LocatorPane[Dynamic[{loc1, loc2}],
- ContourPlot[{y^2 - x (x - 1) (x + 1) == 0}, {x, -2, 2}, {y, -2, 2},
- AxesLabel -> Automatic, ImageSize -> 600,
- Epilog -> {Red, PointSize[Large],
- Point[Dynamic[pt1 = Att[loc1]]],
- Green,
- Point[Dynamic[pt2 = Att[loc2]]],
- Yellow, Thick,
- Dynamic[InfiniteLine[{pt1, pt2}]]
- }
- ]
- ],
- Dynamic[{pt1, pt2, pt3}];
- }
- ]
- ecp = ContourPlot[y^2 == x (x - 1) (x + 1), {x, -2, 2}, {y, -2, 2}];
- ec = RegionNearest[ImplicitRegion[y^2 == x (x - 1) (x + 1), {{x, -2, 2}, {y, -2, 2}}]];
- DynamicModule[{pts = {{-1, 0}, {1, 0}, {0, 0}}},
- Panel[Row[{LocatorPane[Dynamic[pts, (pts =
- Block[{ip = ec /@ Most[#], sol},
- sol = {[FormalX], [FormalY]} /.
- NSolve[{[FormalY]^2 == [FormalX]
- ([FormalX] - 1) ([FormalX] + 1),
- [FormalY] ==
- InterpolatingPolynomial[ip, [FormalX]]},
- {[FormalX], [FormalY]}];
- Append[ip, First[Pick[sol, Normalize[Chop[Min /@
- DistanceMatrix[sol, ip], 1.*^-6], Max], 1.]]]];) &],
- Show[ecp,
- Graphics[{{Yellow, Thick, Dynamic[InfiniteLine[Most[pts]]]},
- {PointSize[Large],
- {Red, Dynamic[Point[pts[[1]]]]},
- {Green, Dynamic[Point[pts[[2]]]]}},
- {PointSize[Medium], Brown, Dynamic[Point[pts[[3]]]]}}],
- ImageSize -> Medium], Appearance -> None],
- Pane[Dynamic[Grid[Transpose[{{Style["Point 1:", Red, Large],
- Style["Point 2:", Green, Large],
- Style["Point 3:", Brown, Large]},
- Style[#, Large] & /@ pts}]]]]}]]]
- ecr = ImplicitRegion[y^2 == x (x - 1) (x + 1), {{x, -2, 2}, {y, -2, 2}}];
- BlockRandom[SeedRandom["elliptic"]; (* for reproducibility *)
- (* Quiet suppresses a few harmless error messages *)
- {p1, p2} = Quiet[RandomPoint[ecr, 2]];]
- p3 = Chop[EllipticExp[EllipticLog[p1, {0, -1}] + EllipticLog[p2, {0, -1}], {0, -1}]];
- ContourPlot[y^2 == x (x - 1) (x + 1), {x, -2, 2}, {y, -2, 2},
- Epilog -> {{Orange, {Thick, InfiniteLine[{p1, p2}]},
- {Dashed, Line[{{1, -1} p3, p3}]}},
- {PointSize[Large], {Red, Point[p1]}, {Green, Point[p2]}},
- {PointSize[Medium], Brown, Point[p3]}}]
- Chop[Det[PadRight[{p1, p2, {1, -1} p3}, {3, 3}, 1]]]
- 0
- ecp = ContourPlot[y^2 == x (x - 1) (x + 1), {x, -2, 2}, {y, -2, 2}];
- ec = RegionNearest[ImplicitRegion[y^2 == x (x - 1) (x + 1), {{x, -2, 2}, {y, -2, 2}}]];
- DynamicModule[{pts = {{-1, 0}, {1, 0}, {0, 0}}},
- Panel[Row[{LocatorPane[Dynamic[pts, (pts =
- Block[{ip = ec /@ Most[#], sol},
- sol = {[FormalX], [FormalY]} /.
- NSolve[{[FormalY]^2 == [FormalX]
- ([FormalX] - 1) ([FormalX] + 1),
- [FormalY] ==
- InterpolatingPolynomial[ip, [FormalX]]},
- {[FormalX], [FormalY]}];
- Append[ip, First[Complement[sol, ip, SameTest->(Norm[#1-#2]<1*^-5&)]]]];) &],
- Show[ecp,
- Graphics[{{Yellow, Thick, Dynamic[InfiniteLine[Most[pts]]]},
- {PointSize[Large],
- {Red, Dynamic[Point[pts[[1]]]]},
- {Green, Dynamic[Point[pts[[2]]]]}},
- {PointSize[Medium], Brown, Dynamic[Point[pts[[3]]]]}}],
- ImageSize -> Medium], Appearance -> None],
- Pane[Dynamic[Grid[Transpose[{{Style["Point 1:", Red, Large],
- Style["Point 2:", Green, Large],
- Style["Point 3:", Brown, Large]},
- Style[#, Large] & /@ pts}]]]]}]]]
Add Comment
Please, Sign In to add comment