-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtetralogMinimaxApprox.m
84 lines (51 loc) · 2.08 KB
/
tetralogMinimaxApprox.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
(*
Approximation of PolyLog[4,x] by a rational function approximations.
*)
Needs["FunctionApproximations`"];
(* maximum number of terms in the series *)
nMax = 200;
(* output precision *)
outPrec = 20;
(* series for PolyLog[4,x]/x *)
Li4x[x_, n_:nMax] := Sum[x^(i-1)/i^4, {i,1,n}];
(* bring rational function to standard form *)
PolynomialStandardForm[expr_, x_] :=
Module[{n = Numerator[expr], d = Denominator[expr], c},
c = d /. x -> 0;
Expand[n/c] / Expand[d/c]
];
FormatCoeffs[expr_, x_, prec_] :=
N[#, prec]& /@ CoefficientList[expr, x]
(* inversion formula rest term *)
(* -(2 Pi I)^n/Factorial[n] BernoulliB[n, 1/2 + Log[-x]/(2 Pi I)] /. n -> 4 *)
(* [-1,0] *)
Print["Approximation of Li4[x]/x on [-1,0]"];
li4 = Normal@Series[PolyLog[4,x]/x, {x,-1,100}]
approx = MiniMaxApproximation[li4, {x, {-1, 0}, 5, 6}, WorkingPrecision -> nMax];
maxErr = approx[[2,2]]
Print["max rel. error: ", InputForm @ maxErr];
approx = PolynomialStandardForm[approx[[2,1]], x];
Print["Numerator coefficients: ",
FormatCoeffs[#,x,outPrec]& @ Numerator[approx]];
Print["Denominator coefficients: ",
FormatCoeffs[#,x,outPrec]& @ Denominator[approx]];
(* [0,1/2] *)
Print["Approximation of Li4[x]/x on [0,1/2]"];
approx = MiniMaxApproximation[Li4x[x], {x, {0, 1/2}, 5, 5}, WorkingPrecision -> 100];
maxErr = approx[[2,2]]
Print["max rel. error: ", InputForm @ maxErr];
approx = PolynomialStandardForm[approx[[2,1]], x];
Print["Numerator coefficients: ",
FormatCoeffs[#,x,outPrec]& @ Numerator[approx]];
Print["Denominator coefficients: ",
FormatCoeffs[#,x,outPrec]& @ Denominator[approx]];
(* [1/2,8/10] *)
Print["Approximation of Li4[x] on [1/2,8/10]"];
approx = MiniMaxApproximation[PolyLog[4,x], {x, {1/2, 8/10}, 6, 6}, WorkingPrecision -> 100];
maxErr = approx[[2,2]]
Print["max rel. error: ", InputForm @ maxErr];
approx = PolynomialStandardForm[approx[[2,1]], x];
Print["Numerator coefficients: ",
FormatCoeffs[#,x,outPrec]& @ Numerator[approx]];
Print["Denominator coefficients: ",
FormatCoeffs[#,x,outPrec]& @ Denominator[approx]];