0
$\begingroup$

I have a series of $n$ coefficients with parameters $r$ and $b$ that sum up to one. But there i also the initial condition value $c1$ that i required to obtain this normalization. I want to find this $c1$ for each $r$ and $b$ value plug it back in to my table and plot those values. I used manipulate as follows:

     ClearAll["Global`"];
     clc;
     a = 1/(1 - b*r);
     c = (1 - r - b*r (1 - r*b))/((1 - b*r) (b - 1)*r);

     Manipulate[
      solveC1 = 
       Solve[Total[Table[N[1/(c1*n!)*((-1)^n*FactorialPower[a, n]) + 
             1/n!*Sum[(k - n)*Binomial[n, k]*(-1)^(n - k)*FactorialPower[a, n - k], {k,                            1, n}]], {n, 0, 20}]] == 1, c1];
      Print[c1 /. solveC1], {r, 0.001, 1}, {b, 0.001, 1}]

Please bear with me and let me know of any suggestion you have as I'm a beginner in Mathematica.

Thanks.

$\endgroup$
10
  • $\begingroup$ Your brackets and parenthesis don't balance $\endgroup$ Oct 24, 2014 at 16:54
  • $\begingroup$ sorry I had simplified the equation and in that process missed a parenthesis. $\endgroup$
    – Yasmin
    Oct 24, 2014 at 17:02
  • $\begingroup$ I do not understand your code at all. You have 2 control variables r and b, yet they do not appear anywhere in the Manipulate expression. Before jumping to using Manipulate, you should first test your code as standalone, on a cell by its own, to make sure it even works. You can enter some values for the parameters. Then when it is working, you can use Manipulate to automate things. $\endgroup$
    – Nasser
    Oct 24, 2014 at 17:06
  • $\begingroup$ @Nasser $FactorialPower[a, n]$ the $a=\frac{1}{1-br}$ and that's how this depends on b and r. $\endgroup$
    – Yasmin
    Oct 24, 2014 at 17:15
  • $\begingroup$ But this code is not in the Manipulate expression. You should put all control variables dependent code inside Manipulate. $\endgroup$
    – Nasser
    Oct 24, 2014 at 17:17

1 Answer 1

0
$\begingroup$
Manipulate[
       solveC1 = Quiet@Solve[(Total[t[b, r]]) == 1, c1];
       ListLinePlot[t[b, r] /. solveC1, PlotRange -> All],
 {r, 0.001, 1},
 {b, 0.001, 1}, 
 Initialization :> {a[b_, r_] := 1/(1 - b*r), 
                    t[b_, r_] := Table[N@1/(c1*n!)*((-1)^n*FactorialPower[a[b, r], n]) + 
                                  1/n!*Sum[(k - n)*Binomial[n, k]*(-1)^(n - k)*
                                  FactorialPower[a[b, r], n - k], {k, 1, n}], {n, 0, 20}]}]

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ This is working thanks. My question is that how would you plug this back into the equation to plot different entries in the Table? Using Manipulate and DiscretePlot? $\endgroup$
    – Yasmin
    Oct 24, 2014 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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