Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: hints to speed up numerical integration?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60166] Re: Re: [mg60114] hints to speed up numerical integration?
  • From: "Ruth Lazkoz" <ruth.lazkoz at ehu.es>
  • Date: Mon, 5 Sep 2005 22:27:23 -0400 (EDT)
  • References: <200509030606.CAA19051@smc.vnet.net> <acbec1a405090305596dddab38@mail.gmail.com>
  • Sender: owner-wri-mathgroup at wolfram.com

Try this way. It works for me.

datanw = {{0.0400, 36.38, 0.19}, {0.050, 36.84, 0.21}, {0.0307, 35.90, 
0.20},
{0.0560, 37.31, 0.18}, {0.0331, 35.54, 0.20}, {0.0141, 34.13,
0.25}, {0.0460,
36.35, 0.21}, {0.0265, 35.64, 0.20}, {0.101, 38.73, 0.20}, {0.075,
37.77, 0.19}};

ndat = 10;


z = datanw[[#1, 1]] & ; mi = datanw[[#1, 2]] & ; smi =
datanw[[#1, 3]] & ; SetAttributes[smi, Listable];
f[x_, om_, w_] := 1/Sqrt[om*(1 + x)^3 + ( 1 - om)*(1 + x)^(3*(1 + w))];
rr[1, om_, w_] :=
rr[1, om, w] = NIntegrate[f[x, om, w], {x, 0, z [1]}, Compiled -> False];
rr[i_?IntegerQ, om_, w_] :=
rr[i, om, w] =
rr[i - 1, om, w] +
NIntegrate[f[x, om, w], {x, z[i - 1], z[i]}, Compiled -> False];
ff[i_?IntegerQ, om_, w_] := 5*Log[ 10, rr[i, om, w]*(1 + z[i])]; ci =
Sum[1/smi[i]^2, {i, 1, ndat}];
chi2f2[(om_)? NumericQ, (w_)?NumericQ] :=
Module[{vec = ((mi[#1] - ff[#1, om, w])/ smi[#1] & ) /@ Range[ndat]},
vec . vec - Total[vec/smi[Range[ndat]]]^2/ci]


chi2mar[w_] := -2*
Log[NIntegrate[Exp[-chi2f2[0.23 + omvar, w]/2], {omvar, -0.07, 0.07},
Compiled -> False]]


chi2mar[0.1] // Timing


  • Prev by Date: Re: PC Requirements for Mathematica
  • Next by Date: Why this function does not return a single value
  • Previous by thread: Re: hints to speed up numerical integration?
  • Next by thread: Re: hints to speed up numerical integration?