Skip to Main Content
Introduction to Computational Modeling Using C and Open-Source Tools
book

Introduction to Computational Modeling Using C and Open-Source Tools

by Jose M. Garrido
November 2013
Intermediate to advanced content levelIntermediate to advanced
461 pages
12h 1m
English
CRC Press
Content preview from Introduction to Computational Modeling Using C and Open-Source Tools
Models with Interpolation and Curve Fitting 213
9 #include "polyfitgsl.h"
10 #define NC 2 /
*
size of coefficient vector
*
/
11 void polyval(double p[], double xv[], double yv[], int n, int m);
12 int main()
13 {
14 const int NP = 8; // Number of given data points
15 const int M = 30; // number of computed data points
16 /
*
const int NC = 2 ; Number of coefficients
*
/
17 double x[] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0};
18 double y[] = {0.0, 3.0, 6.0, 8.0, 12.0, 21.0, 43.0, 66.0};
19 double coeff[NC]; // vector of coefficients
20 int i;
21 double xc[M]; /
*
computed values for x using polynomial
*
/
22 double yc[M];
23 printf("Program finds best fit polynomial of degree %d \n",
NC-1);
24 printf("Data points (x,y): \n");
25 for (i = 0; i < NP; i++)
26 printf(" %f ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Computer Fundamentals and Programming in C (RMK)

Computer Fundamentals and Programming in C (RMK)

Anita Goel, Ajay Mittal

Publisher Resources

ISBN: 9781482216783