%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PHYS 210 Intro Computational Physics
%
% ex1.m:  Instructor's solution
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 1.2a)
>>  res2a = 23 * (-8 + sqrt(607)/3) + (40/8 + 4.7^2)^2

res2a =  738.75


% 1.4a)
>>  res4a = cos(5*pi/6) * sin(7*pi/8)^2 + tan(pi/6*log(8)) / (sqrt(7) + 2)

res4a =  0.28462

% 1.6a)
>>  x = 5.3

x =  5.3000
>>  z = 7.8

z =  7.8000
>>  res6a = (x*z) / (x/z)^2 + 14*x^2 - 0.8*z^2

res6a =  434.13

% 1.16)
>>  A = 2

A =  2
>>  B = -7

B = -7
>>  C = -10

C = -10
>>  x0 = -3

x0 = -3
>>  y0 = 4

y0 =  4

>>  d = abs(A*x0 + B*y0 + C) / sqrt(A^2 + B^2)

d =  6.0439

% 2.1)
>>  res21 = [6, 8*3, 81, exp(2.5), sqrt(65), sin(pi/3), 23.05]

res21 =

    6.00000   24.00000   81.00000   12.18249    8.06226    0.86603   23.05000


% 2.2)
>>  res22 = [44; 9; log(51); 2^3; 0.1; 5*tand(25)]

res22 =

   44.00000
    9.00000
    3.93183
    8.00000
    0.10000
    2.33154


% 2.9)
>>  B = [0:4:28; 69:-1:62; linspace(1.4,-0.7,8)]

B =

 Columns 1 through 7:

    0.00000    4.00000    8.00000   12.00000   16.00000   20.00000   24.00000
   69.00000   68.00000   67.00000   66.00000   65.00000   64.00000   63.00000
    1.40000    1.10000    0.80000    0.50000    0.20000   -0.10000   -0.40000

 Column 8:

   28.00000
   62.00000
   -0.70000