for those who can appreciate

78 views
Skip to first unread message

Henri Girard

unread,
May 24, 2023, 5:45:37 PM5/24/23
to sage-s...@googlegroups.com

I was trying chatgpt and noticed I was able things I couldn't do myself alone, I think it can help in learning sage because it's a good tool (i am making advert for it lol)

I needed some times to obtain what I wanted and as it gives python sometimes there are mistakes with sage, in graphic I prefer sage libs because I know them better than matplotlib with numpy

from sage.all import *

vertices = [(0, 0), (0, 1), (1, 1), (1, 0)]
p = polygon(vertices, fill=False)

def rotate_point(point, angle):
    rot = matrix([[cos(angle), sin(angle)],
                  [-sin(angle), cos(angle)]])
    return rot * vector(point)

theta1 = pi / 4
theta2 = pi / 2

rotated_vertices1 = [rotate_point(vertex, theta1) for vertex in vertices]
rotated_vertices2 = [rotate_point(vertex, theta2) for vertex in vertices]

# Carré en bas à droite
square_bottom_right = [rotate_point((x + 1, y), theta2) + vector([1, 1]) for x, y in vertices]

# Carré en haut à droite
square_top_right = [rotate_point((x + 1, y + 1), theta2) + vector([0, 2]) for x, y in vertices]

# Centrer le losange
center = vector([0.05, 0.05])
offset = vector([0.245, -0.05])  # Ajuster l'offset selon les besoins
rotated_vertices_centered = [vertex + center + offset for vertex in rotated_vertices1]

show(p + polygon(rotated_vertices_centered, fill=False, color='red') +
     polygon(rotated_vertices2, fill=False, color='blue') +
     polygon(square_bottom_right, fill=False, color='green') +
     polygon(square_top_right, fill=False, color='purple'),
     gridlines="major", axes=False, figsize=5)

William Stein

unread,
May 24, 2023, 6:33:39 PM5/24/23
to sage-s...@googlegroups.com
Thanks for sharing that!

Right now on https://www.phind.com/  if you click on "Use Best Model (slow)" and include "using sagemath" in your question,
it will combine the sagemath docs, web searches, and GPT-4 to answer your question.  This might result in better answers
in some cases than just using chatgpt.   I don't know how long https://www.phind.com will be free or if it is globally available
or what, but it is fun to play with right now.

 -- William 



--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/eccafd8a-9c02-2c65-1275-73f5531cd106%40gmail.com.


--

William Stein

unread,
May 24, 2023, 6:39:07 PM5/24/23
to sage-s...@googlegroups.com
Here is a published version of your code:


A fun thing is that there are now Edit and Run buttons there and anybody can
run and/or edit the code without signing in, and see what happens.   It's kind of
like the sage cell server, except for a notebook...

image.png

William
--

Henri Girard

unread,
May 25, 2023, 1:20:05 AM5/25/23
to sage-s...@googlegroups.com

Thanks for appreciating and doing it on cocalc ! I will send few others I have done all over these  years (since the beginning of sage) with the help of the list ! But first I must find them back !

best

Henri

Henri Girard

unread,
May 25, 2023, 1:25:49 AM5/25/23
to sage-s...@googlegroups.com

I forget to say : I have done it with the windows version installers 9.2 and I compiled sage-10-1 dev because on ubuntu (sage-dev 10.1 compiled but not 10.0 a problem with giac on wsl2), which is a good proof of the facility to get sage working !

Le 25/05/2023 à 00:32, William Stein a écrit :

Henri Girard

unread,
May 25, 2023, 3:36:13 AM5/25/23
to sage-s...@googlegroups.com

thanks to the man in the list I called  f3d, I could make a graphic about a calculation I had done

included : f3d.ipynb and pyramid

Enjoy !

Henri

Le 25/05/2023 à 00:32, William Stein a écrit :
25-5-23-pyramid.ipynb
f3d.ipynb

William Stein

unread,
May 25, 2023, 10:20:06 AM5/25/23
to sage-s...@googlegroups.com

Girard Henri

unread,
May 25, 2023, 11:12:26 AM5/25/23
to sage-s...@googlegroups.com

Very good and speedy : Thanks !

Henri

Henri Girard

unread,
May 25, 2023, 3:11:52 PM5/25/23
to sage-s...@googlegroups.com
New taiji.ipynb and importaiji.ipynb to see how sage developed for about
10 years. (for me )

Enjoy,

Henri

(thanks William for installing them on cocalc)
taiji.ipynb
importaiji.ipynb
Reply all
Reply to author
Forward
0 new messages