# How to check if Integrate solved the integral?

This seems something that must have been asked before, but I am not able to find something.

Integrate does not return status nor throw error when it can't find antiderivative. It just returns the input back. So can't use Check on not.

So how would one check if it solved the integral or not?

Currently I check if First of the result of the integration is the same as the integrand. Since if it failed, then the First of the input will be the integrand.

expr = Sin[x];
r = Integrate[expr, x];
If[r[[1]] === expr, Print["failed"], Print["passed"]]
(*passed*)


While this

expr = Sin[x Exp[x]];
r = Integrate[expr, x];
If[r[[1]] === expr, Print["failed"], Print["passed"]]
(*failed*)


But the above seems like a hack to me. There should be a more robust and systematic way to do this. Any suggestions?

Version 10.02

• Why not just check Head[r]===Integrate?
– Jens
Dec 20, 2014 at 1:14
• @Jens sure. This sounds like a smart way to go about it. I did not think about it. Dec 20, 2014 at 1:32

expr =a Sin[x Exp[x]];

r = Integrate[expr,x];