4
$\begingroup$

This question already has an answer here:

I'm pretty new to Mathematica. I'd like to show the intersection points in my graphic. These are my inputs:

f[y_] := -10 x^2 + 4000 x;
NSolve[f[y] == 144000, x];
Plot[{f[y], 144000}, {x, 0, 400}, PlotRange -> {0, 400000}]
$\endgroup$

marked as duplicate by Jason B., Yves Klett, MarcoB, Öskå, m_goldberg Dec 16 '15 at 0:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Does anyone know how to show on the plot (permanently and/or as tooltips) both the Letters and Values of the intersection points? Thanks again for your kind and qualified answers! puckie $\endgroup$ – puckie Dec 12 '15 at 23:46
6
$\begingroup$

Or, hitting this tiny nail with a sledge-hammer,

f[x_] := -10 x^2 + 4000 x;
Plot[{f[x], 144000}, {x, 0, 400}, PlotRange -> {0, 400000}, 
  MeshFunctions -> {f[#] - 144000 &}, Mesh -> {{0.}}, MeshStyle -> {Red, PointSize[0.02]}]

enter image description here

See the documentation page for MeshFunctions. It's the third example.

$\endgroup$
  • $\begingroup$ I don't consider this a sledgehammer at all. Everything's in the Plot[], without the need for an explicit equation-solving detour. $\endgroup$ – J. M. is away Dec 12 '15 at 9:33
  • $\begingroup$ Very simple and effective solution! Exactly what I needed as a beginner ;-) Many Thanks! $\endgroup$ – puckie Dec 12 '15 at 23:36
  • $\begingroup$ @Narasimham. What is your "simply perfect" in reference to? What is that code about? $\endgroup$ – march Dec 14 '15 at 7:00
  • $\begingroup$ It was a comment in a reply to my question in Mathematica." Surface MeshFunction with independently spaced parameters". It was commented here wrongly. Thanks for pointing out the misplaced comment. Apologies caused due to my error, shall be deleting it. $\endgroup$ – Narasimham Dec 15 '15 at 8:56
5
$\begingroup$
f[y_] := -10 y^2 + 4000 y;
sol = NSolve[f[x] == 144000, x];
Plot[{f[x], 144000}, {x, 0, 400}, PlotRange -> {0, 400000}, 
   Epilog -> {PointSize[Large], (Point[{x, f[x]}] /. sol)}]

enter image description here

$\endgroup$
4
$\begingroup$

With an adjustable threshold level using Manipulate. The Tooltip shows the exact values.

f[y_] := -10 y^2 + 4000 y;

Manipulate[
 Column[{
   (pts = Simplify[{x, f[x]} /. Solve[f[x] == t, x]]) // N,
   Plot[{f[x], t}, {x, 0, 400},
    Epilog -> {Red, PointSize[Large],
      Tooltip[Point[#], #] & /@ pts},
    ImageSize -> 360]}],
 {{t, 144000, "Threshold"}, 0, 400000, 2000,
  Appearance -> "Labeled"}]

enter image description here

$\endgroup$
  • $\begingroup$ Excellent solution! Best solution! I'll definitely use it in my plots. Thanks! $\endgroup$ – puckie Dec 12 '15 at 23:40
1
$\begingroup$
R1 = ParametricRegion[{x, -10 x^2 + 4000 x}, {{x, 0, 400}}];
R2 = ParametricRegion[{x, 144000}, {{x, 0, 400}}];

sol = Point[x /. Solve[x \[Element] R1 && x \[Element] R2, x]]

Point[{{40, 144000}, {360, 144000}}]

RegionPlot[{R1, R2},
 PlotRange -> {{0, 400}, {0, 400000}},
 Epilog -> {Red, PointSize[0.02], sol},
 AspectRatio -> 1/GoldenRatio]

enter image description here

$\endgroup$
  • $\begingroup$ This is a conceptually a good solution since it involves parametrization. I'll use it when I'll be able to understand it fully (such as the meaning of [Elements] and more...). Many thanks! $\endgroup$ – puckie Dec 12 '15 at 23:44

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