B
B
bagos2015-09-14 16:35:01
Mathematics
bagos, 2015-09-14 16:35:01

What are the algorithms for expanding brackets in an expression?

Hello everyone, I need to bring the equation to the canonical form. The first step is to free the equation from brackets, I look towards the recursive descent method and reverse Polish notation. The equation could be x^2+1.5zy^3+2z*(ab+t(x^2+1))=0

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
tsarevfs, 2015-09-14
@bagos

The Polish notation is a little simpler, recursive descent will allow you to work with a tree if you want to not just calculate, but make some kind of transformation. Code examples and descriptions for each of the algorithms are in bulk on the internet.

X
xmoonlight, 2015-09-14
@xmoonlight

I would start with Polish ...
(further - you need to look already "deeper" ...)

S
Stanislav Makarov, 2015-09-14
@Nipheris

Yes, parse this case in AST and free from whatever you want. You can, for example, calculate constant expressions (replace (3 + 4) with 7). Parentheses are even easier to remove - if the node has one child (expression in brackets) - replace the current node with a child.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question