How do I improve Numerical Integration Speed?
이전 댓글 표시
Hi,
I have created a function which will loop several thousand times. I have noticed the time taken to perform the integration necessary is too long to produce the results I need. My integration method is as follows:
fun1= @(x) exp(-(abs(x)).^(1.73)).*((cos(eta1*x)));
fun2= @(x) exp(-(abs(x)).^(1.96)).*((cos(eta2*x)));
R1 =integral(fun1,0,inf);
R4 =integral(fun2,0,inf);
Here I state the function required to be integrated with respect to x and then perform the integral. How would I do this more efficiently. Thank you.
Pierce
댓글 수: 3
John D'Errico
2017년 8월 25일
편집: John D'Errico
2017년 8월 25일
Get a faster computer.
Ok, it is a secret, but I've heard that MathWorks provides intentionally the slowest code possible. Just kidding. But any numerical algorithm has limits.
Seriously, everybody wants faster results. And no matter what, if the code was twice as fast or your computer twice as big and powerful, there would be somebody out there who would decide to solve problems three times as large or ten times as long to solve. This is a fundamental law of computing. I've called it John's law of computing before, but I'm pretty sure someone else has already named it.
So, as I said, get a faster computer. Or buy the parallel computing toolbox, and learn to use it. (It might be easier or cheaper to find a faster computer.) Or get some coffee, and a good book to read while you wait.
Walter Roberson
2017년 8월 25일
You can truncate your integration at
solve(exp(-x^1.73)==eps)
which is about 7 1/2.
However, I do not know if this will help much. In my timing tests it made no difference. If eta1 were large then it probably would make a difference.
David Goodmanson
2017년 8월 25일
Hello Peirce, some ways around this depend on the size of eta1 and eta2. What is the range of these variables?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!