diff options
author | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2020-02-16 14:26:55 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2020-02-16 14:26:55 +0700 |
commit | 82e6cf7d1046d6cee16f7e8b044ec33e7ec6c4b7 (patch) | |
tree | f7b7ae0bce69070c47a1b31a85bd2bc69dfecf09 /usth/MATH2.2/final/EX2.m | |
parent | 29d1001e2e21eff289bff23412e284c8b2e44595 (diff) | |
download | cp-82e6cf7d1046d6cee16f7e8b044ec33e7ec6c4b7.tar.gz |
[usth] Numerical Method is MATH2.4
Diffstat (limited to 'usth/MATH2.2/final/EX2.m')
-rw-r--r-- | usth/MATH2.2/final/EX2.m | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/usth/MATH2.2/final/EX2.m b/usth/MATH2.2/final/EX2.m deleted file mode 100644 index 9b8c95e..0000000 --- a/usth/MATH2.2/final/EX2.m +++ /dev/null @@ -1,38 +0,0 @@ -disp ("Question 2:"); -disp ("(a)"); -pkg load symbolic; -syms x real; -solve (sqrt (x) - x + 1 == 0) -% ans = (sym) -% √5 3 -% ── + ─ -% 2 2 -pkg unload symbolic; -disp ("To get numerical solutions we can use fzero"); -disp ("With the initial guess of 0, fzero (@(x) sqrt (x) - x + 1, 0) returns"); -fzero (@(x) sqrt (x) - x + 1, 0) - -disp ("(b)"); -hold on; -ezplot (@(x) exp (-x)); -ezplot (@(x) sin (x)); -hold off; -disp ("Press any key to continue..."); -kbhit; - -disp ("(c)"); -s = 0; -for k = 1 : 1000 - s += k^3; -endfor -printf ("The cubic sum of integers from 1 to 1000 is %d\n", s); - -disp ("(d)"); -A = [2 1 4 - 1 2 -5 - 3 -2 4]; -b = [10 1 8]'; -disp ("Using mldivide, [x y z] = "); -disp (mldivide (A, b)'); -disp ("Using inv, [x y z] = "); -disp ((inv (A) * b)'); |