Exercise 4.4 Solutions

5.

f[x_] := (x^(1/2))

points = Table[{x, N[f[x]]}, {x, 4, 8}]

np = NewtonPoly[points]

TableForm[Dtable]

TableForm[Table[Take[np, k], {k, 1, 5}]]

TableForm[
      Table[Take[np, k] /. {x -> n}, {k, 1, 5}, {n, 4, 8}]]

8.

f[x_] := (E^(-x))

points = Table[{x, N[f[x]]}, {x, 0, 4}]

np = NewtonPoly[points]

TableForm[Dtable]

TableForm[Table[Take[np, k], {k, 1, 5}]]

TableForm[
      Table[Take[np, k] /. {x -> n}, {k, 1, 5}, {n, 0, 4}]]

10.

points = {{0, -2}, {1, 2}, {2, 4}, {3, 4}, {4, 
          2}, {5, -2}}

NewtonPoly[points]

TableForm[Dtable]

Exercise 4.6 Solutions

1.

Do by hand first--then use the Pade Approximation Routines below with f(x)=(e^x), n=1, and m=1

2.

Do by hand first--then use the Pade Approximation Routines below with f(x)=ln(1 + x)/x, n=1, and m=1

4.

Do by hand first--then use the Pade Approximation Routines below with f(x)=arctan((x^(1/2)))/(x^(1/2)), n=1,and m=1

Functions Used in this notebook

Lagrange[
          XY_] := 
Module[{j, k, n, X, 
            Y}, 
(Subscript[X, k])_  :=  (Subscript[(Transpose[XY]), [[1, k + 1]]]);  
(Subscript[Y, k])_  :=  (Subscript[(Transpose[XY]), [[2, k + 1]]]);  
n  =  
            Length[XY] - 
              1;  
Return[  (∑_(k = 0)^n) (Subscript[Y, k]) ( (∏_(j = 0)^(k - 1))((x - (Subscript[X, j]))/((Subscript[X, k]) - (Subscript[X, j])))) ((∏_(j = k + 1)^n)(( x - (Subscript[X, j]))/((Subscript[X, k]) - (Subscript[X, j])))) ]; ];

\(\(\(NewtonPoly[
        XY_]\)\(:=\)\(
\)\(Module[{d, j, i, n, X, 
          Y}, 
X\  = \ \(Transpose[XY]\)\_\(\([[\)\(1\)\(]]\)\); \ 
Y\  = \ \(Transpose[XY]\)\_\(\([[\)\(2\)\(]]\)\); \ 
n\  = \ 
          Length[XY] - 1; \ 
d\  = \ 
          Table["", {n + 1}, {n + 
                1}\ ]; \ 
d\_\(\([[\)\(All, 1\)\(]]\)\)\  = \ 
          Y\_\(\([[\)\(All\)\(]]\)\); \ 
For[\ j = 1, \ 
          j ≤ 
            n, \ \(j++\), 
\(For[\ i = j, \ 
              i ≤ 
                n, \ \(i++\), 
d\_\(\([[\)\(i + 1, j + 1\)\(]]\)\)\  = \ \(d\_\(\([[\)\(i + 1, j\)\(]]\)\)\  - \ d\_\(\([[\)\(i, j\)\(]]\)\)\)\/\(X\_\(\([[\)\(i + 1\)\(]]\)\)\  - \ X\_\(\([[\)\(i + 1 - j\)\(]]\)\)\)\ ];\)\ ]; \ 
For[\ i = 0, \ 
          i ≤ 
            n, \ \(i++\), 
p[i + 1, 
              x_]\  = \ ∏\+\(j = 1\)\%i\((x - 
                  X\_\(\([[\)\(j\)\(]]\)\))\)\ ]; \ 
Dtable = 
          d; 
Return[\ \ ∑\+\(i = 0\)\%n d\_\(\([[\)\(i + 1, i + 1\)\(]]\)\)\ p[i + 1, 
                x]\ ];\ ]\)\(\ \)\)\)

Pade Approximation--Change functions, and n and m as needed

Clear[a, f, k, m, n, p, q, R, Q, P, 
        x];  
f[x_] = ArcTan[(x^(1/2))]/(x^(1/2));  
F[x_, k_]  :=  Series[f[x], {x, 0, k}];    
P[x_, k_]  =  (∑_(i = 0)^k) (Subscript[p, i]) (x^i);  
Q[x_, k_]  =  
        1  +  (∑_(i = 1)^k) (Subscript[q, i]) (x^i);  
n = 1;  
m = 1;  
vars = 
        Union[Table[(Subscript[p, i]), {i, 0, n}], 
          Table[(Subscript[q, i]), {i, 1, m}]];  
\(\(Print[\*""\!\(P\_n\)(x) = "", P[x, n]\ ];\)\ \ \)
\(\(Print[\*""\!\(Q\_m\)(x) = "", Q[x, m]\ ];\)\ \ \ \)
Print[" f(x) = ", 
        F[x, m + n] ];  
Print[""];  
\(\(Print[\*""Form  f(x)(Subscript[Q, m])(x) - (Subscript[P, n])(x) = 0""];\)\ \ \)
Print[
        Expand[F[x, n + m] Q[x, m] - P[x, n]] == 0];

\(\(\(\(L = Expand[F[x, n + m] Q[x, m] - P[x, n]];\)\ \ 

    \(coeffs = CoefficientList[L, x];\)\ \ 

    \(Eqns = Distribute[coeffs == 0, \ List];\)\ \ 

    \(Print[TableForm[Eqns]\ ];\)\ \ 

    \(Print[""];\)\ \ 

    \(solset = Solve[Eqns, vars];\)\ \ \ 

    \(R[x_] = 
        Simplify[
          ReplaceAll[P[x, n]\/Q[x, n], 
            solset\_\(\([[\)\(1\)\(]]\)\)]\ ];\)\ \ 

    \(Print[TableForm[Transpose[solset]]\ ];\)\ \ 

    \(Print[""];\)\ \ 

    \(Print["f[x] = ", f[x]\ ];\)\ 

    \(Print["R[x] = ", R[x]\ ];\)\)\(\ \)\)\)