If (x1,y1), (x2,y2), (Xn,yn) are n points in the xy coordinate system, then the
ID: 3635624 • Letter: I
Question
If (x1,y1), (x2,y2), (Xn,yn) are n points in the xy coordinate system, then the least squares approximation to these points is the line y=mx+b, where m = middot (sum of x( middot yt) - (sum of xi) middot (sum of yi) / n middot (sum of xi middot xi) - (sum of xi)2 and b = (sum of yi) - m middot (sum of xi)/ n Write a program that will calculate and displays the equation of the least squares line. Prompt the user to input n " the number of points". Use a user defined function calculate_m to fill all the possible points of xi and yi to find m and another user defined function calculate_b to fill all the possible points of xi and yi to find b Note: Using Loops and user defined functions is a must.Explanation / Answer
#include #include double calculate_m(double *x, double *y, int n) { int i; double sxy=0, sxx=0, sx=0, sy=0, m; for(i=0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.