TOFSANSResolution does not deal with uncertainty of the last bin edge?
In `TOFSANSResolution.cpp` line 114 we have:

``` cpp
  // Initialize Dq
  MantidVec &DxOut = iqWS->dataDx(0);
  for (int i = 0; i < xLength - 1; i++)
    DxOut[i] = 0.0;
```

For some reason the algorithm does not deal with the `Dx` of the last bin edge, and I don't understand if there is a reason for this, or if it is an oversight. This continues throughout the exec method of that algorithm.

@mdoucet Have a look at this, this might be relevant for you.

diff --git a/Framework/Algorithms/src/EQSANSResolution.cpp b/Framework/Algorithms/src/EQSANSResolution.cpp
index d2c958d7d5f..03e5d50e345 100644
--- a/Framework/Algorithms/src/EQSANSResolution.cpp
+++ b/Framework/Algorithms/src/EQSANSResolution.cpp
@@ -13,17 +13,12 @@ DECLARE_ALGORITHM(EQSANSResolution)
  * Double Boltzmann fit to the TOF resolution as a function of wavelength
  */
 double EQSANSResolution::getTOFResolution(double wl) {
-  double y0 = -388;
-  double A = 3838;
-  double frac = 0.04398;
-  double x01 = 3.392;
-  double x02 = 134.3;
-  double k1 = -0.5587;
-  double k2 = -65.46;
-
-  return y0 +
-         A * (frac / (1 + std::exp((wl - x01) / k1)) +
-              (1 - frac) / (1 + std::exp((wl - x02) / k2)));
+  if (wl > 2.0) {
+    return 0.0148 * wl * wl * wl - 0.5233 * wl * wl + 6.4797 * wl + 231.99;
+  } else {
+    return 392.31 * pow(wl, 6) - 3169.3 * pow(wl, 5) + 10445 * pow(wl, 4) -
+           17872 * wl * wl * wl + 16509 * wl * wl - 7448.4 * wl + 1280.5;
+  }
 }
 
 } // namespace Algorithms
diff --git a/Framework/Algorithms/src/TOFSANSResolution.cpp b/Framework/Algorithms/src/TOFSANSResolution.cpp
index 0d19fb72913..578a9a79d6d 100644
--- a/Framework/Algorithms/src/TOFSANSResolution.cpp
+++ b/Framework/Algorithms/src/TOFSANSResolution.cpp
@@ -113,7 +113,7 @@ void TOFSANSResolution::exec() {
 
   // Initialize Dq
   MantidVec &DxOut = iqWS->dataDx(0);
-  for (int i = 0; i < xLength - 1; i++)
+  for (int i = 0; i < xLength; i++)
     DxOut[i] = 0.0;
 
   const V3D samplePos = reducedWS->getInstrument()->getSample()->getPos();
@@ -202,8 +202,8 @@ void TOFSANSResolution::exec() {
                     wl_bin_over_wl * wl_bin_over_wl);
 
       // By using only events with a positive weight, we use only the data
-      // distribution and
-      // leave out the background events
+      // distribution and leave out the background events.
+      // Note: we are looping over bins, therefore the xLength-1.
       if (iq >= 0 && iq < xLength - 1 && !boost::math::isnan(dq_over_q) &&
           dq_over_q > 0 && YIn[j] > 0) {
         _dx[iq] += q * dq_over_q * YIn[j];
@@ -214,6 +214,7 @@ void TOFSANSResolution::exec() {
     }
 
     // Move over the distributions for that pixel
+    // Note: we are looping over bins, therefore the xLength-1.
     PARALLEL_CRITICAL(iq) /* Write to shared memory - must protect */
     for (int iq = 0; iq < xLength - 1; iq++) {
       DxOut[iq] += _dx[iq];
@@ -226,7 +227,9 @@ void TOFSANSResolution::exec() {
     PARALLEL_END_INTERUPT_REGION
   }
   PARALLEL_CHECK_INTERUPT_REGION
+
   // Normalize according to the chosen weighting scheme
+  // Note: we are looping over bins, therefore the xLength-1.
   for (int i = 0; i < xLength - 1; i++) {
     if (XNorm[i] == 0)
       continue;
diff --git a/Testing/SystemTests/tests/analysis/EQSANSIQOutputAPIv2.py b/Testing/SystemTests/tests/analysis/EQSANSIQOutputAPIv2.py
index caef97dbd7d..9bba091f4a0 100644
--- a/Testing/SystemTests/tests/analysis/EQSANSIQOutputAPIv2.py
+++ b/Testing/SystemTests/tests/analysis/EQSANSIQOutputAPIv2.py
@@ -164,23 +164,23 @@ class EQSANSDQOutput(stresstesting.MantidStressTest):
             computes dQ for each of them, and averages those dQ for each
             Q bin of the I(Q) distribution.
         """
-        dq_ref = [0.00179027, 0.00145976, 0.00146710, 0.00163422, 0.00161492, 0.00179164,
-                  0.00179029, 0.00188995, 0.00201170, 0.00207360, 0.00218609, 0.00220714,
-                  0.00234202, 0.00248183, 0.00254135, 0.00267204, 0.00268951, 0.00289434,
-                  0.00296832, 0.00318395, 0.00347480, 0.00342855, 0.00342605, 0.00359649,
-                  0.00384836, 0.00394975, 0.00408187, 0.00422229, 0.00447594, 0.00461118,
-                  0.00472718, 0.00493621, 0.00495764, 0.00535326, 0.00529209, 0.00567744,
-                  0.00583839, 0.00605891, 0.00645220, 0.00644125, 0.00672271, 0.00694243,
-                  0.00726187, 0.00733947, 0.00769454, 0.00790483, 0.00801236, 0.00836713,
-                  0.00841945, 0.00873702, 0.00915623, 0.00944367, 0.00963511, 0.00978777,
-                  0.01014052, 0.01041332, 0.01089778, 0.01102930, 0.01131622, 0.01175365,
-                  0.01178201, 0.01185351, 0.01225765, 0.01291915, 0.01266411, 0.0131045,
-                  0.01327450, 0.01340715, 0.01373935, 0.01437759, 0.01474689, 0.01423396,
-                  0.01505104, 0.01543748, 0.01574309, 0.01584045, 0.01635975, 0.01723819,
-                  0.01683236, 0.01687807, 0.01705414, 0.01736111, 0.01773676, 0.01863491,
-                  0.01872719, 0.01930282, 0.01960495, 0.01965400, 0.02058695, 0.02073798,
-                  0.02093445, 0.02090090, 0.02137465, 0., 0., 0.,
-                  0.02225058, 0., 0., 0., 0.]
+        dq_ref = [0.00179091, 0.00146174, 0.00147197, 0.00164544, 0.00163043, 0.00181878,
+                  0.00182258, 0.00193342, 0.00206702, 0.00213708, 0.00226281, 0.00228791,
+                  0.00243715, 0.00259161, 0.00265703, 0.00280087, 0.00281749, 0.00304302,
+                  0.00312193, 0.00336326, 0.00369032, 0.00363043, 0.00361898, 0.00380932,
+                  0.00409294, 0.00420369, 0.00434701, 0.00449854, 0.00478654, 0.00493388,
+                  0.00505692, 0.00528792, 0.00530439, 0.00576054, 0.00567652, 0.00611692,
+                  0.00629483, 0.00654051, 0.00699489, 0.00697047, 0.00729058, 0.0075435,
+                  0.00790411, 0.00799244, 0.00839339, 0.00863375, 0.00875037, 0.00915707,
+                  0.00920598, 0.00956547, 0.0100485, 0.010375, 0.0105826, 0.0107592,
+                  0.0111573, 0.0114594, 0.0120101, 0.0121598, 0.0124813, 0.0129782,
+                  0.0130015, 0.013079, 0.0135361, 0.0142822, 0.0139875, 0.0144879,
+                  0.0146769, 0.0148238, 0.0151934, 0.0159136, 0.0163288, 0.0157482,
+                  0.0166674, 0.0170985, 0.0174427, 0.0175502, 0.0181306, 0.0191156,
+                  0.0186574, 0.0187086, 0.0189025, 0.0192468, 0.0196659, 0.0206723,
+                  0.0207745, 0.0214165, 0.0217546, 0.0218078, 0.0228492, 0.023019,
+                  0.0232376, 0.0231974, 0.0237268,       0,       0,       0,
+                  0.0247018,       0,       0,       0,       0]
 
         dq = mtd['EQSANS_1466_event_Iq'].readDx(0)
         diff = [math.fabs(dq_ref[i]-dq[i])<0.0001 for i in range(7,100)]
@@ -228,39 +228,21 @@ class EQSANSDQOutput_FS(stresstesting.MantidStressTest):
             computes dQ for each of them, and averages those dQ for each
             Q bin of the I(Q) distribution.
         """
-        dq_ref = [0.0025562401875382367, 0.0021790962062932595, 0.0021290959068076083,
-                  0.0026802124939521062, 0.0031074321602349289, 0.0026774405911485217,
-                  0.0027207082270666681, 0.0027487677707096962, 0.0026247953341494452,
-                  0.0026651032275206979, 0.0027635552536132684, 0.0028676821934358675,
-                  0.0029818100223198852, 0.0031035596823376366, 0.0032232077253371329,
-                  0.0033576194755771654, 0.0034907516138855572, 0.0036265816355667713,
-                  0.0037710626911531238, 0.0039250441580203372, 0.0040609475263300582,
-                  0.0042096897493604209, 0.0043588342800656822, 0.0045079887072827212,
-                  0.0046667831858807959, 0.0048317029230020786, 0.0050076609393374626,
-                  0.0052096495474734219, 0.0054232998460007533, 0.005641697184990838,
-                  0.0058532801279732871, 0.0060757844127261465, 0.0063365609784989552,
-                  0.006587022381459454, 0.0068386196975272822, 0.0071160446125018472,
-                  0.0073962666023466806, 0.0076683067760816501, 0.0079737228854276504,
-                  0.0082634135825662806, 0.0085556257575542059, 0.0088584657638246869,
-                  0.0091601703141331713, 0.0094733500518526109, 0.0097983865929968557,
-                  0.01010745525673251, 0.010431878268358239, 0.010760933631508998,
-                  0.01108229480294976, 0.011406132095524922, 0.011764424130191145,
-                  0.012085507458974829, 0.01242913230492846, 0.012772948956576465,
-                  0.013112594274109792, 0.013445656575060812, 0.01378640824830157,
-                  0.014179748618504842, 0.014524468855731137, 0.014837067717344261,
-                  0.015198005009872338, 0.015554082381810538, 0.015886081122916094,
-                  0.01624516716243159, 0.01656915276248308, 0.016906720665017649,
-                  0.017229976003919293, 0.017575054680507338, 0.017910950643762438,
-                  0.01820892047464711, 0.018537501040326795, 0.018886196930150295,
-                  0.019160712001214622, 0.019562906334057995, 0.019919424059868483,
-                  0.0202332025818662, 0.020603789727188158, 0.020995732565035612,
-                  0.021275592193502255, 0.021709848093393911, 0.022104923572868702,
-                  0.022427716772188584, 0.022791105771053317, 0.023217797545887896,
-                  0.023554197370525821, 0.023837707894543755, 0.024281298934845711,
-                  0.024757280918840573, 0.025119051654789667, 0.025303540846777578,
-                  0.025720732183297266, 0.026328472612552979, 0.02667374336275298,
-                  0.026975736979349105, 0.027241340711120433, 0.027501260220704871,
-                  0.027779626404565765, 0.0, 0.0, 0.0, 0.0]
+        dq_ref = [0.00255737, 0.00218259, 0.00213623, 0.00270166, 0.00314686, 0.00271786,
+        0.00277551, 0.0028148, 0.0026912, 0.00274053, 0.00285143, 0.00296802, 0.00309525,
+        0.00323062, 0.00336323, 0.00351213, 0.0036594, 0.00380924, 0.00396875, 0.00413898,
+        0.00428816, 0.0044516, 0.00461547, 0.00477897, 0.00495329, 0.00513446, 0.00532868,
+        0.00555334, 0.00579135, 0.00603596, 0.00627302, 0.00652278, 0.00681888, 0.00710323,
+        0.00738927, 0.0077063, 0.00802685, 0.00833806, 0.00868906, 0.00902133, 0.00935685,
+        0.00970481, 0.0100514, 0.0104113, 0.0107849, 0.0111394, 0.0115118, 0.0118885,
+        0.0122565, 0.0126266, 0.0130366, 0.0134029, 0.013795, 0.014187, 0.0145736,
+        0.0149527, 0.0153406, 0.0157879, 0.0161792, 0.0165336, 0.0169434, 0.0173473,
+        0.0177233, 0.0181306, 0.0184971, 0.0188791, 0.0192451, 0.0196353, 0.0200155,
+        0.0203521, 0.0207234, 0.0211177, 0.0214272, 0.0218823, 0.0222852, 0.0226389,
+        0.0230577, 0.0235006, 0.0238156, 0.0243063, 0.0247524, 0.0251161, 0.025526,
+        0.0260076, 0.0263866, 0.0267056, 0.0272062, 0.0277434, 0.0281509, 0.0283573,
+        0.028828, 0.0295137, 0.0299022, 0.030241, 0.0305401, 0.0308333,
+        0.0311474,       0,       0,       0,       0]
 
         dq = mtd['EQSANS_4061_event_frame1_Iq'].readDx(0)
         diff = [math.fabs(dq_ref[i]-dq[i])<0.0001 for i in range(7,100)]
['Testing/SystemTests/tests/analysis/EQSANSIQOutputAPIv2.py', 'Framework/Algorithms/src/EQSANSResolution.cpp', 'Framework/Algorithms/src/TOFSANSResolution.cpp']