Skip to content

Commit

Permalink
stopgap patch to fix issues with integrating simple rational functions
Browse files Browse the repository at this point in the history
Task #139 - simple rational function integral not calculated
  • Loading branch information
grzegorzmazur committed Oct 12, 2015
1 parent f1c1f60 commit 4466691
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions scripts/integrate.rep/code.ys
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,31 @@ UnFence("IntegrateMultiplicative",4);
`AntiDeriv(@var,@ee);
];

15 # IntRat(_var,_exy / _exx,_exyu,_exxu)_
(Degree(exyu, var) = 0 And Degree(exxu, var) = 2 And
IsNumericList(Coef(exxu,var,0 .. Degree(exxu))) And
IsNumericList(Coef(exyu,var,0 .. Degree(exyu)))) <-- [
Local(a,b,c,d,e,delta);
{d} := Coef(exyu, var, 0 .. 0);
{c, b, a} := Coef(exxu, var, 0 .. 2);

delta := b^2-4*a*c;

2 * d / Sqrt(-delta) * ArcTan((2*a*var+b) / Sqrt(-delta));
];

15 # IntRat(_var,_exy / _exx,_exyu,_exxu)_
(Degree(exyu, var) = 1 And Degree(exxu, var) = 2 And
IsNumericList(Coef(exxu,var,0 .. Degree(exxu))) And
IsNumericList(Coef(exyu,var,0 .. Degree(exyu)))) <-- [
Local(a,b,c,d,e,r);
{e, d} := Coef(exyu, var, 0 .. 1);
{c, b, a} := Coef(exxu, var, 0 .. 2);

r := (e - b * d / (2 * a)) / exx;

d / (2 * a) * Ln(exx) + `AntiDeriv(@var, @r);
];

20 # IntRat(_var,_exy / _exx,_exyu,_exxu) <--
`Hold(AntiDeriv(@var,((@exy)/(@exx))));
Expand Down
2 changes: 2 additions & 0 deletions tests/integrate.yts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Verify(Integrate(x) (x + 4)/(x + 3)^2, Ln(x+3)-(x+3)^(-1));
Verify(Integrate(x) 1/(4 * x^2 + 1), ArcTan(2*x)/2);
Verify(Integrate(x) (x-1)/(x^2-1), Ln(x+1));

Verify(Integrate(x) x/(x^3+1), Ln(3*(1-x+x^2))/6+Sqrt(1/3)*ArcTan((4*x-2)/Sqrt(12))-Ln(3*(x+1))/3);

Verify(Integrate(x) 3/Sin(x),3*Ln(1/Sin(x)-Cos(x)/Sin(x)) );

Verify(Integrate(x) Ln(x), x*Ln(x)-x );
Expand Down

0 comments on commit 4466691

Please sign in to comment.