I would like to plot a function with a sum in it. Here is the function:

$$v(k) = \sum_{j=1}^k \frac{v_E \cdot m_j \cdot c}{m_j(1-c)+\sum_{i=j+1}^n m_i} $$

As you can see, the problem is that I have a set of $m_i$ ($m_1 = 12, m_2=35...$) and now I set them manually. If I want to change the set or add new masses, I also have to do it manually.

Is there a way to define this set separately and then make the series "read" the elements of this set?

  • $\begingroup$ why not make a function, and pass it the the maximum summation index k and n needed and the set m and v and also c ? $\endgroup$
    – Nasser
    Mar 5 '19 at 20:46
  • $\begingroup$ @Nasser How do I define the set m? How do I make the sum find the appropriate value for m matching the index? $\endgroup$
    – Hrach
    Mar 5 '19 at 20:52
  • $\begingroup$ The set m is just a list, right? This is the input you have, right? If you give a small example of your data v and m it helps. $\endgroup$
    – Nasser
    Mar 5 '19 at 20:56
  • $\begingroup$ @Nasser Yes, the set of m-s is just a list and it is the input. m has to contain arbitrary real values (m stands for masses) and the output is velocities. $\endgroup$
    – Hrach
    Mar 5 '19 at 21:23

Here is a sample implementation. See if I have understood your notation and goal:

v[mList_, k_] := 
 vE c Sum[mList[[j]] / (mList[[j]] (1 - c) + Total@mList[[j ;;]]), {j, 1, k}]

I assumed that vE and c are constants, and I gave them some arbitraty value; similarly, let's choose an arbitrary list of masses:

c = 0.5;
vE = 32;
mlist = {1, 45, 12, 35};

v[mlist, 4]
(* Out: 20.7486 *)

Let's plot it for a range of k:

Plot[v[{12, 45, 30, 35}, k], {k, 0, 4}]

Mathematica graphics

m = {12, 35, 48};ve = 12;mj = 14;c = 14;numofmasses = Length[m];tot = 0;
For[a2 = 1, a2 < numofmasses + 1, a2 = a2 + 1,
an[a2] = ve*Part[m, a2]*c/(Part[m, a2]*(1 - c) + Total[m[[a2 + 1 ;; numofmasses]]]);

tot = an[a2] + tot;

Put your values for the variables and it will read along the masses

  • $\begingroup$ be honest it was the plot $\endgroup$
    – Rookey
    Mar 6 '19 at 23:34

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.