I am writing a program in which I am using NumericQ. I am trying to allow symbols to also be considered Numeric, so I have been using NumericQ[a]=True
for all of the symbols that I want to be numeric. However, this messes with the functionality of Solve so that I have to write NumericQ[a]=False
for all of the symbols before using Solve. Going back and forth repeatedly, even using a map function, is annoying. To solve the issue, I created a new function defined by numeric[x_Symbol]=True; numeric[x_?NumericQ]=True; numeric[___]=False;
. The issue with this method is that I want numeric[b+5]
to evaluate as True. For example, when you type NumericQ[c]=True; NumericQ[c + 7];
evaluates to True. Initially, I added a line for every operation between symbols that I wanted to be True --Plus[x_?numeric,y_?numeric]=True
. Even just adding Plus made the code significantly slower, but adding it for all of the operations - Times, Conjugate, Exponent - made it too slow to evaluate. My code makes extensive use of NumericQ, so I need whatever I use to not be much slower than it if I want it to run in a reasonable time. Thank you for the help.
Edit: The reason I want to do this is I am trying to add commutative properties like distributive to NonCommutativeMultiply. The NonCommutativeAlgebra package does this, but the symbols that I want to be noncommutative (one's with a subscript) are commutative in this package. Combining NumericQ with assigning certain symbols as numeric implements what I am wanting to do perfectly, but I have to change those symbols back to not numeric if I want to use the solve function.
Solve
? I hope you are not doingNumericQ[a] = True
then try toSolve
fora
, as that makes no sense. If you are doing that, then why do you wantNumericQ[a]
to beTrue
? It only really makes sense to setNumericQ[a]
toTrue
if you also setN[a]
, soa
truly behaves like a numeric constant. $\endgroup$a[1]
and givea
theNumericFunction
attribute? $\endgroup$