       Re: mapping of function

• To: mathgroup at smc.vnet.net
• Subject: [mg69961] Re: mapping of function
• From: Peter Pein <petsie at dordos.net>
• Date: Thu, 28 Sep 2006 06:16:02 -0400 (EDT)
• References: <efdjnn\$ms\$1@smc.vnet.net>

```dimmechan at yahoo.com schrieb:
> Hello.
>
> I am working on John Gray's Book Mastering Mathematica.
>
> Here is one simple expression.
>
> exp1 = x^3 + (1 + z)^2
> x^3 + (1 + z)^2
>
> I am thinking of ways to map the sine function only to {x,z}.
> Here are some alternatives I considered.
>
> MapAt[Sin, exp1, Flatten[(Position[exp1, #1] & ) /@ Variables[exp1],
> 1]]
> Sin[x]^3 + (1 + Sin[z])^2
>
> MapAt[Sin, exp1, Position[exp1, _Symbol, Heads -> False]]
> Sin[x]^3 + (1 + Sin[z])^2
>
> Are there any other possibilities?
>
> Thanks for any response.
>

Hi,

the following is not mapping, but IMHO it does the same in a very simple
way:

In:= exp1 = x^3 + (1 + z)^2;
In:= exp1 /. v: x | z :> Sin[v]
Out= Sin[x]^3 + (1 + Sin[z])^2

or more general:

In:= exp1 /. v:Alternatives @@ Variables[exp1] :> Sin[v]
Out= Sin[x]^3 + (1 + Sin[z])^2

Peter

```

• Prev by Date: Re: Program to calculate rational function with imbedded continued fraction
• Next by Date: Wolfram Technology Conference 2006
• Previous by thread: Re: Re: mapping of function
• Next by thread: equation question