Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #define E 2.7182818284590452353
- using namespace std;
- double ket = 0.365 / 60, vap = 3250, ke = ket / vap;
- double f(double ka){
- double tmax = 1.6 / 60.0;
- return ka*pow(E, -ka*tmax) - ket*pow(E, -ket*tmax);
- }
- //Método da bisseção
- double bissec(double a, double b){
- double h = 0;
- while (h < 1000){
- double m = (a + b) / 2.0;
- if (f(a)*f(m) < 0){
- b = m;
- }
- else a = m;
- h++;
- }
- return b;
- }
- //Método da corda
- double corda(double a, double b){
- double h = 0;
- while (h < 10000){
- double w = (a*f(b) - b*f(a) / (f(b) - f(a)));
- if (f(a)*f(w) < 0)
- b = w;
- else a = w;
- h++;
- }
- return b;
- }
- void main(){
- cout << "zero: " << bissec(0, 0.1) << endl;
- cout << "zero: " << corda(0, 0.1) << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement