Posts

Showing posts from October, 2020

Value is not the value

Sometimes the most simplest thing - computing the value of the function - can be surprisingly difficult. When I was studying in university, and there were numerical exercises, they were always skipped with a note like "There's interesting in this example. Just put the formulas into Matlab or Octave or what else." But as we will see many times from now on, it's not just putting formulas and pressing enter. In this post I'll show some of such problematic cases and ways to improve accuracy of computing. Case I Let \[ f(x) = \displaystyle\prod_{v = 1}^{16} (x - v). \] The roots of the polynomial are easily recognized. But what happens if we multiply parentheses out and try to compute \( f(14) \)? (Note: The results will most likely differ if you use integer type instead of float or double. Here double is assumed, because that is the most usable from algorithmic point of view for general purposes. Integer type can be used in some cases to achieve better results, but t...