2
$\begingroup$

i have 3 lists called Fi,Ti and Si, that go from 1 to 17. Each i corresponds to a certain value, i.e.

f = {0.05, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.6, 1, 2, 3, 4, 5, 6, 7, 8, 10};
Ta = {1, 1, 1, 1, 1.05, 1.15, 1.3, 1.5, 1.7, 1.9, 1.1, 0.5, 0.01, 0.001, 0.001, 0.001, 0.001}
Sui = {0.00126182, 0.00126182, 0.00126182, 0.00126181,
0.0012618, 0.00126178, 0.00126175, 0.00126172, 0.00126153, 0.00126064, 0.00125915, 0.00125708, 0.00125443, 0.0012512, 0.00124742, 0.00124308};

I am trying to compute the sum of the image attached (tried to paste the equation, but doesn't show in a mathematical form). Sorry my first time posting a question. Any advice ?

enter image description here

$\endgroup$
  • $\begingroup$ How are you defining fn,tn? $\endgroup$ – Feyre Aug 26 '16 at 18:18
  • $\begingroup$ fdata = {0.05, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.6, 1, 2, 3, 4, 5, 6, 7, 8, 10} and Ta = {1, 1, 1, 1, 1.05, 1.15, 1.3, 1.5, 1.7, 1.9, 1.1, 0.5, 0.01, 0.001, 0.001, 0.001, 0.001} $\endgroup$ – St LFC Aug 26 '16 at 18:23
  • $\begingroup$ Please include all the needed information, including su, in your question itself. $\endgroup$ – bbgodfrey Aug 26 '16 at 18:44
1
$\begingroup$

Given (I added an extra element to Su as it seemed to be one short)

f = {0.05, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.6, 1, 2, 3, 4, 5,
   6, 7, 8, 10};
Ta = {1, 1, 1, 1, 1.05, 1.15, 1.3, 1.5, 1.7, 1.9, 
  1.1, 0.5, 0.01, 0.001, 0.001, 0.001, 0.001};
Su = {0.00126182, 0.00126182, 0.00126182, 0.00126181, 0.0012618, 0.00126178, 
  0.00126175, 0.00126172, 0.00126153, 0.00126064, 0.00125915, 
  0.00125708, 0.00125443, 0.0012512, 0.00124742, 0.00124308, 0.001};

The "Mathematica" way is

Total[Differences[f] (Drop[Su Ta^2, -1] + Drop[Su Ta^2, 1])]/2
(* 0.0104223 *)

The literal way is

Sum[1/2 (f[[i + 1]] - f[[i]]) (Su[[i]] Ta[[i]]^2 + Su[[i + 1]] Ta[[i + 1]]^2), {i, 1, 16}]
(* 0.0104223 *)
$\endgroup$
  • $\begingroup$ yep, i forgot the last element. it was: 0.0012328. Nevermind. Thanks a lot for your help. Appreciate it. Gonna look through these commands to fully understand it. $\endgroup$ – St LFC Aug 26 '16 at 19:17
0
$\begingroup$

Don't use subscripts for this kind of thing, they are best at display. You can directly index into your arrays:

Total[0.5 Table[(f[[i + 1]] - f[[i]]) (su[[i]] Ta[[i]]^2 + 
      su[[i + 1]] Ta[[i+1]]^2), {i, 1, Length[f] - 2}]]
$\endgroup$
  • $\begingroup$ Why Length[f]-2 shouldn't it be Length[f]-1? $\endgroup$ – mikado Aug 26 '16 at 19:11
  • $\begingroup$ worked. thanks a lot for your help and fast reply. I would like to add a "newbie" question. Which is the role of the gaps in-between the equation u posted ? e.g. (f[[i+1]] - f[[i]]) GAP (su[[i]] GAP Ta[[i]]^2 .... $\endgroup$ – St LFC Aug 26 '16 at 19:12
  • $\begingroup$ @bill s, isn't putting Total round a Table redundant? Wouldn't Sum be better? $\endgroup$ – mikado Aug 26 '16 at 19:20
  • $\begingroup$ The gaps (spaces) are multiplication. I tend to use Total[Table[ ]] rather than Sum[ ] because it is easy to look at the elements of the Table and make sure they are correct. But yes, you can save a few characters with Sum. $\endgroup$ – bill s Aug 26 '16 at 20:45
0
$\begingroup$

You just need to use the Subscript form of Part. I have used ta and su since you should not begin variables with a capital letter. I also added 0.001 to the end of su as it only has 16 entries.

Mathematica graphics

Or in InputForm

Sum[(1/2)*(f[[i + 1]] - f[[i]])*(su[[i]]*ta[[i]]^2 + 
    su[[i + 1]]*ta[[i + 1]]^2), {i, 1, 16}]

You can enter the subscript form of Part by surrounding the indices in the subscript with the part double square brackets. Either [[ and ]] or Esc+[[+Esc and Esc+]]+Esc.

Hope this helps.

$\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.