Edit or run this notebook

HW 1 for CS 4220

You may (and probably should) talk about problems with the each other, with the TAs, and with me, providing attribution for any good ideas you might get. Your final write-up should be your own.

202 μs
339 μs
28.6 ms

1: Placing Parens

Suppose A,BRn×n and d,u,v,wRn. Rewrite each of the following Julia functions to compute the same result but with the indicated asymptotic complexity.

182 μs
hw1p1a (generic function with 1 method)
373 μs
"P1a code passes correctness test"
453 ms
"Estimated complexity: O(n^2.876225695250725)"
3.0 s
hw1p1b (generic function with 1 method)
416 μs
"P1b code passes correctness test"
154 ms
"Estimated complexity: O(n^2.2188158938444063)"
3.3 s
hw1p1c (generic function with 1 method)
322 μs
"P1c code passes correctness test"
12.8 ms
"Estimated complexity: O(n^3.006758543014128)"
17.1 s

2: Making matrices

In terms of the power basis, write

  1. The matrix AR3×3 corresponding to the inner product between two quadratics; that is, if p(x)=c0+c1x+c2x2 and q(x)=d0+d1x+d2x2, then 11p(x)q(x)dx=dTAc.

  2. The matrix BR2×3 corresponding to the linear map from quadratics to linears associated with differentiation.

The following testers will sanity check your answer, but you should also (briefly) describe how you got the right matrix.

1.4 ms
A_quadratic
3×3 Matrix{Float64}:
 1.0  0.0  0.0
 0.0  1.0  0.0
 0.0  0.0  1.0
12.9 ms
"A fails basic check"
24.8 ms
B_deriv
2×3 Matrix{Float64}:
 0.0  0.0  0.0
 0.0  0.0  0.0
12.0 μs
"B fails basic check"
8.3 ms

3: Crafty cosines

Suppose is a inner product norm in some real vector space and you are given

a=u,b=v,c=uv

Express u,v in terms of a, b, and c. Be sure to explain where your formula comes from.

212 μs
compute_dot (generic function with 1 method)
266 μs
"Fails sanity check"
83.8 ms
Loading...
ii