Area of circle by integration

41 views
Skip to first unread message

Ajith Kumar

unread,
Apr 23, 2024, 3:25:11 PMApr 23
to sympy

from sympy import *
x,y = symbols('x y')
y = sqrt(1 - x**2)
integrate(y,x ,(x, 0, 1)).evalf()

result is

I expected  value of Pi/4, by integrating a quarter of a circle with unit radius. Can anyone explain the reason, I am new to Simpy.

Regards

peter.st...@gmail.com

unread,
Apr 23, 2024, 3:48:38 PMApr 23
to sy...@googlegroups.com

This code:

 

import sympy as sm

x = sm.symbols('x')  

f = sm.integrate(sm.sqrt(1-x**2), (x, 0, 1))

print('f=', f)

 

gives:

f = pi /4

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/4bfbada5-0317-4272-a854-169e3ae6903cn%40googlegroups.com.

Chris Smith

unread,
Apr 23, 2024, 5:05:37 PMApr 23
to sympy
Your second arg is being interpreted as a flag for the `integrate` routine. You should not be telling it the integration variable via second arg when you have a limits:

```python
integrate(y,x) -> x*sqrt(1 - x**2)/2 + asin(x)/2
integrate(y,(x,1) -> pi/4
integrate(y,(x,0,1)) -> pi/4
```

/c
Reply all
Reply to author
Forward
0 new messages