// lsfit_log.c // compile gcc -o lsfit_log.c simeq.c -lm // run lsfit_log > lsfit_log.out // // | SUM(S*S) SUM(S*T) SUM(S*U) SUM(S*V) | | a | | SUM(S*Y) | // | SUM(T*S) SUM(T*T) SUM(T*U) SUM(T*V) | x | b | = | SUM(T*Y) | // | SUM(U*S) SUM(U*T) SUM(U*U) SUM(U*V) | | c | | SUM(U*Y) | // | SUM(V*S) SUM(V*T) SUM(V*U) SUM(V*V) | | d | | SUM(V*Y) | #include "simeq.h" // needed to solve simultaneous equations #include #include #include #define n 21 // data set observations #define nt 8 // number of terms // 1, log(x), log(x^2), sin(x), cos(x), x, x^2, x^3 #undef abs #define abs(x) (((x)<0.0)?(-(x)):(x)) #undef max #define max(x,y) (((x)>(y))?((x)):(y)) #undef min #define min(x,y) (((x)<(y))?((x)):(y)) int main(int argc, char* argv[]) { double xd[n]; double yd[n]; double A[nt][nt]; double X[nt]; double Y[nt]; // |A| * |X| = |Y| |X| will be a, b, c double trmi[nt]; double trmj[nt]; int i, j, k; double Yc; printf("lsfit_log.c run to make lsfit_log.out \n"); // create data for(i=0; i