Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #define thshold 2 * pow(10,-4)
- double sinfx(double x){
- return (x*x - sin(x));
- }
- void false_position(double xl, double xu)
- {
- int i;
- double q0, q1, q,p;
- double num = 40;
- double xr2;
- q0 = sinfx(xl);
- q1 = sinfx(xu);
- i = 1;
- p = xu - q1 * (xu - xl) / (q1 - q0);
- q = sinfx(p);
- double e0=100.0;
- printf("%d\t%lf\t%lf\t%lf\t%lf\n", i, xl,xu,p, e0);
- while(1)
- {
- p = xu - q1 * (xu - xl) / (q1 - q0);
- q = sinfx(p);
- if (e0 < thshold)
- {
- break;
- }
- else
- {
- if((q*q1) < 0.)
- {
- xl = xu; q0 = q1;
- }
- xu = p; q1 = q;
- }
- xr2 = (xl+xu)/2;
- e0 = fabs(q);
- printf("%d\t%lf\t%lf\t%f\t %lf\n", ++i, xu,xl,p,e0);
- }
- printf("%lf\n", p);
- }
- int main()
- {
- false_position(0.5,1);
- return 1;
- }
- int pcap_compile ( pcap_t * p,
- struct bpf_program * fp,
- char * str,
- int optimize,
- bpf_u_int32 netmask
- )
- int pcap_setfilter ( pcap_t * p,
- struct bpf_program * fp
- )
- int pcap_next_ex ( pcap_t * p,
- struct pcap_pkthdr ** pkt_header,
- const u_char ** pkt_data
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement