Unformatted text preview:

LAB 2 Edward Bernstein MAT 275 Exercise 1 Part a A 9 9 1 1 7 2 9 8 1 B 8 2 1 17 8 10 2 4 19 b 17 3 8 c 0 3 4 d 2 2 1 AB A B BA B A cA c A Bd B d Part b C A B C 6 3 9 9 1 1 7 2 9 8 1 8 2 1 17 8 10 2 4 19 D B d Part c x A b x 3 1 0 6087 0 8261 4 0870 Part d A 1 1 0 A 3 3 0 9 1 1 7 2 9 8 1 Part e D 3 4 8 2 1 2 17 8 10 2 2 4 19 1 1 Part a Display contents of geomsum1 M file type geomsum1 m function S geomsum1 r a n Function to compute geometric sum using a for loop S 0 Initialize sum for k 0 n 1 S S a r k Add each term to the sum end end a A 2 a 1 3 1 7 2 Part f B 1 B 3 2 2 1 8 10 4 19 Exercise 2 Assign values to input variables r 1 9 a 4 n 12 geomsum1 r a n geomsum1 1 9 4 12 ans 3 6000 Part b type geomsum2 m function S geomsum2 r a n Function to compute geometric sum using built in sum function e 0 n 1 Create a vector of exponents 0 1 2 n 1 R r e Compute r raised to the power of each exponent S sum a R Multiply by a and sum all terms end geomsum2 1 9 4 12 ans 2 3 6000 Exercise 3 Part a Initiate product P P 1 m 1 k 2 Define starting iteration index Define stepsize of iteration Define ending iteration index n 13 Compute product 135135 Part b 135135 Exercise 4 Initiate variables P prod prod m k n disp P prod power 4 First power of 4 k 1 Initiate counter Initialize the vector v to the empty vector 3 for i m k n P P i Multiply P by the current odd number end disp P NOTE i m k n is also a vector A for loop essentially iterates through each element of a vector Keep this in mind for part b 4 16 64 256 1024 4096 16384 65536 262144 1048576 4194304 v Compute powers and store in v while power 10 7 v k power k k 1 power power 4 end Display vector v disp v Exercise 5 Display contents of function f M file type f m function y f x Function to evaluate the piecewise function f x if x 3 y x 3 Case for x 3 elseif x 3 x 6 y exp x 8 Case for 3 x 6 elseif x 6 x 8 y x x 8 Case for 6 x 8 elseif x 8 y the function is undefined at x 8 end end Evaluate f at the given vaue of x Evaluate f at the given value of x Evaluate f at the given value of x disp f 2 5 disp f 3 6 disp f 3 5 0 0111 Evaluate f at the given value of x 4 Evaluate f at the given value of x the function is undefined at x 8 Evaluate f at the given value of x disp f 6 0 1353 disp f 8 disp f 9 9 5


View Full Document

ASU MAT 275 - LAB 2

Download LAB 2
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LAB 2 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LAB 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?