Mathematica:how to plot a maximum point in a graph

Click For Summary

Discussion Overview

The discussion revolves around plotting a maximum point on a graph using Mathematica, specifically focusing on the function Sin[j] over the interval from 0 to Pi. Participants explore methods to automate the plotting of the maximum point without manually entering coordinates obtained from the FindMaximum function.

Discussion Character

  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant describes their initial approach using FindMaximum to determine the maximum point of Sin[j] and manually entering the coordinates for plotting.
  • Another participant suggests creating a test function with specific points to facilitate plotting while adjusting for graph scaling.
  • A different approach is proposed where the maximum point is directly extracted from the output of FindMaximum and used in ListPlot without manual entry.
  • Further, a participant inquires about dynamically using the y-coordinate from FindMaximum instead of a fixed value, seeking a method to automate this process.

Areas of Agreement / Disagreement

Participants present various methods and suggestions for plotting the maximum point, but there is no consensus on a single best approach. The discussion remains open with multiple competing views on how to achieve the desired outcome.

Contextual Notes

Some methods discussed depend on the specific output format of FindMaximum and may require adjustments based on the function being plotted or the desired appearance of the graph.

shafieza_garl
Messages
20
Reaction score
0
anyone can help me to plot a point.

Code:
 r = Plot[Sin[j], {j, 0, Pi}];
what i am doing is i use FindMaximum first to know the point of maximum.
Code:
FindMaximum[Sin[j], {j, Pi}]

then i manually key in the x,y coordinate from the search.

Code:
onedot = ListPlot[{{1.5707963267948966, 1}}, 
   PlotStyle -> {Hue[0.67], AbsolutePointSize[7]}];
Show[r, onedot]

is there any way i can plot the maximum point without key-in manually using the findmaximum point.
thanks
 
Physics news on Phys.org
shafieza_garl said:
anyone can help me to plot a point.

Code:
 r = Plot[Sin[j], {j, 0, Pi}];
what i am doing is i use FindMaximum first to know the point of maximum.
Code:
FindMaximum[Sin[j], {j, Pi}]

then i manually key in the x,y coordinate from the search.

Code:
onedot = ListPlot[{{1.5707963267948966, 1}}, 
   PlotStyle -> {Hue[0.67], AbsolutePointSize[7]}];
Show[r, onedot]

is there any way i can plot the maximum point without key-in manually using the findmaximum point.
thanks

One suggestion I have is to create a test function with {-1,0} {0,maxpoint} and {+1,0) and then plot that data like any other data. If you need to adjust scaling or if Mathematica produces a very narrow graph then make the non-max points larger in the respective directions.

If you need the point at its original position then just add the x coordinate to every x point in the dataset.
 
r = Plot[Sin[j], {j, 0, Pi}];
onedot = ListPlot[{j, 1} /. Rest[FindMaximum[Sin[j], {j, Pi}]], PlotStyle -> {Hue[0.67], AbsolutePointSize[7]}];
Show[r, onedot]
 
Bill Simpson said:
r = Plot[Sin[j], {j, 0, Pi}];
onedot = ListPlot[{j, 1} /. Rest[FindMaximum[Sin[j], {j, Pi}]], PlotStyle -> {Hue[0.67], AbsolutePointSize[7]}];
Show[r, onedot]

thanx 4 ur reply.1 more question. if i don't want to put value 1 by myself and i want the same as finding the j-value(using findmaximum).
Code:
onedot = ListPlot[{j, k} /. Rest[FindMaximum[Sin[j], {j, Pi}]],  PlotStyle -> {Hue[0.67], AbsolutePointSize[7]}];
is this possible to do?
thanks again.
 
r = Plot[Sin[j], {j, 0, Pi}];
onedot = ListPlot[{j, Sin[j]} /. Rest[FindMaximum[Sin[j], {j, Pi}]], \
PlotStyle -> {Hue[0.67], AbsolutePointSize[7]}];
Show[r, onedot]
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K