hello everyone,
While I was searching the net for my math problem, I found this site. If anyone can help me it is very appriciated. Also I have searched through this site but found nothing. I am taking numerical anaylsis lecture and I have a homework. and I am in trouble in some parts.
I got a general formula. it depends on the given x and y variables.
I am writing an example question so everybody can understand.
ex1; use langrange interpolation polynomial that approximate f(x)=x^3
a-)find the linear interpolation polynominal p1(x) using x0=1 and x1=2
b-)quadratic p2(x) x0=0, x1=1, x2=2
answer:
a-) langrange formula for p1there are 2 points given)
p1(x)=(y0*((x-x1)/(x0-x1)))+(y1*((x-x0)/(x1-x0)))
so if x0=1 y0=1^3=1(put x0 into f(x), so we find y0) and after that we have;
x0=1,y0=1
x1=2,y1=8
so when we replace the x and y varaibles into langrange;
p1(x)=(1*((x-2)/(1-2)))+(8*((x-1)/(2-1)))=(2-x)+8x-8=7x-6
p1(x)=7x-6 , SO this is answer. I found an approximation formula.
b-)langrange formula for p2there are 3 points given)
p2(x)=(y0*(((x-x1)*(x-x2))/((x0-x1)*(x0-x2))))+(y1*(((x-x0)*(x-x2))/((x1-x0)*(x1-x2))))+(y2*(((x-x0)*(x-x1))/((x2-x0)*(x2-x1))))
so if x0=0 y0=0^3=0 (put x0 into f(x), so we find y0) and after that we have;
x0=0,y0=0
x1=1,y1=1
x2=2,y2=8
so when we replace the x and y varaibles into langrange;
p2(x)=(0*(((x-1)*(x-2))/((0-1)*(0-2))))+(1*(((x-0)*(x-2))/((1-0)*(1-2))))+(8*(((x-0)*(x-1))/((2-0)*(2-1))))
p2(x)=(((x^2)-2x)/-1)+(((8x^2)-8x)/2)=2x-(x^2)+(4x^2)-8x=2x-(x^2)+(4x^2)-4x=(3x^2)-2x
p2(x)=(3x^2)-2x , SO this is answer. I found an approximation formula.
how can I calculate something like that in excel? and think that if we have 5 or 6 x variables how can we calculate also?
the general langrange formula is:
if anyone can solve this (developing a macro I think is the only way but I dont know anything about macros) It will very useful for me.
I got;
x0=-2, y0=-9,2
x1=-1, y1=-2,7
x2=0, y2=-1,5
x3=1, y3=0,4
x4=2, y4=7,2
x5=3, y5=26,1
thanks for every help.
While I was searching the net for my math problem, I found this site. If anyone can help me it is very appriciated. Also I have searched through this site but found nothing. I am taking numerical anaylsis lecture and I have a homework. and I am in trouble in some parts.
I got a general formula. it depends on the given x and y variables.
I am writing an example question so everybody can understand.
ex1; use langrange interpolation polynomial that approximate f(x)=x^3
a-)find the linear interpolation polynominal p1(x) using x0=1 and x1=2
b-)quadratic p2(x) x0=0, x1=1, x2=2
answer:
a-) langrange formula for p1there are 2 points given)
p1(x)=(y0*((x-x1)/(x0-x1)))+(y1*((x-x0)/(x1-x0)))
so if x0=1 y0=1^3=1(put x0 into f(x), so we find y0) and after that we have;
x0=1,y0=1
x1=2,y1=8
so when we replace the x and y varaibles into langrange;
p1(x)=(1*((x-2)/(1-2)))+(8*((x-1)/(2-1)))=(2-x)+8x-8=7x-6
p1(x)=7x-6 , SO this is answer. I found an approximation formula.
b-)langrange formula for p2there are 3 points given)
p2(x)=(y0*(((x-x1)*(x-x2))/((x0-x1)*(x0-x2))))+(y1*(((x-x0)*(x-x2))/((x1-x0)*(x1-x2))))+(y2*(((x-x0)*(x-x1))/((x2-x0)*(x2-x1))))
so if x0=0 y0=0^3=0 (put x0 into f(x), so we find y0) and after that we have;
x0=0,y0=0
x1=1,y1=1
x2=2,y2=8
so when we replace the x and y varaibles into langrange;
p2(x)=(0*(((x-1)*(x-2))/((0-1)*(0-2))))+(1*(((x-0)*(x-2))/((1-0)*(1-2))))+(8*(((x-0)*(x-1))/((2-0)*(2-1))))
p2(x)=(((x^2)-2x)/-1)+(((8x^2)-8x)/2)=2x-(x^2)+(4x^2)-8x=2x-(x^2)+(4x^2)-4x=(3x^2)-2x
p2(x)=(3x^2)-2x , SO this is answer. I found an approximation formula.
how can I calculate something like that in excel? and think that if we have 5 or 6 x variables how can we calculate also?
the general langrange formula is:
if anyone can solve this (developing a macro I think is the only way but I dont know anything about macros) It will very useful for me.
I got;
x0=-2, y0=-9,2
x1=-1, y1=-2,7
x2=0, y2=-1,5
x3=1, y3=0,4
x4=2, y4=7,2
x5=3, y5=26,1
thanks for every help.