incresing the precision of epsilon to 30 digits by symbolic toolbox, i could encounter not enough input arguments error?

1 次查看(过去 30 天)
function unidec=quad(a,b,r,eps)
a=input('enter a');
b=input('enter b');
r=sym(eps);
digits(30);
vpa(r);
if abs(a-b)< r
unidec=' a & b are equal';
else
unidec='a & b are not equal in double & single precision 3rd loop';
end

回答(1 个)

Walter Roberson
Walter Roberson 2018-2-9
digits(30) does not increase the precision of the function eps(). The function eps() is a purely numeric function that only operates on single and double.
Your code is inputting a and b as numeric (double precision) . Changing digits() does not affect the result of a double minus a double.
For your code to make any sense, you would need to use
if abs(vpa(a) - vpa(b)) < r

类别

Help CenterFile Exchange 中查找有关 Numbers and Precision 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by