Laboratorium nr 4

Laboratorium nr 4
Metody Obliczeniowe
Interpolacja

MICHAŁ MAZUR

DOMINIK KUSA

1. Interpolacja metodą Lagrange’a – przykład z zajęć

Dla podanego przez prowadzącego zajęcia przykładu, obliczyć wielomian interpolacyjny wybraną metodą.

i 0 1 2 3
x 1 3 9 11
y 12 8 4 3.5

Po podstawieniu punktów z tabeli:


$$W_{3}\left( x \right) = 12*\frac{\left( x - 3 \right)*\left( x - 9 \right)*\left( x - 11 \right)}{\left( 1 - 3 \right)*\left( 1 - 9 \right)*\left( 1 - 11 \right)} + 8*\frac{\left( x - 1 \right)*\left( x - 9 \right)*\left( x - 11 \right)}{\left( 3 - 1 \right)*\left( 3 - 9 \right)*\left( 3 - 11 \right)} +$$


$$+ \ 4*\frac{\left( x - 1 \right)*\left( x - 3 \right)*\left( x - 11 \right)}{\left( 9 - 1 \right)*\left( 9 - 3 \right)*\left( 9 - 11 \right)} + 3.5*\frac{\left( x - 1 \right)*\left( x - 3 \right)*\left( x - 9 \right)}{\left( 11 - 1 \right)*\left( 11 - 3 \right)*\left( 11 - 9 \right)} =$$

- 0.0115 x3 + 0.3156 x2 – 3.1135 x + 14.8094

2. Interpolacja metodą Lagrange’a – zadanie domowe

Dla podanego przez prowadzącego zajęcia zadania domowego (i202):

– napisać program komputerowy obliczający wielomian interpolacyjny wybraną metodą

i 0 1 2 3 4 5
x 0,430000 0,480000 0,550000 0,620000 0,700000 0,750000
y 2,635970 2,732340 2,876860 3,030450 3,228460 3,359730

Implementacja w środowisku MatLab:

function [C,L] = lagrange(X,Y)

w=length(X);

n=w-1;

L=zeros(w,w);

for k=1:n+1

V=1;

for j=1:n+1

if k~=j

V=conv(V,poly(X(j)))/(X(k)-X(j));

end

end

L(k,:)=V;

end

C=Y*L;

Implementacja w języku Python :

x=[0.430000, 0.480000, 0.550000, 0.620000, 0.700000, 0750000]

y=[2,635970, 2,732340, 2,876860, 3,030450, 3,228460, 3,359730]

h=1

wiel_1=y[0]*(((((h-x[1])*(h-x[2])*(h-x[3])*(h-x[4])*(h-x[5]))))/((x[0]-x[1])*(x[0]-x[2])*(x[0]-x[3])*(x[0]-x[4])*(x[0]-x[5])))

wiel_2=y[1]*(((((h-x[0])*(h-x[2])*(h-x[3])*(h-x[4])*(h-x[5]))))/((x[1]-x[0])*(x[1]-x[2])*(x[1]-x[3])*(x[1]-x[4])*(x[1]-x[5])))

wiel_3=y[2]*(((((h-x[0])*(h-x[1])*(h-x[3])*(h-x[4])*(h-x[5]))))/((x[2]-x[0])*(x[2]-x[1])*(x[2]-x[3])*(x[2]-x[4])*(x[2]-x[5])))

wiel_4=y[3]*(((((h-x[0])*(h-x[1])*(h-x[2])*(h-x[4])*(h-x[5]))))/((x[3]-x[0])*(x[3]-x[1])*(x[3]-x[2])*(x[3]-x[4])*(x[3]-x[5])))

wiel_5=y[4]*(((((h-x[0])*(h-x[1])*(h-x[2])*(h-x[3])*(h-x[5]))))/((x[4]-x[0])*(x[4]-x[1])*(x[4]-x[2])*(x[4]-x[3])*(x[4]-x[5])))

wiel_6=y[5]*(((((h-x[0])*(h-x[1])*(h-x[2])*(h-x[3])*(h-x[4]))))/((x[5]-x[0])*(x[5]-x[1])*(x[5]-x[2])*(x[5]-x[3])*(x[5]-x[4])))

print(wiel_1,"x^5 " , wiel_2,"x^4 " , wiel_3 ,"x^3 ", wiel_4,"x^2 ", wiel_5,"x ", wiel_6)

import time

time.sleep(10)


Wyszukiwarka

Podobne podstrony:
ćwiczenia laboratoryjne nr 2
Prezentacja laboratorium nr 2
Laboratorium nr 5 wskaYniki Nieznany
Sprawozdanie nr 3 (3), sem II, Podstawy Technologii Okrętów - Wykład.Laboratorium, Laboratorium nr 3
Ćwiczenie laboratoryjne nr 6 materiały
Automatyka Laboratorium Nr 1 id 73181 (2)
Laboratorium nr 8 dziedziczenie Nieznany
Laboratorium nr 4 funkcje cd id Nieznany
Fizyka - Laboratorium Nr 1 - Mostek Wheatstone'a, Studia, Sem I OiO, Fizyka, Labki, Mostek Wheatston
Sprawozdanie nr 2 (2) Metoda Brinella, sem II, Podstawy Technologii Okrętów - Wykład.Laboratorium, L
laboratorium nr 4
laboratorium nr 20
Laboratorium nr 2 zagadnienia
laboratorium nr 2
26, moja lab 26, ?WICZENIE LABORATORYJNE NR 26.
26, wstep, ĆWICZENIE LABORATORYJNE NR 26.
Dodatkowe nr 1 (1), sem II, Podstawy Technologii Okrętów - Wykład.Laboratorium, Laboratorium nr 1 (1
Zagadnienia na kolokwium z laboratoriów nr 2 by G.K., Mikrobiologia przemysłowa
28, READY28, ˙WICZENIE LABORATORYJNE NR 28.
laboratorium nr 4 edytor vi

więcej podobnych podstron