Ste, [minor edits]
Of course you could use Evans formulas plugin for more advanced math.
I was an advanced basic coder from way back. The problem is basic is a procedural language, in your question, part of computing the result is to call subroutines/gotos etc.. This is not the way its done in tiddlywiki, although you can have transclusions operating similarly. If instead you can take your basic code back to pseudocode I think you will find it easier to then find the tools in tiddlywiki to do the job. For example marks formulae, once you write the "problem" as Tsine(x) =x-(x^3)/6+(x^5)/120 this should be able to be put in evans formula plugin in his cute mushroom brackets (= formulae =) including references to fields and variables.
Although I would love to be better versed in Javascript inclusion in tiddlywiki, my opinion is that you would find value in learning how to implement such solutions in tiddlywiki rather than reverting to javascript, this would be investing in your own development in understanding tiddlywiki, increased reusability over bespoke java script, and much more shareable solutions. Basically move into native tiddlywiki plus generalised plugins.
Once you have mastered native tiddlywiki you may discover some gaps (Not so many remain) which you could remedy with a general solution in javascript you can share with the community and advance tiddlywiki further.
Regards
Tony