I am finding the minima of a 2D cubic periodic function by "brute force", i.e. looking for the (x,y) positions where the both the x and y derivatives are 0.

This returns a list of points, in this case regularly spaced by 1 in both x and y:

enter image description here

Can I give Mathematica this list of 2D points, for it to generate an equation whose solution are these points?

In this case, for example, I would like Mathematica to tell me that my points are the solutions to (x,y) = (n,m) with n, m in the positive/negative integers.

I am asking this becaue I have a quasi-periodic function, and would like to know whether the location of its minima follows an equation, maybe involving an irrational number.

Example code:

RealPotentialCubic[x_, y_] := Sin[ \[Pi] x]^2  + Sin[ \[Pi] y]^2;
Plot3D[RealPotentialCubic[x, y], {x, -2.5, 2.5}, {y, -2.5, 2.5}, 
 PlotRange -> Full]
{RealMiniCubic, RealMinimaCubic, RealcurvMiniCubic, RealMaxiCubic, 
   RealMaximaCubic, RealcurvMaxiCubic} = 
  FindExtrema[RealPotentialCubic, 10, 20];

where the function to find the minima is defined as:

FindExtrema[potential_, windowsize_, points_] := 
 Module[{dx, dy, hl, x, y, hes, crit, mnp, mxp, sdp, mini, maxi, 
   sadl}, {dx[x_, y_], dy[x_, y_]} = D[potential[x, y], {{x, y}}];
  hes[x_, y_] = D[potential[x, y], {{x, y}, 2}];
  crit = Cases[
      dx[x, y] == 0, {x, -windowsize/2, 
       windowsize/2}, {y, -(windowsize/2), windowsize/2}, 
      PlotPoints -> points, ContourStyle -> None, Mesh -> {{0}}, 
      MeshFunctions -> Function[{x, y, z}, dy[x, y]]]], 
    Point[{x0_, y0_}] :> ({\[FormalX], \[FormalY]} /. 
       FindRoot[{dx[\[FormalX], \[FormalY]], 
         dy[\[FormalX], \[FormalY]]}, {{\[FormalX], x0}, {\[FormalY], 
          y0}}]), \[Infinity]];
  hl = hes @@@ crit;
  mnp = PositiveDefiniteMatrixQ /@ hl;
  mxp = PositiveDefiniteMatrixQ /@ (-hl);
  sdp = Thread[mnp \[Nor] mxp];
  mini = Pick[crit, mnp];
  maxi = Pick[crit, mxp];
  sadl = Pick[crit, sdp];
  Chop[{mini, potential @@@ mini, hes @@@ mini, maxi, 
    potential @@@ maxi, hes @@@ maxi}]]
  • $\begingroup$ Well, your equation is setting the derivative to zero. The solution of this equation are your points. $\endgroup$ – kiara May 20 '18 at 15:21
RealPotentialCubic[x_, y_] := Sin[π x]^2 + Sin[π y]^2;

The minima occur at

Assuming[Element[{C[1], C[2]}, Integers],
     D[RealPotentialCubic[x, y], x] == 0,
     D[RealPotentialCubic[x, y], y] == 0,
     D[RealPotentialCubic[x, y], {x, 2}] > 0,
     D[RealPotentialCubic[x, y], {y, 2}] > 0},
    {x, y}, Reals] // Simplify] /. {C[1] -> n, C[2] -> m}

(* {{x -> 2 n, y -> 2 m}, {x -> 2 n, y -> 1 + 2 m}, {x -> 1 + 2 n, 
  y -> 2 m}, {x -> 1 + 2 n, y -> 1 + 2 m}} *)

This states that either both x and y are even, both x and y are odd, or one is even and the other is odd. This covers all possible integer pairs.

  • $\begingroup$ Thanks. Is there any way I can just give Mathematica the list of points ( a list of x,y) and it spits out a relation among themselves? $\endgroup$ – SuperCiocia May 20 '18 at 18:36
  • $\begingroup$ Like, if I gave then (-4, 0), (-3,0) ...(0,0) ... (0,2), (0,3), (0,4), could it tell me just <code> x-> 2n, y-> 0 </code>. $\endgroup$ – SuperCiocia May 20 '18 at 18:37
  • $\begingroup$ Basically I have only access to the minima positions, not the original function. $\endgroup$ – SuperCiocia May 20 '18 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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