2

I have this equation:

integrate(exp(-x**2), (x, c, -c))=1/2

which should look like this:

integral with limits

How can I find a solution for c, for example using a library such as sympy?

JohanC
  • 71,591
  • 8
  • 33
  • 66
  • This post is too general for stackoverflow, you can only ask specific coding questions. I suggest, you read about [sympy](https://docs.sympy.org/latest/index.html) – user8408080 Dec 29 '19 at 12:11
  • Take a look at https://docs.sympy.org/latest/modules/integrals/integrals.html – JohanC Dec 29 '19 at 12:49

1 Answers1

2

With Sympy you can do the following:

from sympy import *
from sympy.abc import x, c

sol = solve(Eq(integrate(exp(-x**2), (x,c,-c)), S(1)/2))
print("symbolic solution:", sol)
print("numeric solution:", [s.evalf() for s in sol])

Output:

symbolic solution: [erfinv(-1/(2*sqrt(pi)))]
numeric solution: [-0.255449286541000]
JohanC
  • 71,591
  • 8
  • 33
  • 66