Menu

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

open
nobody
Lisp Core (457)
5
2014-08-14
2003-04-04
No

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
synch.

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).

-s

Discussion

  • Stavros Macrakis

    Logged In: YES
    user_id=588346

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

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

    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.