STACK - expand/factor question

Re: STACK - expand/factor question

by Stephan Bach -
Number of replies: 2
Hi René
it's just the variable, in your case \(x\). You can find all of this in the docs or on GitHub.
Stephan
In reply to Stephan Bach

Re: STACK - expand/factor question

by r k -
Hello Stephan

Thanks for your help and the link to the documentation.

As far as I can tell, the factorisation now works in principle.

However, \( 2\cdot x^2-2 \) (`ex1`) is corrected as wrong when written as \( (-2)\cdot(-x+1)\cdot(x+1) \) (`ans1`). Is it somehow possible
i) to recognise whether `ans1` is a product and
ii) `ans1` consists of at least `factor(ex1)` factors?

This would then correct answers like \( (-2)\cdot(-x+1)\cdot(x+1) \) or \( (-1)\cdot2\cdot(1-x)\cdot(x+1) \) as correct.

Possibly with something like `length(part(factor(ex1)));`.
In reply to r k

Re: STACK - expand/factor question

by Stephan Bach -
Hi,
FacForm should accept \( (-2)\cdot (-x+1)\cdot (x+1)\), EqualComAss will not.
Of course you could use something like is (safe_op(ans1)="*") to determine if ans1 is a product and length(args(ans1)) to count the factors. But you would have to deal with many different cases if you want to implement this in your feedback variables (\(2\cdot \left(\frac 1 2\right) \cdot (2 x^2 - 2)\) is a product with 3 factors, too.).
Depending on what you want, it's probably easier and more robust to use EqualComAss to first check on \( 2\cdot (x-1)\cdot (x+1)\) and if false also on \( (-2)\cdot (-x+1)\cdot (x+1)\).
Stephan