1

I want to store mathematics formula as string in database and load it to inject and compute in any programming language

It should be easy notation that could write by hand and should support at least basic arithmetic operation include pow and sqrt and log in any base

I wish there would be standard format for math notation that any language could agree upon. Is there anything like that? Is there a most popular notation format?

Thaina Yu
  • 1,372
  • 2
  • 16
  • 27
  • This question would be probably more suited to the [**Math StackExchange**](https://math.stackexchange.com/). – Obsidian Age Jun 15 '18 at 04:10
  • 2
    MathML, but it's almost more trouble than it's worth. For one, while all languages can parse it (it is XML), few if any languages can _execute_ it. – Amadan Jun 15 '18 at 04:11
  • @ObsidianAge Main point here is notation for the programming language – Thaina Yu Jun 15 '18 at 04:23
  • 1
    See https://stackoverflow.com/questions/4071456/opensouce-c-c-math-expression-parser-library – lhf Jun 15 '18 at 10:34

1 Answers1

2

Many shell languages can calculate using elementary mathematical formulae, represented as strings. For example, the Bash shell in Linux contains bc - "An arbitrary precision calculator language":

hekto@ubuntu:~$ bc --version
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.

hekto@ubuntu:~$ echo '2+2' | bc
4

hekto@ubuntu:~$ echo 'sqrt(2)' | bc -l
1.41421356237309504880

So, if your programming language of choice can communicate with shell, and this shell can calculate, then your problem is solved.

HEKTO
  • 3,876
  • 2
  • 24
  • 45