# Mathematica: Find Maximum Value of Interpolating Function

• Mathematica
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];

Dale
Mentor
2020 Award
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]

That works great, thanks. Just the [[1]] at the end of fitz1[[1]] I was missing. That seems to be the way with Mathematica!

Dale
Mentor
2020 Award
Without the [[1]] you wind up with one to many layers of {}.