<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - comments on Blog Entry, Yet More Gems from the Little Red Book of Maple Magic</title>
    <link>http://www.mapleprimes.com/maplesoftblog/103464-Yet-More-Gems-From-The-Little-Red-Book</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 21:17:07 GMT</lastBuildDate>
    <pubDate>Sat, 13 Jun 2026 21:17:07 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest comments added to the Blog Entry, Yet More Gems from the Little Red Book of Maple Magic</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - comments on Blog Entry, Yet More Gems from the Little Red Book of Maple Magic</title>
      <link>http://www.mapleprimes.com/maplesoftblog/103464-Yet-More-Gems-From-The-Little-Red-Book</link>
    </image>
    <item>
      <title>Trig Identitities</title>
      <link>http://www.mapleprimes.com/maplesoftblog/103464-Yet-More-Gems-From-The-Little-Red-Book?ref=Feed:MaplePrimes:Yet More Gems from the Little Red Book of Maple Magic:Comments#comment103513</link>
      <itunes:summary>&lt;p&gt;I do not agree, it may be the user who struggles here, not Maple...&lt;/p&gt;
&lt;p&gt;In principle, &lt;strong&gt;trigsubs&lt;/strong&gt; was intended to handle trigonometric identities. And indeed, it works for this particular expression:&lt;/p&gt;
&lt;pre&gt;trigsubs(sin(x)+sin(y));
                  [2 sin(x/2 + y/2) cos(x/2 - y/2)]

&lt;/pre&gt;
&lt;p&gt;But there is not much joy, as&amp;nbsp; &lt;strong&gt;trigsubs&lt;/strong&gt; is fragile and fails under a slight change:&lt;/p&gt;
&lt;pre&gt;trigsubs(-sin(x)-sin(y));
Error, (in trigsubs) expecting a sum or difference of two functions but got -sin(x)-sin(y)
&lt;/pre&gt;
&lt;p&gt;I say that it is fragile because automatic function normalization "pulls out" the minus sign:&lt;/p&gt;
&lt;pre&gt;trigsubs(sin(-x)+sin(-y));
Error, (in trigsubs) expecting a sum or difference of two functions but got -sin(x)-sin(y)

trigsubs(sin(y-x)+sin(z-w));
Error, (in trigsubs) expecting a sum or difference of two functions but got -sin(-y+x)-sin(-z+w)
&lt;/pre&gt;
&lt;p&gt;Likely, this error message arises because the normalization changes the type of the terms from &lt;strong&gt;function&lt;/strong&gt; to &lt;strong&gt;`*`&lt;/strong&gt;:&lt;/p&gt;
&lt;pre&gt;whattype(sin(-x));
                                  *
&lt;/pre&gt;
&lt;p&gt;And the primitive pattern matcher of &lt;strong&gt;trigsubs&lt;/strong&gt; seems unable to cope this with case.&lt;/p&gt;
&lt;p&gt;I observe an error message arising already in Maple V Release 2 (the oldest version that I have installed):&lt;/p&gt;
&lt;pre&gt;readlib(trigsubs): 
trigsubs(-sin(a)-sin(b)); 
Error, (in trigsubs) sum or difference of two functions expected not , -sin 
(a)-sin(b) 
&lt;/pre&gt;
&lt;p&gt;And I see that the code in Maple 14 and Maple V Release 2 is the same, besides cosmetic changes. Now, Maple V Release 2 was released in Nov. 1992 and &lt;strong&gt;trigsubs&lt;/strong&gt; is copyrighted 1990. So, I find quite likely that the its code has not changed, basically, from its release, over 20 years ago. [Michael Komma should be credited for recently reminding elsewhere about this longstanding bug]&lt;/p&gt;
&lt;p&gt;Trigonometric identities are a very basic subject. So, that the routine devoted to handling them, has not been really improved, and its bugs corrected, in about 20 years (2/3 of the lifetime of Maple) is a shame, in my opinion. Maple has a serious deficit in the critical area of pattern matching. But yet, better faciliies became available in the late 20 years.&lt;/p&gt;
&lt;p&gt;Indeed, for about 15 years, rules like these ones have been lurking around my Maple initialization files:&lt;/p&gt;
&lt;pre&gt;trig_sumtoprod:=[
sin(a::algebraic)+sin(b::algebraic)=2*sin((a+b)/2)*cos((a-b)/2),
sin(a::algebraic)-sin(b::algebraic)=2*cos((a+b)/2)*sin((a-b)/2),
cos(a::algebraic)+cos(b::algebraic)=2*cos((a+b)/2)*cos((a-b)/2),
cos(a::algebraic)-cos(b::algebraic)=2*sin((a+b)/2)*sin((b-a)/2)
]:
&lt;/pre&gt;
&lt;p&gt;So that&lt;/p&gt;
&lt;pre&gt;applyrule(trig_sumtoprod,sin(x)+sin(y));
                   2 sin(x/2 + y/2) cos(x/2 - y/2)
&lt;/pre&gt;
&lt;p&gt;The first two rules may be combined and extended like this:&lt;/p&gt;
&lt;pre&gt;sin_sumtoprod:=conditional(A::algebraic*sin(a::algebraic)+B::algebraic*sin(b::algebraic)=
2*A*sin((a+signum(0,B/A,0)*b)/2)*cos((a-signum(0,B/A,0)*b)/2),A&amp;lt;&amp;gt;0 and _verify(B^2-A^2,0,equal)):

applyrule(sin_sumtoprod,exp(x)*sin(x)+exp(x)*sin(y));
                2 exp(x) sin(x/2 + y/2) cos(x/2 - y/2)

applyrule(sin_sumtoprod,4*sin(y-x)+4*sin(z-w));
      -8 sin(- y/2 + x/2 - z/2 + w/2) cos(y/2 - x/2 - z/2 + w/2)
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Certainly, some of the items that you have raised in this blog series are very useful in spotting at serious defficiences of Maple in the area of symbolic computations. Note, however, that I do not post comments to them for the purpose of my recipes beeing included in your red book (though it is fine for me if you do so with proper attribution). Rather, I post here for awakening the Maplesoft management about their priority and planning problems.&lt;/p&gt;
&lt;p&gt;Indeed, "magic", the key word in the title, is very significative in describing the current status: if performing elementary symbolic operations with Maple require "magic recipes", and even a seasoned user as you needs collecting and keeping such recipes in a handwritten book, then something is very wrong with the design of the whole system.&lt;/p&gt;
&lt;p&gt;And from a more practical point of view, frequently I tend to avoid answering to some of you items, even though they may deserve a comment, because I do edit and preview a lot. And your blogs, so loaded with gifs, makes that each preview cycle take 1-2 mins. Only exceptionally I can afford the extra time required by such an overhead.&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Blog Entry, Yet More Gems from the Little Red Book of Maple Magic</description>
      <guid>103513</guid>
      <pubDate>Sat, 02 Apr 2011 01:18:19 Z</pubDate>
      <itunes:author>Alejandro Jakubi</itunes:author>
      <author>Alejandro Jakubi</author>
    </item>
    <item>
      <title>Longing for more...</title>
      <link>http://www.mapleprimes.com/maplesoftblog/103464-Yet-More-Gems-From-The-Little-Red-Book?ref=Feed:MaplePrimes:Yet More Gems from the Little Red Book of Maple Magic:Comments#comment104087</link>
      <itunes:summary>&lt;p&gt;Longing for more magic gems. They are of educational. Very magic.&lt;/p&gt;
&lt;p&gt;Best regards!&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Blog Entry, Yet More Gems from the Little Red Book of Maple Magic</description>
      <guid>104087</guid>
      <pubDate>Mon, 11 Apr 2011 12:28:22 Z</pubDate>
      <itunes:author>Wang Gaoteng</itunes:author>
      <author>Wang Gaoteng</author>
    </item>
    <item>
      <title>Gem 11</title>
      <link>http://www.mapleprimes.com/maplesoftblog/103464-Yet-More-Gems-From-The-Little-Red-Book?ref=Feed:MaplePrimes:Yet More Gems from the Little Red Book of Maple Magic:Comments#comment120729</link>
      <itunes:summary>&lt;p&gt;It can be done without guessing noticing that in this example&lt;/p&gt;
&lt;pre&gt;                                   x
                                  /
                                 |
          phi[k + 1] - phi[k] =  |   phi[k] - phi[k - 1] dx
                                 |
                                /
                                  0&lt;/pre&gt;
&lt;p&gt;so every next difference is the integral of the previous one, and &amp;phi;&lt;sub&gt;k&lt;/sub&gt; is the sum of the differences, so the limit of &amp;phi;&lt;sub&gt;k&lt;/sub&gt; is&lt;/p&gt;
&lt;pre&gt;sum(diff(x^2,x$(-n)),n=1..infinity);

                                             2
                       2 exp(x) - 2 - 2 x - x
&lt;/pre&gt;
&lt;p&gt;(Knowing the Taylor series for exp(x) and the integral of x^m, this sum can be calculated mentally, without Maple.)&lt;/p&gt;
&lt;p&gt;_______________&lt;br&gt; Alec Mihailovs, PhD&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Blog Entry, Yet More Gems from the Little Red Book of Maple Magic</description>
      <guid>120729</guid>
      <pubDate>Mon, 30 May 2011 23:26:01 Z</pubDate>
      <itunes:author>Alec Mihailovs</itunes:author>
      <author>Alec Mihailovs</author>
    </item>
    <item>
      <title>Gem 12</title>
      <link>http://www.mapleprimes.com/maplesoftblog/103464-Yet-More-Gems-From-The-Little-Red-Book?ref=Feed:MaplePrimes:Yet More Gems from the Little Red Book of Maple Magic:Comments#comment120733</link>
      <itunes:summary>&lt;p&gt;Not only for real x. Also, evalc would give the same result in the original post even without assumptions (evalc automatically assumes that all variables in it are real).&lt;/p&gt;
&lt;p&gt;To do this properly, one has to look at the branch cuts of sqrt(z^2+1), sqrt(z+I), and sqrt(z-I).&lt;/p&gt;
&lt;pre&gt;z:=x+y*I:
solve({Re(z^2+1)&amp;lt;=0,Im(z^2+1)=0}) assuming real;

                  {x = 0, y &amp;lt;= -1}, {x = 0, 1 &amp;lt;= y}

solve({Re(z+I)&amp;lt;=0,Im(z+I)=0}) assuming real;

                           {y = -1, x &amp;lt;= 0}

solve({Re(z-I)&amp;lt;=0,Im(z-I)=0}) assuming real;

                           {y = 1, x &amp;lt;= 0}
&lt;/pre&gt;
&lt;p&gt;They divide complex plane in 3 domains, in one of which (containing the real axis) the identity holds, and in 2 others - doesn't. That can be visualized with densityplot,&lt;/p&gt;
&lt;pre&gt;plots:-densityplot(abs(sqrt(z^2+1)-sqrt(z+I)*sqrt(z-I)),
x=-4..4,y=-4..4,colorstyle=HUE,style=patchnogrid,axes=box);&lt;/pre&gt;
&lt;p&gt;&lt;a href="/view.aspx?sf=120733/384195/dplot1.png"&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" src="/view.aspx?sf=120733/384195/dplot1.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;_______________&lt;br&gt; Alec Mihailovs, PhD&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Blog Entry, Yet More Gems from the Little Red Book of Maple Magic</description>
      <guid>120733</guid>
      <pubDate>Tue, 31 May 2011 01:13:19 Z</pubDate>
      <itunes:author>Alec Mihailovs</itunes:author>
      <author>Alec Mihailovs</author>
    </item>
    <item>
      <title>Gem 11</title>
      <link>http://www.mapleprimes.com/maplesoftblog/103464-Yet-More-Gems-From-The-Little-Red-Book?ref=Feed:MaplePrimes:Yet More Gems from the Little Red Book of Maple Magic:Comments#comment120736</link>
      <itunes:summary>&lt;p&gt;Of course, what the Picard iteration is doing in this case is grinding out, one term at a time, the Maclaurin series of the solution.&amp;nbsp; That could be obtained more simply with &lt;strong&gt;dsolve(..., type=series)&lt;/strong&gt;.&amp;nbsp; &lt;br&gt;As for &lt;strong&gt;guessgf&lt;/strong&gt;, how does it come up with an answer?&amp;nbsp; Let's use infolevel[gfun] to get information on what it did.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;&amp;gt; infolevel[gfun]:= 2;
 guessgf(L, x);

guessgf:   Trying to find a rational generating function
guessgf:   Trying to find an hypergeometric generating function
guessgf:   Trying to find an algebraic generating function
guessgf:   Trying to find a linear differential equation
listtodiffeq:   The   ogf   seems to satisfy   x^2+y(x)-diff(y(x),x)
guessgf:   Trying to solve it
                                     2
                        [-2 - 2 x - x  + 2 exp(x), ogf]
&lt;br&gt;&lt;br&gt;Surprise!  It did it by solving the same differential equation we started with.&lt;/pre&gt;</itunes:summary>
      <description>The latest comments added to the Blog Entry, Yet More Gems from the Little Red Book of Maple Magic</description>
      <guid>120736</guid>
      <pubDate>Tue, 31 May 2011 02:53:00 Z</pubDate>
      <itunes:author>Robert Israel</itunes:author>
      <author>Robert Israel</author>
    </item>
    <item>
      <title>Gem 14</title>
      <link>http://www.mapleprimes.com/maplesoftblog/103464-Yet-More-Gems-From-The-Little-Red-Book?ref=Feed:MaplePrimes:Yet More Gems from the Little Red Book of Maple Magic:Comments#comment120941</link>
      <itunes:summary>&lt;p&gt;That can be written in 2 lines,&lt;/p&gt;
&lt;pre&gt;f:=sin(u+v)+sin(u-v):
eval(f=expand(f),solve({u+v=x,u-v=y},{u,v}));

          sin(x) + sin(y) = 2 sin(x/2 + y/2) cos(x/2 - y/2)
&lt;/pre&gt;
&lt;p&gt;Alec&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Blog Entry, Yet More Gems from the Little Red Book of Maple Magic</description>
      <guid>120941</guid>
      <pubDate>Thu, 02 Jun 2011 08:43:32 Z</pubDate>
      <itunes:author>Alec Mihailovs</itunes:author>
      <author>Alec Mihailovs</author>
    </item>
  </channel>
</rss>