#include #include #include double compute_iterative(int); double compute_recursive(int n); double compute_formula(int); double compute_matrix(int); double power(double, int); void power_matrix(double*,double*,double*,double*,int); int main(){ int n; printf("Write n: "); scanf("%d",&n); clock_t start, end; double cpu_time_used; start=clock(); printf("I_%d (computed using iterative method) = %lf\n", n, compute_iterative(n)); end=clock(); printf("Time taken in iterative method = %lf seconds\n\n",((double) (end - start)) / CLOCKS_PER_SEC); start=clock(); printf("I_%d (computed using recursive method) = %lf\n", n, compute_recursive(n)); end=clock(); printf("Time taken in recursive method = %lf seconds\n\n",((double) (end - start)) / CLOCKS_PER_SEC); start=clock(); printf("I_%d (computed using formula) = %lf\n", n, compute_formula(n)); end=clock(); printf("Time taken in formula = %lf seconds\n\n",((double) (end - start)) / CLOCKS_PER_SEC); start=clock(); printf("I_%d (computed using matrix multiplication) = %lf\n", n, compute_matrix(n)); end=clock(); printf("Time taken in matrix = %lf seconds\n\n",((double) (end - start)) / CLOCKS_PER_SEC); return 0; } double compute_iterative(int n){ double previous=0, current =1, next; if(n==0) return 0; else{ for(int i=1; i