List of triple factorization without repetition of a whole number

jospercomp shared this question 1 month ago
Answered

How to create a list of possible triple factorizations of a number without repetition.

6=> {{1,1,6},{1,2,3}}

12=> {{1,1,12},{1,2,6},{1,3,4},{2,2,3}}

etc.

Best Answer
photo

que trabaje el PC

o en una sola linea

KeepIf(Product(P) ≟ a, P, Unique(Join(Join(Zip(Zip(Zip(Sort({p, q, r}), p, DivisorsList(a)), q, DivisorsList(a)), r, DivisorsList(a))))))

Files: foro.ggb

Comments (8)

photo
2

Why do you need that? Up to what number?

photo
1

That is to create the set of rectangular prisms with the same volume.

They are the whole partitions of the volume in width, length and height.

At least I have an idea that it can be solved with the two DivisorsList command

and two Sequence command nested, Sort command and Unique command.

https://wiki.geogebra.org/e...

n=1,000

photo
1

l1=DivisorsList(n);

========================


RemoveUndefined(Sequence(Sequence(Sort({Element(l1, i),

Element(ListDivisors(Element(l1, a - i + 1)),j),

n / (Element(l1, i) * Element(ListDivisors(Element(l1, a - i + 1)),j))}),

j,1,Length(ListDivisors(Element(l1, a - i + 1)))), i, 1, a))

Something similar to this but it gives me an error.

Lexical error at line 1, column 30. Encountered "[" (91), after: ""

/oojNFw0utRJqC0JyWQUqDSi1UaWJIoURCAMdAG1AA1QA1QA0vVQCKm+AHKhpSA6v8B1Z7AnnMhZh0AAAAASUVORK5CYII=

photo
photo
1

Idee:


1. Die Teilerliste mit entsprechenden Häufigkeiten ermitteln (im angehängten Ideen-File die Liste G )


2. Alle Zweierpartitionen ermitteln mit Hilfe der Binärdarstellung, denn die Potenzmenge lässt sich mit der Menge {0,1,2,3,... 2^Länge(G)-1} in Binärdarstellung identifizieren (im angehängten Ideen-File l1)


3. Wenn z. B. Deine Teilermenge G={2,2,3,7} ist, dann entspricht "1001": Faktor1={2,3} (die Nullen), Faktor2={2,7} (die Einsen) => {1, factor1, factor2}

Natürlich kann eine Darstellung mehrfach vorkommen, aber das kann man dann ja aufräumen.


Problem:


Leider weiß ich nicht, wie man aus dem Text "1001" die entsprechenden Elemente aus der Teilerliste erzeuge, weil IndexVon("1","1001") wohl immer nur den Index für das erstmalige Auftreten von 1 angibt und nicht alle Indizes.


Aber ich vermute mal, dass das im Prinzip geht und einer auch den/die entsprechenden Befehle kennt. :-)


Für die Faktorisierung {factor1, factor2, factor3} mit factor1 >1 wiederholt man dann den Vorgang, indem man alle zuvor gefunden Faktoren ihrerseits nochmal in zwei Faktoren aufteilt.


Gruß

mire2

photo
3

que trabaje el PC

o en una sola linea

KeepIf(Product(P) ≟ a, P, Unique(Join(Join(Zip(Zip(Zip(Sort({p, q, r}), p, DivisorsList(a)), q, DivisorsList(a)), r, DivisorsList(a))))))

Files: foro.ggb
photo
1

As I would love to create these nested command using KeepIf, Join, Zip, Sort, DivisorsList nest.

Powerful commands and super commands.

photo
1

Generating a list all divisor combinations and trimming the list only at the end is quite inefficient.

If I do this with a = 504 on my old computer, it takes 5-10 seconds to compute. The intermediate list contains 13824 triples, shortened to 2600 after "unique", then trimmed to the final 32 triples. Way too much overhead.

If I try this with 2520, Geogebra tries for half a minute or so, then stops with an error message. (The intermediate list would contain 110592 triples, which Geogebra seems to have problems with.)

Here's a much more efficient version that generates only the final triples without all the intermediate overhead:

Join(Zip(Zip({p, q, a / (p q)}, q, KeepIf(t ≥ p ∧ t² p ≤ a ∧ Mod(a, p t) ≟ 0, t, DivisorsList(a))), p, KeepIf(t³ ≤ a, t, DivisorsList(a))))


Feasible for high numbers with many divisors, but also becomes quite slow for numbers with ~100 divisors and eventually also gives up.

photo
1

Hm....better use

Join(Zip(Zip({p, q, a / (p q)}, q, KeepIf(t ≥ p ∧ t² p ≤ a+0.5 ∧ Mod(a+0.4, p t) <= 0.6, t, DivisorsList(a))), p, KeepIf(t³ ≤ a+0.5, t, DivisorsList(a))))

to make it floating point error proof (at least up to 2^51). I hadn't actually expected floating point issues here (at least not if t^3 is replaced by t*t*t etc. to hopefully avoid calling power functions), but there is some issue with a "less or equal" condition in KeepIf, which I will address in a separate topic.


I also made a javascript version in hopes that it would be faster. Well, the actual computation in javascript is done practically immediately, but I couldn't find an efficient way to get an array of triples from javascript to a Geogebra list. For big lists (a few hundred triples) this step can take over a minute, but at least Geogebra doesn't throw any errors even for large lists this way. File is attached if anyone cares.

photo
© 2021 International GeoGebra Institute