1

First of all I would like to apologize for the newbie question. I am just starting up with mathematica and I have 2 simple plots. What i want to do is have Mathematica automatically find the intersections, label them and show me the coordinates. I have searched this forum and there are a lot of similar questions, but they are too advanced for me. Can someone explain how i can do this the easiest way? this is what I have

2

1 Answer 1

2

Solve for equality. Get values for the points using replacement : points = {x, x^2} /. sol would work just as well. Offset the labels and set as text in epilog.

sol = Solve[x^2 == x + 2, x];
points = {x, x + 2} /. sol;
offset = Map[# + {0, 3} &, points];
Plot[{x^2, x + 2}, {x, -6, 6},
 Epilog -> {Thread[Text[points, offset]],
   Blue, PointSize[0.02], Point[points]}]

enter image description here

2
  • Thank you Chris! can you please explain what is happening after the EPILOG -> ...? after that i got lost. What is Thread?
    – Ray
    Jan 26, 2016 at 13:22
  • We have points = {{-1, 1}, {2, 4}} and offset = {{-1, 4}, {2, 7}} and for the labels we need {Text[{-1, 1}, {-1, 4}], Text[{2, 4}, {2, 7}]}, where the second pair of coordinates are for the label position. This can be done using Thread[Text[points, offset]] or MapThread[Text, {points, offset}]. See the documentation: Thread, MapThread, Epilog, Text. Jan 26, 2016 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.