m=[-1*1.8 1.2 0.6]*[1,1,1]'
In scientific computing, the meaning of that is
m=[ range(-18/10-5/100,-18/10+5/100,'semiopen'), range(12/10-5/100,12+5/100,'semiopen') range(6/10-5/100,6/10+5/100,'semiopen')]*[exactly(1),exactly(1),exactly(1)]'
where range(A,B,'semiopen') is the semi-open interval [A,B) .
That is, every floating point number you write expresses the set of numbers that round to the rational equivalent of the floating point number entered. You are not asking to calculate an exact value: you are asking to make the calculation over sets of values, and the "right" answer is everything in the resulting set. The result should not be EXACTLY zero.
If you write,
syms d1 d2 d3
assume(-5/100 <= d1 & d1 < 5/100)
assume(-5/100 <= d2 & d2 < 5/100)
assume(-5/100 <= d3 & d3 < 5/100)
m =[-1*18/10+d1, 12/10+d2, 6/10+d3]*[1,1,1]'
then you will get the mathematical result, which is d1+d2+d3 -- mathematically the solution is the sum of the uncertainties in expressing the numbers. The uncertainty for each is a range, though. Every result between -15/100 inclusive and 15/100 exclusive is possible for m.
1 Comment
James Tursa (view profile)
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/485500-why-is-matlab-giving-me-a-a-very-small-number-when-the-answer-should-be-exactly-zero#comment_756620
Sign in to comment.