Ask Your Question

wisher's profile - activity

2023-07-31 18:05:24 +0200 received badge  Nice Question (source)
2023-07-29 10:20:07 +0200 commented answer sol = solve([x^2+y^2+z^2==2, x^3+y^3+z^3==2,x^4+y^4+z^4==2], x,y,z)

Thank you very much for your answer. I update my version of SageMath immediately.

2023-07-29 10:18:35 +0200 marked best answer sol = solve([x^2+y^2+z^2==2, x^3+y^3+z^3==2,x^4+y^4+z^4==2], x,y,z)

Hello, to answer a question asked on QUORA I asked SageMath to solve the following system of 3 equations with 3 unknowns.

var('x,y,z')
sol = solve([x^2+y^2+z^2==2, x^3+y^3+z^3==2, x^4+y^4+z^4==2] , X Y Z)
for s in sol:
     print s[0], s[1], s[2]

I got 9 solutions: 3 real and 6 complex.

x == 1 y == 1 z == 0
x == 0 y == 1 z == 1
x == 1.240011837821841 y == (-0.6200059048588131 + 0.3914357752931961*I) z == (-0.6200059048588134 - 0.3914357752931976*I)
x == 1.240011837821841 y == (-0.6200059048588131 - 0.3914357752931961*I) z == (-0.6200059048588134 + 0.3914357752931976*I)
x == (-0.6200059048588129 - 0.391435775293197*I) y == (-0.6200059048588129 + 0.391435775293197*I) z == 1.240011837821841
x == (-0.6200059048588129 - 0.391435775293197*I) y == (1.240011809717629 + 2.19850512568856e-15*I) z == (-0.6200059048588252 + 0.3914357752932104*I)
x == (-0.6200059048588129 + 0.391435775293197*I) y == (-0.6200059048588158 - 0.3914357752931977*I) z == (1.240011809717626 - 4.44089209850063e-16*I)
x == (-0.6200059048588129 + 0.391435775293197*I) y == (1.240011809717633 + 2.41169094738639e-14*I) z == (-0.620005904858701 - 0.3914357752932433*I)
x == 1 y == 0 z == 1

A reader answered me this: In fact, there are 15 solutions. SageMath forgets certain permutations. And it doesn't give the exact values (except for the three obvious real solutions).

Can any of you explain to me how to get all the exact solutions (with exponentials)? I thank you in advance.

2023-07-29 01:15:29 +0200 commented question sol = solve([x^2+y^2+z^2==2, x^3+y^3+z^3==2,x^4+y^4+z^4==2], x,y,z)

Indeed I still work with version 7.3. I will make the transition as soon as possible to the latest version. A big thank

2023-07-29 00:37:26 +0200 asked a question sol = solve([x^2+y^2+z^2==2, x^3+y^3+z^3==2,x^4+y^4+z^4==2], x,y,z)

sol = solve([x^2+y^2+z^2==2, x^3+y^3+z^3==2,x^4+y^4+z^4==2], x,y,z) Hello, to answer a question asked on QUORA I asked S

2023-06-23 08:21:04 +0200 commented question Why does Sage seem to be wrong?

You are right, I still use Sage v7.3.

2023-06-23 00:53:17 +0200 commented answer Why does Sage seem to be wrong?

Thank you for your quick reply, which I understood, but as I'm still working with Sage v7.3 the instruction real_nth_roo

2023-06-23 00:15:35 +0200 received badge  Notable Question (source)
2023-06-23 00:15:35 +0200 received badge  Popular Question (source)
2023-06-23 00:11:48 +0200 received badge  Notable Question (source)
2023-06-23 00:10:26 +0200 received badge  Popular Question (source)
2023-06-23 00:07:23 +0200 received badge  Notable Question (source)
2023-06-23 00:07:23 +0200 received badge  Popular Question (source)
2023-06-23 00:05:34 +0200 received badge  Popular Question (source)
2023-06-23 00:05:34 +0200 received badge  Notable Question (source)
2023-06-22 23:34:49 +0200 asked a question Why does Sage seem to be wrong?

Why does Sage seem to be wrong? I ask Sage to calculate the following expression x = (70 - 13*sqrt(29))^(1/3) + (70 + 1

2023-02-26 16:30:05 +0200 received badge  Famous Question (source)
2022-05-20 23:54:48 +0200 received badge  Popular Question (source)
2022-05-20 23:54:48 +0200 received badge  Notable Question (source)
2020-12-24 15:53:25 +0200 received badge  Notable Question (source)
2020-12-24 15:53:25 +0200 received badge  Popular Question (source)
2020-12-16 09:43:45 +0200 received badge  Popular Question (source)
2020-12-15 23:42:31 +0200 commented answer Square, cube, octahedron, equations

Thank you for your reply. She made me understand that I have math gaps. I'm going to check out math sites to try and figure out what L-infinity norm is. I have cut out!

2020-12-15 11:00:00 +0200 asked a question Square, cube, octahedron, equations

We know that $|x| + |y| - 1 = 0$ is the equation of a square having its vertices on the axes.

I asked to represent the equation $|x| + |y| + |z| - 1 - 0$, believing to obtain a cube in space.

But I obtain an octahedron. Why? And how do you get a cube?

# with SageMath 7.3
var('x, y, z')
f = abs(x) + abs(y) + abs(z) - 1
implicit_plot3d(f, (x, -1, 1), (y, -1, 1), (z, -1, 1), color='aquamarine ')
2020-08-26 15:54:33 +0200 received badge  Necromancer (source)
2020-08-26 15:54:33 +0200 received badge  Teacher (source)
2020-08-26 10:18:15 +0200 answered a question output.txt not updated

This problem has already made me bitch a few times until I found a solution: I copy the script to a new cell, make the modifications and there I get a new "full_output.txt file" which takes into account my modifications. One response says: "But reloading should get you what you want." I have found that this is not true! the old "full_output.txt file" is still present. (sorry for my bad english, i use google translator)

2019-01-24 16:28:04 +0200 commented question Problem with boring message

Excuse me for the delay in answering you. I did a restoration of my previous work to the problem caused by the use of LaTeX, which I do not need, and everything is back to normal. Sorry for your lost time.

2019-01-19 23:12:50 +0200 commented question Problem with boring message

Good evening, I do not use Latex.After being seen on the site ctan.org I decided that I did not need Latex. I also tried bits of codes like

var ('z ')
print latex (z ^ 12)

to see what that gave. As said in my request I always get the following message.

Error: PDFLaTeX does not seem to be installed. Download it from ctan.org and try again. None

What is serious now is that if I activate cells that already contain code that worked I still get this message and nothing else.

2019-01-19 17:45:55 +0200 asked a question Problem with boring message

In one of my worksheets I wanted to test Latex. I was directed to ctan.org After reading a bit about it, I decided that I did not need it. But since this test, whenever one of my exercises launches I get the following message and nothing else. How to get rid of this? Thanks in advance for your time.

Error: PDFLaTeX does not seem to be installed. Download it from ctan.org and try again. None

2018-12-06 09:43:04 +0200 commented answer Speed a function with hex grid and primes numbers

I did two more tests, here is the result:

lim       DP3           time in s
60001     1057          18 440
90001     1454          37 690  !
100001  -> the Sage software stops after a few seconds without an error.

I think the matrix has become too big. We must find another method of resolution, either mathematical or computer. I'll think about it. Anyway thank Mr. Lelièvre you for your help that allowed me to learn new concepts about prime numbers.

2018-12-05 10:52:19 +0200 commented answer Speed a function with hex grid and primes numbers

I'm going to run the program for more value from "lim" quite to running my computer all night. I will provide the results later.

2018-12-05 10:47:09 +0200 commented answer Speed a function with hex grid and primes numbers

I tested your second idea in more depth. As soon as we increase the value of "lim" it is your second idea that is the most powerful.

lim         DP3      time in s
1001      78           4.6
2001      119        17.5
3001      152          38
4001      180          69
5001      208        108
6001      240        157
8001      288        282
16001    433       1151
30001    644       4077

The curve that adjusts the pairs of points (DP3, time) seems parabolic or exponential. So it's not pleasant since you have to reach a DP3 = 2016. Rather than the brute force of the computer, there must be a simpler mathematical process that goes beyond me. It is simply frustrating to feel incapable of not knowing the right simplification techniques. Thank you

2018-12-04 00:10:08 +0200 commented answer Speed a function with hex grid and primes numbers

Thanks for your answer but your idea is slower. I have made a little try.

  • with my code: dp = len( [t for t in d if is_prime(abs(n-t))] ) I found an answer after 7.8 s

  • with your code: dp = len( [t for t in d if (n-t).abs().is_pseudoprime()] ) I found an answer after 10.4 s

2018-11-30 17:31:22 +0200 asked a question Speed a function with hex grid and primes numbers

Hello, I am trying to solve the question 175 of the Turing Challenge. We create a network of hexagonal tiles containing the following integers 1, 2, 3, 4, ... I represent this network in a square matrix by placing the number 1 in the center of the matrix. We must calculate the difference between each tile numbered n and each of its six neighbors, we will call DP (n) the number of these differences # which are a prime number. My problem is this: I have to calculate a lot of times the function below. We save in DP3 the n which are surrounded by exactly 3 prime numbers. Here is all my script. My idea is this: every time I have completed a turn I can calculate the DP3 of the previous turn. The program stops when len (DP3) = 2016. As the spirals become bigger and bigger you have to make more and more calls to the DP3 () search function. My question is: is it possible to speed up this function?

PS: I'm sorry for my bad english. I also note that I am a beginner in programming.

# TURING 175 - Tuiles hexagonales (essai VII)  DERNIER 26/11/18   OK ma!s trop lent
# Une tuile hexagonale portant le numéro 1 est entourée d'un anneau de six tuiles numérotées de 2 à 7, la première tuile de l'anneau étant # posée à midi et en tournant dans le sens inverse des aiguilles d'une montre. 
# De nouveaux anneaux sont ajoutés de la même façon, les anneaux suivants étant numérotés 8 à 19, de 20 à 37, de 38 à 61, et ainsi de 
# suite. Le diagramme ci-contre montre les trois premiers anneaux. 

# En calculant la différence entre la tuile numérotée n et chacune de ses six voisines, nous appellerons DP(n) le nombre de ces différences # qui sont un nombre premier. 
# Par exemple, autour de la tuile numéro 8, les différences sont 12, 29, 11, 6, 1 et 13. Donc DP(8)=3. 
# De la même manière, autour de la tuile numéro 17, les différences sont 1, 17, 16, 1, 11 et 10, d'où DP(17)=2. 
# On peut montrer que la valeur maximale de DP(n) est 3. 
# Quand toutes les tuiles pour lesquelles DP(n)=3 sont énumérées dans l'ordre croissant pour former une suite, la 10ème tuile
# porte le numéro 271. 
# Trouver le numéro de la 2016ème tuile de cette suite.

temps = walltime()

var('n,x,y')

def rechercheDP3(n,x,y):
    n = M[x, y]
    d = [ M[x-1, y], M[x, y+1], M[x+1, y+1], M[x+1, y], M[x, y-1], M[x-1, y-1] ]    # les 6 cases qui entourent n
    dp = len( [t for t in d if is_prime(abs(n-t))] )
    if dp == 3:
        DP3.append(n)
    return

lim  = 17                  # Attention, il faut que lim soit impair
M = matrix(ZZ, lim, lim)     # création matrice nulle M    ATTENTION:  X est vertical vers le bas &  Y est horizontal vers la droite 
x, y = lim//2, lim//2        # centre de M on compte à partir de 0 
print "Centre:", x, y
M[x, y]     = 1              # le nombre 1 est placé au centre puis le 1er tour (2,3,4,5,6,7)
M[x-1, y]   = 2
M[x-1, y-1] = 3
M[x, y-1]   = 4 
M[x+1, y]   = 5
M[x+1, y+1] = 6
M[x, y+1]   = 7
n = 7
x_debut_prec, y_debut_prec = x-1, y

DP3 = [1]
maxtour = lim//2
tour = 1                    # on a déjà placé le 1er tour 2...7
grandeur_deplact = 1        # plus la spirale est extérieure plus le déplacement est grand  
print "maxtour = ", maxtour 
print "*",walltime(temps) 
#print M        # valable si n est petit
#print

# on remplit la table en spirale
while tour < maxtour and len(DP3)<2016:        # 2016 est la valeur demandée dans l'énoncé
    tour += 1
    grandeur_deplact +=1
    # on se place au-dessus de la case de départ (2,8,20,...) -> 6 trajets de 1 au 1er tour, de 2 au 2d tour, de 3 au 3e tour, ....
    x = x_debut_prec - 1
    n += 1                   #n = dernier_terme_tour + 1

    M[x, y] = n
    x_debut_suivant, y_debut_suivant = x, y     # coord case départ tour suivant

    for i in xrange(grandeur_deplact):     # trajet 1 horizontal gauche
        y = y-1
        n += 1
        M[x, y] = n

    for i in xrange(grandeur_deplact):     # trajet 2 vertical bas
        x = x+1
        n += 1
        M[x, y] = n

    for i in xrange(grandeur_deplact):     # trajet 3 oblique bas droit     
        x = x+1  
        y = y+1        
        n += 1
        M[x, y] = n

    for i in xrange(grandeur_deplact):     # trajet 4 horizontal droite       
        y = y+1
        n += 1
        M[x, y] = n        

    for i in xrange(grandeur_deplact):     # trajet 5 vertical haut        
        x = x-1        
        n += 1
        M[x, y] = n  

    for i in xrange(grandeur_deplact-1):     # trajet 6 oblique haut gauche -1 car on retombe sur le 1er -> le tour est fini
        x = x-1 
        y = y-1       
        n += 1
        M[x, y] = n          

    dernier_tour_n = n                        # on mémorise le tour qu'on vient de faire
    xfin_tour = x
    yfin_tour = y   


    # recherche les dp3 -> on recommence le tour précédent et on cherche ses DP3
    grandeur_deplact -= 1       
    # on se place au-début du tour précédent (2,8,20,38,62,92,...)
    x,y = x_debut_prec, y_debut_prec
    np = M[x,y]    # np comme cela on ne touche pas à n
    rechercheDP3(np,x,y)

    for i in xrange(grandeur_deplact):     # trajet 1 horizontal gauche
        y = y-1
        np += 1
        rechercheDP3(np,x,y)

    for i in xrange(grandeur_deplact):     # trajet 2 vertical bas
        x = x+1
        np += 1
        rechercheDP3(np,x,y)

    for i in xrange(grandeur_deplact):     # trajet 3 oblique bas droit     
        x = x+1  
        y = y+1        
        np += 1
        rechercheDP3(np,x,y)

    for i in xrange(grandeur_deplact):     # trajet 4 horizontal droite       
        y = y+1
        np += 1
        rechercheDP3(np,x,y)       

    for i in xrange(grandeur_deplact):     # trajet 5 vertical haut        
        x = x-1        
        np += 1
        rechercheDP3(np,x,y)

    for i in xrange(grandeur_deplact-1):     # trajet 6 oblique haut gauche
        x = x-1 
        y = y-1       
        np += 1
        rechercheDP3(np,x,y)

    # retour aux bonnes valeurs 
    grandeur_deplact += 1   # on revient à la valeur exacte pour le tour suivant
    x = x_debut_suivant  
    y = y_debut_suivant
    x_debut_prec, y_debut_prec = x_debut_suivant, y_debut_suivant

if len(DP3) >= 2016:
    print DP3(2015)
else:
    print "len(DP3) = ", len(DP3)

print "Durée = ", walltime(temps)
2018-10-27 10:43:32 +0200 received badge  Supporter (source)