# Tagged Questions

302 views

### Does Mathematica store hidden information for matrix objects?

Bug introduced in 10.0 and fixed in 10.2.0 I found a case where calling one built-in function (HermitianMatrixQ) for a given matrix changes the behavior of ...
551 views

### Implementing a safe ValueQ that does not evaluate its argument

Mathematica has a built-in function ValueQ. Quoting the docs, ValueQ[expr] gives True if ...
2k views

### How do you check if there are any equal arguments(even sublist) in a list?

I would like to set up a function which has to return True if at least two arguments of a given List are equal. So if I give {1,4,6,2} to the function it has to ...
909 views

### Why does Mathematica claim there is no even prime?

I wonder if this is a bug, or if I'm misunderstanding something: Exists[n, EvenQ[n] && PrimeQ[n]] // Resolve (* ==> False *) So if I interpret this ...
1k views

### _?NumericQ equivalent for lists

A few months ago I got a simple answer (see: 1 ) to the question of how to force numeric evaluation during use of functions such as NMinimize[] - namely the use of <...
4k views

### How to check if an expression is a real-valued number

What is a simple, fast way to test whether an expression is a real-valued number? I ask since there is no RealQ function. If we call this test ...
197 views

### A bug in the overloading of MemberQ and FreeQ for Association?

Bug introduced in 10.0.0 and fixed in 10.1.0. While answering Pattern match for nested Association I came across behavior of MemberQ and ...
609 views

### How do I get Mathematica to return a function call unevaluated?

How do I get Mathematica to return a function call (conditionally) unevaluated? I expect this may use the slightly-mysterious Hold function. As a toy example, ...
2k views

### Fastest square number test

What is the fastest possible square number test in Mathematica 7, both for machine size and big integers? I presume in version 8 the fastest will be a dedicated C LibraryLink function.
287 views

### How can I test properties of a symbol from the string name without the symbol completely evaluating

Suppose I have a few symbols, one of which has a value: {abc1, abc2 = 5, abc3}; I can use Names to get the list of names, as ...
520 views

### Better way to test that a matrix is upper-triangular?

Today, I got to thinking about how to test that a matrix was upper-triangular. So I had a try at it. Algorithm $\quad \quad a_{ij}=0$ Or $i \leq j$ $\Rightarrow$ $True$ My solution is ...
161 views

### IsomorphicGraphQ fails to recognize that two empty graphs are identical

Bug introduced in 9.0.1 or earlier and persisting through 10.4.0 Consider the following two graphs: ...
230 views

### Unexpected slowness checking for empty list?

I thought I had a firm understanding of the differences between Equal and SameQ, but this has me puzzled: ...
252 views

### Why is an empty list not tested by VectorQ?

I am a bit amazed by this behavior of VectorQ[ expr, test ]: VectorQ[ {}, NumberQ ] True It seems that the test itself ...
196 views

### How can one write a robust ListableQ function?

I would like to have a test that determines if a particular function is Listable. In the case of Symbols this is merely a matter of checking Attributes. ...
360 views

### Why does Assuming[x > 0, TrueQ[x > 0]] return False?

Assuming[x>0,TrueQ[x>0]] should, as I understand it, test TrueQ[x>0] after assuming ...
158 views

### ValueQ returns false positive for one argument type only

I'm seeing some perplexing behavior from ValueQ in 10.3. Consider: ...
848 views

...
519 views

### Difficulty understanding difference between == and ===

After doing this: ...
579 views

### How does Mathematica decide that Log[2,8] is integer?

At school we learned that $\log_b(x)=\log(x)/\log(b)$, which is implemented in Mathematica as Log[b, x], but the results are different. ...
214 views

### Test for non-numeric variables

I have a table, testdata, with numeric and non-numeric data. testData = {{1, 2, 3, no, 5}, {5, 6, 7, 8, 9.1}, {1, y, y, n, n}}; I can locate the positions of ...
116 views

### UnitaryMatrixQ function not returning true for a unitary matrix

So I know this matrix is unitary. It's a well proven fact in quantum mechanics and you can even check for yourself on pen and paper, Heres a quick proof: Assume $H$ is hermitian (i.e. $H^\dagger=H$) ...
158 views

### Bug in PositiveDefiniteMatrixQ?

Fixed in 10.1.0. Exists in at least 9.0.1 -- 10.0.2. This seems like a bug in PositiveDefiniteMatrixQ to me: ...
4k views

### How to detect if a sequence of integers is consecutive

I'm not a math-guy really (a programmer actually) and this is my first question. And excuse me if I can not explain my problem good. The problem is I have a sequence of integers and I want to detect ...
264 views

### TrueQ returning False on true statement

Why does TrueQ return False on the following? TrueQ[Log[2]/Log[8] == 1/3] (* False *) ...
169 views

### Checking through an expression

I am writing a code that manipulates expressions that contains functions with an arbitrary number of arguments. An example expression is ...
137 views

### Mystery with ValueQ

Consider the following ClearAll[jd]; ValueQ[jd] We expect False and get it. Now consider ...
522 views

### Determine if all the zeros in a list occur at the end

I have a collection of (short) lists of nonnegative integers. For each, I would like a predicate that decides if all of the zeros in the list appear at the end. For example, ...
280 views

### How to test whether a function is positive over the entire range of an interval?

I would like to test whether a function is positive over a given interval. Say I have f[x_] = -x^3 + x^2 + 7*x and wanted to know whether it is positive for all <...
302 views

### Why does PolynomialQ[x^n, x] return False?

From what I can see PolynomialQ will return False whenever some exponent is another variable such as here: ...
62 views

### Configurable tolerance for numerical equality?

In standard C++ the double values for 1. + 1.2*^-16 and 1. are not considered equal. But in Mathematica, I get the following: ...
89 views

### Faster square test for integers

This question was asked already in Jan '12 and the most recent answer is from Oct '12, so it's several Mathematica versions out of date. What is a faster test for whether an integer is a perfect ...
100 views

### SameQ for unsorted lists

I have to compare two or more lists and check if they are the same, but their elements can be in different position. For instance ...
213 views

### ParallelMemberQ

I tried to make a parallel version of MemberQ for use with a large list, but failed miserably in terms of performance. I used Partition to subdivide the list and ParallelMap to perform the MemberQ ...
410 views

### Why is an integer not considered as a real?

Please consider the following: zeros={0.,0}; data={1, 0., 0}; DeleteCases[data, #]&/@zeros Head/@zeros (*{Real, Integer}*) (*{{1, 0}, {1, 0.}}*) For my ...
140 views

### Using OddQ and EvenQ in piecewise functions: Buggy?

I was trying to evaluate a sum over a piecewise function, not unlike this example. However, my piecewise function needed to be defined differently for even and odd ...
162 views

### lists of conditions

I have got coordinates in two list of Latitude and Longitude and would like to check if those coordinates are in a certain grid Example lists are: ...
66 views

### Rapidly testing for exact vs. inexact expressions

Is there a fast function "ExactExpressionQ" to test whether an expression is exact vs inexact? I'm looking for something like ...
335 views

### Picking points in a plane under a curve given by a list

Suppose that I have a set of points in a plane, which range from $x\in [0,20]$ and $y\in[0,10]$, and a curve given by a list of points in the same region: ...
111 views

### time complexity of MemberQ

I was rather surprised that the operator form of MemberQ takes a form as its argument. I looked for the operator form thinking that repeated testing for elementhood in a given "set" is a common need ...
70 views

### Can I make IsomorphicGraphQ consider other properties besides the EdgeRules?

Consider two graphs, which are isomorphic to each other based on the vertices and edges, ...
39 views

### Testing for nontrivial evaluation

How can I tell programmatically if a function has evaluated in a nontrivial way? I'd like to do, essentially, something along the lines of f[x]===HoldForm[f[x]], a ...
66 views

### Can Mathematica point out why it thinks two symbolic expressions are different?

SameQ checks to see if symbolic expressions are the same. There are some caveats, as pointed out by the answers to: Understanding SameQ What is the proper way to ...
381 views

### How to check if a given expression is an “explicit algebraic number”?

The documentation for PossibleZeroQ says: With the setting Method...
47 views

### Using ValueQ to test whether “hash” key exists fails when key is given as variable

Please ignore ^^^ possible duplicate (raised by me). The solution doesn't cover my case. I'm trying to implement a simple hash table according to this top answer at "Is there HashTable structure in ...
155 views

### How can I test properties of a symbol without unwanted evaluation

Problem How to get the head, size, dimensions, etc. of a symbol without evaluating it? Since Mathematica does not allocate fix storage space and type to symbols it is not trivial to query runtime ...
205 views

### Nested If statement with unevaluated arguments

I have a list of boolean functions {f1, f2, f3, ...} that take a value and return True or ...
222 views

### Finding similar expressions in list

I have a function that returns to me lists of expressions, like: ...