How to find the distances between two adjacent maxima in a solution from NDSolve

I try to find a general approach to plot the time evolution of horizontal distances from maximum to maximum in a solution of PDE. The solution u[x,t] normally have multiple maximum and minimum in space x, which move in space x and evolve in time t.

Here is a simple example, in which the maxima and minima are periodic. But in my real problem they are not periodic and the distances between different pairs of adjacent max are different at a given t, also the distances between two adjacent max can change with t.

sol = NDSolve[{D[u[x, t], t] + u[x, t] D[u[x, t], x] + D[u[x, t], x, x] +  0.4*D[u[x, t], {x, 3}] + D[u[x, t], {x, 4}] == 0, u[-4 \[Pi], t] == u[4 \[Pi], t], u[x, 0] == 0.1*Sin[x]}, u, {t, 0, 20}, {x, -4 \[Pi], 4 \[Pi]}]  Plot3D[Evaluate[u[x, t] /. First[sol]], {t, 0, 10}, {x, -4 Pi, 4 Pi}, PlotRange -> All, PlotPoints -> 100] 

enter image description here

I have tried to use Table[FindMaximum[Evaluate[u[x, t] /. First[sol]], {x, x0}][[2, 1, 2]], {t,0,tend,0.01}] with an initial position x0 to find a local maximum. But I don’t know how to find two adjacent maxima simultaneously in order to plot the time evolution of their distance.

Calculating the maxima of a function subject to a constraint

The first figure below shows the plots of a function $ f(x)$ plotted for different values of a parameter $ \lambda$ , i.e., $ f(x)=f(x,\lambda=\lambda_i);i=1,2,3,..;\lambda$ is maximum for the topmost curve and decreases downwards. The second figure shows the values of $ \lambda$ that corresponds to the extrema.

Each curve has one maxima and one minima. The dotted curve corresponds to the case that has no maxima or minima, i.e., the value of $ \lambda$ corresponding to the dotted curve is the threshold for existence of any extrema.

Note that figure-1 is obtained from particle dynamics where we have an expression for $ f(x)$ and we can obtain figure-2 by calculating the extreme values. However, in hydrodynamics we can only obtain figure-2 which matches exactly with that of particle dynamics. In this sense, figure-2 is the same for particle dynamics as well as hydrodynamics.

Figure 1 Figure 2

The following are my goals:

  • To find the threshold value of $ \lambda$ (corresponding to the black dotted curve): This I had already calculated by finding the minima of the $ \lambda-x$ curve.
  • To find the value of $ \lambda$ for which $ f(x)=1$ (corresponding to the black solid curve): Since all the points on the $ \lambda-x$ curve corresponds to extremum, I do not have any idea about how to use the constraint $ f(x)=1$ as the expression for $ f(x)$ is not available.

Additional details and useful hints:

  • In figure-1, all the curves saturates at $ f(x)=1$ at large values of $ x$ . So the constraint $ f(x)=1$ is satisfied for the black(solid) curve as seen in the figure at $ x=2.91$ and also for all the curves at large $ x$ . So I think that the asymptotic behaviour of $ f(x)$ might be related to the values of $ \lambda$ .

  • In figure-2, initially $ \lambda$ decreases steeply with $ x$ and after the minima, $ \lambda$ varies as $ \lambda=\sqrt x$ .

Any hint about the approach to solve the problem would be sufficient.

Find all local maxima in a one-dimensional array

I implemented the following class (it works) and I just want to hear your opinions about best practices and what can be improved. The idea was to do it using mostly arrays.

The class just finds the peak elements in an array with respect to their neighbors. The first element and the last element are ignored.

Example: {3, 15, 5, 20, 10} Answer: {15, 20}

package findpeak;  import java.util.ArrayList; import java.util.List;   public class ArrayPeak {     private final int[] ARRAY;     private final int LEN;     private static final int IGNORE_FIRST_POSITION = 0;     private final int IGNORE_LAST_POSITION;      public ArrayPeak(int[] array)     {         this.ARRAY = array;         this.LEN = this.ARRAY.length;         this.IGNORE_LAST_POSITION = this.LEN - 1;     }      public List<Integer> findPeaks()     {         List<Integer> peaks = new ArrayList<>();         for (int position = 0; position < LEN; position++)         {             int output = 0;             if (position != IGNORE_FIRST_POSITION && position != IGNORE_LAST_POSITION)             {                 int[] trippleArray =                 {                     ARRAY[position - 1], ARRAY[position], ARRAY[position + 1]                 };                 output = checkPeak(trippleArray);             }             peaks.add(output);         }          return filterZeros(peaks);     }      private static int checkPeak(int[] inputArray)     {         int peak = 0;         if (inputArray[1] > inputArray[0] && inputArray[1] > inputArray[2])         {             peak = inputArray[1];         }         return peak;     }      private static List<Integer> filterZeros(List<Integer> list)     {         List<Integer> filteredList = new ArrayList<>();         for (int i = 0; i < list.size(); i++)         {             if (list.get(i) != 0)             {                 filteredList.add(list.get(i));             }         }         return filteredList;     } }  

Maxima of Brownian motion

It is well-known that Brownian motion attains infinitely many maxima in each time interval $ [0,T]$ a.s..

From a physics perspective it seems reasonable that when the disorder of the path of a particle decreases and the motion becomes more deterministic, then the number of maxima should decrease.

But I could not find anything on that. Now, there were two natural things to look at:

Is there a way to quantify that a Brownian motion with large variance (large disorder) has more maxima than one with little disorder?

Or is there a way to say that a diffusion process

$ dX_t = \mu (X_t) \ dt + \alpha dB_t $

has “less” maxima when $ \alpha $ is small compared to $ \alpha$ large?

I guess it is hard to make this question more precise, since this is not a question of cardinality of maxima but more about finding a suitably chosen measure that could capture such an effect.

About maxima of injective holomorphic maps on $\mathbb{C}^n$

I am hoping the following is true. Mention of related ideas/topics are appreciated.

Suppose $ F:\mathbb{C}^n \to \mathbb{C}^n$ is a injective holomorphic mapping such that $ F(0)=0$ and $ dF(0) = I_n$ where $ I_n$ is the $ n \times n$ identity matrix. Let $ \partial B$ denote the boundary of the unit ball centered at the origin in $ \mathbb{C}^n$ . Let $ M = \sup_{x \in \partial B} ||F(x)||$ where $ || \cdot ||$ is the usual Euclidean norm. Then $ \partial B \cap \{x: M = ||F(x)|| \}$ is equal to one of three things: i) $ \{p\}$ for some point $ p$ , ii) $ \{\alpha p : |\alpha|=1 \}$ for some point $ p$ , iii) $ \partial B$

Rademacher, maxima, convex hulls

Let $ F\subset \mathbb{R}^n$ be a finite set and $ \sigma$ be uniformly distributed over $ \{-1,1\}^n$ . The usual Rademacher average of $ F$ (modulo normalizing factors) is $ $ R_n(F)=\mathbb{E}_\sigma \max_{f\in F}\sum_{i=1}^n \sigma_if_i. $ $ Now let us define two operations on $ F$ : $ \mathrm{conv}(F)$ and $ [F]_\vee$ . The former is just the convex hull of the vector-set $ F$ in $ \mathbb{R}^n$ . The latter is defined by $ $ [F]_\vee=\{ f\vee g :f,g \in F\}, $ $ where $ (f\vee g)_i=\max\{f_i,g_i\}$ is the coordinate-wise maximum.

Question: is it true that $ $ R_n( [\mathrm{conv}(F)]_\vee) \le R_n( [F]_\vee) $ $ ?

On sums of minima and maxima

Let $ h_1,\ldots,h_n$ be positive integers, and define $ $ m(h_1,\ldots,h_n)=\sum_{r_1=0}^{h_1-1}\ldots\sum_{r_n=0}^{h_n-1}\min\left\{\frac{r_1}{h_1},\ldots,\frac{r_n}{h_n}\right\}$ $ and $ $ M(h_1,\ldots,h_n)=\sum_{r_1=0}^{h_1-1}\ldots\sum_{r_n=0}^{h_n-1}\max\left\{\frac{r_1}{h_1},\ldots,\frac{r_n}{h_n}\right\}.$ $ Motivated by Dedekind sums, I introduced $ m(h_1,\ldots,h_n)$ and $ M(h_1,\ldots,h_n)$ in my paper in Discrete Math. 257(2002), 143-159, and determined their exact values for $ n\le 3$ in that paper. For example, I showed that if $ h,k,l$ are positive integers then \begin{align} m(h,k,l)=&\frac{hkl}4-\frac{hk+hl+kl}6+\frac{h+k+l-1}8 \&+\frac{h+k-2hk}{24l}+\frac{h+l-2hl}{24k}+\frac{k+l-2kl}{24h} \&+\frac{(h-1)(k,l)^2}{24kl}+\frac{(k-1)(h,l)^2}{24hl}+\frac{(l-1)(h,k)^2}{24hk}, \end{align} where $ (a,b)$ denotes the greatest common divisor of integers $ a$ and $ b$ .

QUESTION. Are $ m(h_1,\ldots,h_n)$ and $ M(h_1,\ldots,h_n)$ rational functions in $ h_1,\ldots,h_n$ whenever $ h_1,\ldots,h_n$ are pairwise coprime?

I conjectured that this question has a positive answer in the mentioned 2002 paper of mine.

Any ideas towards the solution? Your comments are welcome!

Local maxima 3D array python

Hi I’m trying to find local maxima in a 3D numpy array, but I can’t seem to find a easy way to do that using numpy, scipy, or anything else.

For now I implemented it using scipy.signal.argrelexrema. But it’s very long to process large arrays, and only works on separated axis.

import numpy as np from scipy.signal import argrelextrema   def local_maxima_3D(data, order=1):     """Detects local maxima in a 3D array      Parameters     ---------     data : 3d ndarray     order : int         How many points on each side to use for the comparison      Returns     -------     coordinates : ndarray         coordinates of the local maxima     values : ndarray         values of the local maxima     """     # Coordinates of local maxima along each axis     peaks0 = np.array(argrelextrema(data, np.greater, axis=0, order=order))     peaks1 = np.array(argrelextrema(data, np.greater, axis=1, order=order))     peaks2 = np.array(argrelextrema(data, np.greater, axis=2, order=order))      # Stack all coordinates     stacked = np.vstack((peaks0.transpose(), peaks1.transpose(),                          peaks2.transpose()))      # We keep coordinates that appear three times (once for each axis)     elements, counts = np.unique(stacked, axis=0, return_counts=True)     coords = elements[np.where(counts == 3)[0]]      # Compute values at filtered coordinates     values = data[coords[:, 0], coords[:, 1], coords[:, 2]]      return coords, values 

I know this solution is far from optimal and only works with order=1. Is there any better way to find local maxima in a 3D array in python ?

Finding maxima of a function $f(x) = \sqrt{x} – 2x^2$ without calculus

My question is how to prove that $ f(x) = \sqrt x – 2x^2$ has its maximum at point $ x_0 = \frac{1}{4}$

It is easy to do that by finding its derivative and setting it to be zero (this is how I got $ x_0 = \frac{1}{4}$ ). But the task is to do that without using any calculus tools and I`m stuck at it.

My idea was to introduce $ t = \sqrt x$ to get $ f(t) = t – 2t^4$ and then find its maximum because I know how to do that with parabola which can be transformed to $ a(x-x_0)^2 + y_0$ . So I was trying to turn $ f(t) = t – 2t^4$ into $ f(t) = a(x-x_0)^4 + y_0$ but it seems impossible.

My second thought was to use the definition of rising function on an interval so I supposed we have $ a, b \in \left(0; \frac{1}{4}\right) \text{and } a < b$ . Then I prove that $ $ \sqrt a – 2a^2 < \sqrt b – 2b^2$ $ $ $ 2(b – a)(a + b) < \sqrt b – \sqrt a$ $ $ $ 2(\sqrt a + \sqrt b)(a + b) < 1$ $ which is true since $ 0 < a < b < \frac{1}{4}$

Exactly the same way I prove that for every $ a, b \in \left(\frac{1}{4}; +\infty\right) \text{and } a < b$ $ $ \sqrt a – 2a^2 > \sqrt b – 2b^2$ $

So we have that $ f(x)$ is rising on $ \left(0; \frac{1}{4}\right)$ and declining on $ \left(\frac{1}{4}; +\infty\right)$ , consequently at $ \frac{1}{4}$ we have a maximum of $ f$

But I guess it is not fair to use derivatives to find the maximum and then simply prove that this value is correct. Is there an even better solution? What are your thoughts about my proof?