1

Almost all mathematical formulas functions etc can be translated to programming codes, can it be done in reverse i.e. code to math?

Is it possible to convert simple programming codes (programs that are not hardware or software specific) to mathematical formulas and functions? i.e. is it possible to translate a program which remove vowels from a string?

I think 'simple programming codes' is a vague statement so I have given the example of type of programs.

LifeH2O
  • 379
  • 2
    Why would you want to do that? – J. M. ain't a mathematician Nov 23 '11 at 04:28
  • Sure, program it all into diophantine equations. They are as powerful as turing machines. – Carl Nov 23 '11 at 04:29
  • Almost all mathematical formulas functions etc can be translated to programming codes, I was wondering can it be done in reverse i.e. code to math? – LifeH2O Nov 23 '11 at 04:31
  • I don't know what you mean by "translated to". Why don't you give an example of a mathematical formula and what you consider to be the corresponding code? – Zev Chonoles Nov 23 '11 at 04:38
  • @ZevChonoles: simples example would be to add, multiply, divide, summation, factorial etc etc. They all can be implemented in a programming language. My question is that if programs can also be implemented in mathematical language. – LifeH2O Nov 23 '11 at 11:55
  • 1
    I think your question is too unspecific for the answer to even be possible to be "yes". Programming far more than just things to do with mathematics. For example, try to convert the following java line to math: System.out.println("I really don't think this can be written in math, but I could be wrong");. You used the example of removing vowels from a string; it is possible that it is convertible in that specific case, but I doubt you can do it for much more than that. – Ephraim Apr 16 '12 at 22:03

2 Answers2

3

I'll provide an example of, say, removing the third to last letter from a string. You could first translate each letter into a number through a process similar to Godel Coding. Say you use something like ASCII, and each letter gets turned into three digits. So, "math" would become 109097116104, because 109 is ASCII for m, 097 ASCII for a, etc.

If you set $x_3 = 109$, $x_2 = 097$, $x_1 = 116$, $x_0 = 104$, and let $x = 1000^3 x_3 + 1000^2 x_2 + 1000 x_1 + x_0$, so that $x$ denotes the string "math". If we want $y$ to denote "math" with the second letter removed, we let $y = 1000^2 y_2 + 1000 y_1 + y_0$ and add the restraints $y_2 = x_3$, $y_1 = x_2$, and $y_0 = x_0$. If we restrict $0 \le x_i < 1000$ and $0 \le y_i < 1000$ for all $i$, then applying this complicated system of equations on $x,y,x_0,x_1,x_2,x_3,y_0,y_1,y_2 $ gives a system of equations that forces the string denoted by $y$ to be the string denoted by $x$, but with the second letter removed. This system of equations can be transformed easily into one huge diophantine equation.

Through a similar process, it turns out any problem solvable by a turing machine can be transformed into a huge diophantine equation. However, it is not a simple procedure.

Carl
  • 3,548
  • Very grokable answer. For completeness, in Bash removing all as from the string math could look like, s='math', echo "${s//[a]/} $\implies$ mth, and to keep all but the third letter could be echo "${s:0:2}${s:3}" $\implies$ mah... I think the exercise of translating programming to math would be beneficial in cases where math is more succinct and readable than the code, otherwise I'd keep it as code so as to not frustrate future developers. – S0AndS0 Apr 06 '19 at 16:58
0

x$\begin{array}{*{20}{c}}

{{\rm{lim}}}\

\to

\end{array}0\frac{{{{\rm{e}}^{\rm{x}}} - {\rm{x}} - 1}}{{{{\rm{x}}^2}}},\left( {\frac{0}{0}} \right)=x\begin{array}{*{20}{c}}

{{\rm{lim}}}\

\to

\end{array}0\frac{{{{\rm{e}}^{\rm{x}}} - 1}}{{2{\rm{x}}}},\left( {\frac{0}{0}} \right)=x\begin{array}{*{20}{c}}

{{\rm{lim}}}\

\to

\end{array}0\frac{{{{\rm{e}}^{\rm{x}}}}}{2}=\frac{1}{2}$.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. – Community Sep 20 '21 at 12:53