Quote:
Originally Posted by flameout
I've refactored my code to be much faster...
|
How slow was it before? Maxima solves Question 5 in less than half a second:
Code:
Maxima 5.27.0 http://maxima.sourceforge.net
using Lisp GNU Common Lisp (GCL) GCL 2.6.8
assume(t>0)$
Qo: 15/180*%pi$
dFdT: 5.0*sin(t/2.0)$
dSdT: 4.0*sin(t/2.2)$
dQdT: 1.5*sin(t/2.5)$
Q: Qo + integrate(dQdT,t,0,t)$
dXdT: dFdT*sin(Q)+dSdT*cos(Q)$
dYdT: dFdT*cos(Q)-dSdT*sin(Q)$
dLdT: sqrt(dXdT^2+dYdT^2)$
quad_qags(dXdT, t, 0, 30);
[- 5.94428316349145, 5.1523954241625701E-10, 315, 0]
quad_qags(dYdT, t, 0, 30);
[- 9.110270199929753, 3.4870273187953572E-10, 315, 0]
quad_qags(dLdT, t, 0, 30);
[129.5971872631463, 1.1496649242892635E-6, 441, 0]
Quote:
|
...using basic manual Euler integration
|
Use trapezoidal instead. It's very simple to do and much more accurate, so you can use fewer steps and speed it up even more.
Also see Post 13 for a simple change to improve accuracy so you can use fewer steps and run even faster. Post 15 explains why.
Quote:
|
I would have done this in C++, but MATLAB lets me plot much more easily
|
Get yourself a copy of gnuplot. It's free and script-driven, so you can write a script to edit/compile/run/and plot your C++ program.