There are also wildcards to use in the replacement matcher, unfortunately 
in SymPy wild symbols often match too much or in an unexpected way.

Consider an attempt with a wild:

In [1]: w = Wild('w')

In [2]: cos(4*x+6).replace(w*(2*x+3), u*w)
Out[2]: 
   ⎛     2              ⎞
   ⎜  4⋅u ⋅x       6⋅u  ⎟
cos⎜────────── + ───────⎟
   ⎜         2   2⋅x + 3⎟
   ⎝(2⋅x + 3)           ⎠


It would be nice to have assumptions work on wildcards, in order to 
restrict their matching possibilities.

On Friday, March 20, 2015 at 9:01:05 AM UTC+1, Paul Royik wrote:
>
>
> Yes. This version  is not for me.
> x in front of cosine shouldn't be replaced.
>
> On Thursday, March 19, 2015 at 4:56:42 PM UTC+2, Mike Boyle wrote:
>>
>> It seems to me that the easy way to do this is to solve your replacement 
>> for `x`:
>>
>> cos(4*x+6).subs(x, (u-3)/2)
>>
>> And if this is just a special case of a more general substitution, you 
>> can of course do that solve step with sympy.
>>
>> I can't tell from your question, but this might not be exactly what you 
>> wanted.  For example, look at
>>
>> (x*cos(4*x+6)).subs(x, (u-3)/2)
>>
>> This will also replace the `x` out front.  If you don't want that, you'd 
>> need to do an even more complicated version of what Francesco suggests.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/d05efab2-7007-4fe9-9267-62e605b3727d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to