-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- new @FunctionalInterface Function4 represents a function with 4 args. - extracted PowerTimesFunction to determine pattern x^n_ * f_(m_*x)
- Loading branch information
Showing
5 changed files
with
163 additions
and
63 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
...brary/matheclipse-core/src/main/java/org/matheclipse/core/generic/PowerTimesFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package org.matheclipse.core.generic; | ||
|
||
import org.matheclipse.core.eval.EvalEngine; | ||
import org.matheclipse.core.expression.F; | ||
import org.matheclipse.core.expression.S; | ||
import org.matheclipse.core.interfaces.Function4; | ||
import org.matheclipse.core.interfaces.IAST; | ||
import org.matheclipse.core.interfaces.IASTAppendable; | ||
import org.matheclipse.core.interfaces.IExpr; | ||
|
||
/** | ||
* Analyze if a {@link S#Times} expression <code>factor1 * factor2</code> is of the form | ||
* <code>x^n_ * f_(m_*x)</code>. If <code>true</code> call the defined <code>function</code>. | ||
*/ | ||
public class PowerTimesFunction { | ||
Function4<IAST, IExpr, IExpr, IExpr, IExpr> function; | ||
|
||
/** | ||
* Define the function which should be called, if the form <code>x^n_ * f_(m_*x)</code> was found. | ||
* | ||
* @param function <code>function(f,x,n,m)</code> | ||
* @see #xPowNTimesFmx(IExpr, IExpr, IExpr, EvalEngine) | ||
*/ | ||
public PowerTimesFunction(Function4<IAST, IExpr, IExpr, IExpr, IExpr> function) { | ||
this.function = function; | ||
} | ||
|
||
/** | ||
* Analyze if <code>factor1 * factor2</code> is of the form <code>x^n_ * f_(m_*x)</code>. If | ||
* <code>true</code> call {@link #function}. | ||
* | ||
* @param factor1 | ||
* @param factor2 | ||
* @param x | ||
* | ||
* @return {@link F#NIL} if the expression is not of the form. | ||
*/ | ||
public IExpr xPowNTimesFmx(IExpr factor1, IExpr factor2, final IExpr x, EvalEngine engine) { | ||
IExpr n = F.NIL; | ||
if (factor1.equals(x)) { | ||
n = F.C1; | ||
} else if (factor2.equals(x)) { | ||
n = F.C1; | ||
IExpr temp = factor2; | ||
factor2 = factor1; | ||
factor1 = temp; | ||
} | ||
if (n.isNIL()) { | ||
if (factor1.isPower() && factor1.base().equals(x) | ||
&& (factor1.exponent().isInteger() || factor1.exponent().isVariable())) { | ||
if (!factor1.exponent().equals(x)) { | ||
n = factor1.exponent(); | ||
} | ||
} else if (factor2.isPower() && factor2.base().equals(x) | ||
&& (factor2.exponent().isInteger() || factor2.exponent().isVariable())) { | ||
if (!factor2.exponent().equals(x)) { | ||
n = factor2.exponent(); | ||
IExpr temp = factor2; | ||
factor2 = factor1; | ||
factor1 = temp; | ||
} | ||
} | ||
} | ||
if (n.isPresent() && factor2.isAST1()) { | ||
IExpr m = F.NIL; | ||
IExpr t2Arg1 = factor2.first(); | ||
if (t2Arg1.equals(x)) { | ||
m = F.C1; | ||
} else if (t2Arg1.isTimes()) { | ||
IAST timesAST = (IAST) t2Arg1; | ||
IASTAppendable[] filter = timesAST.filter(arg -> arg.equals(x)); | ||
if (filter[0].argSize() == 1) { | ||
IExpr rest = engine.evaluate(filter[1]); | ||
if (rest.isFree(x)) { | ||
m = rest; | ||
} | ||
} | ||
} | ||
if (m.isPresent()) { | ||
IExpr temp = function.apply((IAST) factor2, x, n, m); | ||
if (temp.isPresent()) { | ||
return engine.evaluate(temp); | ||
} | ||
} | ||
} | ||
return F.NIL; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...n/java/org/matheclipse/core/reflection/system/rules/IntegratePowerTimesFunctionRules.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.matheclipse.core.reflection.system.rules; | ||
|
||
import static org.matheclipse.core.expression.F.*; | ||
import org.matheclipse.core.interfaces.IAST; | ||
|
||
/** | ||
* <p>Generated by <code>org.matheclipse.core.preprocessor.RulePreprocessor</code>.</p> | ||
* <p>See GIT repository at: <a href="https://github.com/axkr/symja_android_library">github.com/axkr/symja_android_library under the tools directory</a>.</p> | ||
*/ | ||
public class IntegratePowerTimesFunctionRules { | ||
final public static IAST RULES = List( | ||
// {ArcCos,x_,n_,m_}:=(x^(1+n)*((2+n)*ArcCos(m*x)+m*x*Hypergeometric2F1(1/2,1+n/2,2+n/2,m^2*x^2)))/((1+n)*(2+n)) | ||
SetDelayed(List(ArcCos,x_,n_,m_), | ||
Times(Power(Times(Plus(C1,n),Plus(C2,n)),CN1),Power(x,Plus(C1,n)),Plus(Times(Plus(C2,n),ArcCos(Times(m,x))),Times(m,x,Hypergeometric2F1(C1D2,Plus(C1,Times(C1D2,n)),Plus(C2,Times(C1D2,n)),Times(Sqr(m),Sqr(x))))))), | ||
// {ArcCosh,x_,n_,m_}:=(x^(1+n)*(ArcCosh(m*x)+(-m*x*Sqrt(1-m^2*x^2)*Hypergeometric2F1(1/2,1+n/2,2+n/2,m^2*x^2))/((2+n)*Sqrt(-1+m*x)*Sqrt(1+m*x))))/(1+n) | ||
SetDelayed(List(ArcCosh,x_,n_,m_), | ||
Times(Power(Plus(C1,n),CN1),Power(x,Plus(C1,n)),Plus(ArcCosh(Times(m,x)),Times(CN1,m,x,Sqrt(Plus(C1,Times(CN1,Sqr(m),Sqr(x)))),Power(Times(Plus(C2,n),Sqrt(Plus(CN1,Times(m,x))),Sqrt(Plus(C1,Times(m,x)))),CN1),Hypergeometric2F1(C1D2,Plus(C1,Times(C1D2,n)),Plus(C2,Times(C1D2,n)),Times(Sqr(m),Sqr(x))))))), | ||
// {ArcCot,x_,n_,m_}:=(x^(1+n)*((2+n)*ArcCot(m*x)+m*x*Hypergeometric2F1(1,1+n/2,2+n/2,-m^2*x^2)))/((1+n)*(2+n)) | ||
SetDelayed(List(ArcCot,x_,n_,m_), | ||
Times(Power(Times(Plus(C1,n),Plus(C2,n)),CN1),Power(x,Plus(C1,n)),Plus(Times(Plus(C2,n),ArcCot(Times(m,x))),Times(m,x,Hypergeometric2F1(C1,Plus(C1,Times(C1D2,n)),Plus(C2,Times(C1D2,n)),Times(CN1,Sqr(m),Sqr(x))))))), | ||
// {ArcCoth,x_,n_,m_}:=(x^(1+n)*((2+n)*ArcCoth(m*x)-m*x*Hypergeometric2F1(1,1+n/2,2+n/2,m^2*x^2)))/((1+n)*(2+n)) | ||
SetDelayed(List(ArcCoth,x_,n_,m_), | ||
Times(Power(Times(Plus(C1,n),Plus(C2,n)),CN1),Power(x,Plus(C1,n)),Plus(Times(Plus(C2,n),ArcCoth(Times(m,x))),Times(CN1,m,x,Hypergeometric2F1(C1,Plus(C1,Times(C1D2,n)),Plus(C2,Times(C1D2,n)),Times(Sqr(m),Sqr(x))))))), | ||
// {ArcSin,x_,n_,m_}:=(x^(1+n)*((2+n)*ArcSin(m*x)-m*x*Hypergeometric2F1(1/2,1+n/2,2+n/2,m^2*x^2)))/((1+n)*(2+n)) | ||
SetDelayed(List(ArcSin,x_,n_,m_), | ||
Times(Power(Times(Plus(C1,n),Plus(C2,n)),CN1),Power(x,Plus(C1,n)),Plus(Times(Plus(C2,n),ArcSin(Times(m,x))),Times(CN1,m,x,Hypergeometric2F1(C1D2,Plus(C1,Times(C1D2,n)),Plus(C2,Times(C1D2,n)),Times(Sqr(m),Sqr(x))))))), | ||
// {ArcSinh,x_,n_,m_}:=(x^(1+n)*((2+n)*ArcSinh(m*x)-m*x*Hypergeometric2F1(1/2,1+n/2,2+n/2,-m^2*x^2)))/((1+n)*(2+n)) | ||
SetDelayed(List(ArcSinh,x_,n_,m_), | ||
Times(Power(Times(Plus(C1,n),Plus(C2,n)),CN1),Power(x,Plus(C1,n)),Plus(Times(Plus(C2,n),ArcSinh(Times(m,x))),Times(CN1,m,x,Hypergeometric2F1(C1D2,Plus(C1,Times(C1D2,n)),Plus(C2,Times(C1D2,n)),Times(CN1,Sqr(m),Sqr(x))))))), | ||
// {ArcTan,x_,n_,m_}:=x^(1+n)/((1+n)*(2+n))*((2+n)*ArcTan(m*x)-m*x*Hypergeometric2F1(1,1+n/2,2+n/2,-m^2*x^2)) | ||
SetDelayed(List(ArcTan,x_,n_,m_), | ||
Times(Power(Times(Plus(C1,n),Plus(C2,n)),CN1),Power(x,Plus(C1,n)),Plus(Times(Plus(C2,n),ArcTan(Times(m,x))),Times(CN1,m,x,Hypergeometric2F1(C1,Plus(C1,Times(C1D2,n)),Plus(C2,Times(C1D2,n)),Times(CN1,Sqr(m),Sqr(x))))))), | ||
// {ArcTanh,x_,n_,m_}:=(x^(1+n)*((2+n)*ArcTanh(m*x)-m*x*Hypergeometric2F1(1,1+n/2,2+n/2,m^2*x^2)))/((1+n)*(2+n)) | ||
SetDelayed(List(ArcTanh,x_,n_,m_), | ||
Times(Power(Times(Plus(C1,n),Plus(C2,n)),CN1),Power(x,Plus(C1,n)),Plus(Times(Plus(C2,n),ArcTanh(Times(m,x))),Times(CN1,m,x,Hypergeometric2F1(C1,Plus(C1,Times(C1D2,n)),Plus(C2,Times(C1D2,n)),Times(Sqr(m),Sqr(x))))))) | ||
); | ||
} |
10 changes: 10 additions & 0 deletions
10
symja_android_library/rules/IntegratePowerTimesFunctionRules.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
List(ArcCos,x_,n_,m_) := (x^(1+n)*((2+n)*ArcCos(m*x)+m*x*Hypergeometric2F1(1/2,1+n/2,2+n/2,m^2*x^2)))/((1+n)*(2+n)), | ||
List(ArcCosh,x_,n_,m_) := (x^(1+n)*(ArcCosh(m*x)+(-m*x*Sqrt(1-m^2*x^2)*Hypergeometric2F1(1/2,1+n/2,2+n/2,m^2*x^2))/((2+n)*Sqrt(-1+m*x)*Sqrt(1+m*x))))/(1+n), | ||
List(ArcCot,x_,n_,m_) := (x^(1+n)*((2+n)*ArcCot(m*x)+m*x*Hypergeometric2F1(1,1+n/2,2+n/2,-m^2*x^2)))/((1+n)*(2+n)), | ||
List(ArcCoth,x_,n_,m_) := (x^(1+n)*((2+n)*ArcCoth(m*x)-m*x*Hypergeometric2F1(1,1+n/2,2+n/2,m^2*x^2)))/((1+n)*(2+n)), | ||
List(ArcSin,x_,n_,m_) := (x^(1+n)*((2+n)*ArcSin[m*x]-m*x*Hypergeometric2F1[1/2,1+n/2,2+n/2,m^2*x^2]))/((1+n)*(2+n)), | ||
List(ArcSinh,x_,n_,m_) := (x^(1+n)*((2+n)*ArcSinh(m*x)-m*x*Hypergeometric2F1(1/2,1+n/2,2+n/2,-m^2*x^2)))/((1+n)*(2+n)), | ||
List(ArcTan,x_,n_,m_) := x^(1+n)/((1+n)*(2+n))*((2+n)*ArcTan(m*x)-m*x*Hypergeometric2F1(1,1+n/2,2+n/2,-m^2*x^2)), | ||
List(ArcTanh,x_,n_,m_) := (x^(1+n)*((2+n)*ArcTanh(m*x)-m*x*Hypergeometric2F1(1,1+n/2,2+n/2,m^2*x^2)))/((1+n)*(2+n)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters