Rules for integrands involving piecewise linear functions

1:  ∫(u^m)dx  when  (∂_x)u==c

Derivation: Integration by substitution

Basis: If  (∂_x)u==c, then (u^m)==(1/c)(u^m)(∂_x)u

Rule: If  (∂_x)u==c, then

∫(u^m)dx  ⟶  (1/c)Subst[∫(x^m)dx,x,u]

Program code:

Int[u_^m_.,x_Symbol] :=
  With[{c=Simplify[D[u,x]]},
  1/c*Subst[Int[x^m,x],x,u]] /;
FreeQ[m,x] && PiecewiseLinearQ[u,x]

2:  ∫(u^m) (v^n)dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0

1.  ∫((v^n)/u)dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0

1.  ∫((v^n)/u)dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ n>0

1:  ∫(v/u)dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0

Derivation: Piecewise linear recurrence 2 with m=-1 and n=1

Derivation: Inverted integration by parts

Rule: If  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0, then

∫(v/u)dx  ⟶  ((b x)/a)-((b u-a v)/a)∫(1/u)dx

Program code:

Int[v_/u_,x_Symbol] :=
  With[{a=Simplify[D[u,x]],b=Simplify[D[v,x]]},
  b*x/a - (b*u-a*v)/a*Int[1/u,x] /;
 NeQ[b*u-a*v,0]] /;
PiecewiseLinearQ[u,v,x]

2:  ∫((v^n)/u)dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ n>0 ∧ n≠1

Derivation: Piecewise linear recurrence 2 with m=-1

Derivation: Inverted integration by parts

Rule: If  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ n>0 ∧ n≠1, then

∫((v^n)/u)dx  ⟶  ((v^n)/(a n))-((b u-a v)/a)∫((v^(n-1))/u)dx

Program code:

Int[v_^n_/u_,x_Symbol] :=
  With[{a=Simplify[D[u,x]],b=Simplify[D[v,x]]},
  v^n/(a*n) - (b*u-a*v)/a*Int[v^(n-1)/u,x] /;
 NeQ[b*u-a*v,0]] /;
PiecewiseLinearQ[u,v,x] && GtQ[n,0] && NeQ[n,1]

2.  ∫((v^n)/u)dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ n<0

1:  ∫(1/(u v))dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0

Derivation: Algebraic expansion and piecewise constant extraction

Basis: (1/(u v))==(b/(b u-a v))(1/v)-(a/(b u-a v))(1/u)

Basis: If  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0, then (∂_x)(1/(b u-a v))==0

Rule: If  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0, then

∫(1/(u v))dx  ⟶  (b/(b u-a v))∫(1/v)dx-(a/(b u-a v))∫(1/u)dx

Program code:

Int[1/(u_*v_),x_Symbol] :=
  With[{a=Simplify[D[u,x]],b=Simplify[D[v,x]]},
  b/(b*u-a*v)*Int[1/v,x] - a/(b*u-a*v)*Int[1/u,x] /;
 NeQ[b*u-a*v,0]] /;
PiecewiseLinearQ[u,v,x]

2.  ∫(1/(u(Sqrt[v])))dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0

1:  ∫(1/(u(Sqrt[v])))dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ ((b u-a v)/a)>0

Rule: If (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ ((b u-a v)/a)>0, then

∫(1/(u (Sqrt[v])))dx  ⟶  (2/(a (Sqrt[((b u-a v)/a)])))ArcTan[((Sqrt[v])/(Sqrt[((b u-a v)/a)]))]

Program code:

Int[1/(u_*Sqrt[v_]),x_Symbol] :=
  With[{a=Simplify[D[u,x]],b=Simplify[D[v,x]]},
  2*ArcTan[Sqrt[v]/Rt[(b*u-a*v)/a,2]]/(a*Rt[(b*u-a*v)/a,2]) /;
 NeQ[b*u-a*v,0] && PosQ[(b*u-a*v)/a]] /;
PiecewiseLinearQ[u,v,x]

2:  ∫(1/(u(Sqrt[v])))dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ ¬(((b u-a v)/a)>0)

Rule: If  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ ¬(((b u-a v)/a)>0), then

∫(1/(u (Sqrt[v])))dx  ⟶  -(2/(a (Sqrt[-((b u-a v)/a)])))ArcTanh[((Sqrt[v])/(Sqrt[-((b u-a v)/a)]))]

Program code:

Int[1/(u_*Sqrt[v_]),x_Symbol] :=
  With[{a=Simplify[D[u,x]],b=Simplify[D[v,x]]},
  -2*ArcTanh[Sqrt[v]/Rt[-(b*u-a*v)/a,2]]/(a*Rt[-(b*u-a*v)/a,2]) /;
 NeQ[b*u-a*v,0] && NegQ[(b*u-a*v)/a]] /;
PiecewiseLinearQ[u,v,x]

3:  ∫((v^n)/u)dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ n<-1

Derivation: Piecewise linear recurrence 3 with n=-1

Derivation: Integration by parts

Rule: If  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ n<-1, then

∫((v^n)/u)dx  ⟶  ((v^(n+1))/((n+1)(b u-a v)))-((a (n+1))/((n+1)(b u-a v)))∫((v^(n+1))/u)dx

Program code:

Int[v_^n_/u_,x_Symbol] :=
  With[{a=Simplify[D[u,x]],b=Simplify[D[v,x]]},
  v^(n+1)/((n+1)*(b*u-a*v)) - 
  a*(n+1)/((n+1)*(b*u-a*v))*Int[v^(n+1)/u,x] /;
 NeQ[b*u-a*v,0]] /;
PiecewiseLinearQ[u,v,x] && LtQ[n,-1]

3:  ∫((v^n)/u)dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ n∉ℤ

Rule: If  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ n∉ℤ, then

∫((v^n)/u)dx  ⟶  ((v^(n+1))/((n+1) (b u-a v)))Hypergeometric2F1[1,n+1,n+2,-((a v)/(b u-a v))]

Program code:

Int[v_^n_/u_,x_Symbol] :=
  With[{a=Simplify[D[u,x]],b=Simplify[D[v,x]]},
  v^(n+1)/((n+1)*(b*u-a*v))*Hypergeometric2F1[1,n+1,n+2,-a*v/(b*u-a*v)] /;
 NeQ[b*u-a*v,0]] /;
PiecewiseLinearQ[u,v,x] && Not[IntegerQ[n]]

2.  ∫(1/((Sqrt[u])(Sqrt[v])))dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0

1:  ∫(1/((Sqrt[u])(Sqrt[v])))dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ a b>0

Rule: If  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ a b>0, then

∫(1/((Sqrt[u])(Sqrt[v])))dx  ⟶   (2/(Sqrt[a b]))ArcTanh[(((Sqrt[a b]) (Sqrt[u]))/(a(Sqrt[v])))]

Program code:

Int[1/(Sqrt[u_]*Sqrt[v_]),x_Symbol] :=
  With[{a=Simplify[D[u,x]],b=Simplify[D[v,x]]},
  2/Rt[a*b,2]*ArcTanh[Rt[a*b,2]*Sqrt[u]/(a*Sqrt[v])] /;
 NeQ[b*u-a*v,0] && PosQ[a*b]] /;
PiecewiseLinearQ[u,v,x]

2:  ∫(1/((Sqrt[u])(Sqrt[v])))dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ ¬(a b>0)

Rule: If  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ ¬(a b>0), then

∫(1/((Sqrt[u])(Sqrt[v])))dx  ⟶   (2/(Sqrt[-a b]))ArcTan[(((Sqrt[-a b]) (Sqrt[u]))/(a(Sqrt[v])))]

Program code:

Int[1/(Sqrt[u_]*Sqrt[v_]),x_Symbol] :=
  With[{a=Simplify[D[u,x]],b=Simplify[D[v,x]]},
  2/Rt[-a*b,2]*ArcTan[Rt[-a*b,2]*Sqrt[u]/(a*Sqrt[v])] /;
 NeQ[b*u-a*v,0] && NegQ[a*b]] /;
PiecewiseLinearQ[u,v,x]

3:  ∫(u^m) (v^n)dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ m+n+2==0 ∧ m≠-1

Derivation: Piecewise linear recurrence 3 with m+n+2==0

Rule: If  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ m+n+2==0 ∧ m≠-1, then

∫(u^m) (v^n)dx  ⟶   -(((u^(m+1)) (v^(n+1)))/((m+1)(b u-a v)))

Program code:

Int[u_^m_*v_^n_,x_Symbol] :=
  With[{a=Simplify[D[u,x]],b=Simplify[D[v,x]]},
  -u^(m+1)*v^(n+1)/((m+1)*(b*u-a*v)) /;
 NeQ[b*u-a*v,0]] /;
FreeQ[{m,n},x] && PiecewiseLinearQ[u,v,x] && EqQ[m+n+2,0] && NeQ[m,-1]

4:  ∫(u^m) (v^n)dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ m<-1 ∧ n>0

Derivation: Piecewise linear recurrence 1

Derivation: Integration by parts

Rule: If  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ m+n+2≠0 ∧ m<-1 ∧ n>0, then

∫(u^m) (v^n)dx  ⟶  (((u^(m+1)) (v^n))/(a(m+1)))-((b n)/(a(m+1)))∫(u^(m+1)) (v^(n-1))dx

Program code:

Int[u_^m_*v_^n_.,x_Symbol] :=
  With[{a=Simplify[D[u,x]],b=Simplify[D[v,x]]},
  u^(m+1)*v^n/(a*(m+1)) - 
  b*n/(a*(m+1))*Int[u^(m+1)*v^(n-1),x] /;
 NeQ[b*u-a*v,0]] /;
FreeQ[{m,n},x] && PiecewiseLinearQ[u,v,x] (* && NeQ[m+n+2,0] *) && NeQ[m,-1] && (
  LtQ[m,-1] && GtQ[n,0] && Not[ILtQ[m+n,-2] && (FractionQ[m] || GeQ[2*n+m+1,0])] || 
  IGtQ[n,0] && IGtQ[m,0] && LeQ[n,m] ||
(* ILtQ[n,0] && ILtQ[m,0] && LeQ[n,m] || *)
  IGtQ[n,0] && Not[IntegerQ[m]] ||
  ILtQ[m,0] && Not[IntegerQ[n]])

5:  ∫(u^m) (v^n)dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ m+n+2≠0 ∧ n>0 ∧ m+n+1≠0

Derivation: Piecewise linear recurrence 2

Derivation: Inverted integration by parts

Rule: If  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ m+n+2≠0 ∧ n>0 ∧ m+n+1≠0, then

∫(u^m)(v^n)dx  ⟶  (((u^(m+1)) (v^n))/(a(m+n+1)))-((n(b u-a v))/(a(m+n+1)))∫(u^m) (v^(n-1))dx

Program code:

Int[u_^m_*v_^n_.,x_Symbol] :=
  With[{a=Simplify[D[u,x]],b=Simplify[D[v,x]]},
  u^(m+1)*v^n/(a*(m+n+1)) - 
  n*(b*u-a*v)/(a*(m+n+1))*Int[u^m*v^(n-1),x] /;
 NeQ[b*u-a*v,0]] /;
PiecewiseLinearQ[u,v,x] && NeQ[m+n+2,0] && GtQ[n,0] && NeQ[m+n+1,0] && 
  Not[IGtQ[m,0] && (Not[IntegerQ[n]] || LtQ[0,m,n])] && 
  Not[ILtQ[m+n,-2]]

Int[u_^m_*v_^n_,x_Symbol] :=
  With[{a=Simplify[D[u,x]],b=Simplify[D[v,x]]},
  u^(m+1)*v^n/(a*(m+n+1)) - 
  n*(b*u-a*v)/(a*(m+n+1))*Int[u^m*v^Simplify[n-1],x] /;
 NeQ[b*u-a*v,0]] /;
PiecewiseLinearQ[u,v,x] && NeQ[m+n+1,0] && Not[RationalQ[n]] && SumSimplerQ[n,-1]

6:  ∫(u^m) (v^n)dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ m+n+2≠0 ∧ m<-1

Derivation: Piecewise linear recurrence 3

Derivation: Integration by parts

Basis: (u^m) (v^n)==(v^(m+n+2)) ((u^m)/(v^(m+2)))

Rule: If  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ m+n+2≠0 ∧ m<-1, then

∫(u^m)(v^n)dx  ⟶  -(((u^(m+1)) (v^(n+1)))/((m+1)(b u-a v)))+((b (m+n+2))/((m+1)(b u-a v)))∫(u^(m+1)) (v^n)dx

Program code:

Int[u_^m_*v_^n_,x_Symbol] :=
  With[{a=Simplify[D[u,x]],b=Simplify[D[v,x]]},
  -u^(m+1)*v^(n+1)/((m+1)*(b*u-a*v)) + 
  b*(m+n+2)/((m+1)*(b*u-a*v))*Int[u^(m+1)*v^n,x] /;
 NeQ[b*u-a*v,0]] /;
PiecewiseLinearQ[u,v,x] && NeQ[m+n+2,0] && LtQ[m,-1]

Int[u_^m_*v_^n_,x_Symbol] :=
  With[{a=Simplify[D[u,x]],b=Simplify[D[v,x]]},
  -u^(m+1)*v^(n+1)/((m+1)*(b*u-a*v)) + 
  b*(m+n+2)/((m+1)*(b*u-a*v))*Int[u^Simplify[m+1]*v^n,x] /;
 NeQ[b*u-a*v,0]] /;
PiecewiseLinearQ[u,v,x] && Not[RationalQ[m]] && SumSimplerQ[m,1]

7:  ∫(u^m) (v^n)dx  when  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ m∉ℤ ∧ n∉ℤ

Rule: If  (∂_x)u==a ∧ (∂_x)v==b ∧ b u-a v≠0 ∧ m∉ℤ ∧ n∉ℤ, then

∫(u^m)(v^n)dx  ⟶  (((u^m) (v^(n+1)))/(b (n+1) (((((b u)/(b u-a v))))^m)))Hypergeometric2F1[-m,n+1,n+2,-((a v)/(b u-a v))]

Program code:

Int[u_^m_*v_^n_,x_Symbol] :=
  With[{a=Simplify[D[u,x]],b=Simplify[D[v,x]]},
  u^m*v^(n+1)/(b*(n+1)*(b*u/(b*u-a*v))^m)*Hypergeometric2F1[-m,n+1,n+2,-a*v/(b*u-a*v)] /;
 NeQ[b*u-a*v,0]] /;
PiecewiseLinearQ[u,v,x] && Not[IntegerQ[m]] && Not[IntegerQ[n]]

3.  ∫(u^n)(((a+b x))^m)Log[a+b x]dx  when  (∂_x)u==c

1:  ∫(u^n)Log[a+b x]dx  when  (∂_x)u==c ∧ n>0

Derivation: Integration by parts

Basis: If  (∂_x)u==c, then (∂_x)((u^n)Log[a+b x])==((b (u^n))/(a+b x))+c n (u^(n-1))Log[a+b x]

Rule: If  (∂_x)u==c ∧ n>0, then

∫(u^n)Log[a+b x]dx  ⟶  (((u^n)(a+b x)Log[a+b x])/b)-∫(u^n)dx-((c n)/b)∫(u^(n-1))(a+b x) Log[a+b x]dx

Program code:

Int[u_^n_.*Log[a_.+b_.*x_],x_Symbol] :=
  With[{c=Simplify[D[u,x]]},
  u^n*(a+b*x)*Log[a+b*x]/b - 
  Int[u^n,x] - 
  c*n/b*Int[u^(n-1)*(a+b*x)*Log[a+b*x],x]] /;
FreeQ[{a,b},x] && PiecewiseLinearQ[u,x] && Not[LinearQ[u,x]] && GtQ[n,0]

2.  ∫(u^n)(((a+b x))^m)Log[a+b x]dx  when  (∂_x)u==c

x:  ∫(((u^n) Log[a+b x])/(a+b x))dx  when  (∂_x)u==c ∧ n>0

Derivation: Integration by parts with a double-back flip

Basis: If  (∂_x)u==c, then (∂_x)((u^n)Log[a+b x])==((b (u^n))/(a+b x))+c n (u^(n-1))Log[a+b x]

Rule: If  (∂_x)u==c ∧ n>0, then

∫(((u^n) Log[a+b x])/(a+b x))dx  ⟶  (((u^n)((Log[a+b x])^2))/(2b))-((c n)/(2b))∫(u^(n-1))((Log[a+b x])^2)dx

Program code:

(* Int[u_^n_.*Log[a_.+b_.*x_]/(a_.+b_.*x_),x_Symbol] :=
  With[{c=Simplify[D[u,x]]},
  u^n*Log[a+b*x]^2/(2*b) - 
  c*n/(2*b)*Int[u^(n-1)*Log[a+b*x]^2,x]] /;
FreeQ[{a,b},x] && PiecewiseLinearQ[u,x] && GtQ[n,0] *)

2:  ∫(u^n)(((a+b x))^m)Log[a+b x]dx  when  (∂_x)u==c ∧ n>0 ∧ m≠-1

Derivation: Integration by parts

Basis: If  (∂_x)u==c, then (∂_x)((u^n)Log[a+b x])==((b (u^n))/(a+b x))+c n (u^(n-1))Log[a+b x]

Rule: If  (∂_x)u==c ∧ n>0 ∧ m≠-1, then

∫(u^n)(((a+b x))^m)Log[a+b x]dx  ⟶  
(((u^n)(((a+b x))^(m+1))Log[a+b x])/(b(m+1)))-(1/(m+1))∫(u^n)(((a+b x))^m)dx-((c n)/(b(m+1)))∫(u^(n-1))(((a+b x))^(m+1))Log[a+b x]dx

Program code:

Int[u_^n_.*(a_.+b_.*x_)^m_.*Log[a_.+b_.*x_],x_Symbol] :=
  With[{c=Simplify[D[u,x]]},
  u^n*(a+b*x)^(m+1)*Log[a+b*x]/(b*(m+1)) - 
  1/(m+1)*Int[u^n*(a+b*x)^m,x] - 
  c*n/(b*(m+1))*Int[u^(n-1)*(a+b*x)^(m+1)*Log[a+b*x],x]] /;
FreeQ[{a,b,m},x] && PiecewiseLinearQ[u,x] && Not[LinearQ[u,x]] && GtQ[n,0] && NeQ[m,-1]