0
$\begingroup$

I observe some strange behaviour of Mathematica when pulling functions into the integrator. I know that Mathematica's capabilities are limited when computing Stieltje or Lebesgue Integrals. But even simple outputs behave quite strangely:

Integrate[f'[x], x]
Integrate[1, f[x]]

Gives, correctly:

f[x]
f[x]

But

Integrate[x  f'[x], x]
Integrate[x, f[x]]

Returns quite strangely: enter image description here

Hence, as @Ulrich Neumann suggests, the second formulation contains the implicit assumption that g'[x] is Riemann integrable. It seems that Mathematica treats f[x] as a separate variable with not dependence on x.

$\endgroup$
1
  • $\begingroup$ Probably Mathematica "knows" Integrate[x, f[x]]==Integrate[x f'[x]],x] $\endgroup$ Commented Jul 2 at 9:26

2 Answers 2

4
$\begingroup$

You can write is as

\begin{align*} \int xd\left( f\left( x\right) \right) & =\int x\frac{df}{dx}dx\\ & =\int xf^{\prime}dx \end{align*}

And Mathematica gives now

 Integrate[x*f'[x], x]

enter image description here

I do not understand how Mathematica operates when Integrating with respect to functions

It looks like you need to reformulate the command yourself like the above so that the integration is with respect to a variable and not a function.

I do not know why Mathematica gave the result it did with your input.

update

fyi, I tried this in Rubi, and Maple 20204 and Fricas and Maxima and XCas/GIAC. Out of these, maxima and giac returned back same result as Mathematica. This is the result

<< Rubi`
Int[x, f[x]]

enter image description here

Maple:

int(x,f(x))

enter image description here

Fricas:

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.3, Release Date: 2024-03-19                    │
│ Using Python 3.11.1. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x')
x
sage: f=function("f",nargs=1)

sage: integrate(f(x),x, algorithm="fricas")
integral(f(x), x)

sage: integrate(x,f(x), algorithm="fricas")

Gives

TypeError: An error occurred when FriCAS evaluated 'integrate(sage4,sage3)':

Maxima:

sage: integrate(x,f(x), algorithm="maxima")
x*f(x)

Giac:

sage: integrate(x,f(x), algorithm="giac")
x*f(x)
$\endgroup$
3
$\begingroup$

The Mathematica result seems to be correct if we assume Integrate[x, f[x]]==Integrate[x f'[x]],x]

Integration by parts

Integrate[u f'[u],{u,x0,x}]==x f[x]-x0 f[x0]-Integrate[f[u],{u,x0,x}]

differentiate result

D[x f[x]-x0 f[x0]-Integrate[f[u],{u,x0,x}],x] (* x Derivative[1][f][x] *)
$\endgroup$
6
  • $\begingroup$ Thank you -I specified the details of the question accordingly. $\endgroup$
    – oyy
    Commented Jul 2 at 11:50
  • $\begingroup$ May I ask you why you can differentiate the result? I don't see it. $\endgroup$
    – oyy
    Commented Jul 4 at 9:22
  • $\begingroup$ @oyy I differentiate the result to confirm that integral Integrate[x f'[x]],x] is correct $\endgroup$ Commented Jul 4 at 9:32
  • $\begingroup$ But then the Mathematica output is incorrect. Integrate[x,f[x]] should not evaluate to x f[x]. Without differentiation, we should get with integration by parts: Integrate[x f'[x]],x]==x f[x]-Integrate[f[x],x]. $\endgroup$
    – oyy
    Commented Jul 4 at 9:45
  • $\begingroup$ Correct, and D[x f[x]-Integrate[f[x],x],x] evaluates to x f'[x] $\endgroup$ Commented Jul 4 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.