Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please fix my python code so that interpoly(x,y) works for the following x and y: x=(0.0,0.5,1.0,1.5,2.0,2.5) y=(-2.0,0.5,-2.0,1.0,-0.5,1.0) ------ from scipy import * from pylab import
Please fix my python code so that
interpoly(x,y) works for the following x and y:
x=(0.0,0.5,1.0,1.5,2.0,2.5)
y=(-2.0,0.5,-2.0,1.0,-0.5,1.0)
------
from scipy import *
from pylab import *
from scipy.integrate import quad
import sys
import numpy as np
import matplotlib.pyplot as plt
def matrix(x):
n=[]
N=len(x)
for i in range(N):
temp=[]
for j in range(N+1):
temp.append(x[i]**(N-j))
n.append(temp)
return n
def interpoly(x,y):
c=linalg.solve([matrix(x)],[y])
return c
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started