#289 part/nformat loses simp flags: part(factor(12),1)

Lisp Core (471)

part(factor(12),1) yields 4, not 2^2.

This is because part (as opposed to inpart) calls
nformat, and nformat drops simp flags.

This is actually not trivial to fix in general, since nformat
does create unsimplified expressions (involving quotient)
which need to be resimplified.

There are two solutions I can think of:

1) Instead of using nformat in part, do the reformatting
on the fly, only creating new unsimplified list structure
where necessary (e.g. part(x*y/z,1)). This is bad
because it means that the logic of nformat would exist in
two different versions, which would have to be kept in

2) Have nformat preserve simp flags to the largest extent
possible. This might appear inconsistent in some
cases, although I don't think there are any such cases
in current Maxima.

I vote for (2).



  • Stavros Macrakis

    Logged In: YES

    This also affects other functions that use nformat, such as
    args, so that args(factor(12)) returns [4,3], not [2^2,3]. Also

    So the only way to extract the exponents of a numbered
    factor appears to be to use inpart to get directly to the

    It is also incorrect that factor doesn't put a factored flag on
    the individual mexpt's. (reported separately)

  • Robert Dodier

    Robert Dodier - 2006-07-06
    • labels: --> Lisp Core

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks