How can I check if a function remains unevaluated?
check if a function remains unevaluated.
Why not just check the head?
func = Log[3 x]^5*Sec[3 x];
result = Integrate[func, x]
If[Head[result] === Integrate,
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"]
]
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 *)