Re: Question regarding Compile
- To: mathgroup at smc.vnet.net
- Subject: [mg33780] Re: Question regarding Compile
- From: Madhusudan Singh <ar at sc.hc.de>
- Date: Tue, 16 Apr 2002 03:50:31 -0400 (EDT)
- Organization: University of Michigan Electrical Engineering and Computer Science
- References: <a8m33c$oaq$1@smc.vnet.net> <a8tt4m$fmg$1@smc.vnet.net> <a90hj5$kfv$1@smc.vnet.net> <a939s1$pe3$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Thanks for your response. > > integrand := Compile[{{y, _Real}, {x1, _Real}, {x2, _Real}}, f1[pl[argument[y]] + x1, x2, c]]; > > > > pl[] is an array, f1 and argument are functions (fairly simple functions). > > c is a constant. > > > > answer1[x1_, x2_] := Exp[-2 Integrate[integrand[y, x1, x2], {y, a, b}]]; > > > > a=0, b~1e-8 > > > > I get an error : > > > > CompiledFunction::cfsa: Argument y at position should be a machine-size > > real number. > > > You can't symbolical integrate a compiled function ! and you can't pass > a > symbol like y (without a value) to a compiled function where you > declared > the argument as Real So perhaps the solution is to expand integrand directly inside the definition of answer1 and the resulting expression directly inside jt3 ? That way, the variable y would not be an issue at all. > > > > > when I try to use answer1 with > > > > jt3=q NIntegrate[v[x1, 50, 0.2] g3[0.2, x1, 50] partjt3[x1] > > answer1[0.0, x1], {x1, 50, maxpl + dummyinfinity}, Method -> MonteCarlo, MaxPoints -> 10000]; > > > > v, g3, partjt3 are simple functions. > > > > As you can see, this is quite complicated. However, since a and b are > > fixed numbers, and nowhere near machine precision, I do not not understand > > the error above. > > > > This is leading to other errors later. > > > > Any ideas ? > > Use NIntegrate[] instead of Integrate[]. There is no need to compile the > argument of NIntegrate[] because Mathematica will do it by default. > I wonder why do calculations take so long then (one step of this calculation takes as long as 40 minutes). Maybe I should try to use some timing statements to identify the step that takes the longest to run. Thanks.