METODO DE NEWTON-RAPHSON
David Rodríguez
Sebastián Bonilla
Sherling Chalá
In [702]:
from sympy import init_session
init_session(use_latex=True)
IPython console for SymPy 1.13.2 (Python 3.12.7-64-bit) (ground types: python)
These commands were executed:
>>> from sympy import *
>>> x, y, z, t = symbols('x y z t')
>>> k, m, n = symbols('k m n', integer=True)
>>> f, g, h = symbols('f g h', cls=Function)
>>> init_printing()
Documentation can be found at [Link]
Definimos f(h)
In [705]:
h=symbols('h')
In [707]:
R=3
V=40
f=[Link]*h**2*(3*R-h)/3
In [709]:
f
Out[709]:
2
−1.0471975511966h (9 − h) + 40
In [711]:
x1=lambdify(h,f)
In [713]:
x1
Out[713]:
<function _lambdifygenerated(h)>
x1 es el Valor que se obtiene de f(2.5)
In [716]:
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
x1(2.5)
Out[716]:
−2.54240051736188
In [718]:
df1=diff(f,h)
df1
Out[718]:
2
1.0471975511966h − 2.0943951023932h (9 − h)
In [720]:
df1=lambdify(h,df)
In [722]:
df1
Out[722]:
<function _lambdifygenerated(h)>
df1 es el Valor que se obtiene de f'(2.5)
In [725]:
df1(2.5)
Out[725]:
−27.4889357189108
x2 es la Respuesta de el Método de Newton-Raphson donde
x1=2.5
In [728]:
x2=2.5--2.54240051736188/-27.4889357189108
In [730]:
x2
Out[730]:
2.40751186064971
|xi+1-x1|
In [733]:
abs(2.40751186604971-2.5)
Out[733]:
0.0924881339502899
In [735]:
x2=lambdify (h,f)
In [737]:
x2
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
Out[737]:
<function _lambdifygenerated(h)>
x2 es el Valor que se obtiene de f(2.40751186604971)
In [740]:
x2(2.40751186604971)
Out[740]:
−0.0142653153433159
In [742]:
df2=lambdify (h,df)
In [744]:
df2
Out[744]:
<function _lambdifygenerated(h)>
df2 es el Valor que se obtiene de f'(2.40751186604971)
In [747]:
df2(2.40751186604971)
Out[747]:
−27.1715023206482
x3 es la Respuesta de el Método de Newton-Raphson donde
x2=2.40751186604971
In [750]:
x3=2.40751186604971--0.0142653153433159/-27.1715023206482
In [752]:
x3
Out[752]:
2.40698685586901
|xi+1-x1|
In [755]:
abs(2.40698685586901-2.40751186604971)
Out[755]:
0.000525010180699947
In [757]:
import [Link] as plt
import numpy as np
In [759]:
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
R=3
V=40
f=lambda h:[Link]*h**2*(3*R-h)/3
In [761]:
h=[Link](0,2*R,1500)
[Link](h,f(h),'r')
[Link]()
[Link]()
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF