'********************************************************* '* Calculate a limited development of a real function * '* f(x)*g(x) at x=0 up to order 25, knowing the limited * '* developments of f(x) and g(x). * '* ----------------------------------------------------- * '* SAMPLE RUN: * '* * '* Limited development of a real function f(x)*g(x): * '* * '* Function to develop: exp(x)*(1/1+x) * '* * '* Limited development of f(x)=exp(x) is: * '* 1 + x + x^2/2! + x^3/3! + ... + x^n/n! + ... * '* * '* Limited development of g(x)=1/(1+x) is: * '* 1 -x + x^2 + ... + (-1)^n*x^n + ... * '* * '* Order of development (max=25): 5 * '* * '* Input coefficients of limited dev. of f(x): * '* a 0 = 1 * '* a 1 = 1 * '* a 2 = 0.5 * '* a 3 = 0.1666667 * '* a 4 = 0.0416667 * '* a 5 = 0.0083333 * '* * '* Input coefficients of limited dev. of g(x): * '* b 0 = 1 * '* b 1 = -1 * '* b 2 = 1 * '* b 3 = -1 * '* b 4 = 1 * '* b 5 = -1 * '* * '* The coefficients of limited dev. of f(x)*g(x) are: * '* c 0 = 1.0000000 * '* c 1 = 0.0000000 * '* c 2 = 0.5000000 * '* c 3 = -0.3333333 * '* c 4 = 0.3750000 * '* c 5 = -0.3666667 * '* * '* ----------------------------------------------------- * '* Ref.: "Mathematiques en Turbo Pascal by Alain * '* Reverchon and Marc Ducamp, Armand Colin * '* Editeur, Paris, 1991" [BIBLI 03]. * '* * '* Basic Version By J-P Moreau. * '* (www.jpmoreau.fr) * '********************************************************* 'Program ltddev1 DEFDBL A-H, O-Z DEFINT I-N NSIZE = 25 DIM t1(NSIZE + 1), t2(NSIZE + 1), R(NSIZE + 1) CLS PRINT PRINT " Limited development of a real function f(x)*g(x):" PRINT PRINT " Function to develop: exp(x)*(1/1+x)" PRINT PRINT " Limited development of f(x)=exp(x) is:" PRINT " 1 + x + x^2/2' + x^3/3' + ... + x^n/n' + ..." PRINT PRINT " Limited development of g(x)=1/(1+x) is:" PRINT " 1 -x + x^2 + ... + (-1)^n*x^n + ..." PRINT INPUT " Order of development (max=25): ", n PRINT PRINT " Input coefficients of limited dev. of f(x):" FOR i = 0 TO n PRINT " a"; i; " = "; : INPUT "", t1(i + 1) NEXT i PRINT PRINT " Input coefficients of limited dev. of g(x):" FOR i = 0 TO n PRINT " b"; i; " = "; : INPUT "", t2(i + 1) NEXT i PRINT GOSUB 1000 'call ar_dlmult(n,t1,t2,R) PRINT " The coefficients of limited dev. of f(x)*g(x) are:" FOR i = 0 TO n PRINT " c"; i; " = "; : PRINT USING "##.#######"; R(i + 1) NEXT i PRINT END 'Subroutine ar_dlmult(n, t1, t2, R) 1000 IF n > NSIZE THEN RETURN FOR i = 0 TO n x = 0# FOR j = 0 TO i x = x + t1(j + 1) * t2(i - j + 1) NEXT j R(i + 1) = x NEXT i RETURN 'end of file ltddev1.bas