How can I check if a function remains unevaluated?

I am trying to check if a function remains unevaluated.

For example

$$\int \ln ^5(3 x) \sec (3 x) \, dx$$

remains unevaluated in Mathematica, instead $$\int \sec (3 x) \, dx$$ doesn't.

What I tried is

func = Log[3 x]^5*Sec[3 x];
IntFunc = With[{function = func}, HoldForm[Integrate[function, x]]];
SameQ[IntFunc,ReleaseHold[IntFunc]]

which returns False. I also tried

Equal[IntFunc,ReleaseHold[IntFunc]]

which remains unevaluated. I am pretty sure that this has to do with Hold $(*)$ but I don't understand how to fix this. Is there a way to test if a function remains unevaluatd? In other words, get True if it's unevaluated and False if it's evaluated?

$(*)$ Because when I try:

SameQ[Integrate[func, x], ReleaseHold[IntFunc]]

it returns True.

• ValueQ should do the trick. – JEM_Mosig Feb 15 '18 at 5:49
• @JEM_Mosig how? – DMH16 Feb 15 '18 at 6:03
• From the documentation: ValueQ[expr] gives True if a value has been defined for expr, and gives False otherwise. ValueQ gives False only if expr would not change if it were to be entered as Wolfram Language input. – JEM_Mosig Feb 15 '18 at 8:21

check if a function remains unevaluated.

Why not just check the head?

func = Log[3 x]^5*Sec[3 x];
result = Integrate[func, x] Print["Opps"],
Print["it worked"]
]

Update for comment

Use this to check if result contains Integrate anywhere

func = 20* Log[3 x]^5*Sec[3 x];
result = Integrate[func, x] If[FreeQ[result, Integrate, Infinity],
Print["it worked"],
Print["Opps"]
]
• Wow, I did not think of this! Thanks! ' – DMH16 Feb 15 '18 at 4:15
• Hey, I just noticed that this does not work if a constant is added in front of the function (ex: func = 20*Log[3 x]^5*Sec[3 x];). This because the head now is Times. How would you fix this? – DMH16 Feb 15 '18 at 6:03
• @DMH16 I added check – Nasser Feb 15 '18 at 6:38

ValueQ should do exactly what you want. From the documentation: ValueQ[expr] gives True if a value has been defined for expr, and gives False otherwise. ValueQ gives False only if expr would not change if it were to be entered as Wolfram Language input.

So

ValueQ[Integrate[Log[3 x]^5*Sec[3 x], x]]
(* False *)

and

ValueQ[Integrate[Sec[3 x], x]]
(* True *)