0
$\begingroup$

It looks fundamental but I cannot find way to input a set of data into integration calculation. I need to get f value and f is defined as follows:

f=P*Exp[Integrate[(C-1)/P, {p, 0, p}]];
P={0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0};
C={-1337.49, -2675.98, -4014.47, -5352.96, -6691.44, -8029.93, -9368.42, -10706.9, -12045.4, -13383.9}
data = Transpose@{P, C}
{{0.5, -1337.49}, {1., -2675.98}, {1.5, -4014.47}, {2., -5352.96}, {2.5, -6691.44}, {3., -8029.93}, {3.5, -9368.42}, {4., -10706.9}, {4.5, -12045.4}, {5., -13383.9}}

I would like to find f value for each p and c data set.

Thanks in advance!!

$\endgroup$
4
  • $\begingroup$ I think this would benefit by an explanation of what you are trying to do. As it is, this is very difficult to follow. Are you trying to do a finite Riemann sum with those lists? Or is it that you have an integrand which is a function of some parameters, and you want to do the integral for each of those parameters? Also note: your integration variable p does not appear in your integrand. Please give us more details. $\endgroup$
    – march
    Commented Feb 1, 2017 at 21:38
  • $\begingroup$ It seems you want to use Map. In addition to what march said, you should avoid capital names for your variables. The character C is already defined by Mathematica, which will lead to problems. $\endgroup$
    – Felix
    Commented Feb 1, 2017 at 22:10
  • $\begingroup$ Sorry for giving confusion. What I want is to get f value (f=P*exp[Integrate[(C-1)/P]dP from 0 to P) and I want to input P and its corresponding C value. That's why I made a pair of P and C. I can do it manually by putting for example P=0.5 and C=-1337.49 but I'm looking for if there is a good way to input P and C pair into the f equation to get f value for each pair. $\endgroup$
    – Sean
    Commented Feb 2, 2017 at 2:45
  • $\begingroup$ your f expression simply makes no sense. You need to fix that first before worrying about applying it to lists. $\endgroup$
    – george2079
    Commented Feb 2, 2017 at 12:56

1 Answer 1

3
$\begingroup$
p = {0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0};
c = {-1337.49, -2675.98, -4014.47, -5352.96, -6691.44, -8029.93, 
     -9368.42, -10706.9, -12045.4, -13383.9};

data = Transpose[{p, c}];

Use SetDelayed

f[p_, c_] := p*Exp[Integrate[(c - 1)/p, {t, 0, p}]]

Use Apply at level 1

results = f @@@ data

(*  {2.512747917061579*10^-582, 2.525560837878922*10^-1163, 
 1.903829320439066*10^-1744, 1.275691509165536*10^-2325, 
 8.094267261094953*10^-2907, 4.881324768115008*10^-3488, 
 2.861959016839073*10^-4069, 1.660264261598790*10^-4650, 
 9.29320921611432*10^-5232, 5.137586860445090*10^-5813}  *)
$\endgroup$

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.