<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, Matlab to Maple</title>
    <link>http://www.mapleprimes.com/questions/139144-Matlab-To-Maple</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Tue, 09 Jun 2026 09:28:48 GMT</lastBuildDate>
    <pubDate>Tue, 09 Jun 2026 09:28:48 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, Matlab to Maple</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, Matlab to Maple</title>
      <link>http://www.mapleprimes.com/questions/139144-Matlab-To-Maple</link>
    </image>
    <item>
      <title>round-off</title>
      <link>http://www.mapleprimes.com/questions/139144-Matlab-To-Maple?ref=Feed:MaplePrimes:Matlab to Maple:Comments#answer139145</link>
      <itunes:summary>&lt;p&gt;You are looking at round-off errors. In my environment I set Digits to 15 and I get&lt;/p&gt;
&lt;p&gt;n=1: 1.12000000000000 E+15 (this is probably infinite as the exponent goes up with Digits)&lt;/p&gt;
&lt;p&gt;You probably have Maple's default of 10 Digits.&lt;/p&gt;
&lt;p&gt;For n=2 clearly Matlab is underrunning.&lt;/p&gt;
&lt;p&gt;For n=3 Maple may be doing it symbolically and correct. You can get a similar result as Matlab if you evalhf(A3(3)) thus forcing floating-point evaluation using your computer's FPU. Floating hardware is not accurate to the last bit (many numbers cannot be represented exactly in fp) &amp;amp; thus the denominator can underrun to a small non-zero number rather than exact zero.&lt;/p&gt;
&lt;p&gt;Mac Dude&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;You are looking at round-off errors. In my environment I set Digits to 15 and I get&lt;/p&gt;
&lt;p&gt;n=1: 1.12000000000000 E+15 (this is probably infinite as the exponent goes up with Digits)&lt;/p&gt;
&lt;p&gt;You probably have Maple's default of 10 Digits.&lt;/p&gt;
&lt;p&gt;For n=2 clearly Matlab is underrunning.&lt;/p&gt;
&lt;p&gt;For n=3 Maple may be doing it symbolically and correct. You can get a similar result as Matlab if you evalhf(A3(3)) thus forcing floating-point evaluation using your computer's FPU. Floating hardware is not accurate to the last bit (many numbers cannot be represented exactly in fp) &amp;amp; thus the denominator can underrun to a small non-zero number rather than exact zero.&lt;/p&gt;
&lt;p&gt;Mac Dude&lt;/p&gt;</description>
      <guid>139145</guid>
      <pubDate>Sat, 03 Nov 2012 17:02:52 Z</pubDate>
      <itunes:author>Mac Dude</itunes:author>
      <author>Mac Dude</author>
    </item>
    <item>
      <title>singularity</title>
      <link>http://www.mapleprimes.com/questions/139144-Matlab-To-Maple?ref=Feed:MaplePrimes:Matlab to Maple:Comments#answer139148</link>
      <itunes:summary>&lt;p&gt;The limits as you approach A3(3) from each side are +infinity and -infinity. Which result you get, as you compute in floating-point, might depend upon the working precision (Digits) due to numerical error.&lt;/p&gt;
&lt;pre&gt;restart:
alpha_p:=1: p:=2: mu0:=4*Pi*1e-7: Br:=1.12:

A1:=unapply(sin((n*p+1)*alpha_p*Pi/(2*p))/((n*p+1)*alpha_p*Pi/(2*p)),n):

A2:=unapply(sin((n*p-1)*alpha_p*Pi/(2*p))/((n*p-1)*alpha_p*Pi/(2*p)),n):

M1:=unapply((Br/mu0)*alpha_p*(A1(n)+A2(n)),n):

M2:=unapply((Br/mu0)*alpha_p*(A1(n)-A2(n)),n):

M3:=unapply(M1(n)+n*p*M2(n),n):

A3:=unapply(((n*p-1/(n*p))*M1(n)/M3(n)+1/(n*p)),n):
evalhf(A3(3));
                                         15
                     4.595173115007179 10  
A3c:=Compiler:-Compile(A3):
A3c(3);
                                         15
                     5.514207738008614 10  
for i from 10 to 20 do
  Digits:=i;
  q:=A3(3.0):
  printf("\nDigits: %ld   evalf(A3(3)): %e\n",Digits,evalf(q));
end do:

Digits: 10   evalf(A3(3)): -2.292637e+09

Digits: 11   evalf(A3(3)): -1.604846e+11

Digits: 12   evalf(A3(3)): -8.024228e+11

Digits: 13   evalf(A3(3)): -2.292637e+12

Digits: 14   evalf(A3(3)): -2.292637e+13

Digits: 15   evalf(A3(3)): 2.674743e+14

Digits: 16   evalf(A3(3)): 1.458951e+15

Digits: 17   evalf(A3(3)): 1.604846e+16

Digits: 18   evalf(A3(3)): -4.012114e+17

Digits: 19   evalf(A3(3)): 1.783162e+18

Digits: 20   evalf(A3(3)): -3.209691e+19

A3(3);
                                     (1/2)    
                    Float(infinity) 2        1
                  - ---------------------- + -
                               2             6
                             Pi               

limit(A3(x),x=3,left);
                        Float(infinity)

limit(A3(x),x=3,right);
                        -Float(infinity)

plot(A3, 2.5..3.5);
&lt;/pre&gt;
&lt;!--break--&gt;
&lt;p&gt;acer&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;The limits as you approach A3(3) from each side are +infinity and -infinity. Which result you get, as you compute in floating-point, might depend upon the working precision (Digits) due to numerical error.&lt;/p&gt;
&lt;pre&gt;restart:
alpha_p:=1: p:=2: mu0:=4*Pi*1e-7: Br:=1.12:

A1:=unapply(sin((n*p+1)*alpha_p*Pi/(2*p))/((n*p+1)*alpha_p*Pi/(2*p)),n):

A2:=unapply(sin((n*p-1)*alpha_p*Pi/(2*p))/((n*p-1)*alpha_p*Pi/(2*p)),n):

M1:=unapply((Br/mu0)*alpha_p*(A1(n)+A2(n)),n):

M2:=unapply((Br/mu0)*alpha_p*(A1(n)-A2(n)),n):

M3:=unapply(M1(n)+n*p*M2(n),n):

A3:=unapply(((n*p-1/(n*p))*M1(n)/M3(n)+1/(n*p)),n):
evalhf(A3(3));
                                         15
                     4.595173115007179 10  
A3c:=Compiler:-Compile(A3):
A3c(3);
                                         15
                     5.514207738008614 10  
for i from 10 to 20 do
  Digits:=i;
  q:=A3(3.0):
  printf("\nDigits: %ld   evalf(A3(3)): %e\n",Digits,evalf(q));
end do:

Digits: 10   evalf(A3(3)): -2.292637e+09

Digits: 11   evalf(A3(3)): -1.604846e+11

Digits: 12   evalf(A3(3)): -8.024228e+11

Digits: 13   evalf(A3(3)): -2.292637e+12

Digits: 14   evalf(A3(3)): -2.292637e+13

Digits: 15   evalf(A3(3)): 2.674743e+14

Digits: 16   evalf(A3(3)): 1.458951e+15

Digits: 17   evalf(A3(3)): 1.604846e+16

Digits: 18   evalf(A3(3)): -4.012114e+17

Digits: 19   evalf(A3(3)): 1.783162e+18

Digits: 20   evalf(A3(3)): -3.209691e+19

A3(3);
                                     (1/2)    
                    Float(infinity) 2        1
                  - ---------------------- + -
                               2             6
                             Pi               

limit(A3(x),x=3,left);
                        Float(infinity)

limit(A3(x),x=3,right);
                        -Float(infinity)

plot(A3, 2.5..3.5);
&lt;/pre&gt;
&lt;!--break--&gt;
&lt;p&gt;acer&lt;/p&gt;</description>
      <guid>139148</guid>
      <pubDate>Sat, 03 Nov 2012 17:18:28 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>tan</title>
      <link>http://www.mapleprimes.com/questions/139144-Matlab-To-Maple?ref=Feed:MaplePrimes:Matlab to Maple:Comments#comment139151</link>
      <itunes:summary>&lt;pre&gt;T:=convert(expand(simplify(convert(A3(n),rational))),tan);

                             /1     \
                          tan|- Pi n|
                             \2     /
&lt;/pre&gt;
&lt;!--break--&gt;
&lt;p&gt;acer&lt;/p&gt;</itunes:summary>
      <description>&lt;pre&gt;T:=convert(expand(simplify(convert(A3(n),rational))),tan);

                             /1     \
                          tan|- Pi n|
                             \2     /
&lt;/pre&gt;
&lt;!--break--&gt;
&lt;p&gt;acer&lt;/p&gt;</description>
      <guid>139151</guid>
      <pubDate>Sat, 03 Nov 2012 17:43:17 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>Thanks Acer but small problem</title>
      <link>http://www.mapleprimes.com/questions/139144-Matlab-To-Maple?ref=Feed:MaplePrimes:Matlab to Maple:Comments#comment139156</link>
      <itunes:summary>&lt;p&gt;Thanks alot for the help guys.&amp;nbsp; But using evalhf I can't sum A3(n)&lt;/p&gt;
&lt;p&gt;Sum(A3(n)*cos(n*p*theta),n=1..10)&lt;/p&gt;
&lt;p&gt;it gives following error&lt;/p&gt;
&lt;p&gt;Error (in A3) cannot handle unevaluated name'n' in evalhf&lt;/p&gt;
&lt;p&gt;Is there anyway I can get series of above equation.&lt;/p&gt;
&lt;p&gt;The solution look like this&amp;nbsp;&amp;nbsp;&amp;nbsp; n=1,&amp;nbsp;&amp;nbsp; 6.935e15*cos(2*theta)+.....&lt;/p&gt;
&lt;p&gt;Thanks in advance&lt;/p&gt;
&lt;p&gt;Looking forward to your kind replies&lt;/p&gt;
&lt;p&gt;A.Q&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Thanks alot for the help guys.&amp;nbsp; But using evalhf I can't sum A3(n)&lt;/p&gt;
&lt;p&gt;Sum(A3(n)*cos(n*p*theta),n=1..10)&lt;/p&gt;
&lt;p&gt;it gives following error&lt;/p&gt;
&lt;p&gt;Error (in A3) cannot handle unevaluated name'n' in evalhf&lt;/p&gt;
&lt;p&gt;Is there anyway I can get series of above equation.&lt;/p&gt;
&lt;p&gt;The solution look like this&amp;nbsp;&amp;nbsp;&amp;nbsp; n=1,&amp;nbsp;&amp;nbsp; 6.935e15*cos(2*theta)+.....&lt;/p&gt;
&lt;p&gt;Thanks in advance&lt;/p&gt;
&lt;p&gt;Looking forward to your kind replies&lt;/p&gt;
&lt;p&gt;A.Q&lt;/p&gt;</description>
      <guid>139156</guid>
      <pubDate>Sat, 03 Nov 2012 18:55:24 Z</pubDate>
      <itunes:author>AliKhan</itunes:author>
      <author>AliKhan</author>
    </item>
    <item>
      <title>add</title>
      <link>http://www.mapleprimes.com/questions/139144-Matlab-To-Maple?ref=Feed:MaplePrimes:Matlab to Maple:Comments#comment139157</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/questions/139144-Matlab-To-Maple#comment139156"&gt;@AliKhan&lt;/a&gt;&amp;nbsp;The Matlab result for A3(3) is wrong, The evalhf result for A3(3) is wrong. But if you really want to use evalhf then try it with `add` instead of `Sum` or `sum`.&lt;/p&gt;
&lt;p&gt;I find that people really don't like hearing it, but one thing you might reconsider is the methodology of assigning float values to your parameters at the start of your worksheet. Such values are useful for numeric evaluation, but often make it awkward to get the best symbolic benefits before doing numeric evaluations. Maple can often be a lot more easily powerful if you don't make such assignments at the start.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/questions/139144-Matlab-To-Maple#comment139156"&gt;@AliKhan&lt;/a&gt;&amp;nbsp;The Matlab result for A3(3) is wrong, The evalhf result for A3(3) is wrong. But if you really want to use evalhf then try it with `add` instead of `Sum` or `sum`.&lt;/p&gt;
&lt;p&gt;I find that people really don't like hearing it, but one thing you might reconsider is the methodology of assigning float values to your parameters at the start of your worksheet. Such values are useful for numeric evaluation, but often make it awkward to get the best symbolic benefits before doing numeric evaluations. Maple can often be a lot more easily powerful if you don't make such assignments at the start.&lt;/p&gt;</description>
      <guid>139157</guid>
      <pubDate>Sat, 03 Nov 2012 21:31:13 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>@acer I'd like to second your advise about</title>
      <link>http://www.mapleprimes.com/questions/139144-Matlab-To-Maple?ref=Feed:MaplePrimes:Matlab to Maple:Comments#comment139161</link>
      <itunes:summary>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/questions/139144-Matlab-To-Maple#comment139157"&gt;@acer&lt;/a&gt; I'd like to second your advise about late assignment of (floating-point-) numbers to variables. Sometimes it is a little awkward to do it late, however, e.g. when modules are involved one loads by menas of "with()". In such cases I have been experimenting with a scheme where I include a list of replacements in the module, like rlist:=[p1=...,p2=...] and so on and then apply a simple subs(rlist,...) when the time comes to get to numbers. Doing this I find takes some of the tedium out of switching to numbers at a late stage.&lt;/p&gt;
&lt;p&gt;M.D.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;&lt;a href="http://www.mapleprimes.com/questions/139144-Matlab-To-Maple#comment139157"&gt;@acer&lt;/a&gt; I'd like to second your advise about late assignment of (floating-point-) numbers to variables. Sometimes it is a little awkward to do it late, however, e.g. when modules are involved one loads by menas of "with()". In such cases I have been experimenting with a scheme where I include a list of replacements in the module, like rlist:=[p1=...,p2=...] and so on and then apply a simple subs(rlist,...) when the time comes to get to numbers. Doing this I find takes some of the tedium out of switching to numbers at a late stage.&lt;/p&gt;
&lt;p&gt;M.D.&lt;/p&gt;</description>
      <guid>139161</guid>
      <pubDate>Sun, 04 Nov 2012 00:50:36 Z</pubDate>
      <itunes:author>Mac Dude</itunes:author>
      <author>Mac Dude</author>
    </item>
  </channel>
</rss>