Do by hand: Only do 3-digit arithmetic part. Write out all equations by

advertisement
Problem 3.1 3.1mod 3.6 3.10 3.12 3.14 3.15 3.15mod 3.17 3.19 4.1 + convert to binary the number 34.75 Instructions and changes in problems Use a while loop and fprintf, provide a table of order, true value, approx value, and percent error, see class notes Repeat 3.1 with an M‐file that accepts input in degrees instead of radians, and check it for 60 degrees with only five terms. Either convert to degrees or use cosd. Use if statements. Make sure output is in degrees. If you use elseif statement, do not break it into two words! Use two M‐files. One for u_y and one for singularity, a is the position on the beam. You can use a for loop for the displacement. Check also what is the highest value of ni that you can run in one minute on your computer with the original code and then with the vectorized code. For vector spacing use (tend‐tstart)/ni. For the plot, calculate the function in intervals of 0.1. To plot use another m‐file. Read about functions floor, ceil, fix Use the round function in 3.15 to create a banker rounding that may be different if the if the number to be rounded is halfway between two options. It is then rounded so that the last digit is even. For example, 0.135 will be rounded up to 0.14, and 0.125 will be rounded down to 0.12. Use the switch and case structure Use varargin and a while loop Do by hand, or with Matlab 4.3 Find also the number of binary digits required to represent epsilon 4.4 4.7 Do by hand: Only do 3-digit arithmetic part.
Write out all equations by hand and use Matlab
or calculator for intermediate results. Chopping
means truncate to only 3 digits after each
intermediate calculation step
4.11 Write an M‐file that will add terms and perform the approximation until two significant digits are expected to be accurate. 4.15 4.22 Compare the forward and central differences also on the same plot using a legend to augment Figure 4.11 3.1 order true value
1 0.0707372017
2 0.0707372017
3 0.0707372017
4 0.0707372017
5 0.0707372017
6 0.0707372017
7 0.0707372017
8 0.0707372017 approximation
1.0000000000
-0.1250000000
0.0859375000
0.0701171875
0.0707528251
0.0707369341
0.0707372050
0.0707372016 error
-1313.68329030
276.71041129
-21.48840776
0.87650367
-0.02208652
0.00037823
-0.00000469
0.00000004 3.1mod order true value approximation 1 0.5000000000 1.0000000000 2 0.5000000000 0.4516886444 3 0.5000000000 0.5017962015 4 0.5000000000 0.4999645653 5 0.5000000000 0.5000004334 3.6 x
1.00
1.00
0.00
-1.00
-1.00
-1.00
3.10
error ‐100.0000 9.6623 ‐0.3592 0.0071 ‐0.0001 y
0.00
1.00
1.00
1.00
0.00
-1.00
radius
1.0000
1.4142
1.0000
1.4142
1.0000
1.4142
angle
0.0000
45.0000
90.0000
135.0000
180.0000
-135.0000
3.12 Both versions should produce
t =
0 4 8 12 16 20
y =
15.0000 11.5451 5.9549 5.9549 11.5451 15.0000
3.14
3.15: You can
check for yourself.
3.17:
>> days(1,1,1999)
ans =
1
>> days(2,29,2000)
ans =
60
>> days(3,1,2001)
ans =
60
>> days(6,21,2002)
ans =
172
>> days(12,31,2004)
ans =
366
3.19
>> odesimp(dvdt,0.5,0,12,0,68.1,0.25)
ans = 50.9259
4.1 First binary number is 89, second is 6.15625. Decimal number is 100010.11 4.3 >> eps ans = 2.2204e‐016 52 binary digits. 4.4 4.9407e-324
(or any extremely small value on the order of e-320 – solution may vary slightly from one
computer to the next)
4.7
True value: f’(0.57) = 2,352,911
3-digit result with chopping: f’(0.57) = 216,250
t ε = 90.8%
4.11
With one term get 1.047198, with two terms 0.855801, with three terms 0.866295, with four terms 0.866201. 4.15
True value: f’(2) = 283
Forward: f’(2) = 312.8, t E = 29.8
Backward: f’(2) = 255.2, t E = 27.8
Centrered: f’(2) = 284, t E = 1
Forward: a E = 28.8
Backward: a E = 28.8
Centrered: a E = 1
4.22
For the central difference formula get
Download