Floating-point values give limitations for true-false?
2 views (last 30 days)
Decide if the equation is mathematically true for the variable values provided below.
Implement the equations in MATLAB, and test if they are true in the floating point arithmetic within MATLAB for the variable values provided. (For example, the equation 3 + 7^2 = 5 in matlab would correspond to the command disp(3+7^2==5) and yields, upon execution of the command, the value 0 corresponding to false. This is expected since the equation is not mathematically true.)
Where the MATLAB result differs from the mathematical expectation explain in one or more full sentences why the MATLAB results are different.
The equations to be considered are, with x = 10^7,
1. x^2 + x = x
2. x + x^5 = x
3. x^21/x^6 = x^15
In regards to 3. how come the value is equal to 0 (false) and not equal 1 (true) unless the input of x is less than 10. should it be true or false?
%Matlab program to check True or false of the statements for given values
%OUTPUT where 1 means True, 0 means False
x = 10^7;
aPart1 = x^2+ x
disp(x^2+ x== x)
aPart2 = x+ x^5
disp(x+ x^5== x)
aPart3 = x^21/ x^6