Wyklad 2.pdf

(151 KB) Pobierz
Microsoft PowerPoint - Wyklad 2.ppt
S
Schemat Hornera
P x a x a x a
= +
n
n
-
+ +
n
n
n
-
a
k
k
=
n
a
n
x x n n
+ n S
b a
n
Í
Í
Í
Í
b b a
x
n
-
Û
b b a
x
Í
Í
Í
Í
k k
-
n k
b b a
-
x
Ü
=
Ú
= +
= +
-
= +
n n
41976184.001.png
a
n
x
+
a
n
-
x
+
a
n
-
x
+
+
a
x
+
a
P
n
x
=
b
n
n
Q x b x b x b
= + + +
n
-
n
-
n
-
n
-
P x
n
x - x
P x Q x x P
n
=
n
-
- +
x x
n
P x b x b b x b b
= + -
n
x
n
-
+ + -
x
n
n n
-
{Program 1.1}
uses
a a a n
Crt;
var
k,n: Integer;
ksi,P: Real;
a,b: array[0..20] of Real;
zn: Char;
label powt;
begin
powt:
ClrScr;
Writeln('PROGRAM 1.1');
Writeln('Schemat Hornera.');
Writeln;
Write('Stopien wielomianu - n = '); Read(n);
Writeln('Wspolczynniki wielomianu Pn(x):');
for k:=n downto 0 do begin
Write(' a[',k:2,'] = ');
Read(a[k]);
x
PROGRAM 1.1
Schemat Hornera.
Stopien wielomianu - n = 5
Wspolczynniki wielomianu Pn(x):
a[ 5] = 4
a[ 4] = 1
a[ 3] = 0
a[ 2] = -3
a[ 1] = 2
a[ 0] = -1
Argument - ksi = 3
Pn(ksi) = 1.031000E+03
Wspolczynniki wielomianu Qn-1(x):
b[ 0] = 4.000000E+00
b[ 1] = 1.300000E+01
b[ 2] = 3.900000E+01
b[ 3] = 1.140000E+02
b[ 4] = 3.440000E+02
Nowe obliczenia: (t/n)?
end;
Write('Argument - ksi = '); Readln(ksi);
P:=a[n]; b[0]:=P;
for k:=1 to n do begin
P:=P*ksi+a[n-k];
b[k]:=P;
end;
Writeln;
Writeln('Pn(ksi) = ',P:13);
Writeln('Wspolczynniki wielomianu Qn-1(x):');
for k:=0 to n-1 do
Writeln(' b[',k:2,'] = ',b[k]:13);
Writeln;
Writeln('Nowe obliczenia: (t/n)?');
zn:=ReadKey;
if zn = 't' then goto powt;
end.
Zgłoś jeśli naruszono regulamin