Mathematica: Find Maximum Value of Interpolating Function

In summary, the person is seeking help in finding the maximum value of the w2 variable in a Fitzhugh-Nagumo dynamics problem using Mathematica. They have tried using MaxValue and FindMaximum, but initially were missing the [[1]] at the end of the fitz1 variable. With that addition, the solution works correctly.
  • #1
musicgirl
12
0
Hi everyone,

I'm pretty new to Mathematica, and I'm trying to find the maximum value of an interpolating function.

I'm looking at Fitzhugh-Nagumo dynamics and below is what I have so far. My 'fitz1' gives me 4 variables each described as an Interpolating Function, and I would like to find the maximum value of the w2 variable. I've tried all variations on maxw = MaxValue[{Evaluate[w2/.fitz1]},w2] that I can think of, but I haven't been able to come up with a solution yet. I would be grateful for any ideas you have!


A = 1;
\[Epsilon] = 0.5;
\[Alpha] = 2;
\[Gamma] = 0.2;
v0 = 0.1;
w0 = 0.1;
T = 20;
K = 2;
kick = 1;

initial = Solve[wi == A*vi*(vi-\[Alpha])*(1-vi)-w0 && wi == (vi-v0)/\[Gamma], {vi,wi}, Reals];

fitz1 = NDSolve[{v1'[t]==((A*v1[t]*(v1[t]-\[Alpha])*(1-v1[t])-w1[t]-w0)/\[Epsilon])+(K*(v2[t]-v1[t])), v2'[t]==((A*v2[t]*(v2[t]-\[Alpha])*(1-v2[t])-w2[t]-w0)/\[Epsilon])+(K*(v1[t]-v2[t])), w1'[t]==v1[t]-\[Gamma]*w1[t]-v0, w2'[t]==v2[t]-\[Gamma]*w2[t]-v0, v1[0]==kick+vi/.initial, v2[0]==vi/.initial, w1[0]==wi/.initial, w2[0]==wi/.initial}, {v1,v2,w1,w2},{t,0,T},MaxSteps->10000];
 
Physics news on Phys.org
  • #2
MaxValue seems to work fine for me:
MaxValue[{w2[x] /. fitz1[[1]], 0 < x < 20}, x]

Although I prefer FindMaximum:
FindMaximum[{w2[x] /. fitz1[[1]], 0 < x < 20}, x]
 
  • #3
That works great, thanks. Just the [[1]] at the end of fitz1[[1]] I was missing. That seems to be the way with Mathematica!
 
  • #4
Without the [[1]] you wind up with one to many layers of {}.
 
  • #5



Hello there,

To find the maximum value of an interpolating function in Mathematica, you can use the "Maximize" function. Here's an example:

maxw = Maximize[{w2[t], t>=0, t<=T}, {t}]

This will give you the maximum value of w2 over the time interval from 0 to T. You can also specify additional constraints, such as t>=0 and t<=T, to narrow down the search for the maximum value.

I hope this helps, and good luck with your research!
 

1. How do I find the maximum value of an interpolating function in Mathematica?

To find the maximum value of an interpolating function in Mathematica, you can use the Maximize function. This function takes in the interpolating function as its argument and returns the maximum value along with the corresponding input value.

2. Can I specify a specific range to search for the maximum value in an interpolating function?

Yes, you can specify a specific range to search for the maximum value by using the option WorkingPrecision in the Maximize function. This allows you to narrow down the search to a specific interval.

3. What if my interpolating function has multiple local maximum values?

If your interpolating function has multiple local maximum values, the Maximize function will only return one of them. To find all the local maximum values, you can use the FindMaximum function with the option MaxIterations set to a higher value.

4. How can I plot the maximum value of an interpolating function on a graph?

You can use the MaxvaluePlot function in Mathematica to plot the maximum value of an interpolating function on a graph. This function takes in the interpolating function as its argument and plots the maximum value at each point along the x-axis.

5. Can I find the maximum value of a multidimensional interpolating function?

Yes, you can find the maximum value of a multidimensional interpolating function in Mathematica using the Maximize function. Simply specify the variables in the function and the range of values for each variable to search for the maximum value.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
6K
  • Introductory Physics Homework Help
Replies
5
Views
3K
  • Differential Equations
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
15
Views
4K
Back
Top