Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main() {
- double r_arr[10] {1.21, 1.26, 1.30, 1.34, 1.39, 1.44, 1.50, 1.55, 1.59, 1.65};
- double t_arr[10] {16.85, 26.85, 36.85, 46.85, 56.85, 66.85, 76.85, 86.85, 96.85, 106.85};
- double alpha[5];
- double alpha_avg = 0;
- for (int i = 0; i < 5; i++){
- alpha[i] = (r_arr[i] - r_arr[i+5])/(r_arr[i+5]*t_arr[i] - r_arr[i]*t_arr[i+5]);
- alpha_avg += alpha[i];
- }
- alpha_avg /= 5;
- double sum = 0;
- for (double i : alpha) {
- sum += pow(i - alpha_avg, 2);
- }
- double abs = sqrt(sum/20);
- cout << "alpha: " << alpha_avg << "\n";
- cout << "absolute error: " << abs << "\n";
- double r_arr2[10] {266.1, 204.4, 115.1, 89.4, 64.1, 43.1, 28.4, 19.3, 13.6, 11.1};
- double t_arr2[10] {290, 300, 310, 320, 330, 340, 350, 360, 370, 380};
- double e[5];
- double k = 8.62*pow(10, -5);
- double e_avg = 0;
- for (int i = 0; i < 5; i++){
- e[i] = 2*k*t_arr2[i]*t_arr2[i+5]*log(r_arr2[i]/r_arr2[i+5])/(t_arr2[i] - t_arr[i+5]);
- e_avg += e[i];
- }
- e_avg /= 5;
- sum = 0;
- for (double i : e) {
- sum += pow(i - e_avg, 2);
- }
- abs = sqrt(sum/20);
- cout << "band gap: " << e_avg << "\n";
- cout << "absolute error: " << abs << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement