# Global maxima and minima for a multivariable function (brute-force search)

I have a function $$p(\theta,z,t)$$ defined at the end of this question. I am trying to do two things here:

1. Find the global maximum and the global minimum of $$p$$, for some specific values of $$a$$ and $$d$$, over all possible $$0 < \theta \le 2\pi$$, $$0 \le z \le 100$$ and $$2000 \ge t \ge 0$$.
2. Incorporate the method from 1 into nested loops with a brute-force method - to find the values of $$a$$ and $$d$$ which will give the greatest global maximum of $$p$$, and the smallest global minimum of $$p$$ over the ranges of $$\theta,z,t$$, looping over a numerical range such as $$-1\le a \le 1$$ and $$-1\le d \le 1$$.

$$a$$ and $$d$$ are non-zero. Here is what I have tried for task 1, trying e.g. $$a=1/200$$ and $$d=-1/200$$:

FindMaximum[{p,100 >= z >= 0 && 2000>=t>=0 && 0 <\[Theta]<=2*Pi && a==1/200 && d==-1/200} , {\[Theta],t,z}]
(* {8.34524*10^-7, {\[Theta] -> 2.60554, t -> 143.986, z -> 15.5302}} *)


However this provides an answer for a specific value of $$\theta,z,t$$ (local maximum) and not a global maximum over all the ranges of $$\theta,z,t$$.

I tried Maximize but that simply returns the same input that I provided.

Maximize[{p,100 >= z>= 0 && 2000>=t>=0 && 0 <\[Theta]<=2*Pi && a==1/200 && d==-1/200} , {a,d}]


Also, for task 2 I am thinking that maybe iterating over a sort of grid might work, but I am not sure how to approach this / proceed, since this would be a grid in 3 dimensions ($$\theta,z,t$$)?

P.S. This is a simpler component of an existing question with an open bounty and no answers yet.

And here is $$p$$, in case it matters. Thanks.

p = -(1/2) a E^(-2 d^2 t) (4 E^(
d^2 t) (E^(a z)
Cos[\[Theta]] Cos[
a Cos[\[Theta]] + d Sin[\[Theta]]] (a Cos[\[Theta]] +
d Sin[\[Theta]])^2 -
E^(a Sin[\[Theta]])
Sin[\[Theta]] (a d Cos[a z + d Cos[\[Theta]]] Sin[
2 \[Theta]] + (-d^2 Cos[\[Theta]]^2 +
a^2 Sin[\[Theta]]^2) Sin[a z + d Cos[\[Theta]]]) -
a^2 E^(a Cos[\[Theta]])
Sin[d z + 3 \[Theta] + a Sin[\[Theta]]]) +
a (2 a E^(2 a Cos[\[Theta]]) Cos[\[Theta]] +
d E^(a (Cos[\[Theta]] + Sin[\[Theta]]))
Cos[\[Theta]] Cos[
a z - d z + d Cos[\[Theta]] - a Sin[\[Theta]]] +
d E^(a (Cos[\[Theta]] + Sin[\[Theta]]))
Cos[\[Theta]] Cos[(a + d) z + d Cos[\[Theta]] +
a Sin[\[Theta]]] +
a E^(a (z + Cos[\[Theta]]))
Cos[\[Theta]] Cos[
d z + a Cos[\[Theta]] + (a + d) Sin[\[Theta]]] +
2 a E^(2 a Sin[\[Theta]]) Sin[\[Theta]] -
a E^(a (Cos[\[Theta]] + Sin[\[Theta]]))
Cos[a z - d z + d Cos[\[Theta]] -
a Sin[\[Theta]]] Sin[\[Theta]] +
a E^(a (Cos[\[Theta]] + Sin[\[Theta]]))
Cos[(a + d) z + d Cos[\[Theta]] +
a Sin[\[Theta]]] Sin[\[Theta]] +
a E^(a (z + Cos[\[Theta]]))
Cos[d z +
a Cos[\[Theta]] + (a + d) Sin[\[Theta]]] Sin[\[Theta]] +
d E^(a (z + Cos[\[Theta]]))
Cos[d z +
a Cos[\[Theta]] + (a + d) Sin[\[Theta]]] Sin[\[Theta]] +
E^(a (z + Sin[\[Theta]]))
Cos[a z - a Cos[\[Theta]] + d Cos[\[Theta]] -
d Sin[\[Theta]]] ((a - d) Cos[\[Theta]] + d Sin[\[Theta]]) -
E^(a (z + Cos[\[Theta]]))
Cos[d z -
a Cos[\[Theta]] + (a -
d) Sin[\[Theta]]] (a Cos[\[Theta]] + (-a +
d) Sin[\[Theta]]) +
a E^(a (Cos[\[Theta]] + Sin[\[Theta]]))
Cos[\[Theta]] Sin[
a z - d z + d Cos[\[Theta]] - a Sin[\[Theta]]] +
a E^(a (Cos[\[Theta]] + Sin[\[Theta]]))
Sin[\[Theta]] Sin[
a z - d z + d Cos[\[Theta]] - a Sin[\[Theta]]] +
a E^(a (Cos[\[Theta]] + Sin[\[Theta]]))
Cos[\[Theta]] Sin[(a + d) z + d Cos[\[Theta]] +
a Sin[\[Theta]]] +
a E^(a (Cos[\[Theta]] + Sin[\[Theta]]))
Sin[\[Theta]] Sin[(a + d) z + d Cos[\[Theta]] +
a Sin[\[Theta]]] +
a E^(a (z + Cos[\[Theta]]))
Cos[\[Theta]] Sin[
d z - a Cos[\[Theta]] + (a - d) Sin[\[Theta]]] +
E^(a (z +
Sin[\[Theta]])) (Cos[
a z + (a + d) Cos[\[Theta]] +
d Sin[\[Theta]]] ((a + d) Cos[\[Theta]] +
d Sin[\[Theta]]) +
a Sin[\[Theta]] (-Sin[
a z - a Cos[\[Theta]] + d Cos[\[Theta]] -
d Sin[\[Theta]]] +
Sin[a z + (a + d) Cos[\[Theta]] + d Sin[\[Theta]]])) +
a E^(a (z + Cos[\[Theta]]))
Cos[\[Theta]] Sin[
d z + a Cos[\[Theta]] + (a + d) Sin[\[Theta]]]))