1

I have almost zero knowledge of TEX.
I want an easy way to take common algorithms and use them to calculate values.
This would ideally be done in the browser, but if not appropriate I could run on a server and connect through a web API.
I have found that Wikipedia offers many algorithms with markup written in TEX-like code.
Searching about this returns a variety of different posts that seem unrelated and are difficult for someone with little knowledge to understand.

If, for example I take the algorithm from Wikipedia with code below, how could I calculate the answer of Cx with required parameters?

https://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon

C_{\mathrm {x} }={\frac {1}{6A}}\sum _{i=0}^{n-1}(x_{i}+x_{i+1})(x_{i}\ 
y_{i+1}-x_{i+1}\ y_{i})
7
  • 4
    Sorry, but TeX is not the tool you are looking for.
    – Johannes_B
    Apr 26, 2018 at 5:09
  • @Johannes_B Thanks. TeX may not be the tool I am looking for, but the source is TeX so it is what I had to start searching from. I am assuming that because such an important site like Wikipedia uses it for its algorithms, that there would be a good chance this has already been solved by somebody. Apr 26, 2018 at 5:11
  • 3
    TeX is purely used to make the equations look good. There are no calculations.
    – Johannes_B
    Apr 26, 2018 at 5:12
  • 4
    This seems to be off topic for the site for two reasons: TeX code on web pages is not actual LaTeX but an approximation called MathJax (or similar). Secondly, the rendering of equations has very little to do with implementing the equation in code (which would certainly not be TeX code.)
    – Alan Munn
    Apr 26, 2018 at 5:14
  • 1
    It's not exactly MathJax, but something similar (definitely not a full TeX system), see en.wikipedia.org/wiki/Help:Displaying_a_formula (and the extension site). Why should there be no way to convert it to another language? It's just very difficult, because the syntax does contain stylistic commands apart from operators etc, which have no influence on the computation result. But you could try to find or implement a converter.
    – TeXnician
    Apr 26, 2018 at 5:29

1 Answer 1

1

As answered by other users in the comments, TeX is not suitable for performing calculations.
In addition to this, Wikipedia uses a variant of TeX and other formats such as Mathjax are common on web pages.
Wikipedia also seems to output MathML, so I will take it into consideration.
At the time of writing, there does not appear to be an easy way to convert to a format for calculating. If a solution does appear, please add here.

5
  • @Mico Please show me calculations done by TeX. The answer uses Lua to perform the calculations. Apr 26, 2018 at 9:12
  • I do not understand what you mean. I am referring to TeX. You seem to be referring to LuaTeX. Apr 26, 2018 at 9:36
  • I am looking at this from the perspective of parsing and calculating. The syntax is of much importance. Lua is completely different, and pretty much any other language could replace it if support was added. Apr 26, 2018 at 10:05
  • I realize now that my well-intentioned comments have been utterly worthless to you; I've deleted them all. To address your latest comments directly: TeX's and LaTeX's math-typesetting directives -- such as \int, \sum, \frac and \prod -- were designed to handle typesetting jobs. They were never meant to do anything else, such as constitute the basis for performing actual calculations. I don't understand why you insist on thîs not being the case.
    – Mico
    Apr 26, 2018 at 13:12
  • "I don't understand why you insist on thîs not being the case." - I do not insist on anything, especially this. From all the responses I have received it is clear that it would be difficult and inappropriate but not impossible to implement what I am asking. Apr 27, 2018 at 2:00

Not the answer you're looking for? Browse other questions tagged .