{ our perturbation function F_1 = Sum_(n=2)^N [ ( (r^n)/(r'^(n+1)) ) * P_n(cos(H)) ] row for r^n is in text file range0n.txt row for P_n is in text file poleg0n.txt } unit unfunone ; { to build perturbation function } interface { with global numpol from untypvar } { to build perturbation function F_1 } procedure pertufone ; { to make deal with files } implementation uses untypvar , { types and global variables } unrowmul , { procedure MultForRow } unwrtext ; { procedure texttorow to read results } procedure forcurpow ( i , j : shortint ; { i=-n j=-n-1 } meccoh : word ; { number of terms } rowcoh : TRowPtr ; { in this array } var mecone : word ; { number of terms } var rowone : TRowPtr ) ; { in this array } var m : word ; { count for terms } begin mecone:=0; { initial nullo terms in rowone^[..] } for m:=1 to meccoh do { current term } if ( rowcoh^[m].mec[11] = i ) { in mec[11] power for r } then { there is term for us } begin { to rowone^ please } mecone:=mecone+1; { the next our term } rowone^[mecone]:=rowcoh^[m]; { this is our term } rowone^[mecone].mec[12]:=j; { negative power r' } end; { for all terms } end; { to keep mecone terms in array rowtmp^ } procedure termtotmp ( mecone : word ; { number of terms } rowone : TRowPtr ; { in this array } var mectmp : word ; { current terms } var rowtmp : TRowPtr ) ; { untypvar to keep } var m : word ; begin for m:=1 to mecone do { term by term to keep } begin { in array rowtmp^[..] } mectmp:=mectmp+1; { the next term } rowtmp^[mectmp]:=rowone^[m]; { to keep } rowtmp^[mectmp].mec[11]:=0; { nullo power r } end; end; procedure toaddcurp ( n : byte ; { order for P_n(cos(H)) } i : shortint ; { i may be -n -n+2 .. } meccoh : word ; { number of terms P_n } rowcoh : TRowPtr ; { array for terms P_n } var mectmp : word ; { to keep terms } var rowtmp : TRowPtr ) ; { in this array } var j : shortint ; { current power for r' range giant planet } k : byte ; { for number of file } begin j:=-n-1; { current power for (1/r'^(n+1)) to each term .mec[12] } forcurpow(i,j,meccoh,rowcoh,mecone,rowone); { with i to rowone } if mecone > 0 then { there are terms in rowone^ } if ( rowone^[1].mec[11] = -n ) { to compare power r } then { there are terms with power r^(-n) } begin termtotmp(mecone,rowone,mectmp,rowtmp); { to keep } writeln(n:8,i:8,rowone^[1].mec[11]:8, mecone:12,' ':24,mectmp:12,' terms'); end else { power for r is greater then -n may be -n+2 ... } begin k:=Abs(n+rowone^[1].mec[11]); { power for r^k that need } texttorow(k,'range0',mectwo,rowtwo); { to array rowtwo^ } mectre:=0; { before multiplication nullo result terms } MultForRow(+1.0); { UnRowMul result to rowtre^[..] } termtotmp(mectre,rowtre,mectmp,rowtmp); { to keep } writeln(n:8,i:8,rowone^[1].mec[11]:8, mecone:12,mectwo:12,mectre:12,mectmp:12,' terms'); end; end; { to build perturbation function F_1 } procedure pertufone ; { to make deal with files } var i : shortint ; { simple count for variants } n : byte ; { simple count in Sum } m : word ; { count for terms } begin writeln('to build perturbation function F_1'); maxsum:=numsum; { global untypvar power for giant planet } mectmp:=0; { rowtmp^[..] array to keep function } { with global numpol from untypvar } for n:=2 to numpol do { Sum [((r^n)/(r'^(n+1)))*P_n(cos(H))] } begin { to sum terms to function } texttorow(n,'poleg0',meccoh,rowcoh); { to read terms P_n(cos(H)) } i:=-n; { rowcoh^ may be terms with r^(-n),r^(-n+2)..r^(-1 or 0) } repeat toaddcurp(n,i,meccoh,rowcoh,mectmp,rowtmp); i:=i+2; { the next negative power for range in P_n(cos(H)) } until i > 0 ; { may be 0 or -1 with step 2 : -4,-2,0 or -3,-1 } end; { perturbation function F_1 } for m:=1 to mectmp do { for all terms by factor fm'=n'^2*a'^3 } with rowtmp^[m] do { a' in mec[10] n' in mec[14] } begin { a' n' for the perturbing body the Sun } mec[10]:=mec[10]+3; { a'^3 in factor fm'=n'^2*a'^3 } mec[14]:=mec[14]+2; { n'^2 in factor fm'=n'^2*a'^3 } end; { to multiply our function fm' } rowtotext(1,mectmp,rowtmp,'prefon'); { unwrtext result to text file } writeln('in perturbation function F_1 ',mectmp,' terms'); end; end.