Error while using Polyval
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Dyuman Joshi
el 2 de En. de 2021
Comentada: Dyuman Joshi
el 3 de En. de 2021
While solving a problem using polyval, I encountered an error. Here is the screenshot of the code attached (just the part which focuses on the use of polyval)
It seems that polyval isn't accurate when number of digits of the array exceed 15. I am unable to understand what is the cause of this discrepancy.

0 comentarios
Respuesta aceptada
Steven Lord
el 2 de En. de 2021
Editada: Steven Lord
el 2 de En. de 2021
Not all numbers in the vicinity of large values can be exactly represented in double precision. In particular 12345678901234567 is not exactly representable in double.
v = [1:9 0:7];
format longg
p = polyval(v, 10)
s = sym(p)
What's the distance between p and the next largest representable number?
eps(p)
If we add something smaller than eps(p) to p it's not enough to get us to the next largest double precision number.
p2 = p + 0.5;
p == p2 % true
Más respuestas (0)
Ver también
Categorías
Más información sobre Entering Commands en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!