CoCalc Public FilesProblemas / Matemática Básica.sagewsOpen with one click!
Author: Leon Denis
Views : 39
Compute Environment: Ubuntu 18.04 (Deprecated)

Encontre o zeros da função f(x)=x+x2sin(x)f(x)=x+x^2\sin(x) em um intervalo de 0 até 20.

%md **Solução**:

Solução:

f=x+x^2*sin(x) Ox=range(0,21) Oy=range(-200,400, 100) plot(f,(x,0,20), figsize=[6,4],ticks=[Ox,Oy], gridlines=True)
intervalos=[(i, i+1) for i in Ox if i<20] intervalos
[(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10), (10, 11), (11, 12), (12, 13), (13, 14), (14, 15), (15, 16), (16, 17), (17, 18), (18, 19), (19, 20)]
raizes=[] for j in intervalos: a=j[0] b=j[1] try: root = find_root(f, a, b) except RuntimeError: continue raizes.append(root) print raizes
[0.0, 3.4368289123266766, 6.119024225042324, 9.529904336449029, 12.486196308339682, 15.771411695083252, 18.7963289139448]
def encontrar_todas_raizes(f,a,b): Ox=range(0,b+1) Oy=range(-200,400, 100) intervalos=[(i, i+1) for i in Ox if i<b] raizes=[] v=[] for j in intervalos: a=j[0] b=j[1] try: root = find_root(f, a, b) except RuntimeError: continue raizes.append(root) print 'Todas as raizes de', f, 'entre %d e %d:' %(a,b),'\n' for k in range(len(raizes)): print raizes[k] p=plot(f,(x,a,b), figsize=[6,4],ticks=[Ox,Oy], gridlines=True, title=f) return p encontrar_todas_raizes(ln(x)*x, 1, 3)
Todas as raizes de x*log(x) entre 2 e 3: 1.0 1.0
print 'Informacao:' print '-----------------------------------------------------' print 'n','\t','Interacoes', '\t','Maior','\t','Sequencia' print N, '\t', str(vezes), '\t',' ', str(maior),' ', sequencia conjectura3n1() latex(matrix([[1,1],[0,sqrt(5)/2]])
print "o velo %f" %pi
o velo 3.141593
f=x+x^2*sin(x) a=0 b=20 Ox=range(0,b+1) Oy=range(-200,400, 100) plot(f,(x,a,b), figsize=[6,4],ticks=[Ox,Oy], gridlines=True, title=f) raizes=[] intervalos=[(i, i+1) for i in Ox if i<b] for j in intervalos: a=j[0] b=j[1] try: r = find_root(f, a, b) except RuntimeError: continue raizes.append(r) print 'Todas as raizes de', f, 'entre %d e %d:' %(a,b),'\n' print raizes p=plot(f,(x,a,b), figsize=[6,4],ticks=[Ox,Oy], gridlines=True, title=f) save(p, 'plot_root.pdf')
Todas as raizes de x^2*sin(x) + x entre 19 e 20: [0.0, 3.4368289123266766, 6.119024225042324, 9.529904336449029, 12.486196308339682, 15.771411695083252, 18.7963289139448]
sage: f=x+x^2*sin(x) sage: a=0 sage: b=20 sage: Ox=range(0,b+1) sage: Oy=range(-200,400, 100) sage: plot(f,(x,a,b), figsize=[6,4],ticks=[Ox,Oy], gridlines=True, title=f) sage:intervalos=[(i, i+1) for i in Ox if i<b] sage:raizes=[] sage:for j in intervalos: a=j[0] b=j[1] try: r = find_root(f, a, b) except RuntimeError: continue raizes.append(n(r, digits=4)) sage:print 'Todas as raizes de', f, 'entre %d e %d:' %(a,b),'\n' sage:print raizes
Todas as raizes de x^2*sin(x) + x entre 19 e 20: [0.0000, 3.437, 6.119, 9.530, 12.49, 15.77, 18.80]
f=x + x^2*sin(x) y0,x0=find_local_maximum(f,0,20) y1,x1=find_local_minimum(f,0,20) sage: plot(f,(0,20))+point((x0,y0),color='red',size=25) +point((x1,y1),color='red',size=25)
sage: p=plot(f,(0,20)) sage: m1=point((x0,y0),color='red',size=25) sage: m2=point((x1,y1),color='red',size=25) sage: p+m1+m2