DEV Community

Caleb Zhao
Caleb Zhao

Posted on

Incorrect calculations by the computer: polynomials

In this blog post, we discuss incorrect calculations of polynomials in MATLAB.

Example 1. Given
f(x)=727313x1289459499x1144x2+665683.13, g(x)=584927x9721800000x8+101188x713x2+19795832. f(x)=727313\,x^{12}-89459499\,x^{11}-44\,x^2+665683.13\,, \ g(x)=584927\,x^9-721800000\,x^8+101188\,x^7-13\,x^2+19795832\,.

Calculate f(123)f(123) and g(1234).g(1234)\,.

Let's just post the figure directly.

MATLAB outputFrom the above screenshot, it can be seen that the two outputs from MATLAB are both large numbers, with one having 16 integer digits and the other having 17 integer digits.

However, the accurate values of the two polynomials are 7.13 and 4, respectively (as provided by ISRealsoft). Thus, the outputs from MATLAB are both incorrect.

Top comments (0)