I typically write my programs in Matlab and then port the picture into LaTeX. At times it appears that one has better efficiency or flexibility to have the program within LaTeX itself, either you have access to more control over graphing or that the work-flow is easier. I am looking for an intermediate article that explains elements of mathematical programming in LaTeX. Typical math programs are items such as Newton method for root finding, Runge-Kutta solution of differential equations, basic Monte Carlo, etc. If no such article exists links to your sample math-within-LaTeX would be appreciated.
Edit 4/3/2019
Where Matlab does not function well is in "annotations". Matlab performs nicely so long as you are plotting some graph. But if you are putting pieces together and adding text, arrows, etc to a plot then it becomes a bit of problem to use Matlab. Matlab has an "annotation" function to help you do this but it is geared to "normalized windows coordinates", which somehow takes your window to be $[0,1]*[0,1]$ and asks you specify the coordinates with respect to this window, as opposed to your data coordinates. This is perhaps for interactive placement of annotations on the graph but it is awkward to use for data-driven annotations. The switch-over is confusing enough to have created a side industry of third party contributed functions, most of which do not work because of one issue or another. Even if you manage to make it work then the annotations move around under zoom, as they are geared to the window you see not the data coordinates. In addition you encounter the limited version of \LaTeX that is supported by Matlab, for example here is the text support. In short, if you are contemplating a good bit of "hand modifications" to a graph then you may want to do it from start in \LaTeX. For drawing arrows in Matlab, "arrow3.m" functioned well.
pst-ode
package. Example: Phase Plane Plot using pst-ode