A simple but well-tested Swift package to solve math problems.
Add this package dependency to your Xcode project: https://github.com/wegenerlabs/NaturalMath.git
Call the package like this:
import Natural Math
let result = NaturalMath("1+2").result
// returns a Result<Double, Error>, in this case .success(3)+ - * / ^ sqrt abs sin cos tan arcsin arccos arctan pi ln log lb e
()
See NaturalMathIntegrationsTests for example usage.
Trig functions use radians. log uses base 10. lb uses base 2.
Synonyms can be used for many operators (e.g. : for division). See NaturalMathToken.
2^3^2 = 2^(3^2), not (2^3)^2
6/3(2+1) = (6/3)(2+1), not 6/(3*(2+1))