double-double
Version:
Pure double-double precision functions *with strict error bounds*.
1 lines • 8.67 kB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[49],{185:function(e,t,r){"use strict";r.r(t),r.d(t,"frontMatter",(function(){return i})),r.d(t,"metadata",(function(){return c})),r.d(t,"rightToc",(function(){return l})),r.d(t,"default",(function(){return u}));var n=r(2),a=r(9),o=(r(0),r(207)),i={id:"index",title:"Introduction",sidebar_label:"Getting started"},c={id:"index",isDocsHomePage:!0,title:"Introduction",description:"Pure double & double-double floating point arithmetic functions with strict error bounds",source:"@site/docs\\index.md",permalink:"/double-double/docs/",sidebar_label:"Getting started",sidebar:"sidebar",next:{title:"fastTwoDiff",permalink:"/double-double/docs/modules/_basic_fast_two_diff_"}},l=[{value:"Pure double & double-double floating point arithmetic functions <em>with strict error bounds</em>",id:"pure-double--double-double-floating-point-arithmetic-functions-with-strict-error-bounds",children:[]},{value:"Installation",id:"installation",children:[]},{value:"Overview",id:"overview",children:[]},{value:"Research",id:"research",children:[]},{value:"Benchmark",id:"benchmark",children:[]},{value:"License",id:"license",children:[]}],b={rightToc:l};function u(e){var t=e.components,r=Object(a.a)(e,["components"]);return Object(o.b)("wrapper",Object(n.a)({},b,r,{components:t,mdxType:"MDXLayout"}),Object(o.b)("h2",{id:"pure-double--double-double-floating-point-arithmetic-functions-with-strict-error-bounds"},"Pure double & double-double floating point arithmetic functions ",Object(o.b)("em",{parentName:"h2"},"with strict error bounds")),Object(o.b)("h2",{id:"installation"},"Installation"),Object(o.b)("pre",null,Object(o.b)("code",Object(n.a)({parentName:"pre"},{className:"language-cli"}),"npm install double-double\n")),Object(o.b)("blockquote",null,Object(o.b)("p",{parentName:"blockquote"},Object(o.b)("strong",{parentName:"p"},"\u2757Important\u2757")),Object(o.b)("p",{parentName:"blockquote"},"Use"),Object(o.b)("pre",{parentName:"blockquote"},Object(o.b)("code",Object(n.a)({parentName:"pre"},{className:"language-TypeScript"}),"import { operators } from 'double-double'\n")),Object(o.b)("p",{parentName:"blockquote"},"and then later in the code get the functions you need, e.g.:"),Object(o.b)("pre",{parentName:"blockquote"},Object(o.b)("code",Object(n.a)({parentName:"pre"},{className:"language-TypeScript"}),"const { ddAddDd as add, twoProduct, /* etc. */ } = operators;\n")),Object(o.b)("p",{parentName:"blockquote"},"as opposed to importing the operators directly."),Object(o.b)("p",{parentName:"blockquote"},"This will increase performance roughly 5 times!"),Object(o.b)("p",{parentName:"blockquote"},Object(o.b)("strong",{parentName:"p"},"Why?")," Because Webpack (and Rollup) exports functions using getters that gets\ninvoked on every function call adding a big overhead and slowing down each\nfunction. This will not be an issue if code is not bundled, e.g. when\nusing Node.js.")),Object(o.b)("h2",{id:"overview"},"Overview"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("strong",{parentName:"li"},Object(o.b)("a",Object(n.a)({parentName:"strong"},{href:"https://en.wikipedia.org/wiki/Quadruple-precision_floating-point_format#Double-double_arithmetic"}),"Double-double precision"))," floating point operators (similar to quad precision)"),Object(o.b)("li",{parentName:"ul"},"Each function documents a strict error bound (see research ","[1]"," below)"),Object(o.b)("li",{parentName:"ul"},"Optimized for speed (see benchmark below)"),Object(o.b)("li",{parentName:"ul"},"Operators include: +, -, *, /, \u221a, abs, <, >, ===, etc."),Object(o.b)("li",{parentName:"ul"},"No classes \u21d2 a double-double is simply a length 2 ",Object(o.b)("inlineCode",{parentName:"li"},"Number")," array, e.g.")),Object(o.b)("pre",null,Object(o.b)("code",Object(n.a)({parentName:"pre"},{className:"language-typescript"}),"import { twoSum } from 'double-double';\n// Specified directly (low order double first)\nconst a = [-4.357806199228875e-10, 11_638_607.274152497];\n// ...or more usually from an earlier calculation\nconst b = twoSum(213.456, 111.111); // => [-1.4210854715202004e-14, 324.567] (completely error-free)\n")),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"All functions are pure, e.g. ")),Object(o.b)("pre",null,Object(o.b)("code",Object(n.a)({parentName:"pre"},{className:"language-typescript"}),"// using `a` and `b` as defined above (ddAddDd => double-double + double-double)\nconst c = ddAddDd(a,b); // => [-2.42072459299969e-10, 11638931.841152497]\n")),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"No dependencies")),Object(o.b)("h2",{id:"research"},"Research"),Object(o.b)("p",null,"The following research / books / lectures have been used or are directly relevant to this library (especially the first two):"),Object(o.b)("ol",null,Object(o.b)("li",{parentName:"ol"},Object(o.b)("a",Object(n.a)({parentName:"li"},{href:"https://hal.archives-ouvertes.fr/hal-01351529v3/document"}),"Mioara Joldes, Jean-Michel Muller, Valentina Popescu, ",Object(o.b)("em",{parentName:"a"},"Tight and rigourous error bounds for basic building\nblocks of double-word arithmetic"))),Object(o.b)("li",{parentName:"ol"},Object(o.b)("a",Object(n.a)({parentName:"li"},{href:"http://csclub.uwaterloo.ca/~pbarfuss/dekker1971.pdf"}),"T. J. Dekker, ",Object(o.b)("em",{parentName:"a"},"A Floating-Point Technique for Extending the Available Precision"))),Object(o.b)("li",{parentName:"ol"},Object(o.b)("a",Object(n.a)({parentName:"li"},{href:"https://www.researchgate.net/publication/228570156_Library_for_Double-Double_and_Quad-Double_Arithmetic"}),"Yozo Hida, Xiaoye S. Li, David H. Bailey, ",Object(o.b)("em",{parentName:"a"},"Library for Double-Double and Quad-Double Arithmetic"))),Object(o.b)("li",{parentName:"ol"},Object(o.b)("a",Object(n.a)({parentName:"li"},{href:"http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf"}),"Nicholas J. Higham, ",Object(o.b)("em",{parentName:"a"},"Accuracy and Stability of Numerical Algorithms")))),Object(o.b)("h2",{id:"benchmark"},Object(o.b)("a",Object(n.a)({parentName:"h2"},{href:"https://florissteenkamp.github.io/big-float-benchmark/"}),"Benchmark")),Object(o.b)("p",null,Object(o.b)("img",Object(n.a)({parentName:"p"},{src:"../img/benchmark.png",alt:"benchmark"}))),Object(o.b)("h2",{id:"license"},"License"),Object(o.b)("p",null,"MIT"))}u.isMDXComponent=!0},207:function(e,t,r){"use strict";r.d(t,"a",(function(){return p})),r.d(t,"b",(function(){return m}));var n=r(0),a=r.n(n);function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function l(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}var b=a.a.createContext({}),u=function(e){var t=a.a.useContext(b),r=t;return e&&(r="function"==typeof e?e(t):c(c({},t),e)),r},p=function(e){var t=u(e.components);return a.a.createElement(b.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},s=a.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,o=e.originalType,i=e.parentName,b=l(e,["components","mdxType","originalType","parentName"]),p=u(r),s=n,m=p["".concat(i,".").concat(s)]||p[s]||d[s]||o;return r?a.a.createElement(m,c(c({ref:t},b),{},{components:r})):a.a.createElement(m,c({ref:t},b))}));function m(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var o=r.length,i=new Array(o);i[0]=s;var c={};for(var l in t)hasOwnProperty.call(t,l)&&(c[l]=t[l]);c.originalType=e,c.mdxType="string"==typeof e?e:n,i[1]=c;for(var b=2;b<o;b++)i[b]=r[b];return a.a.createElement.apply(null,i)}return a.a.createElement.apply(null,r)}s.displayName="MDXCreateElement"}}]);