- #1
ver_mathstats
- 260
- 21
Homework Statement
We were given a tutorial to complete which I did complete.
Now the question is:
By modifying the appropriate lines in your script file, find the values of a, b, c, and d so that the cubic polynomial y = ax3 + bx2 + cx + d passes through the (x, y) pairs (-1, 3), (0, 8), (1, 1), and (2, 5).
Note that to check your answer you can plot the given points together with your cubic polynomial on the same graph, and check to see that all 4 points lie on the curve (as in the tutorial file). Note that you will likely have to modify the t vector so that it corresponds with the range of x-values above.
Homework Equations
The Attempt at a Solution
So far I have this
xi=[-1:2]'
yi=[3 8 1 5]'
A=[xi.^2 xi ones(3,1)] (this is from the tutorial I did, I am not sure how to change it so that it is a cubic function rather than a parabola. Would it be A=[xi.^3 xi.^2 xi. ones(2,-1)]?
b=yi
So now I would have
xi=[-1:2]'
yi=[3 8 1 5]'
A=[xi.^3 xi.^2 xi. ones(2,-1)]
b=yi
I am unsure of what to do next however?
In the tutorial I was given this
f = @(t) x(1)*t.^2+x(2)*t+x(3);
t = 0.5:.01:3.5;
y = f(t);
But I am unsure of how to modify this for my own question.
Thank you.