Question: I'm having trouble adding this functionality to my calculator app. Here's what I had in mind:

I want to solve: `2x = 5 + 4x`.

To solve this is no problem if I would use an external token library to parse the equation, but since my entire program is built around a shunting yard parser (EXP4J), it complicates things. You might say that I could just use the token parser for specific cases, but when you consider that I have FUNCTIONS using EXP4J, it becomes really tangled.

So, while I could make it work for `2x = 5 + 4x` by simply alternating to a token parser for this specific case, calculations that use EXP4J, like:

`2x = 5*exp4jfunc(x + 5,x) + cos(x)` are completely beyond me.

Does anyone have any idea on how to get around this? I don't even know how my CASIO tackles this, as it freezes on solve-for-x equations like `x = 9^x`...

Answer: 
I am not really familiar with exp4j... Given that the `Expression` class doesn't seem to provide much access to the parsed structure, a symbolic approach seems not really feasible with exp4j.

One thing you could try with exp4j instead:

* Split the equation at `=` into `left` and `right`
* Build a new equation that is the difference of both sides:

`String diff = "(" + left + ") - (" + right + ")"`
* Parse `diff` with exp4j
* Use a numerical method (e.g. the [Secant method](https://en.wikipedia.org/wiki/Secant_method)) with `setVariable()` and `evaluate()` to find the solution(s).

Shameless plug: If you are considering to use a different parser, take a look at [this one](https://github.com/stefanhaustein/expressionparser)
First, define the domain of your equations. Are you talking about linear equations, polynomials, general non-linear equations, differential equations? Then define your dimension: Do you have one variable or many? Finally, select the appropriate solver (numerical, symbolical, Gauss, Newton etc.). 

Once you have defined this, you need to transform the syntax tree of exp4j into the format required by the solver. However it seems that you won't be able to do this with exp4j, since it does not expose the structure of an expression as an API. 

I would advice to use a proper AST. If you cannot do that, you can see [in the implementation](https://github.com/fasseg/exp4j/blob/master/src/main/java/net/objecthunter/exp4j/Expression.java), that the internal structure is basically just a token list.