MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Labelling a plot with maximum

  • To: mathgroup at
  • Subject: [mg105179] Re: [mg105146] Labelling a plot with maximum
  • From: Bob Hanlon <hanlonr at>
  • Date: Mon, 23 Nov 2009 06:53:46 -0500 (EST)
  • Reply-to: hanlonr at

jinc[x_] := BesselJ[1, 2 *Pi* x]/(2 *Pi* x);

Since you are working with Real functions, you do not need the Abs

f[x_, d_] := 4 (jinc[x + d] - jinc[x - d])^2;

The global maximum is

gmax = NMaximize[f[x, d], {x, d}]


gPts = {{gmax[[2, 1, 2]], gmax[[1]]},
   {-gmax[[2, 1, 2]], gmax[[1]]}};

Module[{nmax, pts},
  nmax = NMaximize[f[x, d], x];
  pts = {{nmax[[2, 1, 2]], nmax[[1]]},
    {-nmax[[2, 1, 2]], nmax[[1]]}};
  Plot[f[x, d], {x, -1.22, 1.22},
   PlotRange -> {{-0.5, 0.5}, {0, 1.5}},
   Epilog -> {
     Text[NumberForm[nmax, {4, 3}],
      {-0.5, 1.5}, {-1, 1}],
     Red, Point[gPts],
     Orange, Point[pts]}],
  {d, 0.125, 0.5, 0.005,
   Appearance -> "Labeled"}]]

I do not know how to export a movie.


---- Shalin Mehta <shalin.mehta at> wrote: 

Hi everyone,

 I am very new to Mathematica. I wish to prepare a figure and a movie
where the maximum of the plot is labelled on the figure.

I am using Manipulate to animate a function as shown below:

jinc[x_] := BesselJ[1, 2 \[Pi] x]/(2 \[Pi] x);
f[x_, \[CapitalDelta]_] :=
  4 Abs[jinc[x + \[CapitalDelta]] - jinc[x - \[CapitalDelta]]]^2;
 Plot[f[x, \[CapitalDelta]], {x, -1.22, 1.22},
  PlotRange -> {{-0.5, 0.5}, {0, 1.5}}], {\[CapitalDelta], 0.125,

I find the maximum for different values of Delta using:
 NMaximize[f[x, \[CapitalDelta]], x], {\[CapitalDelta], 0.125,

Can someone please help with a code that can print the result returned
by NMaximize on (say) top-left of the Plot generated by the first
Manipulate above? The plot will look  neat if I can place a marker at
the X-position of maximum.

Also, I wish to have a Motion-JPEG compressed quicktime mov file
exported from this manipulate. How can that be achieved?

thanks in advance for any help.

mobile: +65-90694182

Bioimaging Lab, Block-E3A, #7-10
Div of Bioengineering, NUS Singapore 117574

  • Prev by Date: Re: Setting global InputAutoReplacements
  • Next by Date: Re: Labelling a plot with maximum
  • Previous by thread: Re: Labelling a plot with maximum
  • Next by thread: Re: Labelling a plot with maximum