change operators position increase computational cost
이전 댓글 표시
Dear all,
I noticed a strange (to me) behavior in my code. I'm solving a system of ODEs using ODE15s. The following term 'prefac' is calculated many times, and I noticed that, if I used the first equation, the calculation is about half of the time faster than using the second equation (~450s VS. ~870s). The only difference is that the term ./T_c is moved from the end of the equation to the beginning. If, during the simulation, I display the difference between the two, the maximum I get is 8e-22. I used 'prefac' to calculate terms in the order of magnitude of 1e-3, and in fact the solution does not change, only the computational cost increase.
prefac = (Mmix_c./param.R) .* (param.eps_c(end,:,:)./param.tau_c(end,:,:)) .* (1-s_c) .* (5.21e-1) .* ((T_c./139.681).^1.823) ./ (T_c);
or
prefac = (1 ./ (T_c)) .* (Mmix_c./param.R) .* (param.eps_c(end,:,:)./param.tau_c(end,:,:)) .* (1-s_c) .* (5.21e-1) .* ((T_c./139.681).^1.823);
do you have some explanation for it?
regards
Mauri
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!