Chat with our AI personalities
What do you mean by "compute"? Do you want to graph it? Factor it? Calculate it's function given a set of points that lie on it? If you're looking to compute the function given three points that fall on the parabola, then I have just the code for you. If you're given three points, (x1, y1), (x2, y2) and (x3, y3), then you can compute the coefficients of your quadratic equation like this: a = (y1 * (x2 - x3) + y2 * (x3 - x1) + y3 * (x1 - x2)) / (x1 * x1 * (x2 - x3) + x2 * x2 * (x3 - x1) + x3 * x3 * (x1 - x2)) b = (y1 - y2) / (x1 - x2) - a * (x1 + x2); c = y1 - (x1 * x1) * a - x1 * b; You now can calculate the y co-ordinate of any point given it's x co-ordinate by saying: y = a * x * x + b * x + c;
i think its pretty much the same thing because matrix X1 X2 IS ACTUALLY X1 X2
The equation for the slope between the points A = (x1, y1) and B = (x2, y2) = (y2 - y1)/(x2 - x1), provided x1 is different from x2. If x1 and x2 are the same then the slope is not defined.
If (x1, y1) and (x2, y2) are two points on the line, then the formula for the slope is (y2-y1)/(x2-x1) provided x2 ≠x1. If x2 = x1 then the line is vertical and the slope is not defined.
Suppose that you have simple two variable model: Y=b0+b1X1+e The least squares estimator for the slope coefficient, b1 can be obtained with b1=cov(X1,Y)/var(X1) the intercept term can be calculated from the means of X1 and Y b0=mean(Y)-b1*mean(X1) In a larger model, Y=b0+b1X1+b2X2+e the estimator for b1 can be found with b1=(cov(X1,Y)var(X2)-cov(X2,Y)cov(X1,X2))/(var(X1)var(X2)-cov(X1,X2)2) to find b2, simply swap the X1 and X2 terms in the above to get b2=(cov(X2,Y)var(X1)-cov(X1,Y)cov(X1,X2))/(var(X1)var(X2)-cov(X1,X2)2) Find the intercept with b0=mean(Y)-b1*mean(X1)-b2*mean(X2) Beyond two regressors, it just gets ugly.