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] = Truethen try toSolvefora, 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]toTrueif you also setN[a], soatruly behaves like a numeric constant. – Szabolcs Jul 01 '21 at 19:52a[1]and giveatheNumericFunctionattribute? – Carl Woll Jul 01 '21 at 19:53Subscript[S,1]orSubscript[U,2]. (The NCAlgebra package treats these as commutative.) – Davis Ellis Jul 01 '21 at 20:22NumericQ[a] = Truethen later when I want to solve for a, I setNumericQ[a] = False. I am using NumericQ as a shortcut to check for elements that I want to commute with NonCommutativeMultiply because of how quickly it runs even if I add symbols that should also be commutative. – Davis Ellis Jul 01 '21 at 20:28CentralQas in my answer https://mathematica.stackexchange.com/a/165511/29926 , which allows for commuting quantities including symbolic functions and so on – Jules Lamers Jul 02 '21 at 00:57