Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Mathematica seems not to be able to minimize this univariate function over integer arguments, $r>2, r \in \mathbb{Z}$.

k=6;
SB[n_, r_] := 
 Sum[Binomial[r Binomial[2 k, 2]/2, i] Binomial[
    Binomial[n, 2] - r Binomial[2 k, 2]/2, 
    r Binomial[k, 2] + r - i], {i, r Binomial[k, 2] + r/2, 
   r Binomial[k, 2] + r}]


NMinimize[{SB[k r, r], Element[r, Integers] && r > 2}  , r]

This takes forever, even if, evaluated with Table the function in the interval $r=(2,100]$ for example, has perfectly valid values. The other command FindInstance seems unable to tell me a valid value when checking if $S_B(k r,r) > 0$ even if this is true for every value of $r$.

Some help to make this computation faster or let it converge to a feasible solution? I know the solution is at $r=2$ but I just want to know how to properly specify this problem that is part of a more general framework.

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

If you use: SB[n_?NumericQ, r_?NumericQ] in your definition things work as you expect.

Otherwise, SB is evaluated symbolically and that will take forever...

share|improve this answer
    
Thanks! This saved my day! –  linello Mar 24 at 14:17
add comment
Clear["Global`*"]
k = 6.;
SB[n_, r_] := 
 Sum[Binomial[r Binomial[2 k, 2]/2, i] Binomial[
    Binomial[n, 2] - r Binomial[2 k, 2]/2, r Binomial[k, 2] + r - i], 
 {i, r Binomial[k, 2] + r/2, r Binomial[k, 2] + r}]
SB[# k, #] & /@ Range[100] // Timing
ListLogPlot[%[[2]]]

way 2

Clear["Global`*"]
sum[r_] := Sum[(Gamma[1 + 33 r] Gamma[1 - 36 r + 18 r^2])/(
   Gamma[1 + i] Gamma[1 - i + 16 r] Gamma[1 - i + 33 r] Gamma[
  1 + i - 52 r + 18 r^2]), {i, (31 r)/2, 16 r}];
(data = sum[1. #] & /@ Range[2, 300];) // Timing
ListLogPlot[data, AxesLabel -> {"r", "sum"}]
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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