1
$\begingroup$

I am using the WolframAlpha command to automated solution sets of homework exercises. Here is an sample usage, although this can happen with many different examples:

WolframAlpha["limit (1 + k)^10/(10*k^10) as k -> Infinity", {{"Limit", 2}, "Content"}, PodStates -> {"Limit__Step-by-step solution"}]

Every so often, I receive the error message:

XML`Parser`XMLGetString::prserr: The main XML document cannot be empty at Line: 6 Character: 1.

When I reissue the command, it returns fine. That would seem to indicate that it is a timeout issue. OTOH, using the TimeConstraint option returns a different message.

Therefore, I would like to know what causes this, in order to build a workaround. Alternatively, to know (programmatically) that it happened (in some error value), in order to reissue the command.

TYVM.

$\endgroup$
8
  • 1
    $\begingroup$ Can you include the command you are running? The fact that TimeConstrained returns a different error does not surprise me, since the failure mode becomes different (your code is aborted locally rather than failing). $\endgroup$
    – MarcoB
    Commented Jun 22, 2022 at 12:17
  • $\begingroup$ @MarcoB, thank you for your reply. I have included a sample invocation, although the error message can either happen or not, with many different types of invocations. $\endgroup$ Commented Jun 22, 2022 at 14:50
  • $\begingroup$ 1) This is likely an intermittent connection problem. 2) how to avoid it -> That will depend on what is actually being returned upon error. WolframAlpha returns a RawBoxes object when the call works. I could not reproduce the error, so I don't know what would be returned in that case (maybe $Failed?), but you could check for an unexpected Head in the return value. Maybe wrap wa = WolframAlpha[...] in While and re-evaluate it until Head[wa] returns RawBoxes? $\endgroup$
    – MarcoB
    Commented Jun 22, 2022 at 15:14
  • $\begingroup$ And an aside: I know that this is not your point, but in the particular example you propose, I personally would find the results of Apart[(1 + k)^10/(10*k^10)] much clearer in illustrating why the limit is $1/10$ than the explanation given by W|A. $\endgroup$
    – MarcoB
    Commented Jun 22, 2022 at 15:18
  • $\begingroup$ @MarcoB, excellent suggestion. I ran this 50 times -- no problems. I ran it another 50 times and "fortunately" the problem reared its ugly Head and it equaled: Missing. Thanx again. $\endgroup$ Commented Jun 22, 2022 at 21:30

1 Answer 1

1
$\begingroup$

Thank you again to @MarcoB for guiding me.

Due to all of the possible results from WolframAlpha, it would be difficult to tag what is a valid result, and what suffered from what is apparently a connection problem. Specifically, Missing could be either.

Therefore, the way to go to is to check the system whether an error occurred, either a specific one (like parse error mentioned in the question), or any error. This can easily be accomplished with Check or MessageList.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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