Implement in c the monte carlo algorithm and find the time complexity
9 replies to this topic
#1
Posted 19 October 2010 - 05:19 PM
|
|
|
#2
Posted 19 October 2010 - 05:21 PM
Do you have any code yet?
#3
Posted 19 October 2010 - 05:25 PM
No I need Help in that one
#4
Posted 19 October 2010 - 05:31 PM
We don't do homework for you. What part are you having trouble with? There are a LOT of pieces involved, and you've given no indication where your issue is.
#5
Posted 20 October 2010 - 05:29 AM
you can find area under the curve f(x)= e^x cosx and then find time complexity. Or some other problems related numerical methods.
I can do programming but unable to get referance about Monte Carlo algo. If you give me small example and illustrate the time complexity then i will able to develop so
I can do programming but unable to get referance about Monte Carlo algo. If you give me small example and illustrate the time complexity then i will able to develop so
#6
Posted 20 October 2010 - 04:31 PM
http://en.wikipedia....te_Carlo_method
It's not a single algorithm, it's an approach to solving a category of problems. Which particular problem you are solving will determine the details.
It's not a single algorithm, it's an approach to solving a category of problems. Which particular problem you are solving will determine the details.
#7
Posted 20 October 2010 - 05:38 PM
My Problem is
Quote
Write a C program to implement Monte Carlo algorithm to find area under the curve y= e^-x
between the limits a=0 and b=1. Determinte how many cycles are required to obtain an answer
that is accurate to three significant figures. Compare the Computer time required for this
problem with the time required for problem ( find area under the curve y= e^-x using
trapezoidal Rule ) . Discuss the Time Complexity in this Monte Carlo method.
between the limits a=0 and b=1. Determinte how many cycles are required to obtain an answer
that is accurate to three significant figures. Compare the Computer time required for this
problem with the time required for problem ( find area under the curve y= e^-x using
trapezoidal Rule ) . Discuss the Time Complexity in this Monte Carlo method.
// Program for trapezoidal Rule is as follows
#include<stdio.h>
#include<conio.h>
#include<math.h>
double fun1(double x)
{ return((double)exp(-x));
}
void main()
{ double y[30],a,b,h,ans1,z=0.0;
int i,n;
clrscr();
printf("\n Enter Upper limit : ");
scanf("%lf",&b);
printf("\n Enter Lower limit : ");
scanf("%lf",&a);
printf("\n How many Intervals : ");
scanf("%d",&n);
h=(double)(b-a)/n;
for(i=0;i<=n;i++)
{ y[i]=fun1(a+i*h);
printf("\nY[%d] : %lf",i,y[i]);
}
for(i=1;i<n;i++)
z+=y[i];
ans1=(h/2)*((y[0]+y[n])+2*z);
printf("\n\n Observed Solution is : %lf ",ans1);
getch();
}
Edited by Alexander, 20 October 2010 - 06:39 PM.
Please add [code] tags around your code
#8
Posted 21 October 2010 - 03:20 AM
#9
Posted 23 October 2010 - 05:50 PM
but i have main problem in Time complexity. I had been tried to learn thoritically but not able to find time complexity of monte carlo problem.
Any One please give some idea about time complexity finding technique..........................................
Any One please give some idea about time complexity finding technique..........................................
#10
Posted 24 October 2010 - 05:54 AM
If you've written the code, then you can analyze it for time complexity. Different implementations of the same algorithm can have different complexities.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









