MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: mapping of function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69998] Re: [mg69938] Re: mapping of function
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Sat, 30 Sep 2006 05:12:18 -0400 (EDT)
  • References: <efdjnn$ms$1@smc.vnet.net> <200609281014.GAA25555@smc.vnet.net>

Or if one insists on "mapping" and does not want to bother about  
positions one can use:

MapAll[If[# === x || # === z, Sin[#], #] &, xp1]

Andrzej Kozlowski


On 28 Sep 2006, at 19:14, dh wrote:

>
> Hi,
> MapAT does not seem to be a very convenient solution because you  
> have to
> bother about positions. Mathematica can do this on its own by pattern
> matching. E.g.:
> exp1 /. {x -> Sin[x], y -> Cos[x]}
> Daniel
>
> dimmechan at yahoo.com wrote:
>> 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.
>>
>


  • Prev by Date: subsets of a set
  • Next by Date: Re: C-formatted strings back to Expressions
  • Previous by thread: Re: Re: mapping of function
  • Next by thread: Re: mapping of function