Tuesday, January 7, 2020

ЛР9 Программирование (2.1 В21) - IV

LabWork9
📑 IT Online Mini Campus. Task 2.1
IV. Программа SageMath (Python)
def create_table(f,x0,hx,n,z0,hz,m,exc):
    pretty_print(html(latex(f)))
    t=[['n','m','x','z','f(x,z)=','f(x,z)≈']]
    for i in [1..n]:
        for j in [1..m]:
            x,z=x0+(i-1)*hx,z0+(j-1)*hz
            if z==exc:
                t.append([i,j,round(x,3),round(z,3),
                          r'$\nexists$',r'$\nexists$'])                
            else:
                t.append([i,j,round(x,3),round(z,3),
                          f(x,z),f(x,z).n(digits=2)])
    return(table(t))
f21(x,z)=(log(sqrt(pi))+abs(2-x))/(3.3-1/z)+z^(2/3)*cos(x^2)
#f22(x,z)=exp((x+2)^(1/3))/(3.5+z)*(1/7+log(sqrt(z)))*sin(x+z)
plot3d(f21,(x,.1,1.1),(z,.1,1.1),mesh=True).show()
create_table(f21,6.7,.1,4,3.3,.2,3,1/3.3)





No comments:

Post a Comment