[Date Index]
[Thread Index]
[Author Index]
Re: Help with map /@
*To*: mathgroup at smc.vnet.net
*Subject*: [mg128590] Re: Help with map /@
*From*: Bill Rowe <readnews at sbcglobal.net>
*Date*: Thu, 8 Nov 2012 02:08:06 -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
On 11/7/12 at 12:56 AM, hussain.alqahtani at gmail.com (KFUPM) wrote:
>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.
Here are a couple of ways to do this with an *indefinite*
integral which might meet your needs:
Total[MapThread[Integrate[#1, #2] &, {List @@ Ex, {x, y, z}}]]
or
Total[Integrate @@@ Transpose@{List @@ Ex, {x, y, z}}]
If you wanted to have the same integration limits the syntax for
the first example would become:
Total[MapThread[Integrate[#1, {#2, a, b}] &, {List @@ Ex, {x, y, z}}]]
But do note, these work when T1, T2 and T3 are undefined
functions. If they were defined functions then Mathematica would
have evaluated Ex to something unlikely to be as cleanly
separated into discrete functions by simply using List@@
For example:
ex = f[x] + g[y];
Total[MapThread[Integrate[#1, {#2, a, b}] &, {List @@ ex, {x, y}}]]
works. But keeping ex defined as above and defining f, g as:
f[x_] := 2 x + 4
g[y_] := 1/y + 3;
causes
Total[MapThread[Integrate[#1, {#2, a, b}] &, {List @@ ex, {x, y}}]]
to fail with an error message since
In[18]:= Length[List @@ ex] == Length[{x, y}]
Out[18]= False
Prev by Date:
**FindFit::nrlnum Error Message**
Next by Date:
**Re: Conformal Mapping**
Previous by thread:
**Re: Help with map /@**
Next by thread:
**Re: Help with map /@**
| |