<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, trouble with "applyrule"</title>
    <link>http://www.mapleprimes.com/questions/142692-Trouble-With-applyrule</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Sat, 13 Jun 2026 20:51:20 GMT</lastBuildDate>
    <pubDate>Sat, 13 Jun 2026 20:51:20 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, trouble with "applyrule"</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, trouble with "applyrule"</title>
      <link>http://www.mapleprimes.com/questions/142692-Trouble-With-applyrule</link>
    </image>
    <item>
      <title>expand, but with "frontend"</title>
      <link>http://www.mapleprimes.com/questions/142692-Trouble-With-applyrule?ref=Feed:MaplePrimes:trouble with "applyrule":Comments#answer142697</link>
      <itunes:summary>&lt;p&gt;You need to expand (&lt;em&gt;i.e.&lt;/em&gt;, distribute &lt;strong&gt;sin(z)&lt;/strong&gt; over the rest) the first expression; otherwise, it won't contain the subexpression that you told &lt;strong&gt;applyrule&lt;/strong&gt; to look for. But simply using the command &lt;strong&gt;expand&lt;/strong&gt; will do too much: It will also apply a trig identity expand&lt;strong&gt; cos(2*z)&lt;/strong&gt;. So do this&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;strong&gt;frontend(expand, [exprsn1]);&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;Then use &lt;strong&gt;applyrule&lt;/strong&gt; on the result of this.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;You need to expand (&lt;em&gt;i.e.&lt;/em&gt;, distribute &lt;strong&gt;sin(z)&lt;/strong&gt; over the rest) the first expression; otherwise, it won't contain the subexpression that you told &lt;strong&gt;applyrule&lt;/strong&gt; to look for. But simply using the command &lt;strong&gt;expand&lt;/strong&gt; will do too much: It will also apply a trig identity expand&lt;strong&gt; cos(2*z)&lt;/strong&gt;. So do this&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;strong&gt;frontend(expand, [exprsn1]);&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;Then use &lt;strong&gt;applyrule&lt;/strong&gt; on the result of this.&lt;/p&gt;</description>
      <guid>142697</guid>
      <pubDate>Sun, 27 Jan 2013 22:33:50 Z</pubDate>
      <itunes:author>Carl Love</itunes:author>
      <author>Carl Love</author>
    </item>
    <item>
      <title>expand with option</title>
      <link>http://www.mapleprimes.com/questions/142692-Trouble-With-applyrule?ref=Feed:MaplePrimes:trouble with "applyrule":Comments#answer142730</link>
      <itunes:summary>&lt;p&gt;To prevent a single function from the effect of &lt;strong&gt;expand&lt;/strong&gt;, here &lt;strong&gt;cos(2*z)&lt;/strong&gt;, it is simpler to use the function name as an option for &lt;strong&gt;expand&lt;/strong&gt;:&lt;/p&gt;
&lt;pre&gt;exprsn1:=sin(z)*(A*cos(z) + B*cos(x)*cos(2*z) + C*cos(x)):
exprsn2:= applyrule(sin(z)*cos(2*z)=1/2*(sin(3*z)-sin(z)), expand(exprsn1,cos));
exprsn2:=
    sin(z) A cos(z) + (1/2 sin(3 z) - 1/2 sin(z)) B cos(x) + sin(z) C cos(x)
&lt;/pre&gt;
&lt;p&gt;On the other hand, the &lt;strong&gt;frontend&lt;/strong&gt; trick is more handy to prevent expansion of all the subexpressions, see &lt;a href="http://www.maplesoft.com/support/help/search.aspx?term=expand"&gt;?expand&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Certainly, it would have been better that &lt;strong&gt;expand&lt;/strong&gt; worked the other way round: just apply the distributive property unless told to expand something else, and an option &lt;strong&gt;all&lt;/strong&gt; to apply all the expansion rules. Also, a mathematical pattern matcher is needed that does not require from the user to accomodate the expressions and rules to such syntactic peculiarities.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;To prevent a single function from the effect of &lt;strong&gt;expand&lt;/strong&gt;, here &lt;strong&gt;cos(2*z)&lt;/strong&gt;, it is simpler to use the function name as an option for &lt;strong&gt;expand&lt;/strong&gt;:&lt;/p&gt;
&lt;pre&gt;exprsn1:=sin(z)*(A*cos(z) + B*cos(x)*cos(2*z) + C*cos(x)):
exprsn2:= applyrule(sin(z)*cos(2*z)=1/2*(sin(3*z)-sin(z)), expand(exprsn1,cos));
exprsn2:=
    sin(z) A cos(z) + (1/2 sin(3 z) - 1/2 sin(z)) B cos(x) + sin(z) C cos(x)
&lt;/pre&gt;
&lt;p&gt;On the other hand, the &lt;strong&gt;frontend&lt;/strong&gt; trick is more handy to prevent expansion of all the subexpressions, see &lt;a href="http://www.maplesoft.com/support/help/search.aspx?term=expand"&gt;?expand&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Certainly, it would have been better that &lt;strong&gt;expand&lt;/strong&gt; worked the other way round: just apply the distributive property unless told to expand something else, and an option &lt;strong&gt;all&lt;/strong&gt; to apply all the expansion rules. Also, a mathematical pattern matcher is needed that does not require from the user to accomodate the expressions and rules to such syntactic peculiarities.&lt;/p&gt;</description>
      <guid>142730</guid>
      <pubDate>Mon, 28 Jan 2013 11:56:50 Z</pubDate>
      <itunes:author>Alejandro Jakubi</itunes:author>
      <author>Alejandro Jakubi</author>
    </item>
  </channel>
</rss>