%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PHYS 210 Intro Computational Physics
%
% q1.m:  Instructor's solution
%
% Note: I have appended _k to all names to facilitate grading of
% student work with a script.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Q1.1
>>  q11_k = 23 * (-8 + sqrt(607)/3) + (40/8 + 4.7^2)^2

q11_k =  738.75

% Q1.2
>>  q12_k = cos(5*pi/6) * sin(7*pi/8)^2 + tan(pi/6*log(8)) / (sqrt(7) + 2)

q12_k =  0.28462

% Q1.3
>>  x_k = 5.3

x_k =  5.3000
>>  z_k = 7.8

z_k =  7.8000
>>  q13_k = (x_k*z_k) / (x_k/z_k)^2 + 14*x_k^2 - 0.8*z_k^2

q13_k =  434.13

% Q1.4
>>  A_k = 2

A_k =  2
>>  B_k = -7

B_k = -7
>>  C_k = -10

C_k = -10
>>  x0_k = -3

x0_k = -3
>>  y0_k = 4

y0_k =  4

>>  d_k = abs(A_k*x0_k + B_k*y0_k + C_k) / sqrt(A_k^2 + B_k^2)

d_k =  6.0439

% Q1.5
>>  vr_q15_k = [6, 8*3, 81, exp(2.5), sqrt(65), sin(pi/3), 23.05]

vr_q15_k =

    6.00000   24.00000   81.00000   12.18249    8.06226    0.86603   23.05000


% Q1.6
>>  vc_q16_k = [44; 9; log(51); 2^3; 0.1; 5*tand(25)]

vc_q16_k =

   44.00000
    9.00000
    3.93183
    8.00000
    0.10000
    2.33154


% Q1.7
>>  W_k = 3.1 : 1.0 : 10.1

W_k =

 Columns 1 through 7:

     3.1000     4.1000     5.1000     6.1000     7.1000     8.1000     9.1000

 Column 8:

    10.1000


% Q1.8
>>  Z_k = linspace(-1.0, 2.5, 8)'

Z_k =

  -1.00000
  -0.50000
   0.00000
   0.50000
   1.00000
   1.50000
   2.00000
   2.50000


% Q1.9
>>  R_k = [0:4:28; 69:-1:62; linspace(1.4,-0.7,8)]

R_k =

 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


% Q1.10
>>  V_k = [3.1 4.1 5.9 2.6 5.3 5.8 9.7 9.3]

V_k =

   3.1000   4.1000   5.9000   2.6000   5.3000   5.8000   9.7000   9.3000


% Q1.11
>>  V_round_k = round(V_k)

V_round_k =

    3    4    6    3    5    6   10    9


% Q1.12
>>  V_int_k = fix(V_k)

V_int_k =

   3   4   5   2   5   5   9   9