SafyanMajeed / symja

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

Function Apart[] isn't works #17

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I call the function "Apart[1/((1 + x) (5 + x))]" in Console but it not works.

What is the expected output? What do you see instead?
-1/4*(x+5)^(-1)+1/4*(x+1)^(-1)

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

Please provide any additional information below.
When I track your codes in file Expand.java, I understand why the problem 
arrived:
public static IAST[] getFractionalParts(final IAST timesAST) {
                IAST[] result = new IAST[2];

                IAST numerator = F.Times();
                IAST denominator = F.Times();
                final IAST ast = (IAST) timesAST;
                IExpr arg;
                IAST temp;
                for (int i = 1; i < ast.size(); i++) {
                        arg = ast.get(i);
                        if (arg.isAST(F.Power, 3)) {
                                temp = (IAST) arg;
                                if (temp.get(2) instanceof ISignedNumber) {
                                        if (temp.get(2).equals(F.CN1)) {
                                                denominator.add(temp.get(1));
                                                continue;
                                        }
                                        if (((ISignedNumber) temp.get(2)).isNegative()) {
                                                denominator.add(F.Power(temp.get(1), ((ISignedNumber) temp.get(2)).negate()));
                                                continue;
                                        }
                                }
                        }
                        numerator.add(arg);
                }
                result[0] = numerator;
                result[1] = denominator;
                return result;

        }
I modify to:
  IAST numerator = F.Times();  
  IAST denominator = F.Times();
  numerator.add(F.integer(1));
  denominator.add(F.integer(1));
It work fine!
I hope it will be useful for you.

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

GoogleCodeExporter commented 9 years ago

Original comment by axelclk@gmail.com on 20 Sep 2010 at 6:08

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

Thank you for reporting this.

Original comment by axelclk@gmail.com on 20 Sep 2010 at 6:09