| Download
Aulas do Curso de Modelagem matemática IV da FGV-EMAp
Project: Modelagem Matemática IV
Path: Modelagem-Matematica-IV/Planilhas Sage / Suplemento 1 - Soluções Numéricas de Equações Diferenciais.ipynb
Views: 2412License: GPL3
Image: default
Kernel: SageMath 9.3
Integração Numérica
Existem diversos métodos comumente utilizados para encontrar soluções aproximadas para sistemas de EDOs. Neste documento introduziremos os mais usados assim com exemplos do seu uso no Sage.
Método de Euler
No método de Euler aproximamos a EDO de primeira ordem por uma série de pontos no tempo a intervalos regulares de tamanho definido pelo usuário. Logo, . Assumindo um EDO da forma , a solução aproximada pelo método de Euler é .
Abaixo temos um exemplo interativo para um sistema relativamente simples:
In [7]:
In [2]:
Campos Vetoriais e o Método de Euler
In [8]:
In [ ]:
Campo Vetorial com Runge-Kutta Fehlberg
In [9]:
In [5]:
In [6]:
<ipython-input-6-9dff5e30990a>:1: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)
See http://trac.sagemath.org/5930 for details.
complex_plot(sol[Integer(0)].subs(x=z), (x,-Integer(1), Integer(1)), (y,-Integer(1),Integer(1)))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-9dff5e30990a> in <module>
----> 1 complex_plot(sol[Integer(0)].subs(x=z), (x,-Integer(1), Integer(1)), (y,-Integer(1),Integer(1)))
~/Downloads/SageMath/local/lib/python3.9/site-packages/sage/misc/lazy_import.pyx in sage.misc.lazy_import.LazyImport.__call__ (build/cythonized/sage/misc/lazy_import.c:4032)()
358 True
359 """
--> 360 return self.get_object()(*args, **kwds)
361
362 def __repr__(self):
~/Downloads/SageMath/local/lib/python3.9/site-packages/sage/misc/decorators.py in wrapper(*args, **kwds)
489 options['__original_opts'] = kwds
490 options.update(kwds)
--> 491 return func(*args, **options)
492
493 #Add the options specified by @options to the signature of the wrapped
~/Downloads/SageMath/local/lib/python3.9/site-packages/sage/plot/complex_plot.pyx in sage.plot.complex_plot.complex_plot (build/cythonized/sage/plot/complex_plot.c:6071)()
402 g = Graphics()
403 g._set_extra_kwds(Graphics._extract_kwds_for_show(options, ignore=['xmin', 'xmax']))
--> 404 g.add_primitive(ComplexPlot(complex_to_rgb(z_values),
405 x_range[:2], y_range[:2], options))
406 return g
~/Downloads/SageMath/local/lib/python3.9/site-packages/sage/plot/complex_plot.pyx in sage.plot.complex_plot.complex_to_rgb (build/cythonized/sage/plot/complex_plot.c:3994)()
113 z = <ComplexDoubleElement>zz
114 else:
--> 115 z = CDF(zz)
116 x, y = z._complex.dat
117 mag = hypot(x, y)
~/Downloads/SageMath/local/lib/python3.9/site-packages/sage/rings/complex_double.pyx in sage.rings.complex_double.ComplexDoubleField_class.__call__ (build/cythonized/sage/rings/complex_double.c:5419)()
334 if im is not None:
335 x = x, im
--> 336 return Parent.__call__(self, x)
337
338 def _element_constructor_(self, x):
~/Downloads/SageMath/local/lib/python3.9/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9335)()
896 if mor is not None:
897 if no_extra_args:
--> 898 return mor._call_(x)
899 else:
900 return mor._call_with_args(x, args, kwds)
~/Downloads/SageMath/local/lib/python3.9/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4622)()
159 print(type(C), C)
160 print(type(C._element_constructor), C._element_constructor)
--> 161 raise
162
163 cpdef Element _call_with_args(self, x, args=(), kwds={}):
~/Downloads/SageMath/local/lib/python3.9/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4514)()
154 cdef Parent C = self._codomain
155 try:
--> 156 return C._element_constructor(x)
157 except Exception:
158 if print_warnings:
~/Downloads/SageMath/local/lib/python3.9/site-packages/sage/rings/complex_double.pyx in sage.rings.complex_double.ComplexDoubleField_class._element_constructor_ (build/cythonized/sage/rings/complex_double.c:5977)()
366 return t
367 elif hasattr(x, '_complex_double_'):
--> 368 return x._complex_double_(self)
369 else:
370 return ComplexDoubleElement(x, 0)
~/Downloads/SageMath/local/lib/python3.9/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._complex_double_ (build/cythonized/sage/symbolic/expression.cpp:11835)()
1663 0.5000000000000001 + 0.8660254037844386*I
1664 """
-> 1665 return self._eval_self(R)
1666
1667 def __float__(self):
~/Downloads/SageMath/local/lib/python3.9/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._eval_self (build/cythonized/sage/symbolic/expression.cpp:10179)()
1430 return R(ans)
1431 else:
-> 1432 raise TypeError("Cannot evaluate symbolic expression to a numeric value.")
1433
1434 cpdef _convert(self, kwds):
TypeError: Cannot evaluate symbolic expression to a numeric value.
In [ ]: