forked from johannesgerer/jburkardt-m
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vpa.html
173 lines (149 loc) · 4.41 KB
/
vpa.html
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<html>
<head>
<title>
VPA - MATLAB's Variable Precision Arithmetic
</title>
</head>
<body bgcolor="#eeeeee" link="#cc0000" alink="#ff3300" vlink="#000055">
<h1 align = "center">
VPA <br> MATLAB's Variable Precision Arithmetic
</h1>
<hr>
<p>
<b>VPA</b>
contains MATLAB programs which
demonstrate the use of variable precision arithmetic.
</p>
<p>
MATLAB's variable precision arithmetic is only available through the
Symbolic Math Toolbox. To find out if you have this toolbox installed,
you can type "ver" within your MATLAB session.
</p>
<p>
In MATLAB, evaluating a symbolic variable means creating a representation of
its value, to a given number of digits, as a floating point number. The
vpa() command is used to create the floating point representation.
Typical uses are:
<pre>
r = vpa ( s )
</pre>
which takes the symbolic object s and evaluates it as a symbolic real number
to the current default number of digits or
<pre>
r = vpa ( s, d )
</pre>
which uses d digits in the real number representation.
</p>
<p>
The current default number of digits can be found by using the digits() command:
<pre>
dignum = digits;
</pre>
or
<pre>
dignum = digits ( );
</pre>
The default number of digits can be changed by including an input argument
to the digits() command:
<pre>
digits ( 50 );
</pre>
</p>
<p>
To my mind, a significant issue with the symbolic math toolbox is that it
is not apparent how to control the printing of the value of a given variable.
If I compute something to 80 digits, I can always display it by naming it.
But what if I prefer a labeled printout? Various alternatives involving
"disp()" and "fprintf()" and string concatenation seem unsatisfactory.
</p>
<h3 align = "center">
Licensing:
</h3>
<p>
The computer code and data files made available on this web page
are distributed under
<a href = "mathworks_bsd_license.txt">the BSD license.</a>
</p>
<h3 align = "center">
Languages:
</h3>
<p>
<b>VPA</b> is available in
<a href = "../../m_src/vpa/vpa.html">a MATLAB version</a>.
</p>
<h3 align = "center">
Reference:
</h3>
<p>
<ol>
<li>
David Bailey, Jonathan Borwein,<br>
Experimental Mathematics: Examples, Methods and Implications,<br>
Notices of the American Mathematical Society,<br>
Volume 52, Number 5, pages 502-514.
</li>
<li>
David Bailey, Karthik Jeyabalan, Xiaoye Li,<br>
A Comparison of Three High-Precision Quadrature Schemes,<br>
Experimental Mathematics,<br>
Volume 14, Number 3, pages 317-329.
</li>
<li>
Cleve Moler,<br>
Cleve's Corner: Computing Pi,<br>
MATLAB News and Notes,<br>
February 2012.
</li>
</ol>
</p>
<h3 align = "center">
Source Code:
</h3>
<p>
<b>COMPUTING_PI</b> is a collection of three functions discussed by
Cleve Moler for computing pi to many digits.
<ul>
<li>
<a href = "agm_pi.m">agm_pi.m</a>,
uses the arithmetic-geometric mean algorithm.
</li>
<li>
<a href = "agm_pi_test.m">agm_pi_test.m</a>,
tests agm_pi.
</li>
<li>
<a href = "bbp_pi.m">bbp_pi.m</a>,
uses the Bailey-Borwein-Plouffe algorithm.
</li>
<li>
<a href = "bbp_pi_test.m">bbp_pi_test.m</a>,
tests bbp_pi.
</li>
<li>
<a href = "chud_pi.m">chud_pi.m</a>,
uses the Chudnovsky algorithm.
</li>
<li>
<a href = "chud_pi_test.m">chud_pi_test.m</a>,
tests chud_pi.
</li>
<li>
<a href = "pi_test.m">pi_test.m</a>, calls all the tests;
</li>
<li>
<a href = "pi_test_output.txt">pi_test_output.txt</a>,
the output file.
</li>
</ul>
</p>
<p>
You can go up one level to <a href = "../m_src.html">
the MATLAB source codes</a>.
</p>
<hr>
<i>
Last modified on 28 February 2012.
</i>
<!-- John Burkardt -->
</body>
</html>