Search code examples
c++numerical-analysis

c++ numerical analysis Accurate data structure?


Using double type I made Cubic Spline Interpolation Algorithm. That work was success as it seems, but there was a relative error around 6% when very small values calculated.

Is double data type enough for accurate scientific numerical analysis?


Solution

  • Double has plenty of precision for most applications. Of course it is finite, but it's always possible to squander any amount of precision by using a bad algorithm. In fact, that should be your first suspect. Look hard at your code and see if you're doing something that lets rounding errors accumulate quicker than necessary, or risky things like subtracting values that are very close to each other.