Error

  1. Execute the two snippets below:
    s=0; 
    for n=999999:-1:1
     s+=1/(n*(n+1))
    end
    s
    
    s=0; 
    for n=1:999999
     s+=1/(n*(n+1))
    end
    s
    
  2. Explain the difference.

Cancellation

  1. Define f(x)=1107+x1107x.
  2. Plot it on the interval [107,105].
  3. Try to explain the phenomena.
  4. Define a mathematically equivalent function that behaves correctly.

Represent

  1. Define a function of the form tobin(a,b,d), that prints the first d digits of the binary expansion of ab. Assume, that a<b and they are integers.
  2. Find the representation of 1736 and 948 in the system a=2,k=4,k+=4,t=8.

Solve 2x2

  1. Define a function of the form x=solve22(A,b), that computes the solution of the Ax=b linear system, for 2×2, invertible matrices.

Back substitution

  1. Define a function of the form x=lsolve(A,b), that computes the solution of the Ax=b linear system, for quadratic, lower triangular matrices. You may assume, that A is invertible.
  2. Define a function of the form x=usolve(A,b), that computes the solution of the Ax=b linear system, for quadratic, upper triangular matrices. You may assume, that A is invertible.