This is a substantial edit of the initial question. Thanks to MikeLimaOscar I can narrow my problem to the use of Input. I want Mathematica to ask me for a value that I will give if I find a complex number. I keep getting Null when I use it. I give a basic example:

    Module[{n, , x, i},
     Clear[n, x, i];
     n = Sqrt[{4., -1., 9.}];
     For[i = 1, i <= 3, i++,
      If[Element[n[[i]], Reals] == True,
       x[i] = n[[i]]*2,
       x[i] = Input["Introduce a value"]
     Table[x[i], {i, 1, 3}]]
    {4., Null, 6.}

Why doesn't it take into consideration the number I give?

Thanks in advance

  • 2
    $\begingroup$ Without even a hint of the structure of your code this is difficult to answer but using Input (and While) is certainly a possibility. For example, wrap your analysis function in something like: While[Im[Chop[result = yourAnalysis[a, t, initialGuess]]] != 0, If[(initialGuess = Input["Enter new initial guess"]) == $Canceled, Abort[]]]. $\endgroup$ – MikeLimaOscar Nov 27 '17 at 17:40
  • $\begingroup$ Thanks for your feedback. I am going to substantially edit my question because I realize I have a basic problem with the use of Input $\endgroup$ – The Mighty Algernon Nov 28 '17 at 22:31
  • $\begingroup$ I'm unable to reproduce the issue. When I input 12.1, the output is {4., 12.1, 6.}. Perhaps try again with a fresh kernel? $\endgroup$ – jjc385 Nov 29 '17 at 6:35
  • $\begingroup$ Everytime I use Input I get Null result. I am even unable to reproduce the basic Input[]^2 that appear in the help documentation. Is there any setting in Mathematica that influences this? $\endgroup$ – The Mighty Algernon Nov 29 '17 at 13:36
  • $\begingroup$ Are you using Mathematica online? If so this question is related. Otherwise, I think you may have set the dreaded option RequireReinstall to True! $\endgroup$ – MikeLimaOscar Nov 29 '17 at 17:46

Your Answer

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

Browse other questions tagged or ask your own question.