Skip to content

Commit

Permalink
Isuue #490 improved ZTransform, HurwitzLerchPhi, PolyLog
Browse files Browse the repository at this point in the history
  • Loading branch information
axkr committed Apr 9, 2022
1 parent b07fafb commit 6371cd8
Show file tree
Hide file tree
Showing 8 changed files with 248 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.matheclipse.core.expression.F;
import org.matheclipse.core.expression.S;
import org.matheclipse.core.interfaces.IAST;
import org.matheclipse.core.interfaces.IASTAppendable;
import org.matheclipse.core.interfaces.IExpr;
import org.matheclipse.core.reflection.system.rules.ZTransformRules;

Expand All @@ -25,6 +26,7 @@ public IAST getRuleAST() {

@Override
public IExpr evaluate(final IAST ast, EvalEngine engine) {
// see http://www.reduce-algebra.com/docs/ztrans.pdf
try {
final IExpr fx = ast.arg1();
if (fx.isIndeterminate()) {
Expand Down Expand Up @@ -63,6 +65,27 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
IExpr rest = function.removeAtCopy(indx);
return F.Times(arg, F.ZTransform(rest, n, z));
}
if (!function.isExpanded()) {
return ast.setAtCopy(1, F.ExpandAll(function));
}
} else if (function.isPower()) {
if (!function.isExpanded()) {
return ast.setAtCopy(1, F.ExpandAll(function));
}
}
if (function.isAST1() && function.arg1().isPlus2()) {
IAST plus2 = (IAST) function.arg1();
int k = plus2.first().toIntDefault();
if (k > 0 && plus2.second().equals(n)) {
// shift equation case
IASTAppendable sum = F.PlusAlloc(k + 1);
for (int i = 0; i < k; i++) {
sum.append(F.Times(F.CN1, F.Power(z, F.ZZ(k - i)), function.setAtCopy(1, F.ZZ(i))));
}
sum.append(
F.Times(F.Power(z, F.ZZ(k)), F.ZTransform(function.setAtCopy(1, n), n, z)));
return sum;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.matheclipse.core.reflection.system.rules;

import static org.matheclipse.core.expression.F.*;
import org.matheclipse.core.interfaces.ISymbol;
import org.matheclipse.core.interfaces.IAST;
import org.matheclipse.core.patternmatching.Matcher;

/**
* <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 interface HurwitzLerchPhiRules {
/**
* <ul>
* <li>index 0 - number of equal rules in <code>RULES</code></li>
* </ul>
*/
final public static int[] SIZES = { 1, 3 };

final public static IAST RULES = List(
IInit(HurwitzLerchPhi, SIZES),
// HurwitzLerchPhi(0,1,1)=1
ISet(HurwitzLerchPhi(C0,C1,C1),
C1),
// HurwitzLerchPhi(z_,s_,1):=PolyLog(s,z)/z
ISetDelayed(HurwitzLerchPhi(z_,s_,C1),
Times(Power(z,CN1),PolyLog(s,z))),
// HurwitzLerchPhi(z_,0,a_):=1/(1-z)
ISetDelayed(HurwitzLerchPhi(z_,C0,a_),
Power(Subtract(C1,z),CN1)),
// HurwitzLerchPhi(0,s_,a_):=a^(-s)
ISetDelayed(HurwitzLerchPhi(C0,s_,a_),
Power(a,Negate(s))),
// HurwitzLerchPhi(z_,1,1):=-Log(1-z)/z
ISetDelayed(HurwitzLerchPhi(z_,C1,C1),
Times(CN1,Power(z,CN1),Log(Subtract(C1,z)))),
// HurwitzLerchPhi(-1,s_,1):=(1-2^(1-s))*Zeta(s)
ISetDelayed(HurwitzLerchPhi(CN1,s_,C1),
Times(Subtract(C1,Power(C2,Subtract(C1,s))),Zeta(s))),
// HurwitzLerchPhi(0,1,a_):=1/a
ISetDelayed(HurwitzLerchPhi(C0,C1,a_),
Power(a,CN1))
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface PolyLogRules {
* <li>index 0 - number of equal rules in <code>RULES</code></li>
* </ul>
*/
final public static int[] SIZES = { 8, 1 };
final public static int[] SIZES = { 9, 1 };

final public static IAST RULES = List(
IInit(PolyLog, SIZES),
Expand Down Expand Up @@ -43,6 +43,12 @@ public interface PolyLogRules {
// PolyLog(2,1+I)=Pi^2/16+I*Catalan+I*Pi*Log(2)/4
ISet(PolyLog(C2,CC(1L,1L,1L,1L)),
Plus(Times(CI,Catalan),Times(QQ(1L,16L),Sqr(Pi)),Times(CC(0L,1L,1L,4L),Pi,Log(C2)))),
// PolyLog(3,1/2)=1/24*(-2*Pi^2*Log(2)+4*Log(2)^3+21*Zeta(3))
ISet(PolyLog(C3,C1D2),
Times(QQ(1L,24L),Plus(Times(CN2,Sqr(Pi),Log(C2)),Times(C4,Power(Log(C2),C3)),Times(ZZ(21L),Zeta(C3))))),
// PolyLog(i_Integer,z_):=Module({n=-i},Sum(Sum((-1)^(k+1)*Binomial(n+1,-1+k)*(-k+m+1)^n,{k,1,m})*z^m,{m,1,n})/(1-z)^(n+1)/;i<0)
ISetDelayed(PolyLog($p(i, Integer),z_),
Module(list(Set(n,Negate(i))),Condition(Times(Power(Power(Subtract(C1,z),Plus(n,C1)),CN1),Sum(Times(Sum(Times(Power(CN1,Plus(k,C1)),Binomial(Plus(n,C1),Plus(CN1,k)),Power(Plus(Negate(k),m,C1),n)),list(k,C1,m)),Power(z,m)),list(m,C1,n))),Less(i,C0)))),
// PolyLog(Undefined,y_):=Undefined
ISetDelayed(PolyLog(Undefined,y_),
Undefined),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,63 @@ public interface ZTransformRules {
* <li>index 0 - number of equal rules in <code>RULES</code></li>
* </ul>
*/
final public static int[] SIZES = { 0, 1 };
final public static int[] SIZES = { 0, 15 };

final public static IAST RULES = List(
IInit(ZTransform, SIZES),
// ZTransform(a_^n_*f_,n_?NotListQ,z_?NotListQ):=ZTransform(f,n,z/a)/;FreeQ(a,n)&&FreeQ(a,z)
ISetDelayed(ZTransform(Times(Power(a_,n_),f_),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Condition(ZTransform(f,n,Times(Power(a,CN1),z)),And(FreeQ(a,n),FreeQ(a,z)))),
// ZTransform(f_*n_,n_?NotListQ,z_?NotListQ):=-z*D(ZTransform(f,n,z),z)
ISetDelayed(ZTransform(Times(f_,n_),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Times(CN1,z,D(ZTransform(f,n,z),z))),
// ZTransform(f_*n_^2,n_?NotListQ,z_?NotListQ):=z*D(ZTransform(f,n,z),z)+z^2*D(ZTransform(f,n,z),{z,2})
ISetDelayed(ZTransform(Times(f_,Sqr(n_)),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Plus(Times(z,D(ZTransform(f,n,z),z)),Times(Sqr(z),D(ZTransform(f,n,z),list(z,C2))))),
// ZTransform(f_*n_^3,n_?NotListQ,z_?NotListQ):=-z*D(ZTransform(f,n,z),z)-3*z^2*D(ZTransform(f,n,z),{z,2})-z^3*D(ZTransform(f,n,z),{z,3})
ISetDelayed(ZTransform(Times(f_,Power(n_,C3)),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Plus(Times(CN1,z,D(ZTransform(f,n,z),z)),Times(CN3,Sqr(z),D(ZTransform(f,n,z),list(z,C2))),Times(CN1,Power(z,C3),D(ZTransform(f,n,z),list(z,C3))))),
// ZTransform(a_^n_,n_?NotListQ,z_?NotListQ):=z/(-a+z)/;FreeQ(a,n)&&FreeQ(a,z)
ISetDelayed(ZTransform(Power(a_,n_),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Condition(Times(z,Power(Plus(Negate(a),z),CN1)),And(FreeQ(a,n),FreeQ(a,z))))
Condition(Times(z,Power(Plus(Negate(a),z),CN1)),And(FreeQ(a,n),FreeQ(a,z)))),
// ZTransform(a_^(f_*n_),n_?NotListQ,z_?NotListQ):=z/(-a^f+z)/;FreeQ({a,f},n)&&FreeQ({a,f},z)
ISetDelayed(ZTransform(Power(a_,Times(f_,n_)),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Condition(Times(z,Power(Plus(Negate(Power(a,f)),z),CN1)),And(FreeQ(list(a,f),n),FreeQ(list(a,f),z)))),
// ZTransform(f_./(g_+n_),n_?NotListQ,z_?NotListQ):=f*HurwitzLerchPhi(1/z,1,g)/;FreeQ({f,g},n)&&FreeQ({f,g},z)
ISetDelayed(ZTransform(Times(f_DEFAULT,Power(Plus(g_,n_),CN1)),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Condition(Times(f,HurwitzLerchPhi(Power(z,CN1),C1,g)),And(FreeQ(list(f,g),n),FreeQ(list(f,g),z)))),
// ZTransform(1/n_!,n_?NotListQ,z_?NotListQ):=E^(1/z)/;FreeQ({f,g},n)&&FreeQ({f,g},z)
ISetDelayed(ZTransform(Power(Factorial(n_),CN1),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Condition(Exp(Power(z,CN1)),And(FreeQ(list(f,g),n),FreeQ(list(f,g),z)))),
// ZTransform(f_./(n_!*g_.),n_?NotListQ,z_?NotListQ):=(E^(1/z)*f)/g/;FreeQ({f,g},n)&&FreeQ({f,g},z)
ISetDelayed(ZTransform(Times(Power(Factorial(n_),CN1),f_DEFAULT,Power(g_DEFAULT,CN1)),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Condition(Times(Exp(Power(z,CN1)),f,Power(g,CN1)),And(FreeQ(list(f,g),n),FreeQ(list(f,g),z)))),
// ZTransform(f_./(1+2*n_)!,n_?NotListQ,z_?NotListQ):=Sqrt(z)*f*Sinh(1/Sqrt(z))/;FreeQ(f,n)&&FreeQ(f,z)
ISetDelayed(ZTransform(Times(Power(Factorial(Plus(C1,Times(C2,n_))),CN1),f_DEFAULT),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Condition(Times(Sqrt(z),f,Sinh(Power(z,CN1D2))),And(FreeQ(f,n),FreeQ(f,z)))),
// ZTransform(Cos(f_.*n_)/n_!,n_?NotListQ,z_?NotListQ):=E^(Cos(f)/z)*Cos(Sin(f)/z)/;FreeQ(f,n)&&FreeQ(f,z)
ISetDelayed(ZTransform(Times(Cos(Times(f_DEFAULT,n_)),Power(Factorial(n_),CN1)),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Condition(Times(Exp(Times(Power(z,CN1),Cos(f))),Cos(Times(Power(z,CN1),Sin(f)))),And(FreeQ(f,n),FreeQ(f,z)))),
// ZTransform(Sin(f_.*n_)/n_!,n_?NotListQ,z_?NotListQ):=E^(Cos(f)/z)*Sin(Sin(f)/z)/;FreeQ(f,n)&&FreeQ(f,z)
ISetDelayed(ZTransform(Times(Power(Factorial(n_),CN1),Sin(Times(f_DEFAULT,n_))),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Condition(Times(Exp(Times(Power(z,CN1),Cos(f))),Sin(Times(Power(z,CN1),Sin(f)))),And(FreeQ(f,n),FreeQ(f,z)))),
// ZTransform(Cos(f_.*(1+n_))/(1+n_),n_?NotListQ,z_?NotListQ):=1/2*z*(-Log((E^(I*f)-1/z)/E^(I*f))-Log(1-E^(I*f)/z))/;FreeQ(f,n)&&FreeQ(f,z)
ISetDelayed(ZTransform(Times(Cos(Times(f_DEFAULT,Plus(C1,n_))),Power(Plus(C1,n_),CN1)),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Condition(Times(C1D2,z,Subtract(Negate(Log(Times(Power(Exp(Times(CI,f)),CN1),Subtract(Exp(Times(CI,f)),Power(z,CN1))))),Log(Plus(C1,Times(CN1,Exp(Times(CI,f)),Power(z,CN1)))))),And(FreeQ(f,n),FreeQ(f,z)))),
// ZTransform(Sin(f_.*(1+n_))/(1+n_),n_?NotListQ,z_?NotListQ):=(-1/2)*I*z*(Log((E^(I*f)-1/z)/E^(I*f))-Log(1-E^(I*f)/z))/;FreeQ(f,n)&&FreeQ(f,z)
ISetDelayed(ZTransform(Times(Sin(Times(f_DEFAULT,Plus(C1,n_))),Power(Plus(C1,n_),CN1)),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Condition(Times(CN1D2,CI,z,Subtract(Log(Times(Power(Exp(Times(CI,f)),CN1),Subtract(Exp(Times(CI,f)),Power(z,CN1)))),Log(Plus(C1,Times(CN1,Exp(Times(CI,f)),Power(z,CN1)))))),And(FreeQ(f,n),FreeQ(f,z)))),
// ZTransform(Cos(f_.*n_+t_.),n_?NotListQ,z_?NotListQ):=(z*(-Cos(f-t)+z*Cos(t)))/(1+z^2-2*z*Cos(f))/;FreeQ({f,t},n)&&FreeQ({f,t},z)
ISetDelayed(ZTransform(Cos(Plus(Times(f_DEFAULT,n_),t_DEFAULT)),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Condition(Times(z,Power(Plus(C1,Sqr(z),Times(CN2,z,Cos(f))),CN1),Plus(Negate(Cos(Subtract(f,t))),Times(z,Cos(t)))),And(FreeQ(list(f,t),n),FreeQ(list(f,t),z)))),
// ZTransform(Cosh(f_.*n_+t_.),n_?NotListQ,z_?NotListQ):=(z*(-Cosh(f-t)+z*Cosh(t)))/(1+z^2-2*z*Cosh(f))/;FreeQ({f,t},n)&&FreeQ({f,t},z)
ISetDelayed(ZTransform(Cosh(Plus(Times(f_DEFAULT,n_),t_DEFAULT)),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Condition(Times(z,Power(Plus(C1,Sqr(z),Times(CN2,z,Cosh(f))),CN1),Plus(Negate(Cosh(Subtract(f,t))),Times(z,Cosh(t)))),And(FreeQ(list(f,t),n),FreeQ(list(f,t),z)))),
// ZTransform(Sin(f_.*n_+t_.),n_?NotListQ,z_?NotListQ):=(z*(Sin(f-t)+z*Sin(t)))/(1+z^2-2*z*Cos(f))/;FreeQ({f,t},n)&&FreeQ({f,t},z)
ISetDelayed(ZTransform(Sin(Plus(Times(f_DEFAULT,n_),t_DEFAULT)),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Condition(Times(z,Power(Plus(C1,Sqr(z),Times(CN2,z,Cos(f))),CN1),Plus(Sin(Subtract(f,t)),Times(z,Sin(t)))),And(FreeQ(list(f,t),n),FreeQ(list(f,t),z)))),
// ZTransform(Sinh(f_.*n_+t_.),n_?NotListQ,z_?NotListQ):=(z*(Sinh(f-t)+z*Sinh(t)))/(1+z^2-2*z*Cosh(f))/;FreeQ({f,t},n)&&FreeQ({f,t},z)
ISetDelayed(ZTransform(Sinh(Plus(Times(f_DEFAULT,n_),t_DEFAULT)),PatternTest(n_,NotListQ),PatternTest(z_,NotListQ)),
Condition(Times(z,Power(Plus(C1,Sqr(z),Times(CN2,z,Cosh(f))),CN1),Plus(Sinh(Subtract(f,t)),Times(z,Sinh(t)))),And(FreeQ(list(f,t),n),FreeQ(list(f,t),z))))
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,76 @@ public void testInverseZTransform001() {


public void testZTransform001() {
check("ZTransform(a*f(n)+ b*g(n), n, z)", //
"a*ZTransform(f(n),n,z)+b*ZTransform(g(n),n,z)");
check("ZTransform(n^2*f(n),n,z)", //
"z*Derivative(0,0,1)[ZTransform][f(n),n,z]+z^2*Derivative(0,0,2)[ZTransform][f(n),n,z]");
check("ZTransform(f(1+n),n,z)", //
"-z*f(0)+z*ZTransform(f(n),n,z)");
check("ZTransform(f(4+n),n,z)", //
"-z^4*f(0)-z^3*f(1)-z^2*f(2)-z*f(3)+z^4*ZTransform(f(n),n,z)");
check("ZTransform(f(5+n),n,z)", //
"-z^5*f(0)-z^4*f(1)-z^3*f(2)-z^2*f(3)-z*f(4)+z^5*ZTransform(f(n),n,z)");

check("ZTransform(a*f(n)+ b*g(n), n, z)", //
"a*ZTransform(f(n),n,z)+b*ZTransform(g(n),n,z)");
check("ZTransform(f(a)^n, n, z)", //
"z/(z-f(a))");
check("ZTransform(f(a)^(f(b)*n), n, z)", //
"z/(z-f(a)^f(b))");
check("ZTransform(f[a]/(n+f[b]),n,z)", //
"f(a)*HurwitzLerchPhi(1/z,1,f(b))");
check("ZTransform(1/(n+k),n,z)", //
"HurwitzLerchPhi(1/z,1,k)");
check("ZTransform(1/(k*n!),n,z)", //
"E^(1/z)/k");
check("ZTransform(1/n!,n,z)", //
"E^(1/z)");
check("ZTransform(f(a)/(2*n+1)!,n,z)", //
"Sqrt(z)*f(a)*Sinh(1/Sqrt(z))");
check("ZTransform(Cos(f(a)*n)/n!,n,z)", //
"E^(Cos(f(a))/z)*Cos(Sin(f(a))/z)");
check("ZTransform(Cos(n)/n!,n,z)", //
"E^(Cos(1)/z)*Cos(Sin(1)/z)");
check("ZTransform(Sin(f(a)*n)/n!,n,z)", //
"E^(Cos(f(a))/z)*Sin(Sin(f(a))/z)");
check("ZTransform(Sin(n)/n!,n,z)", //
"E^(Cos(1)/z)*Sin(Sin(1)/z)");
check("ZTransform(Cos(n+1)/(n+1),n,z)", //
"1/2*z*(-Log((E^I-1/z)/E^I)-Log(1-E^I/z))");
check("ZTransform(Sin(f*(n+1))/(n+1),n,z)", //
"-I*1/2*z*(Log((E^(I*f)-1/z)/E^(I*f))-Log(1-E^(I*f)/z))");
}

public void testZTransform002() {
check("ZTransform((-1)^n*n^2,n,z)", //
"z^2*((2*z)/(1+z)^3-2/(1+z)^2)+z*(-z/(1+z)^2+1/(1+z))");
check("ZTransform(Cos(n*Omega*t),n,z)", //
"(z*(z-Cos(omega*t)))/(1+z^2-2*z*Cos(omega*t))");
check("ZTransform(Cos(n+t),n,z)", //
"(z*(-Cos(1-t)+z*Cos(t)))/(1+z^2-2*z*Cos(1))");
check("ZTransform(Cos(n*t+a),n,z)", //
"(z*(z*Cos(a)-Cos(a-t)))/(1+z^2-2*z*Cos(t))");
check("ZTransform(Cosh(n*t+a),n,z)", //
"(z*(z*Cosh(a)-Cosh(a-t)))/(1+z^2-2*z*Cosh(t))");
check("ZTransform(Sin(n+t),n,z)", //
"(z*(Sin(1-t)+z*Sin(t)))/(1+z^2-2*z*Cos(1))");
check("ZTransform(Sin(f*n+t),n,z)", //
"(z*(Sin(f-t)+z*Sin(t)))/(1+z^2-2*z*Cos(f))");
check("ZTransform(Sinh(f*n+t),n,z)", //
"(z*(Sinh(f-t)+z*Sinh(t)))/(1+z^2-2*z*Cosh(f))");
check("ZTransform(n*Cos(b*n)/(n!),n,z)", //
"z*((E^(Cos(b)/z)*Cos(b)*Cos(Sin(b)/z))/z^2+(-E^(Cos(b)/z)*Sin(b)*Sin(Sin(b)/z))/z^\n"
+ "2)");
// check("ZTransform(Cos(b*(n+2))/(n+2),n,z)", //
// "(z*(Sinh(f-t)+z*Sinh(t)))/(1+z^2-2*z*Cosh(f))");

check("ZTransform((1+n)^2*f(n),n,z)", //
"ZTransform(f(n),n,z)-z*Derivative(0,0,1)[ZTransform][f(n),n,z]+z^2*Derivative(0,\n"
+ "0,2)[ZTransform][f(n),n,z]");
check("ZTransform((1+n)^2*Sin(n),n,z)", //
"(z*Sin(1))/(1+z^2-2*z*Cos(1))+z^2*((-2*z*(2*z-2*Cos(1))*(-2*z+2*Cos(1))*Sin(1))/(\n"
+ "1+z^2-2*z*Cos(1))^3+(-2*z*Sin(1))/(1+z^2-2*z*Cos(1))^2+(2*(-2*z+2*Cos(1))*Sin(1))/(\n"
+ "1+z^2-2*z*Cos(1))^2)+z*((z*(-2*z+2*Cos(1))*Sin(1))/(1+z^2-2*z*Cos(1))^2+Sin(1)/(\n"
+ "1+z^2-2*z*Cos(1)))-z*((2*z*(-2*z+2*Cos(1))*Sin(1))/(1+z^2-2*z*Cos(1))^2+(2*Sin(1))/(\n"
+ "1+z^2-2*z*Cos(1)))");
}
}
10 changes: 10 additions & 0 deletions symja_android_library/rules/HurwitzLerchPhiRules.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
HurwitzLerchPhi(0, 1, 1) = 1,

HurwitzLerchPhi(z_, s_, 1) := PolyLog(s,z)/z,
HurwitzLerchPhi(z_, 0, a_) := 1/(1-z),
HurwitzLerchPhi(0, s_, a_) := a^(-s),
HurwitzLerchPhi(z_, 1, 1) := -Log(1-z)/z,
HurwitzLerchPhi(-1, s_, 1) := (1-2^(1-s))*Zeta(s),
HurwitzLerchPhi(0, 1, a_) := 1/a
}
3 changes: 3 additions & 0 deletions symja_android_library/rules/PolyLogRules.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
PolyLog(2,-I)=(-I)*Catalan-Pi^2/48,
PolyLog(2,1-I)=Pi^2/16-I*Catalan-I*Pi*(Log(2)/4),
PolyLog(2,1+I)=Pi^2/16+I*Catalan+I*Pi*(Log(2)/4),
PolyLog(3,1/2)=(1/24)*(-2*Pi^2*Log(2)+4*Log(2)^3+21*Zeta(3)),

PolyLog(i_Integer, z_) := Module({n=(-i)}, Sum(Sum((-1)^(k + 1)*Binomial(n+1, k-1)*(m-k+1)^n, {k, 1, m}) * z^m, {m, 1, n}) / (1-z)^(n+1) /; i<0 ),

PolyLog(Undefined, y_):=Undefined,
PolyLog(x_, Undefined):=Undefined
Expand Down
41 changes: 40 additions & 1 deletion symja_android_library/rules/ZTransformRules.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
{
(* see http://www.reduce-algebra.com/docs/ztrans.pdf *)
ZTransform(a_^n_*f_,n_?NotListQ,z_?NotListQ):= ZTransform(f,n,z/a)
/; FreeQ(a,n)&&FreeQ(a,z),
ZTransform(n_*f_,n_?NotListQ,z_?NotListQ):= (-1)*z*D(ZTransform(f,n,z),z),
ZTransform(n_^2*f_,n_?NotListQ,z_?NotListQ):= z*D(ZTransform(f,n,z),z)+z^2*D(ZTransform(f,n,z),{z,2}),
ZTransform(n_^3*f_,n_?NotListQ,z_?NotListQ):= -z*D(ZTransform(f,n,z),z)-3*z^2*D(ZTransform(f,n,z),{z,2})-z^3*D(ZTransform(f,n,z),{z,3}),
(* ZTransform(n_^k_Integer*f_,n_?NotListQ,z_?NotListQ):=(-1)*z*D(ZTransform(n^(k-1)*f,n,z),z)
/; k>0,
*)

ZTransform(a_^n_ ,n_?NotListQ,z_?NotListQ):=z/(z-a)
/; FreeQ(a,n)&&FreeQ(a,z)
/; FreeQ(a,n)&&FreeQ(a,z),
ZTransform(a_^(f_*n_) ,n_?NotListQ,z_?NotListQ):=z/(z-a^f)
/; FreeQ({a,f},n)&&FreeQ({a,f},z),
ZTransform(f_./(n_+g_),n_?NotListQ,z_?NotListQ):=f*HurwitzLerchPhi(1/z, 1, g)
/; FreeQ({f,g},n)&&FreeQ({f,g},z),
ZTransform((n_!)^(-1),n_?NotListQ,z_?NotListQ):=(E^(1/z))
/; FreeQ({f,g},n)&&FreeQ({f,g},z) ,
ZTransform(f_./(g_.*n_!),n_?NotListQ,z_?NotListQ):=(E^(1/z)*f)/g
/; FreeQ({f,g},n)&&FreeQ({f,g},z),
ZTransform(f_./(2*n_+1)!,n_?NotListQ,z_?NotListQ):=Sqrt(z)*f*Sinh(1/Sqrt(z))
/; FreeQ(f,n)&&FreeQ(f,z),
ZTransform(Cos(f_.*n_)/(n_)!,n_?NotListQ,z_?NotListQ):=E^(Cos(f)/z)*Cos(Sin(f)/z)
/; FreeQ(f,n)&&FreeQ(f,z),
ZTransform(Sin(f_.*n_)/(n_)!,n_?NotListQ,z_?NotListQ):=E^(Cos(f)/z)*Sin(Sin(f)/z)
/; FreeQ(f,n)&&FreeQ(f,z),
ZTransform(Cos(f_.*(n_+1))/(n_+1),n_?NotListQ,z_?NotListQ):=(1/2)*z*(-Log((E^(I*f)-1/z)/E^(I*f))-Log(1-E^(I*f)/z))
/; FreeQ(f,n)&&FreeQ(f,z),
ZTransform(Sin(f_.*(n_+1))/(n_+1),n_?NotListQ,z_?NotListQ):=(-(1/2))*I*z*(Log((E^(I*f)-1/z)/E^(I*f))-Log(1 - E^(I*f)/z))
/; FreeQ(f,n)&&FreeQ(f,z),

ZTransform(Cos(f_.*n_+t_.),n_?NotListQ,z_?NotListQ):=(z*(-Cos(f-t)+z*Cos(t)))/(1+z^2-2*z*Cos(f))
/; FreeQ({f,t},n)&&FreeQ({f,t},z),
ZTransform(Cosh(f_.*n_+t_.),n_?NotListQ,z_?NotListQ):=(z*(-Cosh(f-t) + z*Cosh(t)))/(1 + z^2 - 2*z*Cosh(f))
/; FreeQ({f,t},n)&&FreeQ({f,t},z),

ZTransform(Sin(f_.*n_+t_.),n_?NotListQ,z_?NotListQ):=(z*(Sin(f-t)+z*Sin(t)))/(1 +z^2-2*z*Cos(f))
/; FreeQ({f,t},n)&&FreeQ({f,t},z),
ZTransform(Sinh(f_.*n_+t_.),n_?NotListQ,z_?NotListQ):=(z*(Sinh(f-t)+ z*Sinh(t)))/(1+z^2-2*z*Cosh(f))
/; FreeQ({f,t},n)&&FreeQ({f,t},z)

}

0 comments on commit 6371cd8

Please sign in to comment.