<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, piecewise or not?</title>
    <link>http://www.mapleprimes.com/questions/35539-Piecewise-Or-Not</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 21:33:45 GMT</lastBuildDate>
    <pubDate>Wed, 10 Jun 2026 21:33:45 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, piecewise or not?</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, piecewise or not?</title>
      <link>http://www.mapleprimes.com/questions/35539-Piecewise-Or-Not</link>
    </image>
    <item>
      <title>piecewise</title>
      <link>http://www.mapleprimes.com/questions/35539-Piecewise-Or-Not?ref=Feed:MaplePrimes:piecewise or not?:Comments#answer44221</link>
      <itunes:summary>&lt;p&gt;Well, you don't need all those x[i] &amp;lt;= x clauses: &lt;br /&gt;
piecewise(x &amp;lt; x[1], hz[1], x &amp;lt; x[2], hz[2], etc) &lt;br /&gt;
would do.&amp;nbsp; But if you want to use x as a symbolic variable, it's probably better to use a different letter for the indexed object, maybe X[i] rather than x[i].&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And for producing it, you could use something like&lt;/p&gt;
&lt;pre&gt;
&amp;gt; piecewise(op(ListTools[Flatten]([seq]([x &amp;lt; X[i], hz[i]],i=1..10)))); &lt;/pre&gt;</itunes:summary>
      <description>&lt;p&gt;Well, you don't need all those x[i] &amp;lt;= x clauses: &lt;br /&gt;
piecewise(x &amp;lt; x[1], hz[1], x &amp;lt; x[2], hz[2], etc) &lt;br /&gt;
would do.&amp;nbsp; But if you want to use x as a symbolic variable, it's probably better to use a different letter for the indexed object, maybe X[i] rather than x[i].&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And for producing it, you could use something like&lt;/p&gt;
&lt;pre&gt;
&amp;gt; piecewise(op(ListTools[Flatten]([seq]([x &amp;lt; X[i], hz[i]],i=1..10)))); &lt;/pre&gt;</description>
      <guid>44221</guid>
      <pubDate>Thu, 11 Mar 2010 11:09:00 Z</pubDate>
      <itunes:author>Robert Israel</itunes:author>
      <author>Robert Israel</author>
    </item>
    <item>
      <title>Sort the x'es</title>
      <link>http://www.mapleprimes.com/questions/35539-Piecewise-Or-Not?ref=Feed:MaplePrimes:piecewise or not?:Comments#answer44222</link>
      <itunes:summary>&lt;p&gt;Robert Israel beat me to it, but I'll let the following stay.&lt;/p&gt;
&lt;p&gt;Assuming that the values x[i] are sorted increasingly, you can do&lt;/p&gt;
&lt;p&gt;piecewise(t &amp;lt; x[1], hz[1], t &amp;lt; x[2], hz[2], t&amp;lt; x[3], hz[3], t &amp;lt; x[4], hz[4], t &amp;lt; x[5], hz[5],t &amp;lt; x[6], hz[6], t &amp;lt; x[7], hz[7], t&amp;lt; x[8], hz[8], t &amp;lt; x[9], hz[9], t &amp;lt;= x[10], hz[10]);&lt;br /&gt;
&amp;nbsp;&lt;/p&gt;
&lt;p&gt;since piecewise checks the inequalities from the left and stops if the inequality is satisfied.&lt;/p&gt;
&lt;p&gt;Even shorter is&lt;/p&gt;
&lt;p&gt;piecewise(op(map(op,[seq([t&amp;lt;x[i],h[i]],i=1..9)])),t&amp;lt;=x[10],hz[10]);&lt;/p&gt;
&lt;p&gt;where I have singled out the last one since you want &amp;lt;= (if you really do).&lt;/p&gt;
&lt;p&gt;Notice that I have used t instead of x. It is not a good idea to use x as a variable name if x[i] is in use.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Preben Alsholm&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Robert Israel beat me to it, but I'll let the following stay.&lt;/p&gt;
&lt;p&gt;Assuming that the values x[i] are sorted increasingly, you can do&lt;/p&gt;
&lt;p&gt;piecewise(t &amp;lt; x[1], hz[1], t &amp;lt; x[2], hz[2], t&amp;lt; x[3], hz[3], t &amp;lt; x[4], hz[4], t &amp;lt; x[5], hz[5],t &amp;lt; x[6], hz[6], t &amp;lt; x[7], hz[7], t&amp;lt; x[8], hz[8], t &amp;lt; x[9], hz[9], t &amp;lt;= x[10], hz[10]);&lt;br /&gt;
&amp;nbsp;&lt;/p&gt;
&lt;p&gt;since piecewise checks the inequalities from the left and stops if the inequality is satisfied.&lt;/p&gt;
&lt;p&gt;Even shorter is&lt;/p&gt;
&lt;p&gt;piecewise(op(map(op,[seq([t&amp;lt;x[i],h[i]],i=1..9)])),t&amp;lt;=x[10],hz[10]);&lt;/p&gt;
&lt;p&gt;where I have singled out the last one since you want &amp;lt;= (if you really do).&lt;/p&gt;
&lt;p&gt;Notice that I have used t instead of x. It is not a good idea to use x as a variable name if x[i] is in use.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Preben Alsholm&lt;/p&gt;</description>
      <guid>44222</guid>
      <pubDate>Thu, 11 Mar 2010 11:30:51 Z</pubDate>
      <itunes:author>alsholm</itunes:author>
      <author>alsholm</author>
    </item>
  </channel>
</rss>