Skip to content
This repository was archived by the owner on Aug 29, 2024. It is now read-only.

Parenthesis on both sides #251

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/solveEquation/EquationOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ EquationOperations.removeSymbolFromDenominator = function(equation, symbolName)
// by multiplying or dividing by a symbol term.
// TODO: support inverting functions e.g. sqrt, ^, log etc.
EquationOperations.removeSymbolFromRightSide = function(equation, symbolName) {
const rightNode = equation.rightNode;
let rightNode = equation.rightNode;

if (Node.Type.isParenthesis(rightNode)) {
// if entire left node is a parenthesis, we can ignore the parenthesis
rightNode = rightNode.content;
}

let symbolTerm = Symbols.getLastSymbolTerm(rightNode, symbolName);

let inverseOp, inverseTerm, changeType;
Expand Down
3 changes: 2 additions & 1 deletion test/solveEquation/solveEquation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ describe('solveEquation for =', function () {
['(3 + x) / (x^2 + 3) = 1', 'x = [0, 1]'],
['6/x + 8/(2x) = 10', 'x = 1'],
['(x+1)=4', 'x = 3'],
['((x)/(4))=4', 'x = 16']
['((x)/(4))=4', 'x = 16'],
['(2x-12)=(x+4)', 'x = 16']
// TODO: fix these cases, fail because lack of factoring support, for complex #s,
// for taking the sqrt of both sides, etc
// ['(x + y) (y + 2) = 0', 'y = -y'],
Expand Down