3 load("hypergeometric"),
4 expand_hypergeometric : false,
7 close_p(a,b, dig) := is(abs(a-b) < 10^-dig * abs(a)),
8 start : absolute_real_time (),
12 close_p(nfloat(sqrt(3), [], 10), 1.7320508075688772, 10);
15 string(nfloat(sqrt(3), [], 25));
16 "1.732050807568877293527446b0"$
18 string(nfloat(sqrt(3), [], 75));
19 "1.73205080756887729352744634150587236694280525381038062805580697945193301691b0"$
21 close_p(nfloat(4/5,[],10), 0.8d0,10);
25 close_p(nfloat(4/5,[], 42), 8.0b-1, 41);
28 string(nfloat(%pi,[],50));
29 "3.1415926535897932384626433832795028841971693993751b0"$
31 string(nfloat(%e,[],50));
32 "2.7182818284590452353602874713526624977572470937b0"$
34 string(nfloat(%phi,[],50));
35 "1.6180339887498948482045868343656381177203091798058b0"$
37 close_p(nfloat(sin(6),[], 20), (block([fpprec : 20], bfloat(sin(6)))), 20);
40 close_p(nfloat(x*cos(x),[x= 6.7], 10), (block([fpprec : 10], bfloat(6.7b0 * cos(6.7b0)))), 10);
43 every(lambda([a,b], close_p(a,b,5)), nfloat([7.03!, exp(3.08), cos(9.13)], [], 5),
44 [5354.48837930151,21.75840239619708,-0.95686667438726]);
47 string(nfloat(a < b, [a = 3, b = 5], 28));
50 is(abs(nfloat(sqrt(2) + sqrt(3) - sqrt(5 + 2 * sqrt(6)),[], 47)) < 1/10^47);
53 is(abs(nfloat(10^75*( 1-sin(x)^2-cos(x)^2),[x = 12.807], 50)) < 1/10^50);
56 string(nfloat(exp(cos(1000)),[], 23));
57 "1.7548424420723242327897b0"$
59 string(makelist(nfloat(1 - sqrt(1 - exp(-x)),[x = 25 * k], 42),k,1,5));
60 "[6.94397193250611967043059826014130435829847b-12,9.64374923981958891509255092525427404224488b-23,1.33931848097919003989446756792808961123831b-33,0.0b0,0.0b0]"$
62 string(nfloat((sqrt(x+1) - 1)/x,[x = 1.0e-10], 42));
63 "4.99999999987500000000624999544558471101821b-1"$
65 every(lambda([a,b], close_p(a,b,18)), nfloat([log(x), cosh(x), sinh(x), csc(x), tan(x), asinh(x), atanh(x), acos(x), asin(x)],[x = 2.082 - %i], 19),
66 [8.371185747911492687b-1-4.477697799919425369b-1*%i,2.200428274786527453b0-3.322048884197778467b0*%i,
67 2.133063058316276022b0-3.426963992701597692b0*%i,6.283668414956201133b-1-2.68443764645675033b-1*%i,-
68 1.119096519392880926b0*%i-2.633126796132956158b-1,1.560007670336818004b0-4.142419418455600467b-1*%i,
69 3.940482433774016247b-1-1.354653476519420094b0*%i,1.502038751933996562b0*%i+4.876895240070315755b-1,
70 1.083106802787865044b0-1.502038751933996562b0*%i]);
73 block([fpprec : 58], close_p(nfloat(acosh(x), [x = 28.07b0 + %i * 22/7], 42),
74 bfloat(acosh(28.07b0 + %i * 22/7)), 40));
77 nfloat(abs(x),[x = 1.0],10);
80 (declare(x,complex), nfloat(conjugate(x),[x = 1.3 + %i],10));
83 nfloat(matrix([sqrt(2), sqrt(3)],[sqrt(8), sqrt(10)]),[],10);
84 matrix([1.4142135623730951, 1.7320508075688772], [2.8284271247461903, 3.1622776601683795])$
86 nfloat([a = b, a < b, a <= b, a > b, a >- b],[a = 2, b = 4],10);
87 [2.0 = 4.0, 2.0 < 4.0, 2.0 <= 4.0, 2.0 > 4.0, 2.0 > - 4.0]$
89 nfloat(map('rhs, solve(x^3 + x + 1,x)),[], 10);
90 [0.341163901914009 - 1.161541399997251 * %i, 1.161541399997251 * %i + 0.341163901914009, - 0.682327803828018]$
92 nfloat([acos(x), asin(x), atan(x), acosh(x), asinh(x), atanh(x)], [x=0.12],10);
93 [1.4505064444001086, 0.12028988239478806, 0.11942892601833845, 1.4505064444001083 *%i,
94 0.11971385039877737, 0.12058102840844402]$
96 nfloat('(sum(1/(k + 1) - 1/k,k,1,42)),[], 10);
99 string(nfloat(sin(10^50),[],53));
100 "-7.8967249342931008271028953991740775396008340462140272b-1"$
102 string(nfloat(sin(10^50),[],100));
103 "-7.89672493429310082710289539917407753960083404621402719145780873622189996980060989863343675758968847b-1"$
105 string(nfloat(%pi,[],50));
106 "3.1415926535897932384626433832795028841971693993751b0"$
108 string(nfloat(1/7,[],50));
109 "1.4285714285714285714285714285714285714285714285714b-1"$
111 string(nfloat(gamma(33/10),[],50));
112 "2.6834373819557687935963273147667112586281870043548b0"$
114 nfloat('(abs(f)),[f=28.07], 10);
117 nfloat('(realpart(f)),[f=28.07 - %i], 10);
120 nfloat('(imagpart(f)),[f=28.07 - %i], 10);
123 nfloat(a * b, [a = 6.7, b= 12],23);
124 8.0400000000000002131628b1$
126 close_p(nfloat(hypergeometric([2,2/3],[5/8], x), [x = 1.2], 20),
127 2.8881276944825158378b1 - 3.7728678507291344336b0 * %i,20);
130 nfloat(a*b,[a = 1.3, b = 42], 16);
133 nfloat(f!, [f= 4], 20);
136 close_p(nfloat(atan2(x,y),[x=1.2b0, y = -8.1b0], 25),2.994514298201390738133141b0, fpprec-2);
139 close_p(nfloat('(realpart(x)),[x= 1.2 + %i]),1.2,20);
142 close_p(nfloat('(imagpart(x)),[x= 1.2 + %i]),1.0,20);
145 nfloat('(a,b),[a=3,b=7]);
148 nfloat([x,y],[x=1,y=2],23);
151 block([fpprec : 25], close_p(nfloat('(product(sin(k*x),k,1,28)),[x = 0.1b0], 25),
152 1.909750489550340725818861b-6, 24));
155 (time : (absolute_real_time ()- start), print(time), is(time < 4));
164 /* nfloat bug - ID: 3358420 */
165 nfloat(1.0*%i,[],20);
168 /* nfloat - ID: 3455326 */
169 close_p(nfloat((sqrt(1+x)-1)/x,[x=1/10^15],15),1/2, 15);
172 (remvalue(start,time), remove(x,complex), reset(domain, fpprec, expand_hypergeometric, max_fpprec),
173 remfunction(close_p),0);