Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Numerical Methods Homework

Views: 706
Kernel: SageMath 8.2
import pandas as pd df = pd.Series({'Year': [1994,1995,1996,1997,1998,1999,2000,2001,2002,2003], "bbl/day*10^6": [67.052,68.008,69.803,72.024,73.400,72063,74.669,74.487,74.065,76.777]}) A = [1994,1995,1996,1997,1998,1999,2000,2001,2002,2003] b = [67.052,68.008,69.803,72.024,73.400,72063,74.669,74.487,74.065,76.777] show(df) import numpy as np c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 = np.polyfit(A,b,9) t = var('t') f(t) = c10*t^9+c9*t^8+c8*t^7+c7*t^6+c6*t^5+c5*t^4+c4*t^3+c3*t^2+c2*t+c1 print "D-9 Esitmation for 2010: ", f(2010) plot(c1*t^9+c2*t^8+c3*t^7+c4*t^6+c5*t^5+c6*t^4+c7*t^3+c8*t^2+c9*t+c10, (t,1990,2020))
/ext/sage/sage-8.2/local/lib/python2.7/site-packages/sage/repl/ipython_kernel/__main__.py:11: RankWarning: Polyfit may be poorly conditioned
D-9 Esitmation for 2010: 1.0185356829006386e+44
Image in a Jupyter notebook

It appears that the D-9 polynomial is a bad fit because of the Runge phenomenon. A linear regression would be more appropriate.