rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

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

Open rtoy opened 2 months ago

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-04 19:35:16 Created by macrakis on 2003-04-04 00:04:35 Original: https://sourceforge.net/p/maxima/bugs/289


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

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-04 19:35:17 Created by macrakis on 2003-04-04 00:11:07 Original: https://sourceforge.net/p/maxima/bugs/289/#aee8


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)

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-04 19:35:21 Created by robert_dodier on 2006-07-06 05:51:51 Original: https://sourceforge.net/p/maxima/bugs/289/#7568