sage sympy

sage

FROM sagemath/sagemath:9.5

RUN sage -pip install pip -i https://pypi.mirrors.ustc.edu.cn/simple/ --upgrade \
    && sage -pip install pandas pydes pyaes pycryptodomex jupyter_contrib_nbextensions jupyter_nbextensions_configurator -i https://pypi.mirrors.ustc.edu.cn/simple/ --no-cache-dir \
    && sage -jupyter contrib nbextension install --user \
    && sage -jupyter nbextensions_configurator enable --user \
    && sage -jupyter nbextension enable highlight_selected_word/main \
    && sage -jupyter nbextension enable hinterland/hinterland \
    && sage -jupyter nbextension enable toc2/main

sage wsl

sage -n jupyter --ip=0.0.0.0 --notebook-dir=/root/sage --allow-root

#https://kojipkgs.fedoraproject.org/packages/Fedora-Container-Base/
#https://koji.fedoraproject.org/koji/packageinfo?packageID=26387
xz -d fedora-34.20211001-x86_64.tar.xz
wsl --import fedora D:\WSL\UFULL fedora-34.20211001-x86_64.tar

sudo sed -e 's|^metalink=|#metalink=|g' \
         -e 's|^#baseurl=http://download.example/pub/fedora/linux|baseurl=https://mirrors.ustc.edu.cn/fedora|g' \
         -i.bak \
         /etc/yum.repos.d/fedora.repo \
         /etc/yum.repos.d/fedora-modular.repo \
         /etc/yum.repos.d/fedora-updates.repo \
         /etc/yum.repos.d/fedora-updates-modular.repo

dnf update -y
dnf install zsh git perl gcc g++ make vim nano util-linux-user wget curl proxychains -y
sh -c "$(proxychains curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
chsh -s $(which zsh)
sed -i '/^ZSH_THEME=/c\ZSH_THEME="ys"' ~/.zshrc
git clone https://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-completions $ZSH_CUSTOM/plugins/zsh-completions
[ -z "`grep "autoload -U compinit && compinit" ~/.zshrc`" ] && echo "autoload -U compinit && compinit" >> ~/.zshrc
sed -i '/^plugins=/c\plugins=(git sudo z zsh-syntax-highlighting zsh-autosuggestions zsh-completions)' ~/.zshrc
echo -e "\nexport LANG=\"zh_CN.UTF8\"" >>~/.zshrc
source ~/.zshrc
#install Miniforge 
conda config --add channels conda-forge
conda config --set channel_priority strict
conda install mamba
mamba create -n sage sage python=X
mamba activate sage
mamba install jupyter_contrib_nbextensions jupyter_nbextensions_configurator

#nbextensions>>
#ExecuteTime
#Hinterland
#Toggle all line numbers
import matplotlib.pyplot as plt
import math
from numpy import linspace
from sympy import Symbol,solve,plot,latex
from sympy.combinatorics.permutations import Permutation
x=Symbol('x')
y1 = 61680+x*0.02/2
y2 = 51120+x*0.04/2
fx=y1-y2
result=solve(fx,x)
markers=[]
annotations=[]
axis_y=y1.subs(x,0)
if axis_y>y2.subs(x,0):
    axis_y=y2.subs(x,0)
for a in result:
    b=y1.subs(x,a)
    markers.append({'args': [a, b, 'r*'], 'ms': 10})
    annotations.append({'xy':(a,b),"text":"$("+latex(a)+","+latex(b)+")$",'ha': 'left', 'va': 'top', 'color': 'blue',"size":10})
p1=plot(y1,(x,0,2000000),legend=True,markers=markers,annotations=annotations,show=False,
    title="title",xlabel='x',ylabel="f(x)",xscale='linear',axis =True,axis_center=[0,axis_y]
    #line_color='r'
    )
p2=plot(y2,(x,0,2000000),legend=True,show=False)
p1.extend(p2)
p1.show()

import matplotlib.pyplot as plt
import numpy as np
 
x1 = np.arange(1500000)
y1 = 61680+x1*0.02
y2 = 51120+x1*0.04
plt.scatter(528000, 61680+528000*0.02, c='red', edgecolors='none', s=80)
plt.plot(x1, y1)
plt.plot(x1, y2)
plt.text(528000, 61680+528000*0.02-3000, '(528000,72240)')
plt.show() 
from sympy.plotting import plot 
from sympy import * 
x=Symbol('x') 
plot( (sin(x),(x, -2*pi, 2*pi)),(cos(x), (x, -pi, pi)), title='SymPy plot example')
import sympy
import matplotlib.pyplot as plt
import math
from numpy import linspace
from sympy import lambdify
x=sympy.Symbol('x')
y1 = 61680+x*0.02/2
y2 = 51120+x*0.04/2
fx=y1-y2
result=sympy.solve(fx,x)
for a in result:
    b=y1.subs(x,a)
    plt.scatter(a, b, c='red', edgecolors='none', s=80)
    plt.text(a,b,"("+str(int(a))+","+str(int(b))+")")
y1x=lambdify(x,y1,modules=['numpy'])
y2x=lambdify(x,y2,modules=['numpy'])
xVals=linspace(0,2000000,10000)
plt.plot(xVals,y1x(xVals),label="y1 = 61680+x*0.02")
plt.plot(xVals,y2x(xVals),label='y2 = 51120+x*0.04')
plt.legend(loc='upper left')
plt.xlabel('x')
plt.ylabel("y")
plt.title('y(x)')
plt.show()
latex(Integral(sqrt(1/x),x))
f=(x**3+x**2-x-1)/(x**2+2*x+1)
pprint(f)
pprint(f.simplify())
def n2s(m):
    return bytes.fromhex(m.hex()).decode()
def s2n(m):
    return Integer(m.encode().heex(),base=16)
import libnum
gift = 0x648019c4947179187e1b091941e1b02579e6553935cd4a062a518e3a887e63f7bf7fae48f8aae6920349d0bfc2e43a3bb6dc0fa65fd9f8200e87b7c349313fd8ccbc5ed9397a15cf5f7e10634d9bebc62ddaca921fc91879d1c51c14f03231ca037bcb0858f0dfe5a0cabdd3a83cff3012babaf4792b8906291bfccfe4ec3e43
x = 0x44b13cd3bccf0839cf7a4570f320a3588b7a6177a8b30237e2d3ccad6966db732e019a9e23312ff35171c2da9f1464f3249b77e67fff76c3f2e9b6390f6b5ec
y = 0xb168b2fcab63103ee619f387a20bbfcfeb0a87bf7f339dd6f84d5f93187c27a0bafa1e0317dc5a02055a6867810fdb0c1976fa9e0101278cafa8e778f4f6cf95
k1p = gift - x
k2q = gift - y
e = 0x10001
n = 0x96ec5a787fe02affea57b535d2ca3475612722967c8d67d2dc950ee7a67dcb432690bbf3ebbab64f1676956ed022d4c3e6fa075cc8f3e83dbb69e17aa8298f21e0fb03f5f119522ce80b02b89d83343cba4d9da3f4b79f34473d28768400bd1704d6b65b9add858801cdb00880ad123024d68263360bb0374d95da3f8f595503
p = gcd(n,k1p)
q = gcd(n,k2q)
phi = (p-1)*(q-1)
d = inverse_mod(e, phi)
c = 0x45ed5cfedd662bc76cae0ec229b3d81328cffd1237640f1866fe4f33cd78ef7a2a3d8566e189cc284d9a901fc2de361ef50910df0830cec7fc02a34a6917107e2926a006fb38db9d2c8f5031c4445e0819a07632e19020f3076b2e1e311ee11f961204016464f7c8cb7a3c87b7571690f25db6bc7427b4156117776f16f6faef
m=pow(c,d,n)
print("m: ",m)
print("p: ", p)
print("q: ", q)
print(type(m))
print(libnum.n2s(int(m)).decode())

posted @ 2021-09-30 15:56  月渊  阅读(702)  评论(0编辑  收藏  举报