NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#include <stdio.h>
#include <math.h>
#define N 50

double integral(double a, double b, int n, double (*f)(double)); //funzione che calcola l'integrale di una funzione
double function(double); //funzione da integrare
int main() {
double a, b; // estremi di integrazione
double I = 0; // valore dell'integrale
double num[N+1]; // numero di intervalli
double integrals[N+1]; // array dei valori di I calcolati per ogni num[i]
double reciproci[N+1]; // ascisse del grafico, ossia 1/num[i]
double A, B; // coefficienti della retta di equazione y=A+Bx
double sigma[N]; // errori nei vari integrali (che puoi sapere solo se sai il cazzo di valore dell'integrale)
double S;.
double Sx;
double Sy;
double Sxx;
double Sxy;
double Stt;
double t;
double tmp;
int i;
printf("inserisci gli estremi di integrazione: ");
scanf("%lf %lf", &a, &b);
for(i=1; i<=N; i++){
num[i] = (double) i;
reciproci[i]=1/num[i];
integrals[i]=integral(a, b, i, function);
printf("%lf %lfn", num[i], integrals[i]);
}
for(i=0; i<N; i++){
sigma[i] = integrals[i+1]-integrals[N+1];
S += 1./(sigma[i]*sigma[i]);
Sx += reciproci[i+1]/(sigma[i]*sigma[i]);
Sy += integrals[i+1]/(sigma[i]*sigma[i]);
Sxx += (reciproci[i+1]*reciproci[i+1])/(sigma[i]*sigma[i]);
Sxy += (reciproci[i+1]*integrals[i+1])/(sigma[i]*sigma[i]);
}
for(i=0; i<N; i++){
t = (1/sigma[i])*(reciproci[i+1]-(Sx/S));
Stt += t*t;
tmp = (t*integrals[i+1])/sigma[i];
}
B = tmp/Stt;
A = (Sy - Sx*B)/S;
printf("%lf %lfn", A, B);
}


double function(double x){
return sin(x);
}

double integral(double a, double b, int n, double (*f)(double)){
double In=0.;
double delta = (b-a)/(double) n;
double x=a;
int j;
for(j=0; j<n; j++){
In += f(x+0.5*delta);
x += delta;
}
In *= delta;
return In;
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.