2

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.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
pisco
  • 229
  • 1
  • 6
  • MMA(11.0.1.0) evaluates Integrate[Log[1 - x] Log[1 + x]^2/x, {x, 0, 1}]==0 which is obviously wrong??? – Ulrich Neumann 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? – user42582 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. – pisco Dec 31 '17 at 17:42
  • @UlrichNeumann I am using an older version of Mathematica, here it returns it unevaluated. But the integral is obviously nonzero, as seen by numerical integration. Probably a bug? – pisco Dec 31 '17 at 17:44
  • @pisco125 : Probably yes – Ulrich Neumann Dec 31 '17 at 18:11
  • 1
    @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... – QuantumDot Dec 31 '17 at 18:26
  • 2
    The linearity properties you would like Mathematica to use are not generally valid, unless you can prove that the integrals are convergent. – Michael E2 Dec 31 '17 at 18:41
  • Possible duplicate: (6169); also related: (19534), (118938) – Michael E2 Dec 31 '17 at 18:52
  • 11.2 returns unevaluated if evaluated after starting Mathematica and 0 on subsequent evals (even after quitting and restarting the kernel) – user42582 Dec 31 '17 at 18:59
  • Another related Q&A: (64422) – Michael E2 Jan 01 '18 at 00:27

2 Answers2

8

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

QuantumDot
  • 19,601
  • 7
  • 45
  • 121
3

Unprotect-ing sounds scary.

This answer is trying to address the following (text in braces is added)

"... 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.

user42582
  • 4,195
  • 1
  • 10
  • 31