Inputs:
Output:
In a correct answer the coefficients a take values such that the function
fit = @(x) a(1)*f{1}(x) + a(2)*f{2}(x) + a(3)*f{3}(x) +...+ a(end)*f{end}(x)
minimizes the sum of the squared deviations between fit(x) and y, i.e. sum((fit(x)-y).^2) is minimal.
Remarks:
your functions are not all truly 'vectorized'; I would change @(x)1 to @(x)ones(size(x)) for a more consistent 'vectorized' behavior...
Yup, you're right. I made the adjustment...
not meaning to be picky, but in the third test you might want to use aref.' instead of aref' (if x take negative values, which occurs at random for this test, then log(x) takes complex values, and the aref' portion takes the conjugate of the complex valued results); perhaps it is simpler to make sure x takes only positive values...
and nice problem, by the way!
Thanks! Nice catch, I fixed that second issue too (those randomized tests have their drawbacks)
Project Euler: Problem 1, Multiples of 3 and 5
1063 Solvers
Project Euler: Problem 6, Natural numbers, squares and sums.
782 Solvers
Remove from a 2-D matrix all the rows that contain at least one element less than or equal to 4
123 Solvers
Number of digits in an integer
271 Solvers
240 Solvers