<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - comments on Post, convexity</title>
    <link>http://www.mapleprimes.com/posts/36587-Convexity</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Wed, 10 Jun 2026 17:39:47 GMT</lastBuildDate>
    <pubDate>Wed, 10 Jun 2026 17:39:47 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest comments added to the Post, convexity</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - comments on Post, convexity</title>
      <link>http://www.mapleprimes.com/posts/36587-Convexity</link>
    </image>
    <item>
      <title>why?</title>
      <link>http://www.mapleprimes.com/posts/36587-Convexity?ref=Feed:MaplePrimes:convexity:Comments#comment62796</link>
      <itunes:summary>&lt;p&gt;.&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, convexity</description>
      <guid>62796</guid>
      <pubDate>Tue, 13 Oct 2009 23:40:39 Z</pubDate>
      <itunes:author>Axel Vogt</itunes:author>
      <author>Axel Vogt</author>
    </item>
    <item>
      <title>why</title>
      <link>http://www.mapleprimes.com/posts/36587-Convexity?ref=Feed:MaplePrimes:convexity:Comments#comment62797</link>
      <itunes:summary>&lt;p&gt;E.g. for the &lt;a href="http://en.wikipedia.org/wiki/Legendre_transform"&gt;Legendre transformation&lt;/a&gt;.&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, convexity</description>
      <guid>62797</guid>
      <pubDate>Wed, 14 Oct 2009 00:18:48 Z</pubDate>
      <itunes:author>jakubi</itunes:author>
      <author>jakubi</author>
    </item>
    <item>
      <title>convexity</title>
      <link>http://www.mapleprimes.com/posts/36587-Convexity?ref=Feed:MaplePrimes:convexity:Comments#comment62798</link>
      <itunes:summary>&lt;p&gt;There's a lot of scope for improving this code below. (A probabilistic fallback might also be worthwhile. I suspect that a fallback that using testeq &amp;amp; signum might not work; testeq is rather limited.)&lt;/p&gt;
&lt;p&gt;Note that `is` can depend upon Digits.&lt;/p&gt;
&lt;pre&gt;
&amp;gt; isconvex := proc(expr,A::realcons:=-infinity,B::realcons:=infinity)
&amp;gt; local a,b,t,x,use_expr,res;
&amp;gt;   x := indets(expr,name) minus {constants};
&amp;gt;   if nops(x) = 1 then
&amp;gt;     x := op(x);
&amp;gt;   else error;
&amp;gt;   end if;
&amp;gt;   # For more than one variable, one could test
&amp;gt;   # positive-definiteness of the Hessian.
&amp;gt;   res := is( diff(expr,x,x) &amp;gt;=0 )
&amp;gt;            assuming x&amp;gt;=A, x&amp;lt;=B;
&amp;gt;   if res&amp;lt;&amp;gt;FAIL then
&amp;gt;     return res;
&amp;gt;   else
&amp;gt;     userinfo(1,'isconvex',`falling back to the definition`);
&amp;gt;     # Is it better to expand, or simplify, or put
&amp;gt;     # Normalizer calls around the two-arg evals or
&amp;gt;     # their difference, oder...?
&amp;gt;     use_expr:=expand(expr);
&amp;gt;     is( eval(use_expr,x=(1-t)*a+t*b) &amp;lt;=
&amp;gt;         (1-t)*eval(use_expr,x=a)+t*eval(use_expr,x=b) )
&amp;gt;       assuming a&amp;lt;=b, t&amp;gt;=0, t&amp;lt;=1, b&amp;lt;=B, a&amp;gt;=A;
&amp;gt;   #else
&amp;gt;   ##Is global optimization another fallback?
&amp;gt;   end if;
&amp;gt; end proc:

&amp;gt; # note: this shows that none of the examples
&amp;gt; # below had to fall back to the defn after failing
&amp;gt; # a 2nd deriv test. But many such will exist.
&amp;gt; infolevel[isconvex]:=1:

&amp;gt; isconvex( y^2 );
                                     true

&amp;gt;
&amp;gt; isconvex( y^3 );
                                     false

&amp;gt; isconvex( y^3, 0 );
                                     true

&amp;gt;
&amp;gt; isconvex( (y-3)^2 );
                                     true

&amp;gt;
&amp;gt; isconvex( (y-3)^4 );
                                     true

&amp;gt;
&amp;gt; isconvex( exp(y) );
                                     true

&amp;gt; isconvex( -exp(y) );
                                     false

&amp;gt;
&amp;gt; isconvex( -sin(y), 0, Pi );
                                     true
&lt;/pre&gt;
&lt;p&gt;acer&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, convexity</description>
      <guid>62798</guid>
      <pubDate>Thu, 15 Oct 2009 01:10:22 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>parameters</title>
      <link>http://www.mapleprimes.com/posts/36587-Convexity?ref=Feed:MaplePrimes:convexity:Comments#comment62799</link>
      <itunes:summary>&lt;p&gt;Another issue would be parameters, on which assumptions may hold as here:&lt;/p&gt;
&lt;pre&gt;
isconvex( (x-a)^2 ) assuming a::real;

Error, (in assuming) when calling 'isconvex'. 
Received: 'testing against an invalid type'
&lt;/pre&gt;
&lt;p&gt;Probably, it would be better to state explicitly the variable as another argument.&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, convexity</description>
      <guid>62799</guid>
      <pubDate>Thu, 15 Oct 2009 01:35:46 Z</pubDate>
      <itunes:author>jakubi</itunes:author>
      <author>jakubi</author>
    </item>
    <item>
      <title>abs</title>
      <link>http://www.mapleprimes.com/posts/36587-Convexity?ref=Feed:MaplePrimes:convexity:Comments#comment62800</link>
      <itunes:summary>&lt;p&gt;Fails for abs though,&lt;/p&gt;
&lt;pre&gt;
isconvex(abs(x));
isconvex:   falling back to the definition

                                 FAIL

isconvex(abs(x^3));
isconvex:   falling back to the definition

                                 FAIL
&lt;/pre&gt;
&lt;p&gt;And while replacing abs(x) with sqrt(x^2) gives the correct answer,&lt;/p&gt;
&lt;pre&gt;
isconvex(sqrt(x^2));

                                 true
&lt;/pre&gt;
&lt;p&gt;the following is wrong,&lt;/p&gt;
&lt;pre&gt;
isconvex(-sqrt(x^2));

                                 true
&lt;/pre&gt;
&lt;p&gt;That was caused by the following Maple feature&lt;/p&gt;
&lt;pre&gt;
diff(sqrt(x^2),x,x);

                              2
                             x          1
                         - ------- + -------
                             2 3/2     2 1/2
                           (x )      (x )

normal(%);

                                  0

is(%%&amp;lt;=0);
                                 true

is(%%%=0);

                                 true
&lt;/pre&gt;
&lt;p&gt;Alec&lt;/p&gt;</itunes:summary>
      <description>The latest comments added to the Post, convexity</description>
      <guid>62800</guid>
      <pubDate>Thu, 15 Oct 2009 02:38:39 Z</pubDate>
      <itunes:author>alec</itunes:author>
      <author>alec</author>
    </item>
    <item>
      <title>also wrong</title>
      <link>http://www.mapleprimes.com/posts/36587-Convexity?ref=Feed:MaplePrimes:convexity:Comments#comment62801</link>
      <itunes:summary>&lt;p&gt;I think inequality should be strict, otherwise:&lt;/p&gt;
&lt;pre&gt;
isconvex(x);
                                 true

&lt;/pre&gt;</itunes:summary>
      <description>The latest comments added to the Post, convexity</description>
      <guid>62801</guid>
      <pubDate>Thu, 15 Oct 2009 02:43:48 Z</pubDate>
      <itunes:author>jakubi</itunes:author>
      <author>jakubi</author>
    </item>
  </channel>
</rss>