MathGroup Archive 2003

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

Search the Archive

RE: how to change arguments of standard functions ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg44981] RE: [mg44962] how to change arguments of standard functions ?
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Fri, 12 Dec 2003 04:41:17 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com


>-----Original Message-----
>From: Wolf, Hartmut 
To: mathgroup at smc.vnet.net
>Sent: Thursday, December 11, 2003 1:03 PM
>To: 'Nakhova, Irina'; mathgroup at smc.vnet.net
>Subject: [mg44981] RE: [mg44962] how to change arguments of standard functions ?
>
>
>
>>-----Original Message-----
>>From: Nakhova, Irina [mailto:I.Nakhova at gcal.ac.uk]
To: mathgroup at smc.vnet.net
>>Sent: Thursday, December 11, 2003 11:28 AM
>>To: mathgroup at smc.vnet.net
>>Subject: [mg44981] [mg44962] how to change arguments of standard functions ?
>>
>>
>>Dear group,
>>
>>I need  to  implement the following function
>>
>>trans[pol_]:=If[PolynomialQ[pol,t],PolynomialQuotient[pol,t+t1,t]
>>(t+t1)+PolynomialRemainder[pol,t+t1,t],pol]
>>
>>to expressions like Sin[pol] + Cos[pol] + Log[pol]. For 
>>example, i want to
>>get Sin[2t+t1] in the form Sin[2(t+t1)-t1]. 
>>
>>Can you help me with this, please.
>>
>>Regards,
>>
>>Irina
>>
>
>Perhaps you might like to try
>
>trans[pol_] /; PolynomialQ[pol, t] := 
>  PolynomialQuotient[pol, t + t1, t] (t + t1) + 
>    PolynomialRemainder[pol, t + t1, t]
>
>trans[Sin[arg_]] := Sin[trans[arg]]
>trans[Cos[arg_]] := Cos[trans[arg]]
>trans[Log[arg_]] := Log[trans[arg]]
>trans[Unevaluated[Plus[summands__]]] := 
>  Thread[Unevaluated[trans[Plus[summands]]], Plus]
>
>?trans
>
>Such trans is threaded over Plus, Sin, etc.
>Then e.g.
>
>In[36]:= Cos[2t + t1] // trans
>Out[36]= Cos[t1 - 2 (t + t1)]
>
>In[37]:= Sin[2t + t1] + Log[15 t + 2 t1] // trans
>Out[37]= Log[-13 t1 + 15 (t + t1)] - Sin[t1 - 2 (t + t1)]
>
>In[47]:= a t^2 + b t + c // trans
>Out[47]= c - b*t1 + a*t1^2 + (t + t1)*(b + a*t - a*t1)
>
>(But this is just a hack, you might get better answers.)
>
>
>--
>Hartmut Wolf
>

Perhaps you were bold enough to try 

ClearAll[trans]

trans[pol_] /; PolynomialQ[pol, t] := 
  PolynomialQuotient[pol, t + t1, t] (t + t1) + 
    PolynomialRemainder[pol, t + t1, t]

trans[f_[arg_]] := f[trans[arg]]

trans[Unevaluated[Plus[summands__]]] := 
  Thread[Unevaluated[trans[Plus[summands]]], Plus]

?trans


Thing brings up the idea, to qualify for the functions by enumeration, thus
simplifying the definition. Replace the line containing f_[...] above by:

transferableQ[f_Symbol] := MemberQ[{Log, Sin, Cos}, f]
trans[f_?transferableQ[arg_]] := f[trans[arg]]

--
Hartmut


  • Prev by Date: RE: log-log plot with error bars, different data markers
  • Next by Date: Efficient Monte Carlo code
  • Previous by thread: RE: how to change arguments of standard functions ?
  • Next by thread: log-log plot with error bars, different data markers