1
$\begingroup$

How can we (loosely) check whether variable A is determined, not directly computing A?
(= How can we define DeterminedQ function ?)

For example,

In[1] x=a+b
In[2] a=2

Then x is not completely determined yet. So,

In[3] DeterminedQ[x]
Out[3] False

But if we go further

In[4] b=2

then

Out[5] DeterminedQ[x]
Out[5] True

Because now x=4.

I have an idea. My idea is inspecting Definition[x], and get variable names v1,v2,... those constructing x. Then inspect Definition[v1], Definition[v2], ..., repeat, repeat.
If we encounter a variable w such that defition[w] produces Null, then x is not determined, DeterminedQ[x] must be false.
Otherwise, variables at bottom level will turn out to be mixture of determined numbers or strings, etc. In this case DeterminedQ[x] must be true.

But there is a problem in my idea. For example,

b=Sqrt[3+2Sqrt[2]]
x=a*(b-1-Sqrt[2])

Then x is mathematically determined becuase x == a*0 == 0, but according to my idea, DeterminedQ[x] becomes false, because Definition[a] becomes Null.

And if we make a mathematica code,

x = the least even number that is not sum of two prime numbers  

(The code can be written using NestWhile command)
Then the existence of x is not known mathematically, but according to my idea, DeterminedQ[x] becomes true.

I don't care whether x is determined mathematically or not.
I just want DeterminedQ function, which is loose but super fast, always give true or false.

...Or, there may be a built-in function already. Can you construct/know
DeterminedQ-like function ?

$\endgroup$
5
  • $\begingroup$ Will NumericQ do what you want? $\endgroup$ Mar 20, 2021 at 11:51
  • $\begingroup$ No the list {1,2,3} is determined but NumericQ gives us false. Matrix of determined numbers or determined strings are also determined, I think. $\endgroup$
    – imida k
    Mar 20, 2021 at 11:53
  • 1
    $\begingroup$ What do you need this functionality for? $\endgroup$
    – MarcoB
    Mar 20, 2021 at 16:56
  • 1
    $\begingroup$ I'm not entirely clear on your definitions of "determined." Do you mean A it would give a numeric value if it were evaluated? If so, note that NumericQ[A] computes A and sees if the result is numeric. That seems not to be what is required by "determined, not directly computing A." $\endgroup$
    – Michael E2
    Mar 20, 2021 at 19:14
  • $\begingroup$ Logically... the first thing to do is, constructing a single 'logical statement' for x according to the definition of x (according to what I've done in .nb file so far). If there is no free variable in 'the logical statement', then it can be said x is determined. In this manner, you do not need any computation, just inspecting the structure of the logical statement is enough. $\endgroup$
    – imida k
    Mar 21, 2021 at 13:34

1 Answer 1

5
$\begingroup$

How about this?

DeterminedQ[x_List] := And @@ DeterminedQ /@ x;
DeterminedQ[x_] := NumericQ[x];
$\endgroup$
2
  • $\begingroup$ Thank you. It is a very clever code and perfectly works for list of list of list of... numbers. But it computes x. So, it will take so long time to the output of DeterminedQ[NestWhile[# + 1 &, 0, # < 10^100 &]] $\endgroup$
    – imida k
    Mar 21, 2021 at 13:23
  • $\begingroup$ My idea will work for such example. $\endgroup$
    – imida k
    Mar 21, 2021 at 13:37

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.