Mathematica: Find Maximum Value of Interpolating Function

Click For Summary

Discussion Overview

The discussion revolves around finding the maximum value of an interpolating function in Mathematica, specifically within the context of Fitzhugh-Nagumo dynamics. Participants share their approaches and solutions related to this computational problem.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant expresses difficulty in using MaxValue to find the maximum of the w2 variable from an interpolating function, seeking assistance.
  • Another participant suggests using MaxValue with the correct syntax, indicating that it works for them.
  • A third participant mentions a preference for FindMaximum, providing an alternative method to achieve the same goal.
  • There is a clarification regarding the need for indexing into the interpolating function, as one participant notes the importance of the [[1]] to avoid errors in the function structure.

Areas of Agreement / Disagreement

Participants generally agree on the methods to find the maximum value, with some preferring different functions (MaxValue vs. FindMaximum). The discussion does not indicate any unresolved disagreements.

Contextual Notes

Participants highlight the importance of proper syntax and indexing when working with interpolating functions in Mathematica, which may affect the outcome of their calculations.

Who May Find This Useful

This discussion may be useful for Mathematica users, particularly those working on problems related to dynamical systems or seeking to understand the nuances of using interpolating functions in their computations.

musicgirl
Messages
12
Reaction score
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
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!
 
Without the [[1]] you wind up with one to many layers of {}.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
7K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 15 ·
Replies
15
Views
4K
  • · Replies 8 ·
Replies
8
Views
22K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
9
Views
2K