27

How can I tell Wolfram Alpha that some variables are natural numbers, when I want to solve a equation?

An example of what I want to do:

$\binom{n}{k}\cdot p^k \cdot (1-p)^{n-k} = \frac{1}{\sqrt{n\cdot p \cdot (1-p)}}\cdot \frac{1}{\sqrt{2 \cdot \pi}} \cdot e^{-\frac{1}{2} \cdot \left(\frac{x-np}{\sqrt{n \cdot p \cdot (1-p)}}\right)^2}$ solve for $x$ with $n,k \in \mathbb{N}$, $0 \lt p \lt 1$.

4 Answers4

8

Just add an "assuming x integer" at the end. I tested it, and it seems to work. (similar to Maple's notation assuming x::integer, I guess) For natural it doesn't seem to work properly: assuming x natural

AlexR
  • 25,110
  • 14
    This doesn't seem to work anymore. – Skeen Oct 10 '17 at 18:38
  • @Skeen Pardon me, but my link seems to work. Funny enough, even assuming x natural works (just click the link) – AlexR Oct 10 '17 at 21:20
  • 2
    I'm getting this: Wolfram|Alpha does not yet know how to respond to your exact query. The "closest interpretation" is based on lexical and semantic similarity in Wolfram|Alpha's computable knowledge space. – Skeen Oct 11 '17 at 15:03
  • Can you give a link? As I said, I have no problem with the link in my Answer - it simplifies Gamma(x) to (x+1)! using the assumption that x is an integer. – AlexR Oct 11 '17 at 16:08
4

It depends on how you are trying what it is you are trying to solve. Telling Mathematica that something is an integer has a different syntax depending on what you are trying to do.

Assuming that you are using the "Solve" function, it would look like this:

Solve[(x - 3/2) (x - 2)== 0 && x \[Element] Integers]

EDIT. After 6 years, the website has changed and this no longer works. However,

 Solve (x-3/2)(x-2)=0 for x integer

seemed to work, as you can can see here.

3

As dirty as this is, I've used modulus 1 to force numbers to be integers. Combine with a >= 0 restriction and you can reach Natural numbers.

Example

BlackVegetable
  • 191
  • 1
  • 8
0

Solve[ ..., Element[..., Integers]]