# Unprotect the Integrate command

I entered the follow code in order to tell Mathematica an integral result, which it is unable to evaluate originally:

Unprotect[Integrate];
Integrate[Log[1-x]*Log[1+x]^2/x,{x,0,1}]:= -Pi^4/240
Protect[Integrate]


Then I entered

Integrate[Log[1-x]*Log[1+x]^2/x,{x,0,1}]


Mathematica gives the result I input, which is fine. However, when I tried

Integrate[1+Log[1-x]*Log[1+x]^2/x,{x,0,1}]
Integrate[2*Log[1-x]*Log[1+x]^2/x,{x,0,1}]


Mathematica return them unevaluated (as if I hadn't made that definition at all).

My question is, is it possible to make Mathematica more intelligent in this aspect? For my purpose, I would already be satisfied if Mathematica knows to use the following two properties: $$\int f + \int g = \int(f+g) \qquad \int (cf) = c\int f$$ that is, whenever I defined the value of $\int f, \int g$, Mathematica can return $\int(f+g)$. My scope of integration will be solely single variable definite with exact arithmetic.

Thank you very much.

• MMA(11.0.1.0) evaluates Integrate[Log[1 - x] Log[1 + x]^2/x, {x, 0, 1}]==0 which is obviously wrong??? Dec 31 '17 at 17:26
• I understand that this comment does not address the question directly, but if you know the 'values'/formulas of $\int f, \int g$, then why would you want to calculate $\int f+g$ / $\int c f$ instead of performing the addition/multiplication directly? Dec 31 '17 at 17:26
• @user42582 The background is that I have several integral results $\int f_1, \int f_2 ,\cdots, \int f_n$ which Mathematica is unable to find out. However, their expression are all quite long, and I have to evaluate a bunch of integrals that are linear combinations of $f_i$ and other functions whose integral that Mathematica can originally calculate. Therefore it would be great if I could feed these integral results into Mathematica directly. Dec 31 '17 at 17:42
• @UlrichNeumann Mathematica 9.0, 10.3 and 11.2 return unevaluated. Mathematica 8.0, 10.4, 11.0, and 11.1 (incorrectly) returns 0. Very interesting history... Dec 31 '17 at 18:26
• The linearity properties you would like Mathematica to use are not generally valid, unless you can prove that the integrals are convergent. Dec 31 '17 at 18:41

You need a more general rule to do your integral:

Unprotect[Integrate];
Integrate[a_. + b_. Log[1 - x]*Log[1 + x]^2/x, {x, 0, 1}] /; FreeQ[b, x] :=
Integrate[a, {x, 0, 1}] - b Pi^4/240;
Protect[Integrate];


Then your examples work as intended:

Integrate[1+Log[1-x]*Log[1+x]^2/x,{x,0,1}]
Integrate[2*Log[1-x]*Log[1+x]^2/x,{x,0,1}]

1-π^4/240

-π^4/120


Unprotect-ing sounds scary.

"... I would already be satisfied if Mathematica knows to use the following two properties: [reversing addition and scalar multiplication for integrals]"

I am not sure if this is helpful, but you can define something like a linear operator that displays the behavior described in the question (and relevant comments):

Plus[int[f_, x_], int[g_, x_]] ^:= int[f + g, x]
Times[a_, int[f_, x_]] ^:= int[a f, x] /; FreeQ[a, x]


Assuming it is possible to replace all expressions like Log[1 - x] Log[1 + x]^2/x with appropriate symbols (eg Log[1 - x] Log[1 + x]^2/x->f1 etc) then evaluating eg a variation of the expressions in the question

int[1+f1,x] + int[2f1,x]


returns

int[1+3f1,x]


Effectively, what this answer proposes is to use the int operator in order to gather all the integrals that would otherwise not evaluate, in an expression of the form int[a1 f1+a2 f2+...an fn,x].

What is supposed to happen from then on is not clear to me.