Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Numerical Methods Homework

Views: 706
Kernel: SageMath (stable)
def nest(x, a): nested = 0 for i in range(0, len(a)): nested = nested * x + a[i] return nested a = [6,1,5,1,1] b = [-3,4,5,-5,1] c = [2,1,-1,0,1] print(nest((1/3),a)) print(nest((1/3),b)) print(nest((1/3),c)) fa(x) = 6*x^4 + x^3 +5*x^2+x+1 fb(x) = -3*x^4+4*x^3+5*x^2-5*x+1 fc(x) = 2*x^4+x^3-x^2+1 print(fa(1/3)) print(fb(1/3)) print(fc(1/3))
2 0 77/81 2 0 77/81

Since method 1 == method 2, we must have done something right!