problem latex of library incompatibility matplotlib rc

asked 2021-12-14 10:36:38 +0100

ortollj gravatar image

Hi

W10 SageMath 9.4 in Ubuntu WSL2

my answer is not a valid answer in the post:LaTeX can't find file for text in plot

my answer is not valid I noticed a problem of library incompatibility:

from sage.symbolic.integration.integral import definite_integral
var('t,a,b')
aNum=3 ;bNum=1
numDictab={a:aNum,b:bNum}
ds2(t)=4*a^4*b^8*t^2/(b^2*t^2 + a^2)^4 + (2*a^2*b^4*t^2/(b^2*t^2 + a^2)^2 - a^2*b^2/(b^2*t^2 + a^2))^2
ds=sqrt(ds2)
E_d(x)=-bNum* sqrt(1-(x/aNum)^2)
fourProjectedPointsFromLine=[[-990/1021, -900/1021], [18/37, -36/37], [90/109, -100/109], [0, 0]]
pointL=['A', 'B', 'C', 'D']
Gds=list_plot(fourProjectedPointsFromLine,color='blue',size=20)
for i in range(0,len(fourProjectedPointsFromLine)) :
    Gds+=text(pointL[i],vector(fourProjectedPointsFromLine[i])+vector([0.1,0.1]),color='blue',fontsize=15)


# incompatibility problem with these 5 lines uncommented and the use of from matplotlib import rc 
#threePointsOnLine=[[-11/10, -1], [1/2, -1], [9/10, -1]]
#pointL1=['A_1', 'B_1', 'C_1', 'D_1']
#Gds+=list_plot(threePointsOnLine,color='blue',size=20)
#for i in range(0,len(threePointsOnLine)) :
#    Gds+=text(pointL1[i],vector(threePointsOnLine[i])+vector([0.1,0.1]),color='blue',fontsize=15)


Gds+=plot(E_d,color='black')
Gds+=text("line outside <-                  -> Ellipse  inside",[0.0,0.1],color='red',fontsize=8)
show(Gds,aspect_ratio=1,figsize=12)

Sc=integrate(3/2*sqrt(-8/9*sin(t)^2 + 1), t, 0, pi)
from matplotlib import rc
rc('text', usetex=True)
aNum=3
aFact=1
legLabelD=r'ds= $\displaystyle'+latex(ds.subs(numDictab))+r'$'
Gds=plot((ds).subs(numDictab)/Sc.n(),(t,-aFact*aNum,aFact*aNum),legend_label=legLabelD,color='blue')
var('sigma,mu,kMax')
normalPDF=1/(sqrt(2*pi*sigma^2)) * e^(-(((t-mu)/sigma )^2)/2)

sig0=(ds(t=0)).subs(numDictab)/(Sc.n())
sig=solve(normalPDF.subs(mu=0,t=0)==sig0,sigma)[-1].rhs()
show(sig)
numDict={mu:0,sigma:sig,kMax:0}
normalCDFnum=definite_integral(normalPDF.subs(numDict),t,-infinity,0) 


legLabelN=r'normal = $\displaystyle'+latex(normalPDF)+r'$'
Gds+=plot(normalPDF.subs(numDict),(t,-aFact*aNum,aFact*aNum),
          legend_label=legLabelN, fontsize=16,color='red')
show(Gds,aspect_ratio=10)
edit retag flag offensive close merge delete