1
$\begingroup$

I entered

MinValue[{Prime[n], n>=1 && Element[n, Integers]}, n]

But I just got back what I entered. Why can mathematica not tell me the smallest prime is 2?

Even

MinValue[{Prime[n], 1<=n<=10 && Element[n, Integers]}, n]

seems to be beyond it, which is bizarre since it only has to check 10 values.

$\endgroup$
3
$\begingroup$

Presumably the problem is that the derivative of Prime is undefined in Mathematica

D[Prime[n], n]

(*  Derivative[1][Prime][n]  *)

Use NMinValue

NMinValue[{Prime[n], 1 <= n}, n, Integers]

(*  2.  *)

NMinValue[{Prime[n], 1 <= n, Element[n, Integers]}, n]

(*  2.  *)

Round to taste.

$\endgroup$
  • $\begingroup$ Ah, thanks. I thought it had more methods than simply taking derivatives. $\endgroup$ – user85798 Dec 11 '15 at 5:45

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.