Name:

fpminimax computes a good polynomial approximation with fixed-point or floating-point coefficients

Library names:

sollya_obj_t sollya_lib_fpminimax(sollya_obj_t, sollya_obj_t, sollya_obj_t,                                   sollya_obj_t, ...) sollya_obj_t sollya_lib_v_fpminimax(sollya_obj_t, sollya_obj_t,                                     sollya_obj_t, sollya_obj_t, va_list)

Usage:

fpminimax(f, n, formats, range, indic1, indic2, indic3, P) : (function, integer, list, range, absolute|relative | fixed|floating | function, absolute|relative | fixed|floating | function, absolute|relative | fixed|floating | function, function) -> function fpminimax(f, monomials, formats, range, indic1, indic2, indic3, P) : (function, list, list, range, absolute|relative | fixed|floating | function, absolute|relative | fixed|floating | function, absolute|relative | fixed|floating | function, function) -> function fpminimax(f, n, formats, L, indic1, indic2, indic3, P) : (function, integer, list, list, absolute|relative | fixed|floating | function, absolute|relative | fixed|floating | function, absolute|relative | fixed|floating | function, function) -> function fpminimax(f, monomials, formats, L, indic1, indic2, indic3, P) : (function, list, list, list, absolute|relative | fixed|floating | function, absolute|relative | fixed|floating | function, absolute|relative | fixed|floating | function, function) -> function

Parameters:

Description:

Example 1:

   > P = fpminimax(cos(x),6,[|DD, DD, D...|],[-1b-5;1b-5]);
   > printexpansion(P);
   (0x3ff0000000000000 + 0xbc09fda15e029b00) + x * ((0x3af9eb57163024a8 + 0x37942c2f3f3e3839) + x * (0xbfdfffffffffff98 + x * (0xbbd1693f9c028849 + x * (0x3fa5555555145337 + x * (0x3c7a25f610ad9ebc + x * 0xbf56c138142da5b0)))))

Example 2:

   > P = fpminimax(sin(x),6,[|32...|],[-1b-5;1b-5], fixed, absolute);
   > display = powers!;
   > P;
   x * (1 + x^2 * (-357913941 * 2^(-31) + x^2 * (35789873 * 2^(-32))))

Example 3:

   > P = fpminimax(exp(x), [|3,4|], [|D,24|], [-1/256; 1/246], 1+x+x^2/2);
   > display = powers!;
   > P;
   1 + x * (1 + x * (1 * 2^(-1) + x * (375300225001191 * 2^(-51) + x * (5592621 * 2^(-27)))))

Example 4:

   > f = cos(exp(x));
   > pstar = remez(f, 5, [-1b-7;1b-7]);
   > listpoints = dirtyfindzeros(f-pstar, [-1b-7; 1b-7]);
   > P1 = fpminimax(f, 5, [|DD...|], listpoints, absolute, default, default, pstar);
   > P2 = fpminimax(f, 5, [|D...|], listpoints, absolute, default, default, pstar);
   > P3 = fpminimax(f, 5, [|D, D, D, 24...|], listpoints, absolute, default, default, pstar);
   > print("Error of pstar: ", dirtyinfnorm(f-pstar, [-1b-7; 1b-7]));
   Error of pstar:  7.9048441259903026332577436001060063099817726177425e-16
   > print("Error of P1:    ", dirtyinfnorm(f-P1, [-1b-7; 1b-7]));
   Error of P1:     7.9048441259903026580081299123420463921479618202064e-16
   > print("Error of P2:    ", dirtyinfnorm(f-P2, [-1b-7; 1b-7]));
   Error of P2:     8.2477144579950871737109573536791331686347620955985e-16
   > print("Error of P3:    ", dirtyinfnorm(f-P3, [-1b-7; 1b-7]));
   Error of P3:     1.08454277156993282593701156841863009789063333951055e-15

Example 5:

   > L = [|exp(x), sin(x), cos(x)-1, sin(x^3)|];
   > g = (2^x-1)/x;
   > p = fpminimax(g, L, [|D...|], [-1/16;1/16],absolute);
   > display = powers!;
   > p;
   -3267884797436153 * 2^(-54) * sin(x^3) + 5247089102535885 * 2^(-53) * (cos(x) - 1) + -8159095033730771 * 2^(-54) * sin(x) + 6243315658446641 * 2^(-53) * exp(x)

Example 6:

   > n = 9;
   > T = [|1, x|];
   > for i from 2 to n do T[i] = canonical(2*x*T[i-1]-T[i-2]);
   > g = (2^x-1)/x;
   > PCheb = fpminimax(g, T, [|DD,DE...|], [-1/16;1/16],absolute);
   > display = dyadic!;
   > print(PCheb);
   8733930098894247371b-98 * (9 * x + -120 * x^3 + 432 * x^5 + -576 * x^7 + 256 * x^9) + 15750497046710770365b-94 * (1 + -32 * x^2 + 160 * x^4 + -256 * x^6 + 128 * x^8) + 6467380330985872933b-88 * (-7 * x + 56 * x^3 + -112 * x^5 + 64 * x^7) + 9342762606926218927b-84 * (-1 + 18 * x^2 + -48 * x^4 + 32 * x^6) + 11814521367456461131b-80 * (5 * x + -20 * x^3 + 16 * x^5) + 6405479474328570593b-75 * (1 + -8 * x^2 + 8 * x^4) + 11584457324781949889b-72 * (-3 * x + 4 * x^3) + 16779705312447201161b-69 * (-1 + 2 * x^2) + 18265014280997359319b-66 * x + 117054497448175143902009975397253b-107
See also: remez, dirtyfindzeros, absolute, relative, fixed, floating, default, halfprecision, single, double, doubleextended, doubledouble, quad, tripledouble, implementpoly, coeff, degree, roundcoefficients, guessdegree
Go back to the list of commands