1 | |
---|
2 | [def __asinh [link boost_math.math_special_functions.asinh asinh]] |
---|
3 | [def __acosh [link boost_math.math_special_functions.acosh acosh]] |
---|
4 | [def __atanh [link boost_math.math_special_functions.atanh atanh]] |
---|
5 | [def __sinc_pi [link boost_math.math_special_functions.sinc_pi sinc_pi]] |
---|
6 | [def __sinhc_pi [link boost_math.math_special_functions.sinhc_pi sinhc_pi]] |
---|
7 | |
---|
8 | [def __log1p [link boost_math.math_special_functions.log1p log1p]] |
---|
9 | [def __expm1 [link boost_math.math_special_functions.expm1 expm1]] |
---|
10 | [def __hypot [link boost_math.math_special_functions.hypot hypot]] |
---|
11 | |
---|
12 | [def __form1 [^\[0;+'''∞'''\[]] |
---|
13 | [def __form2 [^\]-'''∞''';+1\[]] |
---|
14 | [def __form3 [^\]-'''∞''';-1\[]] |
---|
15 | [def __form4 [^\]+1;+'''∞'''\[]] |
---|
16 | [def __form5 `[^\[-1;-1+'''ε'''\[]] |
---|
17 | [def __form6 '''ε'''] |
---|
18 | [def __form7 [^\]+1-'''ε''';+1\]]] |
---|
19 | |
---|
20 | [def __effects [*Effects: ]] |
---|
21 | [def __formula [*Formula: ]] |
---|
22 | [def __exm1 '''<code>e<superscript>x</superscript> - 1</code>'''] |
---|
23 | [def __ex '''<code>e<superscript>x</superscript></code>'''] |
---|
24 | [def __te '''2ε'''] |
---|
25 | |
---|
26 | |
---|
27 | [section Math Special Functions] |
---|
28 | |
---|
29 | [section Overview] |
---|
30 | |
---|
31 | The Special Functions library currently provides eight templated special functions, |
---|
32 | in namespace boost. Two of these (__sinc_pi and __sinhc_pi) are needed by our |
---|
33 | implementation of quaternions and octonions. |
---|
34 | |
---|
35 | The functions __acosh, __asinh and __atanh are entirely classical, |
---|
36 | the function __sinc_pi sees heavy use in signal processing tasks, |
---|
37 | and the function __sinhc_pi is an ad'hoc function whose naming is modelled on |
---|
38 | __sinc_pi and hyperbolic functions. |
---|
39 | |
---|
40 | The functions __log1p, __expm1 and __hypot are all part of the C99 standard |
---|
41 | but not yet C++. Two of these (__log1p and __hypot) were needed for the |
---|
42 | [link boost_math.inverse_complex complex number inverse trigonometric functions]. |
---|
43 | |
---|
44 | The functions implemented here can throw standard exceptions, but no |
---|
45 | exception specification has been made. |
---|
46 | |
---|
47 | [endsect] |
---|
48 | |
---|
49 | [section Header Files] |
---|
50 | |
---|
51 | The interface and implementation for each function (or forms of a function) |
---|
52 | are both supplied by one header file: |
---|
53 | |
---|
54 | * [@../../boost/math/special_functions/acosh.hpp acosh.hpp] |
---|
55 | * [@../../boost/math/special_functions/asinh.hpp asinh.hpp] |
---|
56 | * [@../../boost/math/special_functions/atanh.hpp atanh.hpp] |
---|
57 | * [@../../boost/math/special_functions/expm1.hpp expm1.hpp] |
---|
58 | * [@../../boost/math/special_functions/hypot.hpp hypot.hpp] |
---|
59 | * [@../../boost/math/special_functions/log1p.hpp log1p.hpp] |
---|
60 | * [@../../boost/math/special_functions/sinc.hpp sinc.hpp] |
---|
61 | * [@../../boost/math/special_functions/sinhc.hpp sinhc.hpp] |
---|
62 | |
---|
63 | [endsect] |
---|
64 | |
---|
65 | [section Synopsis] |
---|
66 | |
---|
67 | namespace boost{ namespace math{ |
---|
68 | |
---|
69 | template<typename T> |
---|
70 | T __acosh(const T x); |
---|
71 | |
---|
72 | template<typename T> |
---|
73 | T __asinh(const T x); |
---|
74 | |
---|
75 | template<typename T> |
---|
76 | T __atanh(const T x); |
---|
77 | |
---|
78 | template<typename T> |
---|
79 | T __expm1(const T x); |
---|
80 | |
---|
81 | template<typename T> |
---|
82 | T __hypot(const T x); |
---|
83 | |
---|
84 | template<typename T> |
---|
85 | T __log1p(const T x); |
---|
86 | |
---|
87 | template<typename T> |
---|
88 | T __sinc_pi(const T x); |
---|
89 | |
---|
90 | template<typename T, template<typename> class U> |
---|
91 | U<T> __sinc_pi(const U<T> x); |
---|
92 | |
---|
93 | template<typename T> |
---|
94 | T __sinhc_pi(const T x); |
---|
95 | |
---|
96 | template<typename T, template<typename> class U> |
---|
97 | U<T> __sinhc_pi(const U<T> x); |
---|
98 | |
---|
99 | } |
---|
100 | } |
---|
101 | |
---|
102 | [endsect] |
---|
103 | |
---|
104 | [section acosh] |
---|
105 | |
---|
106 | template<typename T> |
---|
107 | T acosh(const T x); |
---|
108 | |
---|
109 | Computes the reciprocal of (the restriction to the range of __form1) |
---|
110 | [link boost_math.background_information_and_white_papers.the_inverse_hyperbolic_functions |
---|
111 | the hyperbolic cosine function], at x. Values returned are positive. Generalised |
---|
112 | Taylor series are used near 1 and Laurent series are used near the |
---|
113 | infinity to ensure accuracy. |
---|
114 | |
---|
115 | If x is in the range __form2 a quiet NaN is returned (if the system allows, |
---|
116 | otherwise a `domain_error` exception is generated). |
---|
117 | |
---|
118 | [endsect] |
---|
119 | |
---|
120 | [section asinh] |
---|
121 | |
---|
122 | template<typename T> |
---|
123 | T asinh(const T x); |
---|
124 | |
---|
125 | Computes the reciprocal of |
---|
126 | [link boost_math.background_information_and_white_papers.the_inverse_hyperbolic_functions |
---|
127 | the hyperbolic sine function]. |
---|
128 | Taylor series are used at the origin and Laurent series are used near the |
---|
129 | infinity to ensure accuracy. |
---|
130 | |
---|
131 | [endsect] |
---|
132 | |
---|
133 | [section atanh] |
---|
134 | |
---|
135 | template<typename T> |
---|
136 | T atanh(const T x); |
---|
137 | |
---|
138 | Computes the reciprocal of |
---|
139 | [link boost_math.background_information_and_white_papers.the_inverse_hyperbolic_functions |
---|
140 | the hyperbolic tangent function], at x. |
---|
141 | Taylor series are used at the origin to ensure accuracy. |
---|
142 | |
---|
143 | If x is in the range |
---|
144 | __form3 |
---|
145 | or in the range |
---|
146 | __form4 |
---|
147 | a quiet NaN is returned |
---|
148 | (if the system allows, otherwise a `domain_error` exception is generated). |
---|
149 | |
---|
150 | If x is in the range |
---|
151 | __form5, |
---|
152 | minus infinity is returned |
---|
153 | (if the system allows, otherwise an `out_of_range` exception |
---|
154 | is generated), with |
---|
155 | __form6 |
---|
156 | denoting numeric_limits<T>::epsilon(). |
---|
157 | |
---|
158 | If x is in the range |
---|
159 | __form7, |
---|
160 | plus infinity is returned (if the system allows, |
---|
161 | otherwise an `out_of_range` exception is generated), with |
---|
162 | __form6 |
---|
163 | denoting |
---|
164 | numeric_limits<T>::epsilon(). |
---|
165 | |
---|
166 | [endsect] |
---|
167 | |
---|
168 | [section:expm1 expm1] |
---|
169 | |
---|
170 | template <class T> |
---|
171 | T expm1(T t); |
---|
172 | |
---|
173 | __effects returns __exm1. |
---|
174 | |
---|
175 | For small x, then __ex is very close to 1, as a result calculating __exm1 results |
---|
176 | in catastrophic cancellation errors when x is small. `expm1` calculates __exm1 using |
---|
177 | a series expansion when x is small (giving an accuracy of less than __te). |
---|
178 | |
---|
179 | Finally when BOOST_HAS_EXPM1 is defined then the `float/double/long double` |
---|
180 | specializations of this template simply forward to the platform's |
---|
181 | native implementation of this function. |
---|
182 | |
---|
183 | [endsect] |
---|
184 | |
---|
185 | [section:hypot hypot] |
---|
186 | |
---|
187 | template <class T> |
---|
188 | T hypot(T x, T y); |
---|
189 | |
---|
190 | __effects computes [$../../libs/math/doc/images/hypot.png] in such a way as to avoid undue underflow and overflow. |
---|
191 | |
---|
192 | When calculating [$../../libs/math/doc/images/hypot.png] it's quite easy for the intermediate terms to either |
---|
193 | overflow or underflow, even though the result is in fact perfectly representable. |
---|
194 | One possible alternative form is [$../../libs/math/doc/images/hypot2.png], but that can overflow or underflow |
---|
195 | if x and y are of very differing magnitudes. The `hypot` function takes care of |
---|
196 | all the special cases for you, so you don't have to. |
---|
197 | |
---|
198 | [endsect] |
---|
199 | |
---|
200 | [section:log1p log1p] |
---|
201 | |
---|
202 | template <class T> |
---|
203 | T log1p(T x); |
---|
204 | |
---|
205 | __effects returns the natural logarithm of `x+1`. |
---|
206 | |
---|
207 | There are many situations where it is desirable to compute `log(x+1)`. |
---|
208 | However, for small `x` then `x+1` suffers from catastrophic cancellation errors |
---|
209 | so that `x+1 == 1` and `log(x+1) == 0`, when in fact for very small x, the |
---|
210 | best approximation to `log(x+1)` would be `x`. `log1p` calculates the best |
---|
211 | approximation to `log(1+x)` using a Taylor series expansion for accuracy |
---|
212 | (less than __te). |
---|
213 | Note that there are faster methods available, for example using the equivalence: |
---|
214 | |
---|
215 | log(1+x) == (log(1+x) * x) / ((1-x) - 1) |
---|
216 | |
---|
217 | However, experience has shown that these methods tend to fail quite spectacularly |
---|
218 | once the compiler's optimizations are turned on. In contrast, the series expansion |
---|
219 | method seems to be reasonably immune optimizer-induced errors. |
---|
220 | |
---|
221 | Finally when BOOST_HAS_LOG1P is defined then the `float/double/long double` |
---|
222 | specializations of this template simply forward to the platform's |
---|
223 | native implementation of this function. |
---|
224 | |
---|
225 | [endsect] |
---|
226 | |
---|
227 | [section sinc_pi] |
---|
228 | |
---|
229 | template<typename T> |
---|
230 | T sinc_pi(const T x); |
---|
231 | |
---|
232 | template<typename T, template<typename> class U> |
---|
233 | U<T> sinc_pi(const U<T> x); |
---|
234 | |
---|
235 | Computes |
---|
236 | [link boost_math.background_information_and_white_papers.sinus_cardinal_and_hyperbolic_sinus_cardinal_functions |
---|
237 | the Sinus Cardinal] of x. The second form is for complexes, |
---|
238 | quaternions, octonions... Taylor series are used at the origin |
---|
239 | to ensure accuracy. |
---|
240 | |
---|
241 | [endsect] |
---|
242 | |
---|
243 | [section sinhc_pi] |
---|
244 | |
---|
245 | template<typename T> |
---|
246 | T sinhc_pi(const T x); |
---|
247 | |
---|
248 | template<typename T, template<typename> class U> |
---|
249 | U<T> sinhc_pi(const U<T> x); |
---|
250 | |
---|
251 | Computes |
---|
252 | [link boost_math.background_information_and_white_papers.sinus_cardinal_and_hyperbolic_sinus_cardinal_functions |
---|
253 | the Hyperbolic Sinus Cardinal] of x. The second form is for |
---|
254 | complexes, quaternions, octonions... Taylor series are used at the origin |
---|
255 | to ensure accuracy. |
---|
256 | |
---|
257 | [endsect] |
---|
258 | |
---|
259 | [section Test Programs] |
---|
260 | |
---|
261 | The [@../../libs/math/special_functions/special_functions_test.cpp |
---|
262 | special_functions_test.cpp] |
---|
263 | and [@../../libs/math/test/log1p_expm1_test.cpp log1p_expm1_test.cpp] test programs test the functions for |
---|
264 | float, double and long double arguments ([@../../libs/math/special_functions/output.txt sample output], with message |
---|
265 | output enabled). |
---|
266 | |
---|
267 | If you define the symbol BOOST_SPECIAL_FUNCTIONS_TEST_VERBOSE, you will |
---|
268 | get additional output |
---|
269 | ([@../../libs/math/special_functions/output_more.txt verbose output]), |
---|
270 | which may prove useful for |
---|
271 | tuning on your platform (the library use "reasonable" tolerances, |
---|
272 | which may prove to be too strict for your platform); this will only be |
---|
273 | helpfull if you enable message output at the same time, of course |
---|
274 | (by uncommenting the relevant line in the test or by adding `--log_level=messages` |
---|
275 | to your command line,...). |
---|
276 | |
---|
277 | [endsect] |
---|
278 | |
---|
279 | [section Acknowledgements] |
---|
280 | |
---|
281 | The mathematical text has been typeset with [@http://www.nisus-soft.com/ |
---|
282 | Nisus Writer], and the |
---|
283 | illustrations have been made with [@http://www.pacifict.com/ |
---|
284 | Graphing Calculator]. Jens Maurer |
---|
285 | was the Review Manager for this library. More acknowledgements in the |
---|
286 | History section. Thank you to all who contributed to the discution |
---|
287 | about this library. |
---|
288 | |
---|
289 | [endsect] |
---|
290 | |
---|
291 | [section History] |
---|
292 | |
---|
293 | * 1.5.0 - 17/12/2005: John Maddock added __log1p, __expm1 and __hypot. Converted documentation to Quickbook Format. |
---|
294 | * 1.4.2 - 03/02/2003: transitionned to the unit test framework; <boost/config.hpp> now included by the library headers (rather than the test files). |
---|
295 | * 1.4.1 - 18/09/2002: improved compatibility with Microsoft compilers. |
---|
296 | * 1.4.0 - 14/09/2001: added (after rewrite) __acosh and __asinh, which were submited by Eric Ford; applied changes for Gcc 2.9.x suggested by John Maddock; improved accuracy; sanity check for test file, related to accuracy. |
---|
297 | * 1.3.2 - 07/07/2001: introduced namespace math. |
---|
298 | * 1.3.1 - 07/06/2001:(end of Boost review) split special_functions.hpp into atanh.hpp, sinc.hpp and sinhc.hpp; improved efficiency of __atanh with compile-time technique (Daryle Walker); improved accuracy of all functions near zero (Peter Schmitteckert). |
---|
299 | * 1.3.0 - 26/03/2001: support for complexes & all, for cardinal functions. |
---|
300 | * 1.2.0 - 31/01/2001: minor modifications for Koenig lookup. |
---|
301 | * 1.1.0 - 23/01/2001: boostification. |
---|
302 | * 1.0.0 - 10/08/1999: first public version. |
---|
303 | |
---|
304 | [endsect] |
---|
305 | |
---|
306 | [section To Do] |
---|
307 | |
---|
308 | * Add more functions. |
---|
309 | * Improve test of each function. |
---|
310 | |
---|
311 | [endsect] |
---|
312 | [endsect] |
---|
313 | |
---|
314 | |
---|