Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6820979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:29:26+00:00 2026-05-26T21:29:26+00:00

(I made some changes…) very often I want to simplify the function’s argument, or

  • 0

(I made some changes…)

very often I want to simplify the function’s argument, or apply a pattern to it, eg. I want to change:

Exp[a(b+c)]

into

Exp[a b + a c]

simple pattern doesn’t help:

Sin[a(b+c)] /. Sin[aaa_] -> Sin[Expand[aaa]]

gives again

Sin[a(b+c)]

However, with functions other than Simplify / Expand it seems to do what I expect:

Sin[a (b + c)] /. Sin[aaa_] -> Sin[f[aaa]] 

gives

Sin[  f[a(b+c)]  ]

My usual solution was to use 2 patterns and Hold:

(Exp[a(b+c)] /. Exp[aaa_] -> Exp[Hold[  Expand[aaa]  ]] ) /. Hold[xxx_] -> xxx

which results in

E^(a*b + a*c)

The disadvantage of this method is that code gets more complicated than it’s neccesary.

MY REAL LIFE EXAMPLE is:

ppp2 = 
 ( ppp1  
    /. { ExpIntegralEi[aaa_] -> 
           ExpIntegralEi[Hold[aaa /. { u2 -> 0, w2 -> 0, u3 -> x, w3 -> x}]], 
         Log[aaa_] -> 
           Log[Hold[aaa /. {u2 -> 0, w2 -> 0, u3 -> x, w3 -> x}]]
       }
 ) /.  Hold[xxx_] -> xxx;

where ppp1 is a long sum of terms containing u2, w2, u3, w3 and so on. I want to change the values of u, w2… ONLY in ExpIntegral and Log.

My other solution is a function:

ExpandArgument[expr_, what_] := Module[{list},
  list = Extract[expr, Position[   expr, what[_]   ]];
  list = Map[Rule[#, what[Expand[   #[[1]]   ]]] &, list];
  Return[expr /. list]
]

The function I wrote can be easily generalised to make it possible to use not only Expand but also Simplify and so on:

ApplyToArgument[expr_, ToWhat_, WhatFunction_] := Module[{list},
  list = Extract[expr, Position[   expr, ToWhat[_]   ]];
  list = Map[Rule[#, ToWhat[WhatFunction[   #[[1]]   ]]] &, list];
  Return[expr /. list]
]

For example:

ApplyToArgument[Sin[a (b + c)], Sin, Expand]

gives

Sin[a b + a c]

and

ApplyToArgument[Sin[a b + a c ], Sin, Simplify]

gives

Sin[a (b + c)]

This solution is easy to read but needs some refinement before being applied to many-argument functions (and I need these functions).

I guess I’m missing something fundamental about patterns in mathematica… How should I apply patterns to arguments of functions? (Or simplify, expand, etc. them)

Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:29:26+00:00Added an answer on May 26, 2026 at 9:29 pm

    For the first part of the question, you could consider using RuleDelayed:

    Sin[a (b + c)] /. Sin[aaa_] :> Sin[Expand[aaa]]
    

    gives

    Sin[a b + a c]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page for carpools. I made some changes to the function that
I reverted to a previous commit and made some changes. Now I want to
I pulled a remote branch. I made some changes. I want to push my
I made some changes in my repo and staged them. I want to get
I made some changes in my master branch and want to bring those upstream.
i have edited an app and made some changes in it. I want to
I made some changes to an existing application that was previously just straight HTML
I made some changes to an open source project without taking time to create
I have made some changes in one perforce client, but haven't submitted them. I
I've made some changes in the table structure and especially the relationships between tables

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.