f[x_] := (x - 1)^2   + 
          25 (1 +  
                Sin[x]);


Plot[f[x],  {x, -10, 23},  
        PlotStyle -> {RGBColor[0.8, 0.2, 0.1],  
            Thickness[0.01]}, 
Axes -> 
          False, 
Frame -> True];

\(\(\(
\)\(
\)\(\(Nmax = 
        500;\)

    \(sigma = 2;\)


    \(xstart = 10;\)


    \(<< Statistics`ContinuousDistributions`;\)

    \(dist = 
        NormalDistribution[0, 
          sigma^2];\)


    \)\)\)

Clear[x]; 
    out = FindMinimum[f[x],  {x, xstart}]

\(\(\(
\)\(\(x = 
        xstart;\)


    \(For[i = 1, \ i ≤ Nmax, 
        1, 
{
xnew = 
            x + Random[dist]; 
If[
            f[xnew] < f[x]\ , \ 
x = 
              xnew
, \ \ \ 
 (*\ 
              Nic\ *) \ ]; 

\(i++\);}];\)


    \(Print["  x =", \ x, \ " f(x) = ", \ 
        f[x]];\)


    \(alfa = f[x]/f[xstart];\)

    \(Print["  Redukcia alfa =", alfa];\)

    \)\)\)

\(\(\(
\)\(\(f[x_] := \((x - 1)\)^2\  + \ 
          25\ \((1 + Sin[x])\);\)



    \(Plot[f[x], \ {x, \(-10\), 23}, \ 
        PlotStyle -> {RGBColor[0.8, 0.2, 0.1], \ 
            Thickness[0.01]}, 
Axes -> 
          False, 
Frame -> True];\)

    \)\)\)

\(\(k = 1;\)
\)
Nmax = 50; 
sigma = 2;
\(\(theta = 0.9;\)
\)
\(\(xstart = 10. ;\)
\)
Tstart = f[xstart];
\(\(Tmin = 0.001;\)

\)
<< Statistics`ContinuousDistributions`;
dist = NormalDistribution[0, sigma^2];

\(\(\(
\)\(\(x = xstart;\)


    \(For[T = Tstart, \ 
        T ≥ 
          Tmin, \ , 
{
For[i = 1, \ 
            i ≤ Nmax, 
            1, 
{

xnew = x + Random[dist]; 

If[
                f[xnew] < f[x]\  || \ 
                  Random[] < 
                    Exp[\(-\((f[xnew] - f[x]\ )\)\)/\((k*T)\)], \ {x = 
                    xnew; }
, \ \ \  (*\ 
                  Nic\ *) \ ]; 

\(i++\);}]; 


T = 
            theta*T;
}];\)

 (*\(Print["Teplota zihania T =", \ T];\)*) 

    \(Print["  x =", \ x, \ " f(x) = ", \ 
        f[x]];\)


    \(alfa = f[x]/f[xstart];\)

    \(Print["  Redukcia alfa =", alfa];\)

    \)\)\)