# How can I add automatic consistency tests for formulas in my paper? [closed]

In test driven software development, you craft a couple of tests that describe what your program is supposed to do. When introducing a new feature, you start with a test that describes it, and then implement the feature that's supposed to satisfy that test, while not breaking any other existing tests.

Now when writing a paper in LaTeX that involves mathematical formulas, I find myself in the following situation: I might write an early draft based on some calculations that I did on paper or in a Computer Algebra System (CAS). Later, I want to modify some equations, e.g. generalize them. To ensure other equations derived from the modified ones are still correct -- or to modify them, too -- I need to look up my initial calculations, e.g. find the sheet(s) of paper on which I did them, or the CAS file containing them, or, if I can't find them anymore (as it happens), do my entire calculations again.

Now one way to tackle this might just be tidying up my notes ;-) but ideally, I'd like to have automatic tests that ensure e.g. equation (14) follows from (10) and (12) with `a` set to `b^2`, so that if I modify (10), I'm notified that (14) breaks. That way, I would know that I'd also need to modify (14) (or something else it's based on), and when I think I've fixed it, rerun my tests.

Is there an easy way to achieve this? Do people write entire papers in a CAS like Maple or Mathematica (which I've personally never used much) to allow for such a workflow? Personally, I'm writing my papers with LyX, so I'd prefer a solution that integrates with that. For calculations, I'm using paper and pencil, and SymPy for the occasional matrix multiplication, but currently, my SymPy files end up rather chaotic with time, which is one of the reasons why I'm looking for a better workflow.

-

## closed as off topic by egreg, Paulo Cereda, Marco Daniel, lockstep, percusseApr 18 '12 at 23:16

Questions on TeX - LaTeX Stack Exchange are expected to relate to TeX, LaTeX or related typesetting systems within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

This is likely to be closed as off-topic, but Googling 'maple unit test' returned this page at MaplePrimes. I would assume you're going to have to verify symbolic correctness in a CAS, and if the tests pass, export the equations to LaTeX. –  Mike Renfro Apr 18 '12 at 19:21
Not sure I fully understand, but perhaps you should consider defining `\A` as a `\newcommand{\A}{b^2}`, then use `\A` in both equations. If you need to later change this to be a cubic function, for example, you just need to change the definition of `\A`, and all the equations using it get updated. Alternatively, if a particularity equation was typeset with the assumptions that `\A` was indeed `\b^2`, you could put a `\todo` that pops up in `\A` no longer has the same value alerting you to recheck that equation. –  Peter Grill Apr 19 '12 at 0:25
@PeterGrill: that would help for simple substitution cases indeed, but I think for more complicated ones involving more complex algebraic transformations, there's still need for some actual CAS capabilities... –  Bernhard Reiter Apr 20 '12 at 15:22
Can someone advise why this has been closed as off-topic? After all, I'm asking for automated equations consistency checking in TeX files, and I figured that might be of interest to other people writing papers involving mathematical formulae in TeX, too. Do I need to reformulate my question? Or should I move it somewhere else, like stackoverflow.com? –  Bernhard Reiter Apr 20 '12 at 15:24
@BernhardReiter: I don't know if you can fully automate the testing unless you want to build the functionality of something like Maple or Mathematica into Tex (which I do not recommend), but what I was suggesting was to put some checking as in my comment above. Perhaps if you added specific example of the types of things you want to check for. Another possibility would be to do some numerical evaluations at specific values and check that the result still makes sense. –  Peter Grill Apr 20 '12 at 16:07