Jake0303 / symja

Automatically exported from code.google.com/p/symja
0 stars 0 forks source link

Bug in function Expand #19

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.Calling function "Expand[1/((x-1)(1+x))]".

What is the expected output? What do you see instead?
The result has to be (x^2-1)^(-1). Instead of it's (x-1)*(x+1).

What version of the product are you using? On what operating system?

meconsole0.0.9
Please provide any additional information below.

Original issue reported on code.google.com by huynhlam...@gmail.com on 22 Sep 2010 at 8:42

GoogleCodeExporter commented 8 years ago
In method public static IExpr expand(final IAST ast) of Expand class, I modify
else if (ast.isASTSizeGE(F.Times, 3)) {
            // (a+b)*(c+d)...
            // return expandTimes(ast);
            IExpr[] temp = getFractionalParts(ast);
            if (temp[0].equals(F.C1)) {
                return F.Power(expandTimes(ast), F.CN1);
            }
.....
to
else if (ast.isASTSizeGE(F.Times, 3)) {
            // (a+b)*(c+d)...
            // return expandTimes(ast);
            IExpr[] temp = getFractionalParts(ast);
            if (temp[0].equals(F.C1)) {
                IExpr b = EvalEngine.eval(F.Power(ast, F.CN1));
                IExpr a = expandTimes((IAST)b);
                return F.Power(a,F.CN1);
                //return F.Power(expandTimes(ast), F.CN1);
            }
It works fine.
I hope that it's useful for you.

Original comment by huynhlam...@gmail.com on 22 Sep 2010 at 9:30

GoogleCodeExporter commented 8 years ago

Original comment by axelclk@gmail.com on 22 Sep 2010 at 5:07

GoogleCodeExporter commented 8 years ago
Fixed in SVN
http://code.google.com/p/symja/source/detail?r=559

Original comment by axelclk@gmail.com on 22 Sep 2010 at 5:28

GoogleCodeExporter commented 8 years ago

Original comment by axelclk@gmail.com on 22 Sep 2010 at 5:29

GoogleCodeExporter commented 8 years ago

Original comment by axelclk@gmail.com on 27 Oct 2010 at 4:35