{"id":1710,"date":"2013-10-24T08:50:19","date_gmt":"2013-10-24T06:50:19","guid":{"rendered":"http:\/\/mariusbancila.ro\/blog\/?p=1710"},"modified":"2013-10-24T08:50:19","modified_gmt":"2013-10-24T06:50:19","slug":"round-offs-in-floating-point-arithmetic","status":"publish","type":"post","link":"https:\/\/mariusbancila.ro\/blog\/2013\/10\/24\/round-offs-in-floating-point-arithmetic\/","title":{"rendered":"Round-offs in floating-point arithmetic"},"content":{"rendered":"<p>A friend of mine recently proposed the following problem on twitter:<\/p>\n<blockquote class=\"twitter-tweet\">\n<p>Given f y z =108 &#8211; (815 &#8211; 1500\/z)\/y, x0 = 4, x1 = 4.25 and xN+1 = f xN xN-1 then what is x80? Note: This might not be as easy as it looks<\/p>\n<p>&mdash; M\u00e5rten R\u00e5nge (@marten_range) <a href=\"https:\/\/twitter.com\/marten_range\/statuses\/391681689790861312\">October 19, 2013<\/a><\/p><\/blockquote>\n<p><script async src=\"\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><\/p>\n<p>I didn&#8217;t pay much attention to his warning and fell for the trap. I though I could write a small program in two minutes to compute the series and find what was the value of <tt>x[80]<\/tt>. So here is (a slightly modified version of) the C++ code that I put together in a couple of minutes.<\/p>\n<p>C++<\/p>\n<pre class=\"lang:c++ decode:true\">#include &lt;iostream&gt;\r\n#include &lt;iomanip&gt;\r\n\r\ntemplate &lt;typename T, int Size = 80&gt;\r\nT x(int n)\r\n{\r\n   static T cache[Size + 1] = {0};\r\n   if(n == 0) cache[n] = 4.0;\r\n   else if(n == 1) cache[n] = 4.25;\r\n   else cache[n] = 108 - (815 - 1500 \/ cache[n - 2]) \/ cache[n - 1];\r\n\r\n   return cache[n];\r\n}\r\n\r\nint main()\r\n{\r\n   for(int i = 0; i &lt;= 80; ++i)\r\n   {\r\n      std::cout &lt;&lt; \"x[\" &lt;&lt; i &lt;&lt; \"]=\" &lt;&lt; std::setprecision(15) &lt;&lt; x&lt;double&gt;(i) &lt;&lt; std::endl;\r\n   }\r\n   return 0;\r\n}<\/pre>\n<p>When I ran it I was surprised to notice that the series was converging to 100 by <tt>x[26]<\/tt>.<\/p>\n<pre class=\"lang:sh decode:true\">x[0]=4\r\nx[1]=4.25\r\nx[2]=4.47058823529412\r\nx[3]=4.64473684210522\r\nx[4]=4.77053824362508\r\nx[5]=4.85570071256856\r\nx[6]=4.91084749866063\r\nx[7]=4.94553739553051\r\nx[8]=4.966962408041\r\nx[9]=4.98004220429301\r\nx[10]=4.98790923279579\r\nx[11]=4.99136264131455\r\nx[12]=4.96745509555227\r\nx[13]=4.42969049830883\r\nx[14]=-7.81723657845932\r\nx[15]=168.939167671065\r\nx[16]=102.039963152059\r\nx[17]=100.09994751625\r\nx[18]=100.004992040972\r\nx[19]=100.000249579237\r\nx[20]=100.00001247862\r\nx[21]=100.000000623922\r\nx[22]=100.000000031196\r\nx[23]=100.00000000156\r\nx[24]=100.000000000078\r\nx[25]=100.000000000004\r\nx[26]=100\r\n...\r\nx[80]=100<\/pre>\n<p>Actually, the initial program didn&#8217;t call <tt>std::setprecision<\/tt> and the numbers you get without that are less precise, but that doesn&#8217;t change the convergence, since it is just a printing artifact.<\/p>\n<pre class=\"lang:sh decode:true\">x[0]=4\r\nx[1]=4.25\r\nx[2]=4.47059\r\nx[3]=4.64474\r\nx[4]=4.77054\r\nx[5]=4.8557\r\n...<\/pre>\n<p>Finding the series interesting I searched a bit and then I understood his warning. I found this was a well known problem proposed around 1980 by Jean-Michel Muller and discussed in several papers by Prof. W. Kahan.<\/p>\n<blockquote><p>\nGiven the function<br \/>\n\u0152(y, z) := 108 \u2013 ( 815 \u2013 1500\/z )\/y<br \/>\nand initial values x0 := 4 and x1 := 4.25 , de\ufb01ne xn+1 := \u0152(xn, xn-1) for n = 1, 2, 3, &#8230; in turn.<br \/>\nOur task is to compute xN for some moderately big preassigned integer N, say N = 80 .\n<\/p><\/blockquote>\n<p>For details see <a href=\"http:\/\/www.cs.berkeley.edu\/~wkahan\/Mindless.pdf\">How Futile are Mindless Assessments of Roundoff in Floating-Point Computation?<\/a> and <a href=\"http:\/\/www.cs.berkeley.edu\/~wkahan\/Math128\/M128Bsoln09Feb04.pdf\">Three Problems for Math<\/a>.<\/p>\n<p>This exercise is intended to show the problem that arises in using floating-point numbers. The <tt>float<\/tt> and <tt>double<\/tt> (both an IEEE Standard for Floating-Point Arithmetic, IEEE 754) representations use inverse powers of 2, which means most numbers require a an infinite number of bits for a precise representation. Numbers such as 0.25 or 0.875 can be exactly encoded as 1\/4 and 1\/2+1\/4+1\/8, but numbers such as 0.10 cannot be encoded with a finite sum of such terms. The result is problems with accuracy of calculations. Rand-offs can propagate through calculations in unexpected ways, just like Muller&#8217;s recurrence shows.<\/p>\n<p>The actual limit of Muller&#8217;s series is not 100, but 5.<\/p>\n<p>I was curios then how the <tt>decimal<\/tt> type from .NET compares to double. <tt>decimal<\/tt> (that uses base 10 instead of 2) has more precision (but a smaller range) than <tt>float<\/tt> or <tt>double<\/tt> which makes is more suitable for some applications, such as financial ones. (For a discussion of when to use <tt>decimal<\/tt> and when to use <tt>double<\/tt> see <a href=\"http:\/\/stackoverflow.com\/questions\/1165761\/decimal-vs-double-which-one-should-i-use-and-when\">decimal vs double! &#8211; Which one should I use and when?<\/a>). <\/p>\n<p>So here is my C# program that uses <tt>decimal<\/tt>.<\/p>\n<pre class=\"lang:c# decode:true\">class MullersRecurrence\r\n{\r\n  static decimal[] cache = new decimal[100];\r\n\r\n  public decimal x(int n)\r\n  {\r\n     if (n == 0) cache[n] = 4m;\r\n     else if (n == 1) cache[n] = 4.25m;\r\n     else cache[n] = 108 - (815 - 1500 \/ cache[n - 2]) \/ cache[n - 1];\r\n     return cache[n];\r\n  }\r\n}\r\n\r\nclass Program\r\n{\r\n  static void Main(string[] args)\r\n  {\r\n     var mr = new MullersRecurrence();\r\n\r\n     for(int i = 0; i &lt;= 80; ++i)\r\n     {\r\n        Console.WriteLine(\"x[{0}]={1}\", i, mr.x(i));\r\n     }\r\n  }\r\n}<\/pre>\n<p>The output of this program is:<\/p>\n<pre class=\"lang:sh decode:true\">\r\nx[0]=4\r\nx[1]=4.25\r\nx[2]=4.47058823529411764705882353\r\nx[3]=4.64473684210526315789473686\r\nx[4]=4.77053824362606232294617603\r\nx[5]=4.85570071258907363420428376\r\nx[6]=4.91084749908279320044042857\r\nx[7]=4.94553740412391672477683015\r\nx[8]=4.96696258176270059878160878\r\nx[9]=4.98004570135563116267108889\r\nx[10]=4.98797944847839228829979003\r\nx[11]=4.99277028806206866201151005\r\nx[12]=4.99565589150664533306792637\r\nx[13]=4.99739126838157043427422171\r\nx[14]=4.99843394394934565979621707\r\nx[15]=4.99906007206149646425952424\r\nx[16]=4.99943593895922460992955065\r\nx[17]=4.99966156035548033890851805\r\nx[18]=4.99979762579572007199519838\r\nx[19]=4.99989263769854913604459541\r\nx[20]=5.00021692999623515255759378\r\nx[21]=5.00575688343630115907717069\r\nx[22]=5.11585535860978057839952266\r\nx[23]=7.26513170553842597520695497\r\nx[24]=36.178328937337879304087182981\r\nx[25]=91.17958879988455033108590199\r\nx[26]=99.51631713443793014723080822\r\nx[27]=99.97569833055963020623148188\r\nx[28]=99.99878462167868201734350518\r\nx[29]=99.99993923036059445960870932\r\nx[30]=99.99999696151664049461733529\r\nx[31]=99.99999984807584112595945239\r\nx[32]=99.99999999240379245628007687\r\nx[33]=99.99999999962018963513083004\r\nx[34]=99.99999999998100948212683970\r\nx[35]=99.99999999999905047411745292\r\nx[36]=99.99999999999995252370620598\r\nx[37]=99.99999999999999762618532030\r\nx[38]=99.99999999999999988130926632\r\nx[39]=99.99999999999999999406546333\r\nx[40]=99.99999999999999999970327317\r\nx[41]=99.99999999999999999998516366\r\nx[42]=99.99999999999999999999925818\r\nx[43]=99.99999999999999999999996291\r\nx[44]=99.99999999999999999999999815\r\nx[45]=99.99999999999999999999999991\r\nx[46]=100.00000000000000000000000000\r\nx[47]=100\r\n...\r\nx[49]=100<\/pre>\n<p>This represents and improvement, but in the end suffers from the same accumulated round-offs problem. It takes more iterations, but eventually the series also converges to 100.<\/p>\n<p>My friend then suggested trying a data type that doesn&#8217;t suffer from rounding issues. Such a type is <tt>BigRational<\/tt> for F# (it can be used with any .NET language). It is available in the <a href=\"http:\/\/fsharppowerpack.codeplex.com\/\">F# PowerPack<\/a> that is an open-source project available on CodePlex. Below is the F# equivalent of the previous program that uses <tt>BigRational<\/tt>.<\/p>\n<pre class=\"lang:haskell decode:true\">\r\nopen Microsoft.FSharp.Math;;\r\n\r\nlet cache = Array.create 100 BigRational.Zero\r\n\r\nlet x n =\r\n   match n with\r\n   | 0 -&gt; cache.[n] &lt;- 4N\r\n   | 1 -&gt; cache.[n] &lt;- 17N\/4N\r\n   | _ -&gt; cache.[n] &lt;- 108N - (815N - 1500N \/ cache.[n - 2]) \/ cache.[n - 1]\r\n   cache.[n]\r\n\r\n[&lt;EntryPoint&gt;]\r\nlet main argv = \r\n   for i in 0 .. 80 do\r\n      System.Console.WriteLine(double(x i))\r\n   0\r\n<\/pre>\n<p>The output looks like this:<\/p>\n<pre class=\"lang:sh decode:true\">\r\nx[0]=4\r\nx[1]=4.25\r\nx[2]=4.47058823529412\r\nx[3]=4.64473684210526\r\nx[4]=4.77053824362606\r\nx[5]=4.85570071258907\r\nx[6]=4.91084749908279\r\nx[7]=4.94553740412392\r\nx[8]=4.9669625817627\r\nx[9]=4.98004570135563\r\nx[10]=4.98797944847839\r\nx[11]=4.99277028806207\r\nx[12]=4.99565589150663\r\nx[13]=4.99739126838134\r\nx[14]=4.99843394394482\r\nx[15]=4.99906007197089\r\nx[16]=4.99943593714684\r\nx[17]=4.99966152410377\r\nx[18]=4.99979690071342\r\nx[19]=4.99987813547793\r\nx[20]=4.9999268795046\r\nx[21]=4.99995612706116\r\nx[22]=4.99997367600571\r\nx[23]=4.99998420552027\r\nx[24]=4.99999052328223\r\nx[25]=4.99999431395856\r\nx[26]=4.99999658837126\r\nx[27]=4.99999795302136\r\nx[28]=4.99999877181231\r\nx[29]=4.99999926308721\r\nx[30]=4.99999955785226\r\nx[31]=4.99999973471133\r\nx[32]=4.99999984082679\r\nx[33]=4.99999990449607\r\nx[34]=4.99999994269764\r\nx[35]=4.99999996561859\r\nx[36]=4.99999997937115\r\nx[37]=4.99999998762269\r\nx[38]=4.99999999257362\r\nx[39]=4.99999999554417\r\nx[40]=4.9999999973265\r\nx[41]=4.9999999983959\r\nx[42]=4.99999999903754\r\nx[43]=4.99999999942252\r\nx[44]=4.99999999965351\r\nx[45]=4.99999999979211\r\nx[46]=4.99999999987527\r\nx[47]=4.99999999992516\r\nx[48]=4.9999999999551\r\nx[49]=4.99999999997306\r\nx[50]=4.99999999998384\r\nx[51]=4.9999999999903\r\nx[52]=4.99999999999418\r\nx[53]=4.99999999999651\r\nx[54]=4.9999999999979\r\nx[55]=4.99999999999874\r\nx[56]=4.99999999999925\r\nx[57]=4.99999999999955\r\nx[58]=4.99999999999973\r\nx[59]=4.99999999999984\r\nx[60]=4.9999999999999\r\nx[61]=4.99999999999994\r\nx[62]=4.99999999999996\r\nx[63]=4.99999999999998\r\nx[64]=4.99999999999999\r\nx[65]=4.99999999999999\r\nx[66]=5\r\nx[67]=5\r\nx[68]=5\r\nx[69]=5\r\nx[70]=5\r\nx[71]=5\r\nx[72]=5\r\nx[73]=5\r\nx[74]=5\r\nx[75]=5\r\nx[76]=5\r\nx[77]=5\r\nx[78]=5\r\nx[79]=5\r\nx[80]=5\r\n<\/pre>\n<p>Now this is a totally different story. The values converge to the expected value of 5. <\/p>\n<p>You probably noticed the casting to double for printing. It is necessary because otherwise the output would look like this:<\/p>\n<pre class=\"lang:sh decode:true\">x[0]=4\r\nx[1]=17\/4\r\nx[2]=76\/17\r\nx[3]=353\/76\r\n...\r\nx[79]=41359030627651383817474849310671104336332210648235594113\/8271806125530276773348891823090615755005322810072671996\r\nx[80]=206795153138256918939565417139009598365577843034794672964\/41359030627651383817474849310671104336332210648235594113<\/pre>\n<p>That isn&#8217;t very helpful. I can&#8217;t even read these insane large numbers, not to mention dividing them. So to get the actual real number and be able to compare with the previous programs a conversion to double is necessary.<\/p>\n<p>As I mentioned earlier, <tt>BigRational<\/tt> can also be used from C#.<\/p>\n<pre class=\"lang:default decode:true\">class MullersRecurrenceBigRational\r\n{\r\n  BigRational [] cache = new BigRational[100];\r\n\r\n  public BigRational x(int n)\r\n  {\r\n     if (n == 0) cache[n] = BigRational.FromInt(4);\r\n     else if (n == 1) cache[n] = BigRational.FromInt(17)\/BigRational.FromInt(4);\r\n     else cache[n] = BigRational.FromInt(108) - (BigRational.FromInt(815) - (BigRational.FromInt(1500) \/ cache[n - 2])) \/ cache[n - 1];\r\n     return cache[n];\r\n  }\r\n}\r\n\r\nclass Program\r\n{\r\n  static void Main(string[] args)\r\n  {\r\n     var mr = new MullersRecurrenceBigRational();\r\n\r\n     for(int i = 0; i &lt;= 80; ++i)\r\n     {\r\n        Console.WriteLine(\"x[{0}] = {1}\", i, (double)mr.x(i));\r\n     }\r\n  }\r\n}\r\n<\/pre>\n<p>It yields the very same output as the F# program so I will not list it again. However, below is a comparison table with the results for various number data types.<\/p>\n<table style=\"border-collapse: collapse;\" border=\"1px\">\n<tbody>\n<tr>\n<th>index<\/th>\n<th>C++ with float<\/th>\n<th>C++\/C# with double<\/th>\n<th>C# with decimal<\/th>\n<th>C#\/F# with BigRational<\/th>\n<\/tr>\n<tr valign=\"top\">\n<td>0<br \/>\n1<br \/>\n2<br \/>\n3<br \/>\n4<br \/>\n5<br \/>\n6<br \/>\n7<br \/>\n8<br \/>\n9<br \/>\n10<br \/>\n11<br \/>\n12<br \/>\n13<br \/>\n14<br \/>\n15<br \/>\n16<br \/>\n17<br \/>\n18<br \/>\n19<br \/>\n20<br \/>\n21<br \/>\n22<br \/>\n23<br \/>\n24<br \/>\n25<br \/>\n26<br \/>\n27<br \/>\n28<br \/>\n29<br \/>\n30<br \/>\n31<br \/>\n32<br \/>\n33<br \/>\n34<br \/>\n35<br \/>\n36<br \/>\n37<br \/>\n38<br \/>\n39<br \/>\n40<br \/>\n41<br \/>\n42<br \/>\n43<br \/>\n44<br \/>\n45<br \/>\n46<br \/>\n47<br \/>\n48<br \/>\n49<br \/>\n50<br \/>\n51<br \/>\n52<br \/>\n53<br \/>\n54<br \/>\n55<br \/>\n56<br \/>\n57<br \/>\n58<br \/>\n59<br \/>\n60<br \/>\n61<br \/>\n62<br \/>\n63<br \/>\n64<br \/>\n65<br \/>\n66<br \/>\n67<br \/>\n68<br \/>\n69<br \/>\n70<br \/>\n71<br \/>\n72<br \/>\n73<br \/>\n74<br \/>\n75<br \/>\n76<br \/>\n77<br \/>\n78<br \/>\n79<br \/>\n80\n<\/td>\n<td>\n4<br \/>\n4.25<br \/>\n4.47058868408203<br \/>\n4.64474487304688<br \/>\n4.77070617675781<br \/>\n4.85921478271484<br \/>\n4.98312377929688<br \/>\n6.39543151855469<br \/>\n27.6326293945313<br \/>\n86.9937591552734<br \/>\n99.2555084228516<br \/>\n99.9625854492188<br \/>\n99.9981307983398<br \/>\n99.9999084472656<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100\n<\/td>\n<td>\n4<br \/>\n4.25<br \/>\n4.47058823529412<br \/>\n4.64473684210522<br \/>\n4.77053824362508<br \/>\n4.85570071256856<br \/>\n4.91084749866063<br \/>\n4.94553739553051<br \/>\n4.966962408041<br \/>\n4.98004220429301<br \/>\n4.98790923279579<br \/>\n4.99136264131455<br \/>\n4.96745509555227<br \/>\n4.42969049830883<br \/>\n-7.81723657845932<br \/>\n168.939167671065<br \/>\n102.039963152059<br \/>\n100.09994751625<br \/>\n100.004992040972<br \/>\n100.000249579237<br \/>\n100.00001247862<br \/>\n100.000000623922<br \/>\n100.000000031196<br \/>\n100.00000000156<br \/>\n100.000000000078<br \/>\n100.000000000004<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<\/td>\n<td>4<br \/>\n4.25<br \/>\n4.47058823529411764705882353<br \/>\n4.64473684210526315789473686<br \/>\n4.77053824362606232294617603<br \/>\n4.85570071258907363420428376<br \/>\n4.91084749908279320044042857<br \/>\n4.94553740412391672477683015<br \/>\n4.96696258176270059878160878<br \/>\n4.98004570135563116267108889<br \/>\n4.98797944847839228829979003<br \/>\n4.99277028806206866201151005<br \/>\n4.99565589150664533306792637<br \/>\n4.99739126838157043427422171<br \/>\n4.99843394394934565979621707<br \/>\n4.99906007206149646425952424<br \/>\n4.99943593895922460992955065<br \/>\n4.99966156035548033890851805<br \/>\n4.99979762579572007199519838<br \/>\n4.99989263769854913604459541<br \/>\n5.00021692999623515255759378<br \/>\n5.00575688343630115907717069<br \/>\n5.11585535860978057839952266<br \/>\n7.26513170553842597520695497<br \/>\n36.178328937337879304087182981<br \/>\n91.17958879988455033108590199<br \/>\n99.51631713443793014723080822<br \/>\n99.97569833055963020623148188<br \/>\n99.99878462167868201734350518<br \/>\n99.99993923036059445960870932<br \/>\n99.99999696151664049461733529<br \/>\n99.99999984807584112595945239<br \/>\n99.99999999240379245628007687<br \/>\n99.99999999962018963513083004<br \/>\n99.99999999998100948212683970<br \/>\n99.99999999999905047411745292<br \/>\n99.99999999999995252370620598<br \/>\n99.99999999999999762618532030<br \/>\n99.99999999999999988130926632<br \/>\n99.99999999999999999406546333<br \/>\n99.99999999999999999970327317<br \/>\n99.99999999999999999998516366<br \/>\n99.99999999999999999999925818<br \/>\n99.99999999999999999999996291<br \/>\n99.99999999999999999999999815<br \/>\n99.99999999999999999999999991<br \/>\n100.00000000000000000000000000<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<br \/>\n100<\/td>\n<td>4<br \/>\n4.25<br \/>\n4.47058823529412<br \/>\n4.64473684210526<br \/>\n4.77053824362606<br \/>\n4.85570071258907<br \/>\n4.91084749908279<br \/>\n4.94553740412392<br \/>\n4.9669625817627<br \/>\n4.98004570135563<br \/>\n4.98797944847839<br \/>\n4.99277028806207<br \/>\n4.99565589150663<br \/>\n4.99739126838134<br \/>\n4.99843394394482<br \/>\n4.99906007197089<br \/>\n4.99943593714684<br \/>\n4.99966152410377<br \/>\n4.99979690071342<br \/>\n4.99987813547793<br \/>\n4.9999268795046<br \/>\n4.99995612706116<br \/>\n4.99997367600571<br \/>\n4.99998420552027<br \/>\n4.99999052328223<br \/>\n4.99999431395856<br \/>\n4.99999658837126<br \/>\n4.99999795302136<br \/>\n4.99999877181231<br \/>\n4.99999926308721<br \/>\n4.99999955785226<br \/>\n4.99999973471133<br \/>\n4.99999984082679<br \/>\n4.99999990449607<br \/>\n4.99999994269764<br \/>\n4.99999996561859<br \/>\n4.99999997937115<br \/>\n4.99999998762269<br \/>\n4.99999999257362<br \/>\n4.99999999554417<br \/>\n4.9999999973265<br \/>\n4.9999999983959<br \/>\n4.99999999903754<br \/>\n4.99999999942252<br \/>\n4.99999999965351<br \/>\n4.99999999979211<br \/>\n4.99999999987527<br \/>\n4.99999999992516<br \/>\n4.9999999999551<br \/>\n4.99999999997306<br \/>\n4.99999999998384<br \/>\n4.9999999999903<br \/>\n4.99999999999418<br \/>\n4.99999999999651<br \/>\n4.9999999999979<br \/>\n4.99999999999874<br \/>\n4.99999999999925<br \/>\n4.99999999999955<br \/>\n4.99999999999973<br \/>\n4.99999999999984<br \/>\n4.9999999999999<br \/>\n4.99999999999994<br \/>\n4.99999999999996<br \/>\n4.99999999999998<br \/>\n4.99999999999999<br \/>\n4.99999999999999<br \/>\n5<br \/>\n5<br \/>\n5<br \/>\n5<br \/>\n5<br \/>\n5<br \/>\n5<br \/>\n5<br \/>\n5<br \/>\n5<br \/>\n5<br \/>\n5<br \/>\n5<br \/>\n5<br \/>\n5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The conclusion is that you should be aware that round-offs can accumulate and lead to unexpected results. Use the most appropriate data types suitable. Do not use <tt>double<\/tt> (not to mention <tt>float<\/tt>) for financial data.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A friend of mine recently proposed the following problem on twitter: Given f y z =108 &#8211; (815 &#8211; 1500\/z)\/y, x0 = 4, x1 = 4.25 and xN+1 = f xN xN-1 then what is x80? Note: This might not be as easy as it looks &mdash; M\u00e5rten R\u00e5nge (@marten_range) October 19, 2013 I didn&#8217;t &#8230; <a title=\"Round-offs in floating-point arithmetic\" class=\"read-more\" href=\"https:\/\/mariusbancila.ro\/blog\/2013\/10\/24\/round-offs-in-floating-point-arithmetic\/\" aria-label=\"Read more about Round-offs in floating-point arithmetic\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","advgb_blocks_editor_width":"","advgb_blocks_columns_visual_guide":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[11,7,37],"tags":[451,50,388,394,393,391,389,392,390],"class_list":["post-1710","post","type-post","status-publish","format-standard","hentry","category-csharp","category-c","category-fsharp","tag-c","tag-f","tag-floating-point","tag-kahan","tag-math","tag-muller","tag-numbers","tag-recurrence","tag-round-off"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Implementation of the Muller&#039;s recurrence in several programming language showing the problems that can arise in floating-point arithmetic round-offs.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Marius Bancila\"\/>\n\t<meta name=\"keywords\" content=\"floating-point,numbers,c++,c#,f#,round-off,muller,recurrence,math,kahan\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/mariusbancila.ro\/blog\/2013\/10\/24\/round-offs-in-floating-point-arithmetic\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Marius Bancila&#039;s Blog | About code. Mostly on C++\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Round-offs in floating-point arithmetic\" \/>\n\t\t<meta property=\"og:description\" content=\"Implementation of the Muller&#039;s recurrence in several programming language showing the problems that can arise in floating-point arithmetic round-offs.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/mariusbancila.ro\/blog\/2013\/10\/24\/round-offs-in-floating-point-arithmetic\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2013-10-24T06:50:19+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2013-10-24T06:50:19+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Round-offs in floating-point arithmetic\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Implementation of the Muller&#039;s recurrence in several programming language showing the problems that can arise in floating-point arithmetic round-offs.\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/10\\\/24\\\/round-offs-in-floating-point-arithmetic\\\/#article\",\"name\":\"Round-offs in floating-point arithmetic\",\"headline\":\"Round-offs in floating-point arithmetic\",\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"},\"datePublished\":\"2013-10-24T08:50:19+02:00\",\"dateModified\":\"2013-10-24T08:50:19+02:00\",\"inLanguage\":\"en-US\",\"commentCount\":2,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/10\\\/24\\\/round-offs-in-floating-point-arithmetic\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/10\\\/24\\\/round-offs-in-floating-point-arithmetic\\\/#webpage\"},\"articleSection\":\"C#, C++, F#, C++, F#, floating-point, kahan, math, muller, numbers, recurrence, round-off\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/10\\\/24\\\/round-offs-in-floating-point-arithmetic\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"position\":2,\"name\":\"IT\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"position\":3,\"name\":\"Software\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/net\\\/#listItem\",\"name\":\".NET\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/net\\\/#listItem\",\"position\":4,\"name\":\".NET\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/net\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/net\\\/csharp\\\/#listItem\",\"name\":\"C#\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/net\\\/csharp\\\/#listItem\",\"position\":5,\"name\":\"C#\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/net\\\/csharp\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/10\\\/24\\\/round-offs-in-floating-point-arithmetic\\\/#listItem\",\"name\":\"Round-offs in floating-point arithmetic\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/net\\\/#listItem\",\"name\":\".NET\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/10\\\/24\\\/round-offs-in-floating-point-arithmetic\\\/#listItem\",\"position\":6,\"name\":\"Round-offs in floating-point arithmetic\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/net\\\/csharp\\\/#listItem\",\"name\":\"C#\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/\",\"name\":\"Marius Bancila\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/10\\\/24\\\/round-offs-in-floating-point-arithmetic\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Marius Bancila\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/10\\\/24\\\/round-offs-in-floating-point-arithmetic\\\/#webpage\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/10\\\/24\\\/round-offs-in-floating-point-arithmetic\\\/\",\"name\":\"Round-offs in floating-point arithmetic\",\"description\":\"Implementation of the Muller's recurrence in several programming language showing the problems that can arise in floating-point arithmetic round-offs.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2013\\\/10\\\/24\\\/round-offs-in-floating-point-arithmetic\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"datePublished\":\"2013-10-24T08:50:19+02:00\",\"dateModified\":\"2013-10-24T08:50:19+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Round-offs in floating-point arithmetic","description":"Implementation of the Muller's recurrence in several programming language showing the problems that can arise in floating-point arithmetic round-offs.","canonical_url":"https:\/\/mariusbancila.ro\/blog\/2013\/10\/24\/round-offs-in-floating-point-arithmetic\/","robots":"max-image-preview:large","keywords":"floating-point,numbers,c++,c#,f#,round-off,muller,recurrence,math,kahan","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mariusbancila.ro\/blog\/2013\/10\/24\/round-offs-in-floating-point-arithmetic\/#article","name":"Round-offs in floating-point arithmetic","headline":"Round-offs in floating-point arithmetic","author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"},"datePublished":"2013-10-24T08:50:19+02:00","dateModified":"2013-10-24T08:50:19+02:00","inLanguage":"en-US","commentCount":2,"mainEntityOfPage":{"@id":"https:\/\/mariusbancila.ro\/blog\/2013\/10\/24\/round-offs-in-floating-point-arithmetic\/#webpage"},"isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/2013\/10\/24\/round-offs-in-floating-point-arithmetic\/#webpage"},"articleSection":"C#, C++, F#, C++, F#, floating-point, kahan, math, muller, numbers, recurrence, round-off"},{"@type":"BreadcrumbList","@id":"https:\/\/mariusbancila.ro\/blog\/2013\/10\/24\/round-offs-in-floating-point-arithmetic\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog#listItem","position":1,"name":"Home","item":"https:\/\/mariusbancila.ro\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","position":2,"name":"IT","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","position":3,"name":"Software","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/#listItem","name":".NET"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/#listItem","position":4,"name":".NET","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/csharp\/#listItem","name":"C#"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/csharp\/#listItem","position":5,"name":"C#","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/csharp\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2013\/10\/24\/round-offs-in-floating-point-arithmetic\/#listItem","name":"Round-offs in floating-point arithmetic"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/#listItem","name":".NET"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2013\/10\/24\/round-offs-in-floating-point-arithmetic\/#listItem","position":6,"name":"Round-offs in floating-point arithmetic","previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/csharp\/#listItem","name":"C#"}}]},{"@type":"Organization","@id":"https:\/\/mariusbancila.ro\/blog\/#organization","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","url":"https:\/\/mariusbancila.ro\/blog\/"},{"@type":"Person","@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author","url":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/","name":"Marius Bancila","image":{"@type":"ImageObject","@id":"https:\/\/mariusbancila.ro\/blog\/2013\/10\/24\/round-offs-in-floating-point-arithmetic\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g","width":96,"height":96,"caption":"Marius Bancila"}},{"@type":"WebPage","@id":"https:\/\/mariusbancila.ro\/blog\/2013\/10\/24\/round-offs-in-floating-point-arithmetic\/#webpage","url":"https:\/\/mariusbancila.ro\/blog\/2013\/10\/24\/round-offs-in-floating-point-arithmetic\/","name":"Round-offs in floating-point arithmetic","description":"Implementation of the Muller's recurrence in several programming language showing the problems that can arise in floating-point arithmetic round-offs.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/mariusbancila.ro\/blog\/2013\/10\/24\/round-offs-in-floating-point-arithmetic\/#breadcrumblist"},"author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"creator":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"datePublished":"2013-10-24T08:50:19+02:00","dateModified":"2013-10-24T08:50:19+02:00"},{"@type":"WebSite","@id":"https:\/\/mariusbancila.ro\/blog\/#website","url":"https:\/\/mariusbancila.ro\/blog\/","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","inLanguage":"en-US","publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Marius Bancila's Blog | About code. Mostly on C++","og:type":"article","og:title":"Round-offs in floating-point arithmetic","og:description":"Implementation of the Muller's recurrence in several programming language showing the problems that can arise in floating-point arithmetic round-offs.","og:url":"https:\/\/mariusbancila.ro\/blog\/2013\/10\/24\/round-offs-in-floating-point-arithmetic\/","article:published_time":"2013-10-24T06:50:19+00:00","article:modified_time":"2013-10-24T06:50:19+00:00","twitter:card":"summary","twitter:title":"Round-offs in floating-point arithmetic","twitter:description":"Implementation of the Muller's recurrence in several programming language showing the problems that can arise in floating-point arithmetic round-offs."},"aioseo_meta_data":{"post_id":"1710","title":"Round-offs in floating-point arithmetic","description":"Implementation of the Muller's recurrence in several programming language showing the problems that can arise in floating-point arithmetic round-offs.","keywords":[{"label":"floating-point","value":"floating-point"},{"label":"numbers","value":"numbers"},{"label":"C++","value":"C++"},{"label":"C#","value":"C#"},{"label":"F#","value":"F#"},{"label":"round-off","value":"round-off"},{"label":"muller","value":"muller"},{"label":"recurrence","value":"recurrence"},{"label":"math","value":"math"},{"label":"kahan","value":"kahan"}],"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-03-18 21:11:01","updated":"2025-12-12 07:40:13","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"author_meta":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"featured_img":null,"jetpack_publicize_connections":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"uagb_comment_info":2,"uagb_excerpt":"A friend of mine recently proposed the following problem on twitter: Given f y z =108 &#8211; (815 &#8211; 1500\/z)\/y, x0 = 4, x1 = 4.25 and xN+1 = f xN xN-1 then what is x80? Note: This might not be as easy as it looks &mdash; M\u00e5rten R\u00e5nge (@marten_range) October 19, 2013 I didn&#8217;t&hellip;","coauthors":[],"tax_additional":{"categories":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/csharp\/\" class=\"advgb-post-tax-term\">C#<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">C++<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/fsharp\/\" class=\"advgb-post-tax-term\">F#<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">C#<\/span>","<span class=\"advgb-post-tax-term\">C++<\/span>","<span class=\"advgb-post-tax-term\">F#<\/span>"]},"tags":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/fsharp\/\" class=\"advgb-post-tax-term\">C++<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/fsharp\/\" class=\"advgb-post-tax-term\">F#<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/fsharp\/\" class=\"advgb-post-tax-term\">floating-point<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/fsharp\/\" class=\"advgb-post-tax-term\">kahan<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/fsharp\/\" class=\"advgb-post-tax-term\">math<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/fsharp\/\" class=\"advgb-post-tax-term\">muller<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/fsharp\/\" class=\"advgb-post-tax-term\">numbers<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/fsharp\/\" class=\"advgb-post-tax-term\">recurrence<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/net\/fsharp\/\" class=\"advgb-post-tax-term\">round-off<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">C++<\/span>","<span class=\"advgb-post-tax-term\">F#<\/span>","<span class=\"advgb-post-tax-term\">floating-point<\/span>","<span class=\"advgb-post-tax-term\">kahan<\/span>","<span class=\"advgb-post-tax-term\">math<\/span>","<span class=\"advgb-post-tax-term\">muller<\/span>","<span class=\"advgb-post-tax-term\">numbers<\/span>","<span class=\"advgb-post-tax-term\">recurrence<\/span>","<span class=\"advgb-post-tax-term\">round-off<\/span>"]}},"comment_count":"2","relative_dates":{"created":"Posted 13 years ago","modified":"Updated 13 years ago"},"absolute_dates":{"created":"Posted on October 24, 2013","modified":"Updated on October 24, 2013"},"absolute_dates_time":{"created":"Posted on October 24, 2013 8:50 am","modified":"Updated on October 24, 2013 8:50 am"},"featured_img_caption":"","series_order":"","jetpack_shortlink":"https:\/\/wp.me\/pYNdv-rA","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/1710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/comments?post=1710"}],"version-history":[{"count":36,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/1710\/revisions"}],"predecessor-version":[{"id":1746,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/1710\/revisions\/1746"}],"wp:attachment":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/media?parent=1710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/categories?post=1710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/tags?post=1710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}