Message Boards Message Boards

0
|
5231 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

[?] Sum and Solve the following expression?

Posted 7 years ago

The following does not work:

Solve[Sum[(-1)^(k-1)*Binomial[71,k]*(1-(71-k)/71)^n,{k,1,71}]=0.5,n]

I want to find the smallest value for n where that sum will yield at least 0.5. But, when I enter that formula, Mathematica tells me,

In[2]:= Solve[Sum[(-1)^(k-1)*Binomial[71,k]*(1-(71-k)/71)^n,{k,1,71}]=0.5,n]

                           k - 1                      71 - k n

Set::write: Tag Sum in Sum[(-1)      Binomial[71, k] (1 - ------) , {k, 1, 71}] is Protected.

                                                            71

Solve::naqs: 0.5 is not a quantified system of equations and inequalities.

Out[2]= Solve[0.5, n]

Is there a different syntax I can use so that it will calculate n for me?

POSTED BY: Neil Spalter
4 Replies

Strange that Jim's post did not show up for me until after I posted. His answer is better than mine anyway...

POSTED BY: Neil Singer
Posted 7 years ago

Yep, I noticed that my response took a few hours to appear. I must be on a "needs extra security" list.

POSTED BY: Jim Baldwin

You need to use == for equations. = is an assignment. The error is you are trying to assign something to binomial.

The syntax is Solve[a*x==b, x]

Regards

POSTED BY: Neil Singer
Posted 7 years ago

You need to use == rather than = when using Solve (and similar functions). However there is no n that makes the sum exactly equal to 1/2.

Here's a brute-force method: Calculate a bunch of values for n and then take the smallest n that results in a probability of at least 0.5:

data = Table[{n, N[Sum[(-1)^(k - 1)*Binomial[71, k]*(1 - (71 - k)/71)^n, {k, 1, 71}]]}, {n, 1, 500}];
sol = Select[data, #[[2]] >= 1/2 &][[1]]
(* {329,0.5036576494672924} *)

So the n you're looking for is 329.

A better way is to use the While function:

n = 1;
While[Sum[(-1)^(k - 1)*Binomial[71, k]*(1 - (71 - k)/71)^n, {k, 1, 71}] < 1/2, n = n + 1]
n
(* 329 *)
N[Sum[(-1)^(k - 1)*Binomial[71, k]*(1 - (71 - k)/71)^n, {k, 1, 71}]]
(* 0.5036576494672924 *)
POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract