Menu

#4693 Makelist completely fails with simp:false

None
open
nobody
None
5
2026-03-31
2026-03-31
No

The makelist function completely fails with simp:false. This is a minimal example:

simp:false;
makelist(k,k,1,5);

This is a real problem for users of STACK (https://stack-assessment.org/) who need to generate un-simplified expressions.

Related

Bugs: #4693

Discussion

  • Christopher Sangwin

    I think this should be fairly simple to fix, by "simplifying" the numbers before testing. I'm suggesting we don't go as far as using this.

    (defun interval2 (i s d)
      (do ((nn i (let (($simp t))
                   (meval `((mplus) ,s ,nn))))
           (m 0 (1+ m))
           (ans))
          ((> m d) (nreverse ans))
        (push nn ans)))
    

    If you want the values of the variables simplified, you can always use

    makelist(ev(k,simp)^2,k,1,4);

     
  • Christopher Sangwin

     

    Last edit: Christopher Sangwin 2026-03-31
    • Raymond Toy

      Raymond Toy - 2026-03-31

      What's wrong with telling people to use 'makelist(k,k,1,5)?

      I'm not really keen on hacking on things so that simp:false will work in some specific cases. (But I never turn that off, so I'm not a good judge on what simp:false should or should not do.)

       
      • Christopher Sangwin

        Sorry, I should have explained the use-case more clearly. The goal is to create un-simplified objects, e.g. for the student to simplify themselves.

        We use simp:false all the time when using Maxima for online assessment. I appreciate that's unusual to CAS users who always want the answer to a calculation!

        'makelist(k,k,1,5) returns the makelist unevaluated. We would like things like

        makelist(ev(k,simp)+2,k,1,5) to return [1+2,2+2,3+2,4+2,5+2]. The only reason makelist currently fails is because the error trapping does not recognize the un-simplified numbers.

        We're not proposing simp:falsewill work in some specific cases, rather we'd like comprehensive support for simp:false. This particular example (with makelist) comes up a lot. Our long-standing work around is to use something like

        map(lambda([ex], ex+2), ev(makelist(k,k,1,5),simp))

        which is rather artificial! I hope this makes sense.

        (For anyone new to STACK, which uses Maxima, the project website is herehttps://stack-assessment.org/ The Maxima community would be very welcome at one of our conferences or meetings. Thanks for Maxima, it's great. I'm making this suggestion as a genuine improvement).

         
        • Leo Butler

          Leo Butler - 2026-03-31

          Following my post below, the easy and natural way to make your example work is like this:

          (%i1) l : makelist(Plus(k,2),k,1,5);
          (%o1)    [Plus(1, 2), Plus(2, 2), Plus(3, 2), Plus(4, 2), Plus(5, 2)]
          (%i2) lsimp : subst(Plus="+", l);
          (%o2)                           [3, 4, 5, 6, 7]
          

          and then

          (%i3) texput(Plus,lambda([expr],printf(false,"~{~a~^+~}",map(tex1,args(expr)))))$
          (%i4) tex(l);
          $$\left[ 1+2 , 2+2 , 3+2 , 4+2 , 5+2 \right] $$
          

          We can define more complicated simplifiers for the Plus operator (or analogues), but subst will work 99% of the time for the problems in STACK.

          And, if your users prefer an infix operator instead of the prefix operator Plus, that is no problem:

          infix("⨹"); /* or ++ or ... */
          texput("⨹",lambda([expr],tex1(subst("⨹"=Plus,expr))));
          

          For example,

          ```
          (%i20) l : makelist(k ⨹ 2 ⨹ Exp(k,3),k,1,5);

          (%o20) [(1 ⨹ 2) ⨹ Exp(1, 3), (2 ⨹ 2) ⨹ Exp(2, 3), (3 ⨹ 2) ⨹ Exp(3, 3),
          (4 ⨹ 2) ⨹ Exp(4, 3), (5 ⨹ 2) ⨹ Exp(5, 3)]

          (%i21) tex(l);
          $$\left[ 1+2+{1}^{3} , 2+2+{2}^{3} , 3+2+{3}^{3} , 4+2+{4}^{3} , 5+2+{5}^{3}
          \right]
          $$

          (%i22) lsimp : subst(["⨹"="+", Exp="^"], l);
          (%o22) [4, 12, 32, 70, 132]

          ```

           
  • Leo Butler

    Leo Butler - 2026-03-31

    I agree with Ray about simp:false. Besides, Maxima provides a more powerful way to deal with this problem: noun operators. For example, I want to produce a list of (unsimplified) squares:

    l : makelist(Exp(k,2),k,1,5);
    lsimp : subst(Exp="^",l);
    

    In 1d display:

    (%i1) l : makelist(Exp(k,2),k,1,5);
    (%o1) [Exp(1,2),Exp(2,2),Exp(3,2),Exp(4,2),Exp(5,2)]
    (%i2) lsimp : subst(Exp="^",l);
    (%o2) [1,4,9,16,25]
    

    If I want to make the display look nice in TeX, I can add a printer for TeX:

    (%i3) texput(Exp,lambda([expr],printf(false,"{~a}^{~a}",tex1(first(expr)),tex1(second(expr))))) $
    

    and then

    (%i4) tex(l);
    $$\left[ {1}^{2} , {2}^{2} , {3}^{2} , {4}^{2} , {5}^{2} \right] $$
    

    This is, I think, a much more robust way to deal with the problem of generating "unsimplified" expressions. Too much of Maxima's capabilities cease to function when the simplifier is turned off. I don't think this is a bug, because Maxima provides a means to create unsimplified or partially simplified expressions even when the simplifier is on.

     
    • Stavros Macrakis

      makelist uses the simplifier to perform arithmetic in order to cover all
      kinds of number, e.g.,

      makelist(i,i,2/3,5.0b0) => [2/3,5/3,8/3,11/3,14/3]

      makelist(i,i,-2.1b0,0,7/8) => [-2.1b0, -1.225b0, -3.5b-1]

      As an incidental bonus, it handles some non-numeric cases:

      makelist(i,i,n,n+2) => [n, n+1, n+2]
      makelist(i,i,sqrt(%e),%pi) => [sqrt(%e), sqrt(%e)+1]

      I say incidental because it doesn't handle the general symbolic case,
      where the termination condition requires symbolic comparisons. But I don't
      think anyone needs or wants that case (in any case is is very weak).

      Is it reasonable to bind simp to t while evaluating incrementation and
      termination? I guess it doesn't interfere with the usual reasons that
      people use simp:false.

               -s
      

      On Tue, Mar 31, 2026 at 12:12 PM Leo Butler via Maxima-bugs maxima-bugs@lists.sourceforge.net wrote:

      I agree with Ray about simp:false. Besides, Maxima provides a more
      powerful way to deal with this problem: noun operators. For example, I want
      to produce a list of (unsimplified) squares:

      l : makelist(Exp(k,2),k,1,5);lsimp : subst(Exp="^",l);

      In 1d display:

      (%i1) l : makelist(Exp(k,2),k,1,5);
      (%o1) [Exp(1,2),Exp(2,2),Exp(3,2),Exp(4,2),Exp(5,2)]
      (%i2) lsimp : subst(Exp="^",l);
      (%o2) [1,4,9,16,25]

      If I want to make the display look nice in TeX, I can add a printer for
      TeX:

      (%i3) texput(Exp,lambda([expr],printf(false,"{~a}^{~a}",tex1(first(expr)),tex1(second(expr))))) $

      and then

      (%i4) tex(l);$$\left[ {1}^{2} , {2}^{2} , {3}^{2} , {4}^{2} , {5}^{2} \right] $$

      This is, I think, a much more robust way to deal with the problem of
      generating "unsimplified" expressions. Too much of Maxima's capabilities
      cease to function when the simplifier is turned off. I don't think this is
      a bug, because Maxima provides a means to create unsimplified or partially
      simplified expressions even when the simplifier is on.


      [bugs:#4693] https://sourceforge.net/p/maxima/bugs/4693/ Makelist
      completely fails with simp:false

      Status: open
      Group: None
      Created: Tue Mar 31, 2026 09:31 AM UTC by Christopher Sangwin
      Last Updated: Tue Mar 31, 2026 04:04 PM UTC
      Owner: nobody

      The makelist function completely fails with simp:false. This is a minimal
      example:

      simp:false;makelist(k,k,1,5);

      This is a real problem for users of STACK (https://stack-assessment.org/)
      who need to generate un-simplified expressions.


      Sent from sourceforge.net because maxima-bugs@lists.sourceforge.net is
      subscribed to https://sourceforge.net/p/maxima/bugs/

      To unsubscribe from further messages, a project admin can change settings
      at https://sourceforge.net/p/maxima/admin/bugs/options. Or, if this is a
      mailing list, you can unsubscribe from the mailing list.


      Maxima-bugs mailing list
      Maxima-bugs@lists.sourceforge.net
      https://lists.sourceforge.net/lists/listinfo/maxima-bugs

       

      Related

      Bugs: #4693


Log in to post a comment.

MongoDB Logo MongoDB