pure function with an NIntegrate command
- To: mathgroup at smc.vnet.net
- Subject: [mg98957] pure function with an NIntegrate command
- From: Ruth Lazkoz Sáez <wtplasar at lg.ehu.es>
- Date: Wed, 22 Apr 2009 05:21:39 -0400 (EDT)
- References: <200904202312.TAA09654@smc.vnet.net> <23448530.1240284136702.JavaMail.root@n11> <200904210912.FAA24817@smc.vnet.net>
Hi, I posted a question yesterday about pure functions. Probably when you receive this message someone would have posted a solution. While I was waiting I managed to come closer to a possible solution, and the encountered another problem. This is my problem. I define a function Efun[x_, y_, z_] := x + y + z and then this other one, which does an integral using the previous function fintnp[list_, y_, z_] :=NIntegrate[Efun[x, y, z], {x, 0, #}] & /@ list In my computer I run fintnp[{1, 2, 3, 4}, 0.2, 0.3] // Timing and get {0.020001, {1., 3., 6., 10.}} Now I want to construct a pure version of fintnp so that when the list is long I save a good load of time. My first approach is fint = Integrate[Efun[x, ##2], {x, 0, #1}] & It gives the correct results but it is significantly slower because I use Integrate instead of NIntegrate, so I naively define fintn= NIntegrate[Efun[x, ##2], {x, 0, #1}] & and then get errors indicating the definition is not good. Can someone help me? Thanks is advance. Ruth PD: Mathgroup is awesome, it has been amazingly useful for my work, and all the things I learn here made me a stronger Mathematica advocate anyday.
- References:
- Alignment of Graphics Within Expressions
- From: "David Park" <djmpark@comcast.net>
- Re: Alignment of Graphics Within Expressions
- From: "David Park" <djmpark@comcast.net>
- Alignment of Graphics Within Expressions