Skip to main content
2 of 4
deleted 1 character in body
Mariusz Iwaniuk
  • 16.4k
  • 1
  • 27
  • 46

I had to write the answer on user's Anton Antonov special request.

We can speed up a little the code by using method SimulatedAnnealing in NMinimize function and adding PrecisionGoal with low value.

f[x_?NumericQ, y_?NumericQ] := NMinimize[{Sin[a x y], 1 < a < 5}, {a}, 
PrecisionGoal -> 6, Method -> "SimulatedAnnealing"][[1]];

AbsoluteTiming[ 
NIntegrate[If[f[x, y] > 0, 1, 0], {x, 0, 1}, {y, 0, 1}, PrecisionGoal -> 2, 
MaxRecursion -> 3]]

(* {38.8097, 0.922105} *)

Using code user's Anton Antonov on my machine gives output with time:

 (*{192.335, 0.922105}*)

In the comment, what I wrote about method NelderMead in NMinimize.I don't know why gives a incorrect result.

Mariusz Iwaniuk
  • 16.4k
  • 1
  • 27
  • 46