2
$\begingroup$

RegionPlot is plotting for all values. And using ListPlot I can only evaluate one inequality. How can I plot this type of inequality: $$\frac{1}{\alpha+1} \leq \frac{\sum_{i=0}^k i^a}{\sum_{i=0}^k i^b} \leq 1+\alpha$$. $a$,$b$ are const (I know values $a$ and $b$).

I want to plot dependency between $\alpha$ and $k$ only for integer values of $k$ and $\alpha$ is only from $(0,1]$.

So I tried to use ListPlot (as you suggested me in previous post).

ListPlot[Table[{k, (-1) + (Sum[i^a, {i, 0, k}]/
       Sum[i^b, {i, 0, k}])}, {k, 1, n}], PlotRange -> {0, 1}, 
 Filling -> Top]

But I don't know how to add here the second inequality.

I tried also to use RegionPlot. This commend is easier for me, because I know how to add the second inequality, but I don't know how to restrict that k should be only integer

RegionPlot[(Sum[i^a, {i, 0, k}]/
      Sum[i^b, {i, 0, k}]) <= 
   1 + f && (Sum[i^a, {i, 0, k}]/
      Sum[i^b, {i, 0, k}]) >= 1/f, {k, 1, n}, {f, 0, 1}]
$\endgroup$
  • $\begingroup$ It is duplicate of your previous question because ListPlot with appropriate Filling it is what you want. It will be better if you update your previous question instead of new one. $\endgroup$ – ybeltukov Dec 9 '13 at 13:34
  • $\begingroup$ I think it's not, because here qe have to inequalities, not one $\endgroup$ – Ziva Dec 9 '13 at 13:35
  • $\begingroup$ Always try to post all the relevant code you can build for your question $\endgroup$ – Dr. belisarius Dec 9 '13 at 13:51
  • $\begingroup$ @belisarius I made edit and I posted what I tried to do $\endgroup$ – Ziva Dec 9 '13 at 16:44
  • $\begingroup$ Well done! Always try to post code $\endgroup$ – Dr. belisarius Dec 9 '13 at 16:45
2
$\begingroup$

One approach is to use RegionPlot and to add in a constraint that the k value be near an integer. For example:

a = 1.5; b = 1.7; k = 20; n = 10; 
RegionPlot[(Sum[i^a, {i, 0, k}]/Sum[i^b, {i, 0, k}]) <= 1 + f 
        && (Sum[i^a, {i, 0, k}]/Sum[i^b, {i, 0, k}]) >=  1/(1 + f) 
        && ((k - Floor[k] < 0.1) || (Ceiling[k] - k < 0.1)), 
            {k, 1, n}, {f, 0, 1}, PlotPoints -> 100]

enter image description here

We can even solve the problem exactly. First, set up all the equations

a = 1.5; b = 1.6;
eqns=Table[ 1/(1 + f)<=Sum[i^a, {i, 0, k}]/Sum[i^b, {i, 0, k}] <= (1 + f), {k, 1, 10}]

and then use Reduce to solve:

Reduce[#] & /@ eqns
{f >= 0, f >= 0.053026, f >= 0.0893559, f >= 0.117241, f >= 0.139986, 
 f >= 0.159254, f >= 0.176007, f >= 0.190851, f >= 0.204194, f >= 0.216325}

which shows the exact values of f that work for each possible value of k.

$\endgroup$
  • $\begingroup$ Thanks, your suggestion is helpful. But unfortunately I need an integer, not something what is near, because otherwise I will not be able to read $\endgroup$ – Ziva Dec 9 '13 at 18:48
0
$\begingroup$

Mathematica seems to handle the discrete values of k for sum:

f[a_, k_, x_, y_] := 
 1/(1 + a) <= Sum[j^x, {j, 0, k}]/Sum[j^y, {j, 0, k}] <= 1 + a
Manipulate[
 RegionPlot[f[x, y, a, b], {y, 1, 20}, {x, 0, 1}, PlotPoints -> 100, 
  FrameLabel -> {Style["k", 20], Style[\[Alpha], 20]}], {a, 1, 2, 
  ControlType -> LabeledSlider}, {b, 1, 2, 
  ControlType -> LabeledSlider}]

enter image description here

$\endgroup$

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.