File: rtest_nfloat.mac

package info (click to toggle)
maxima 5.21.1-2squeeze
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 94,928 kB
  • ctags: 43,849
  • sloc: lisp: 298,974; fortran: 14,666; perl: 14,325; tcl: 10,494; sh: 4,052; makefile: 2,975; ansic: 471; awk: 24; sed: 7
file content (133 lines) | stat: -rw-r--r-- 4,282 bytes parent folder | download
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
(kill(all), 
   fpprec : 25, 
   load("hypergeometric"), 
   expand_hypergeometric : false, 
   max_fpprec : 1000,
   domain : complex,
   close_p(a,b, dig) := is(abs(a-b) < 10^-dig * abs(a)),
   start : absolute_real_time (), 
   0);
0$

close_p(nfloat(sqrt(3), [], 10), 1.7320508075688772, 10);
true$

string(nfloat(sqrt(3), [], 25));
"1.732050807568877293527446b0"$

string(nfloat(sqrt(3), [], 75));
"1.73205080756887729352744634150587236694280525381038062805580697945193301691b0"$

close_p(nfloat(4/5,[],10), 0.8d0,10);
true$


close_p(nfloat(4/5,[], 42), 8.0b-1, 41);
true$

string(nfloat(%pi,[],50));
"3.1415926535897932384626433832795028841971693993751b0"$

string(nfloat(%e,[],50));
"2.7182818284590452353602874713526624977572470937b0"$

string(nfloat(%phi,[],50));
"1.6180339887498948482045868343656381177203091798058b0"$

close_p(nfloat(sin(6),[], 20), (block([fpprec : 20], bfloat(sin(6)))), 20);
true$

close_p(nfloat(x*cos(x),[x= 6.7], 10), (block([fpprec : 10], bfloat(6.7b0 * cos(6.7b0)))), 10);
true$

every(lambda([a,b], close_p(a,b,5)), nfloat([7.03!, exp(3.08), cos(9.13)], [], 5),
    [5354.48837930151,21.75840239619708,-0.95686667438726]);
 true$

string(nfloat(a < b, [a = 3, b = 5], 28));
"3.0b0 < 5.0b0"$

is(abs(nfloat(sqrt(2) + sqrt(3) - sqrt(5 + 2 * sqrt(6)),[], 47)) < 1/10^47);
true$

is(abs(nfloat(10^75*( 1-sin(x)^2-cos(x)^2),[x = 12.807], 50)) < 1/10^50);
true$

string(nfloat(exp(cos(1000)),[], 23));
"1.7548424420723242327897b0"$

string(makelist(nfloat(1 - sqrt(1 - exp(-x)),[x = 25 * k], 42),k,1,5));
"[6.94397193250611967043059826014130435829847b-12,9.64374923981958891509255092525427404224488b-23,1.33931848097919003989446756792808961123831b-33,0.0b0,0.0b0]"$

string(nfloat((sqrt(x+1) - 1)/x,[x = 1.0e-10], 42));
"4.99999999987500000000624999544558471101821b-1"$

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),
[8.371185747911492687b-1-4.477697799919425369b-1*%i,2.200428274786527453b0-3.322048884197778467b0*%i,
2.133063058316276022b0-3.426963992701597692b0*%i,6.283668414956201133b-1-2.68443764645675033b-1*%i,-
1.119096519392880926b0*%i-2.633126796132956158b-1,1.560007670336818004b0-4.142419418455600467b-1*%i,
3.940482433774016247b-1-1.354653476519420094b0*%i,1.502038751933996562b0*%i+4.876895240070315755b-1,
1.083106802787865044b0-1.502038751933996562b0*%i]);
true$

block([fpprec : 58], close_p(nfloat(acosh(x), [x = 28.07b0 + %i * 22/7], 42),
  bfloat(acosh(28.07b0 + %i * 22/7)), 40));
true$

nfloat(abs(x),[x = 1.0],10);
1.0$

(declare(x,complex), nfloat(conjugate(x),[x = 1.3 + %i],10));
1.3 - 1.0 * %i$

nfloat(matrix([sqrt(2), sqrt(3)],[sqrt(8), sqrt(10)]),[],10);
matrix([1.4142135623730951, 1.7320508075688772], [2.8284271247461903, 3.1622776601683795])$

nfloat([a = b, a < b, a <= b, a > b, a >- b],[a = 2, b = 4],10);
[2.0 = 4.0, 2.0 < 4.0, 2.0 <= 4.0, 2.0 > 4.0, 2.0 > - 4.0]$

nfloat(map('rhs, solve(x^3 + x + 1,x)),[], 10);
[0.341163901914009 - 1.161541399997251 * %i, 1.161541399997251 * %i + 0.341163901914009, - 0.682327803828018]$

nfloat([acos(x), asin(x), atan(x), acosh(x), asinh(x), atanh(x)], [x=0.12],10);
[1.4505064444001086, 0.12028988239478806, 0.11942892601833845, 1.4505064444001083 *%i,
0.11971385039877737, 0.12058102840844402]$

nfloat('(sum(1/(k + 1) - 1/k,k,1,42)),[], 10);
-0.976744186046511$

string(nfloat(sin(10^50),[],53));
"-7.8967249342931008271028953991740775396008340462140272b-1"$

string(nfloat(sin(10^50),[],100));
"-7.89672493429310082710289539917407753960083404621402719145780873622189996980060989863343675758968847b-1"$

string(nfloat(%pi,[],50));
"3.1415926535897932384626433832795028841971693993751b0"$

string(nfloat(1/7,[],50));
"1.4285714285714285714285714285714285714285714285714b-1"$

string(nfloat(gamma(33/10),[],50));
"2.6834373819557687935963273147667112586281870043548b0"$

nfloat(abs(28.07),[], 10);
28.07$

nfloat(realpart(28.07 - %i),[], 10);
28.07$

nfloat(imagpart(28.07 - %i),[], 10);
-1.0$

nfloat(a * b, [a = 6.7, b= 12],23);
8.0400000000000002131628b1$

(time : (absolute_real_time ()- start), print(time), is(time < 2));
true$

(remvalue(start,time), forget(x,complex), reset(domain, fpprec, expand_hypergeometric, max_fpprec), 
 remfunction(close_p),0);
0$