Помогите разобраться! Большая часть даже ключевых данных не совпадает, на мой взгляд, все из-за неправильно прописанной функции нахождения коэфициента D, но как исправить - я не знаю =(
вот часть кода:
Код:
Function GetH_sp(x0:double):double; // kubi4eskij splain - nahozhdenie 6aga h
begin
If x0 < X[0] Then Result := (X[1] - X[0]) Else
If x0 > X[9] Then Result := (X[9] - X[8]) Else
For I := 0 To 8 Do
If (x0 > X[i]) and (x0<X[i+1])Then
Begin
Result := (X[i] - X[i-1]);
Break;
End;
end;
Function GetA_sp(x0:double):double; // kubi4eskij splain - nahozhdenie svobodnogo 4isla A
begin
If x0 < X[0] Then Result := Y[0] Else
If x0 > X[9] Then Result := Y[9] Else
For I := 0 To 8 Do
If (x0 > X[i]) and (x0<X[i+1])Then
Begin
Result := Y[i];
Break;
End;
end;
Function GetB_sp(x0:double):double; // kubi4eskij splain - nahozhdenie koeficienta B
begin
If x0 < X[0] Then Result := (Y[2] - Y[0])/(X[2] - X[0]) Else
If x0 > X[9] Then Result := (Y[9] - Y[7])/(X[9] - X[7]) Else
For I := 0 To 8 Do
If (x0 > X[i]) and (x0<X[i+1])Then
Begin
Result := (Y[i+1] - Y[i-1])/(X[i+1] - X[i-1]);
Break;
End;
end;
Function GetC_sp(x0:double):double; // kubi4eskij splain - nahozhdenie koeficienta C
Var
h:double;
begin
h:= GetH_sp(x0);
If x0 < X[0] Then Result := (Y[0]+Y[2]-2*Y[1])/(h*h) Else
If x0 > X[9] Then Result := (Y[7]+Y[9]-2*Y[8])/(h*h) Else
For I := 0 To 8 Do
If (x0 > X[i]) and (x0<X[i+1])Then
Begin
Result := (Y[i-1]+Y[i+1]-2*Y[i])/(h*h);
Break;
End;
end;
Function GetC_2_sp(x0:double):double; // kubi4eskij splain - nahozhdenie koeficienta C[i-1]
Var
h:double;
begin
h:= GetH_sp(x0);
If x0 < X[0] Then Result := (Y[0]+Y[2]-2*Y[1])/(h*h) Else
If x0 > X[9] Then Result := (Y[7]+Y[9]-2*Y[8])/(h*h) Else
For I := 0 To 8 Do
If (x0 > X[i]) and (x0<X[i+1])Then
Begin
Result := (Y[i-2]+Y[i]-2*Y[i-1])/(h*h);
Break;
End;
end;
Function GetD_sp(x0:double):double; // kubi4eskij splain - nahozhdenie koeficienta D
Var
h,c,c2:double;
begin
h:= GetH_sp(x0);
c:=GetC_sp(x0);
c2:= GetC_2_sp(x0);
Result := (c-c2)/h ;
end;
function Gety0_sp(x0: double): double;
Var
a,c,d,b: double;
begin
a:= GetA_sp(x0);
b:= GetB_sp(x0);
c:= GetC_sp(x0);
d:=GetD_sp(x0);
If x0 < X[0] Then Result := (a+b*(x0-X[0])+(c/2)*(x0-X[0])*(x0-X[0])+(d/6)*(x0-X[0])*(x0-X[0])*(x0-X[0])) Else
If x0 > X[9] Then Result := (a+b*(x0-X[9])+(c/2)*(x0-X[9])*(x0-X[9])+(d/6)*(x0-X[9])*(x0-X[9])*(x0-X[9])) Else
For I := 0 To 8 Do
If (x0 > X[i]) and (x0<X[i+1])Then
Begin
Result := (a+b*(x0-X[i])+(c/2)*(x0-X[i])*(x0-X[i])+(d/6)*(x0-X[i])*(x0-X[i])*(x0-X[i]));
Break;
end;
end;