Re: Help with map /@
- To: mathgroup at smc.vnet.net
- Subject: [mg128587] Re: Help with map /@
- From: "Nasser M. Abbasi" <nma at 12000.org>
- Date: Thu, 8 Nov 2012 02:07:05 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- References: <k7ct71$dpf$1@smc.vnet.net>
- Reply-to: nma at 12000.org
On 11/6/2012 11:56 PM, KFUPM wrote:
> Dear All
>
> I have a this expression:
>
> Ex= T1[x]+T2[y]+T3[z];
>
> I want to integrate the first term with respect to x, the second w.r.t y
>and the third with respect to z and then sum them all.
>I want to use the map function (/@) or similar to do that for me automatically.
>Your help is really appreciated.
>
> HMQ
>
May be
------------------
expr = T1[x]+T2[y]+T3[z];
Total[Table[Integrate[expr[[i]],expr[[i,1]]], {i,Length[expr]}] ]
-----------------------
or if you do not like using Table, another option:
----------------------
expr = T1[x]+T2[y]+T3[z];
funs = Apply[List,expr];
vars = First/@funs;
Total[MapThread[Integrate,{funs,vars}]]
----------------------------
And I am sure, as is typical in Mathematica (since it is a very
flexible language), there are 10 other ways to do this.
--Nasser