(*The global minimization of a function with multiple minima.  L.Piela, J.Kostrowicki and H.A.Scheraga proposed 
a method known as the diffusion equation method. The main idea of the method  is to deform the target function 
in order to get rid of many minima, then find the global minimum of the deformed function, and come back to the original function 
by steps. Each step relaxes the deformation and in the new minimum posotion is adjusted by minimization. 
This excercise shows how the method operates for the sum of the Gaussian functions.  The diffusion equation method 
deforms the original function V->Vt in such a way, that Vt 
exhibits only a single minimum, which therefore can be easily found. Then a sequence of operations follows: 
partial relaxation of the deformation and minimization, repeated till attaining Vt=V. Hopefully we get the
 global minimum. This is the case here.*)
V=-2 (E^(-0.1 (((x-3))^2)-0.2 (y^2)))-3 (E^(-0.5 (((x-5))^2)-0.4 (((y+4))^2)))-4 (E^(-0.1 (((x+5))^2)-0.2 (((y-5))^2)))-2 (E^(-0.2 (((x+5))^2)-0.2 (((y+5))^2)))-0.5Cos[2x] Cos[4y](*na razie proby, dalej jeszcze nie zmienione*)
Plot3D[V,{x,-8,8},{y,-8,8},PlotPoints->30,AxesLabel->{"x","y","V"}] 
ContourPlot[V,{x,-9,9},{y,-9,9},PlotPoints->20]
Show[
Plot3D[V,{x,-8.,8},{y,-8,8},RegionFunction->Function[{x,y,z},-6≤z≤8],BoxRatios->Automatic,PlotPoints->30,
PlotStyle->Directive[Opacity[0.95],Specularity[Red,10]],AxesLabel->{"x","y","V"}],
Graphics3D[{Red,Sphere[{5.,-5.,-2.},0.2 ]}]
]
FindMinimum[{V,{-9≤x≤9,-9≤y≤9}},{{x,5},{y,-5}}](*lokalne*)
FindMinimum[{V,{-9≤x≤9,-9≤y≤9}},{{x,-5},{y,5}}] (*globalne*)

{-3.5088511773083075`,{x->4.880846432527256`,y->-3.9344173734711445`}}

{-4.314769073602337`,{x->-4.79582287495623`,y->5.415264137269327`}}

t=15
Vt=-((2 (E^(-((0.1 (((x-3))^2))/(1+4 0.1 t))-((0.2 (y^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.1 t) (1+4 0.2 t)]))-((3 (E^(-((0.5 (((x-5))^2))/(1+4 0.5 t))-((0.4 (((y+4))^2))/(1+4 0.4 t)))))/(Sqrt[(1+4 0.5 t) (1+4 0.4 t)]))-((4(E^(-((0.1 (((x+5))^2))/(1+4 0.1 t))-((0.2 (((y-5))^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.1 t) (1+4 0.2 t)]))-((2 (E^(-((0.2 (((x+5))^2))/(1+4 0.2 t))-((0.2 (((y+5))^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.2 t) (1+4 0.2 t)]))-0.5Cos[2x] (E^(-4t)) Cos[4y] (E^(-16t))
Plot3D[Vt,{x,-8,8},{y,-8,8},PlotPoints->30,AxesLabel->{"x","y","V(t)"}]
ContourPlot[Vt,{x,-9,9},{y,-9,9}]
FindMinimum[{Vt,{-9≤x≤9,-9≤y≤9}},{{x,5},{y,-5}}]

t=5
Vt=-((2 (E^(-((0.1 (((x-3))^2))/(1+4 0.1 t))-((0.2 (y^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.1 t) (1+4 0.2 t)]))-((3 (E^(-((0.5 (((x-5))^2))/(1+4 0.5 t))-((0.4 (((y+4))^2))/(1+4 0.4 t)))))/(Sqrt[(1+4 0.5 t) (1+4 0.4 t)]))-((4(E^(-((0.1 (((x+5))^2))/(1+4 0.1 t))-((0.2 (((y-5))^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.1 t) (1+4 0.2 t)]))-((2 (E^(-((0.2 (((x+5))^2))/(1+4 0.2 t))-((0.2 (((y+5))^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.2 t) (1+4 0.2 t)]))-0.5Cos[2x] (E^(-4t)) Cos[4y] (E^(-16t))
Plot3D[Vt,{x,-8,8},{y,-8,8},PlotPoints->30,AxesLabel->{"x","y","V(t)"}]
ContourPlot[Vt,{x,-9,9},{y,-9,9},PlotPoints->20]
FindMinimum[{Vt,{-9≤x≤9,-9≤y≤9}},{{x,-2.999906988351878`},{y,2.578240061736218`}}]

13

t=1
Vt=-((2 (E^(-((0.1 (((x-3))^2))/(1+4 0.1 t))-((0.2 (y^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.1 t) (1+4 0.2 t)]))-((3 (E^(-((0.5 (((x-5))^2))/(1+4 0.5 t))-((0.4 (((y+4))^2))/(1+4 0.4 t)))))/(Sqrt[(1+4 0.5 t) (1+4 0.4 t)]))-((4(E^(-((0.1 (((x+5))^2))/(1+4 0.1 t))-((0.2 (((y-5))^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.1 t) (1+4 0.2 t)]))-((2 (E^(-((0.2 (((x+5))^2))/(1+4 0.2 t))-((0.2 (((y+5))^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.2 t) (1+4 0.2 t)]))-0.5Cos[2x] (E^(-4t)) Cos[4y] (E^(-16t))
Plot3D[Vt,{x,-8,8},{y,-8,8},PlotPoints->30,AxesLabel->{"x","y","V(t)"}]
ContourPlot[Vt,{x,-9,9},{y,-9,9},PlotPoints->20]
FindMinimum[{Vt,{-9≤x≤9,-9≤y≤9}},{{x,-4.794364871073353`},{y,4.7900408103278505`}}]

t=0.1
Vt=-((2 (E^(-((0.1 (((x-3))^2))/(1+4 0.1 t))-((0.2 (y^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.1 t) (1+4 0.2 t)]))-((3 (E^(-((0.5 (((x-5))^2))/(1+4 0.5 t))-((0.4 (((y+4))^2))/(1+4 0.4 t)))))/(Sqrt[(1+4 0.5 t) (1+4 0.4 t)]))-((4(E^(-((0.1 (((x+5))^2))/(1+4 0.1 t))-((0.2 (((y-5))^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.1 t) (1+4 0.2 t)]))-((2 (E^(-((0.2 (((x+5))^2))/(1+4 0.2 t))-((0.2 (((y+5))^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.2 t) (1+4 0.2 t)]))-0.5Cos[2x] (E^(-4t)) Cos[4y] (E^(-16t))
Plot3D[Vt,{x,-8,8},{y,-8,8},PlotPoints->30,AxesLabel->{"x","y","V(t)"}]
ContourPlot[Vt,{x,-9,9},{y,-9,9},PlotPoints->20]
FindMinimum[{Vt,{-9≤x≤9,-9≤y≤9}},{{x,-4.997415969798712`},{y,4.998318850168755`}}]

t=0.05
Vt=-((2 (E^(-((0.1 (((x-3))^2))/(1+4 0.1 t))-((0.2 (y^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.1 t) (1+4 0.2 t)]))-((3 (E^(-((0.5 (((x-5))^2))/(1+4 0.5 t))-((0.4 (((y+4))^2))/(1+4 0.4 t)))))/(Sqrt[(1+4 0.5 t) (1+4 0.4 t)]))-((4(E^(-((0.1 (((x+5))^2))/(1+4 0.1 t))-((0.2 (((y-5))^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.1 t) (1+4 0.2 t)]))-((2 (E^(-((0.2 (((x+5))^2))/(1+4 0.2 t))-((0.2 (((y+5))^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.2 t) (1+4 0.2 t)]))-0.5Cos[2x] (E^(-4t)) Cos[4y] (E^(-16t))
Plot3D[Vt,{x,-8,8},{y,-8,8},PlotPoints->30,AxesLabel->{"x","y","V(t)"}]
ContourPlot[Vt,{x,-9,9},{y,-9,9},PlotPoints->20]
FindMinimum[{Vt,{-9≤x≤9,-9≤y≤9}},{{x,-4.9780595701773995`},{y,5.163212726632299`}}]

t=0.02
Vt=-((2 (E^(-((0.1 (((x-3))^2))/(1+4 0.1 t))-((0.2 (y^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.1 t) (1+4 0.2 t)]))-((3 (E^(-((0.5 (((x-5))^2))/(1+4 0.5 t))-((0.4 (((y+4))^2))/(1+4 0.4 t)))))/(Sqrt[(1+4 0.5 t) (1+4 0.4 t)]))-((4(E^(-((0.1 (((x+5))^2))/(1+4 0.1 t))-((0.2 (((y-5))^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.1 t) (1+4 0.2 t)]))-((2 (E^(-((0.2 (((x+5))^2))/(1+4 0.2 t))-((0.2 (((y+5))^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.2 t) (1+4 0.2 t)]))-0.5Cos[2x] (E^(-4t)) Cos[4y] (E^(-16t))
Plot3D[Vt,{x,-8,8},{y,-8,8},PlotPoints->30,AxesLabel->{"x","y","V(t)"}]
ContourPlot[Vt,{x,-9,9},{y,-9,9},PlotPoints->20]
FindMinimum[{Vt,{-9≤x≤9,-9≤y≤9}},{{x,-4.879289678652027`},{y,5.315907344056198`}}]

t=0
Vt=-((2 (E^(-((0.1 (((x-3))^2))/(1+4 0.1 t))-((0.2 (y^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.1 t) (1+4 0.2 t)]))-((3 (E^(-((0.5 (((x-5))^2))/(1+4 0.5 t))-((0.4 (((y+4))^2))/(1+4 0.4 t)))))/(Sqrt[(1+4 0.5 t) (1+4 0.4 t)]))-((4(E^(-((0.1 (((x+5))^2))/(1+4 0.1 t))-((0.2 (((y-5))^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.1 t) (1+4 0.2 t)]))-((2 (E^(-((0.2 (((x+5))^2))/(1+4 0.2 t))-((0.2 (((y+5))^2))/(1+4 0.2 t)))))/(Sqrt[(1+4 0.2 t) (1+4 0.2 t)]))-0.5Cos[2x] (E^(-4t)) Cos[4y] (E^(-16t))
Plot3D[Vt,{x,-8,8},{y,-8,8},PlotPoints->30,AxesLabel->{"x","y","V(t)"}]
ContourPlot[Vt,{x,-9,9},{y,-9,9},PlotPoints->20]
FindMinimum[{Vt,{-9≤x≤9,-9≤y≤9}},{{x,-4.824283977966976`},{y,5.383333290817711`}}]