erro em lista de iteração com números aleatórios

Gilberto de Oliveira Frota shared this question 3 years ago
Answered

Olá para todos.

Eu estava fazendo a seguinte construção:

Dada uma piramide de vértices A, B, C, D e um ponto E aleatório interno a essa pirâmide e uma lista de números inteiros de 1 a 8 que devem ser sorteados, Construir a seguinte lista de pontos. partindo de E, marcar o ponto médio entre E e D, se após o sorteio o número for 1 ou 2, entre E e B, se o número sorteado for 2 ou 3, e por aí vai.

para simular o sorteio, usei uma lista de números aleatórios, associada ao seguinte comando:

ListaDeIteração(PontoMédio(X, Se(1 ≤ NúmeroAleatório(1, 8) ≤ 2, D, Se(3 ≤ NúmeroAleatório(1, 8) ≤ 4, B, Se(5 ≤ NúmeroAleatório(1, 8) ≤ 6, C, A)))), X, {E}, 5000)

A princípio, o comando funciona muito bem e obtenho o resultado esperado, porém após salvar o arquivo e fechar o programa, acontece um fenômeno interessante: O programa elimina o comando número aleatório e cria um número estático, alterando a construção. Quando olho as propriedades da construção o comando passa a ser: ListaDeIteração(PontoMédio(X, Se(1 ≤ 6 ≤ 2, D, Se(3 ≤ 4 ≤ 4, B, Se(5 ≤ 5 ≤ 6, C, A)))), X, {E}, 5000).

Seguem as imagens da construção antes de fechar o programa e depois de abrir o programa.

No caso, quando eu abro novamente o arquivo, A construção é alterada de modo que perco a construção original. dessa forma tenho que alterar o comando para ter recuperar a construção original. Como posso solucionar esse problema?

Agradeço desde já as propostas de solução.

Comments (15)

photo
1

Please post your .ggb file

photo
1

IterationList(Midpoint(X, If(1 ≤ RandomBetween(1, 8) ≤ 2, D, If(3 ≤ RandomBetween(1, 8) ≤ 4, B, If(5 ≤ RandomBetween(1, 8) ≤ 6, C, A)))), X, {E}, 5000)

when i close the program, the comand RandomBetween(1, 8) disapears

photo
1

segue um link com o vídeo explicando o erro:

https://youtu.be/nG-3N4jTt9s

photo
1

I am afraid that great number of points do the device overflows

photo
1

change to 1000 iterations.

Iwill do this, here.

photo
2

corrijo: he hecho pruebas con solo 10 puntos y presionando F9 da errores desde el principio

así que he rehecho el trabajo un poco más simple y creo que funciona hasta con 1000

Files: foro.ggb
photo
1

I did understand.

if I use this comand, geogebra will generates only 10 points, but when I press f9, it wil update the list of points. But the trace is on, then the old position of the points is showing up due to the trace. this doesn't overload the computer's memory, with a lot of points. thank you very much!!

photo
photo
1

Does it work if you change


1 ≤ RandomBetween(1, 8) ≤ 2
to

RandomBetween(1, 4) = 1
and


If(3 ≤ RandomBetween(1, 8) ≤ 4
to

RandomBetween(1, 4) =1
etc?

photo
1

yes, works

I'm not shure, but the corner points are not evenly distributed(?). I think this is a fundamental design flaw (not a GGB-Bug). The chance for the point A is less 1/4(?)

photo
1

I used 200 points without problem

photo
photo
1

thank you, I will try it

photo
1

I have only a Workaround. The following command make the same and is after save restore unchanged.

l1 = IterationList(Midpoint(X, RandomElement({A, B, C, D})), X, {E}, 5000)

.

But now I have a new Bug:

If A=Point(yAxis) then RandomElement(A,B,C,D) bring only for A a value. The other 3 values are undefined.

RandomElement(A,B,C,D) inside the IterationList bring only with the first iteration (value = E) a result.

Workaround for the new Bug: Define A as full-free point. (D is also semi-free, but not must be change to full-free !!?!! Note: RandomElement(C,B,A.E)) also not works (?), although C is full-free.)

photo
1

Point(yAxis) is a 2D point but the others are 3D. All elements of a list need to be the same type

photo
1

agree, thanks

Note: A=Point(yAxis)+(0,0,0) is a 3D-Point

l1 = IterationList(Midpoint(X, RandomElement({A + (0, 0, 0), B, C, D})), X, {E}, 5000)

photo
photo
1

Obrigado a todos que contribuíram com suas ricas ideias para otimizar minha humilde construção.

Aprendi novas abordagens simples que sequer passaram pela minha mente.

Muito obrigado

© 2023 International GeoGebra Institute