Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link
Bounty Ended with 500 reputation awarded by xyz
Updated the ArrayOfFunctionsRule implementation. No need to covert to array of functions in order to call it -- array of expressions works.
Source Link
Anton Antonov
  • 38k
  • 3
  • 103
  • 179

Convert the integrand matrix into a matrix of functions:

I1exprFS = 
  Map[Function[{fx}, Function[Evaluate[fx /. x -> #]]], I1expr, {2}];

Call NIntegrate with the new rule:

res1 =
    NIntegrate[1, {x, 0, 1}, 
      Method -> {"GlobalAdaptive", "SingularityHandler" -> None, 
        Method -> {ArrayOfFunctionsRule, "Functions" -> I1exprFSI1expr}}]; // AbsoluteTiming

(* {0.021779, Null} *)

Converting to functions:

funcs = 
  Map[Function[{fx}, Function[Evaluate[fx /. x -> #]]], 
   funcsExpr, {2}];

This integration is ~ 100 times faster than the default options one:

res1 = NIntegrate[1, {x, 0, 1}, 
   Method -> {"GlobalAdaptive", "SingularityHandler" -> None, 
     Method -> {ArrayOfFunctionsRule, 
       "Functions" -> funcsfuncsExpr}}]; // AbsoluteTiming

(* {5.4292, Null} *)

Convert the integrand matrix into a matrix of functions:

I1exprFS = 
  Map[Function[{fx}, Function[Evaluate[fx /. x -> #]]], I1expr, {2}];

Call NIntegrate with the new rule:

res1 =
    NIntegrate[1, {x, 0, 1}, 
      Method -> {"GlobalAdaptive", "SingularityHandler" -> None, 
        Method -> {ArrayOfFunctionsRule, "Functions" -> I1exprFS}}]; // AbsoluteTiming

(* {0.021779, Null} *)

Converting to functions:

funcs = 
  Map[Function[{fx}, Function[Evaluate[fx /. x -> #]]], 
   funcsExpr, {2}];

This integration is ~ 100 times faster than the default options one:

res1 = NIntegrate[1, {x, 0, 1}, 
   Method -> {"GlobalAdaptive", "SingularityHandler" -> None, 
     Method -> {ArrayOfFunctionsRule, 
       "Functions" -> funcs}}]; // AbsoluteTiming

(* {5.4292, Null} *)

Call NIntegrate with the new rule:

res1 =
    NIntegrate[1, {x, 0, 1}, 
      Method -> {"GlobalAdaptive", "SingularityHandler" -> None, 
        Method -> {ArrayOfFunctionsRule, "Functions" -> I1expr}}]; // AbsoluteTiming

(* {0.021779, Null} *)

This integration is ~ 100 times faster than the default options one:

res1 = NIntegrate[1, {x, 0, 1}, 
   Method -> {"GlobalAdaptive", "SingularityHandler" -> None, 
     Method -> {ArrayOfFunctionsRule, 
       "Functions" -> funcsExpr}}]; // AbsoluteTiming

(* {5.4292, Null} *)
added 4 characters in body
Source Link
Anton Antonov
  • 38k
  • 3
  • 103
  • 179

Load the code for the integration rule ArrayOfFunctionsRule:

Convert the integrand matrix into matricesa matrix of functions:

Load the code for integration rule ArrayOfFunctionsRule:

Convert the integrand matrix into matrices of functions:

Load the code for the integration rule ArrayOfFunctionsRule:

Convert the integrand matrix into a matrix of functions:

added 3 characters in body
Source Link
Anton Antonov
  • 38k
  • 3
  • 103
  • 179
Loading
Changed the code to make the computations faster (without Map). Removed the parallel computations -- no point having them.
Source Link
Anton Antonov
  • 38k
  • 3
  • 103
  • 179
Loading
added 12 characters in body
Source Link
Anton Antonov
  • 38k
  • 3
  • 103
  • 179
Loading
deleted 27 characters in body
Source Link
Anton Antonov
  • 38k
  • 3
  • 103
  • 179
Loading
added 1550 characters in body
Source Link
Anton Antonov
  • 38k
  • 3
  • 103
  • 179
Loading
added 272 characters in body
Source Link
Anton Antonov
  • 38k
  • 3
  • 103
  • 179
Loading
added 187 characters in body
Source Link
Anton Antonov
  • 38k
  • 3
  • 103
  • 179
Loading
Source Link
Anton Antonov
  • 38k
  • 3
  • 103
  • 179
Loading