0

i'd like to know how to solve a definite integral in Mathematica.

screenshot

I do know all variables except b, and need to solve for F(b)=0.

How can i solve it in Mathematica?

Here is my try:

 NSolve[Integrate[1/(8*(1 - ff) (2 Pi)^0.5) E^(-0.5*((x - 1.1)/(1 - ff)/8)^2), {x, 0, 9999}] == -0.44531779637243296, ff]
apaderno
  • 28,547
  • 16
  • 75
  • 90

3 Answers3

3

These integrals can be trivially expressed in terms of an error function: Wiki, Mathworld. Hence what you need here is a library to (i) calculate error functions, (ii) numerically solve non-linear equations. Virtually any language has this, so pick anything you're familiar with. In Mathematica, look up Erf and NSolve.

ev-br
  • 24,968
  • 9
  • 65
  • 78
  • This looks good. Nevertheless, mathematica does not ouput the values. here is my code Nsolve[(-Integrate[ 1/(8*(2*Pi)^0.5)*Exp[-0.5*((x - 1.1)/8)^2], {x, -Inf, 0}] + Integrate[ 1/((1 - f) 8*(2*Pi)^0.5)*Exp[-0.5*((x - 1.1)/(1 - f)/8)^2], {x, 0, Inf}]) == 0, f] – Patrick Seastar Sep 22 '12 at 14:35
  • Break the statement into pieces: start with a single integral, see if it's an erf of some sort (it should be). Plot it (as @duffimo said already)Then make sure you can `Nsolve` an equation where you know the solution. Then get it together. – ev-br Sep 22 '12 at 14:49
  • Error function, of course! I knew it'd be something nameable, but how do you search for an integral form? I leafed through Numerical Recipes quickly but missed it. Great insight, Zhenya. You obviously know this. Being able to name it is half the battle. I voted your answer up. – duffymo Sep 22 '12 at 15:07
  • @duffymo: well, that's just domain knowledge. I'm sure there are tons of things which are immediately obvious to you, while I'd have to scratch my head and ask :-) – ev-br Sep 22 '12 at 15:13
  • Nevertheless, the program refuses an NSolve command: NSolve[Integrate[ 1/(8*(1 - ff) (2 Pi)^0.5) E^(-0.5*((x - 1.1)/(1 - ff)/8)^2), {x, 0, 9999}] == -0.44531779637243296, ff] NSolve::nsmet: This system cannot be solved with the methods available to NSolve. By th way, it is an Error Function :) – Patrick Seastar Sep 22 '12 at 15:33
  • You're asking Mathematica to calculate the integral at each step of the solver. And you're making it harder for the integrator by using a weird upper limit instead of Mathematica-supplied `Infinity` – ev-br Sep 22 '12 at 15:42
  • It doesnt work for any upper limit, tried it for Infinity, 999, 99, 5 – Patrick Seastar Sep 22 '12 at 16:02
  • Can you just do an integral, with an infinite upper limit, for a fixed `ff`? – ev-br Sep 22 '12 at 16:56
  • Yes, and I can plot it as well. – Patrick Seastar Sep 22 '12 at 17:16
  • Plot[Integrate[ x/(8*(1 - fd)*(2 Pi)^0.5) E^(-0.5*((x - 1.1)/(8 - 8*fd))^2), {x, 0, Infinity}] + Integrate[x/(8*(2 Pi)^0.5) E^(-0.5*((x - 1.1)/8)^2), {x, -Infinity, 0}] - 0.5, {fd, 0, 1}] I will go with this solution, thanks a lot for your support. – Patrick Seastar Sep 22 '12 at 17:26
1

I'd start by plugging it into Wolfram Alpha and see what it gives you.

Mathematica should be able to do it. I think of statistics first when R comes up; I don't know about its calculus capabilities. Excel is not the first choice.

If I were you, I'd be less worried about the software and more worried about the solution itself. A function of this form might be well known. Plot each one and visually check to see what the functions look like and how easy they might be to integrate.

Like this:

http://www.wolframalpha.com/input/?i=graph+exp%28-%28%28x%2B5%29%2F1.5%29%5E2%29

You should be wondering why it's three similar looking integrals. Those singularities in the plot tell you why.

If there's no closed form solutions, you'll have to go with a numerical one. You'll have to choose an algorithm (simple Euler or Runga Kutta or something else), interval sizes, etc. You'll want to know about singular points and how best to tackle them.

Choosing a package is just the start.

duffymo
  • 305,152
  • 44
  • 369
  • 561
  • Thank you for the reply. unfortunately, I did not figure out how to solfe defined integration in wolfram alpha. – Patrick Seastar Sep 22 '12 at 13:20
  • I suppose I will try with mathematica then, thanks a lot. Any idea on how i can calculate this concrete problem? – Patrick Seastar Sep 22 '12 at 13:36
  • Vote the answer up if it helps. I'd prefer that to your thanks. I've given you one good bit of advice: plot those functions before you integrate them. Know what they look like before you start. – duffymo Sep 22 '12 at 13:38
  • +1 just for 'plot it' suggestion – ev-br Sep 22 '12 at 15:05
  • I can only vote up if i have more than 15 reputation points. by voting my question a minus 2 i have declined to 4, so i would but i cant. Sorry – Patrick Seastar Sep 23 '12 at 14:26
0

You might find http://r.789695.n4.nabble.com/calculus-using-R-td1676727.html helpful.

learner
  • 1,895
  • 2
  • 19
  • 21