1
$\begingroup$

I have a function that looks like a sigmoid curve. I would like to calculate the right integration limit so that the area under the sigmoid curve has a given value.

my curve:

model = (3.70288 E^(-((0.134844 (30.8 - 17.8731 t)^2)/t)))/Sqrt[t]

I tried:

Solve[Integrate[model == 10^-2, {t, 0, x}], x]

But that didn't work.

$\endgroup$
1
  • $\begingroup$ By this piece of code Solve[ Integrate[ model == 10^-2, {t, 0, x}], x] I guess you mean: "find x such that the area under the curve is 10^-2". However this code cannot do that, Integrate works on functions, not on equations. $\endgroup$
    – Artes
    Commented Sep 22, 2015 at 15:33

1 Answer 1

7
$\begingroup$

Since Mathematica is a really powerful symbolic computing system I recommend to proceed symbolically as far as we can.

We define a function curve depending on t and four real positive parameters a, b, c, d:

curve[t_, a_, b_, c_, d_] := a Exp[-((b (c - d t)^2)/t)]/Sqrt[t]

Now Mathematica can evaluate this integral symbolically:

integral[x0_, x_, a_, b_, c_, d_] =
  Integrate[ curve[ t, a, b, c, d], { t, x0, x}, 
             Assumptions -> Join[{ x0 <= x, x >= 0}, 
                                  Thread[# > 0 &[{a, b, c, d}]]]]
-((a Sqrt[ Pi] (Erf[Sqrt[b/x] (c - d x)] - E^(4 b c d) Erf[Sqrt[b/x] (c + d x)] 
+ Erf[(b (-c + d x0))/Sqrt[b x0]] 
+ E^(4 b c d) Erf[(b (c + d x0))/Sqrt[b x0]]))/(2 Sqrt[b] d))

We have assumed the lower limit of integration x0, if we had assumed x0 == 0 the system couldn't provide a symbolic result yielding only an unsatisfactory warning:

Integrate::idiv: "Integral of E^(-((b (c-d t)^2)/t))/Sqrt[t] does not converge on {0, x}."

However our integral can be evaluated in the limit as x0 -> 0:

area[x_, a_, b_, c_, d_] =
  Limit[ integral[ x0, x, a, b, c, d], x0 -> 0, 
         Assumptions -> {x >= 0, a > 0, b > 0, c > 0, d > 0}]
 (a Sqrt[ Pi] (1 - E^(4 b c d) - Erf[ Sqrt[b/x] (c - d x)]
+ E^(4 b c d) Erf[ Sqrt[b/x] (c + d x)]))/(2 Sqrt[b] d)

Now you can solve your equation with Solve providing rational parameters (possibly using appropriate options), otherwise for real parameters use NSolve or FindRoot. Now, it is reasonable to search for numeric solutions since there are Erf functions involved. Your original parameters haven't been justified and it might be necessary it play with AccuracyGoal and PrecissionGoal. E.g. we can easily find the upper limit of integration x for these reasonable parameters:

FindRoot[ area[x, 0.2, 0.3, 6.1, 3.1] == 0.01, {x, 0.5}, 
          AccuracyGoal -> 5, PrecisionGoal -> 5]
{x -> 1.26325}

In case of your parameters there appear underflow and overflow issues, for more on these topics read e.g.: Numerical underflow for a scaled error function

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