brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · d9dff4d Raw
42 lines · plain
1# Scripts to generate polynomial approximations for expm1f function using Sollya.2#3# To compute expm1f(x), for |x| > Ln(2), using expf(x) - 1.0f is accurate enough, since catastrophic4# cancellation does not occur with the subtraction.5#6# For |x| <= Ln(2), we divide [-Ln2; Ln2] into 3 subintervals: [-Ln2; -1/8], [-1/8, 1/8], [1/8, Ln2],7# and use a degree-6 polynomial to approximate expm1f in each interval.8 9> f := expm1(x);10 11# Polynomial approximation for e^(x) - 1 on [-Ln2, -1/8].12> P1 := fpminmax(f, [|0, ..., 6|], [|24...], [-log(2), -1/8], relative);13 14> log2(supnorm(P1, f, [-log(2), -1/8], relative, 2^(-50)));15[-29.718757839645220560605567049447893449270454705067;-29.7187578396452193192777968211678241631166415833034]16 17> P1;18-6.899231408397099585272371768951416015625e-8 + x * (0.999998271465301513671875 + x * (0.499982565641403198242187519+ x * (0.16657467186450958251953125 + x * (4.1390590369701385498046875e-2 + x * (7.856394164264202117919921875e-320+ x * 9.380675037391483783721923828125e-4)))))21 22# Polynomial approximation for e^(x) - 1 on [-1/8, 1/8].23> P2 := fpminimax(f, [|1,...,6|], [|24...|], [-1/8, 1/8], relative);24 25> log2(supnorm(P2, f, [-1/8, 1/8], relative, 2^(-50)));26[-34.542864999883718873453825391741639571826398336605;-34.542864999883717632126055163461570285672585214842]27 28> P2;29x * (1 + x * (0.5 + x * (0.16666664183139801025390625 + x * (4.1666664183139801025390625e-230+ x * (8.3379410207271575927734375e-3 + x * 1.3894210569560527801513671875e-3)))))31 32# Polynomial approximation for e^(x) - 1 on [1/8, Ln2].33> P3 := fpminimax(f, [|0,...,6|], [|24...|], [1/8, log(2)], relative);34 35> log2(supnorm(P3, f, [1/8, log(2)], relative, 2^(-50)));36[-29.189438260653683379922869677995123967174571911561;-29.1894382606536821385950994497150546810207587897976]37 38> P3;391.23142086749794543720781803131103515625e-7 + x * (0.9999969005584716796875 + x * (0.50003129243850708007812540+ x * (0.16650259494781494140625 + x * (4.21491153538227081298828125e-2 + x * (7.53940828144550323486328125e-341+ x * 2.05591344274580478668212890625e-3)))))42