# Finding maximum of 2D interpolating function as a function of one of the variables

I am solving a 2D PDE in space and time b(r,t) and would like to find the maximum value of b in space as a function of time t.

Using the solution for maximising a 1D interpolating function from here, I tried the following minimal working example, but it doesn't work:

largerad = 10;
tmax = 80;
b0 = 0.1;

pde = {D[b[r, t], t] == D[b[r, t], r, r] - b[r, t]};
ic = {b[r, 0] == b0};
bc = {Derivative[1, 0][b][largerad, t] == 0,
Derivative[1, 0][b][0, t] == 0};

zsolv = NDSolve[{pde, ic, bc}, {b}, {r, 0, largerad}, {t, 0, tmax},
MaxStepSize -> 0.01];

Nbins = 200;

mytableb =
Table[NMaximize[{ b[r, t] /. zsolv, 0 <= r <= rad}, r,
Method -> "SimulatedAnnealing"], {t, 0, tmax, tmax/Nbins}];


Does anyone have a suggestion for an alternative implementation that would give b_max(t) as a list of values?

Edit: I'm looking for a general solution, also for PDE's that are not exactly solvable using DSolve. I just gave this as a simple example.

• DSolve [{pde, ic, bc}, b , {r, 0, largerad}, {t, 0, tmax} ]  evaluates the exact solution {b -> Function[{r, t}, 0.1 2.71828^(-1. t)]}} which doesn't depend on r! Mar 29, 2022 at 16:54
• Thanks! However, I'm looking for a general solution, also for PDE's that are not exactly solvable using DSolve. I just gave this as a simple example. I clarified that in an edit. Mar 31, 2022 at 13:27
• In my comment I tried to emphasize that your example has no unique solution, that's why a numerical solution can't be found Mar 31, 2022 at 14:30

bval = b@"ValuesOnGrid" /. First@zsolv // Transpose; 