Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Enter the following code into the command window of MatLab. format long e; (0.4

ID: 3887330 • Letter: E

Question

Enter the following code into the command window of MatLab. format long e; (0.4 + 0.4 + 0.4) - 1.2

Copy the output into a document editor of your choice, exporting it as file a2task4.pdf. In this file, also answer these questions: Is this a result you would expect from the perspective of mathematics? Explain why the computer gave you this result. (Note: after executing the format command given above, all command window display information for numerical values will look something like this: 1.402000000000000e+001. To get it back to a normal single-precision output, type format in the command window prompt and press enter. For more information on this MatLab command, type help format into the command window.)

Explanation / Answer

Code: format long e;

>> (0.4+0.4+0.4)-1.2

ans =

    2.220446049250313e-016

No this is not the as I expected from the Mathematics perspective.

Reason: Format is the function which affects how the number displays. Format “type” is a syntax like format long, which shows 15 digits after decimal point.

format

>> ans

ans =

2.2204e-016

After giving format only command, answer reduced to 4 digits after decimal point