TransWikia.com

Unprotect the Integrate command

Mathematica Asked on December 10, 2020

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) = cint 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.

2 Answers

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

Correct answer by QuantumDot on December 10, 2020

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.

Answered by user42582 on December 10, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP