4
$\begingroup$

I guess I do not understand how Mathematica evaluates this simple expression inside FreeQ

a = 2 I
FreeQ[a, I]
FreeQ[2 I, I]
FreeQ[I, I]

(* 2 I *)
(* True *)
(* True *)
(* False *)
$\endgroup$
  • 3
    $\begingroup$ Check FullForm[a] or FullForm[ I ], etc. There are a lot of questions in the site about complex numbers an some ideas about how to cope with the difficulties that arise when trying to match them $\endgroup$ – Dr. belisarius Jun 29 '15 at 4:08
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$ – bbgodfrey Jun 29 '15 at 4:17
  • 2
    $\begingroup$ FreeQ[...,Complex]... $\endgroup$ – ciao Jun 29 '15 at 4:17
  • 2
    $\begingroup$ Thank you, FreeQ[..., Complex] works just fine. $\endgroup$ – Peter Jun 29 '15 at 4:23
  • 3
    $\begingroup$ If you want to check the form of the expression as you entered it, you can do FreeQ[HoldForm[2 I], HoldPattern[I]]. $\endgroup$ – Simon Rochester Jun 29 '15 at 4:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.