Python sympy integral calculation questions

Asked 2 years ago, Updated 2 years ago, 60 views

I used integrals and integrates commands to integrate functions containing square roots using Python's sympy module, but the results didn't come out well...

For example, root{(x^2+1)} I wrote the code to integrate the same function.

import sympy as sm
x=sm.Symbol('x')
f=(x**2+1)**(0.5)
g=sm.Integral(f,x).doit()
print(g)

I can't get the results.

How do you integrate the functions in the root with Python??

python sympy integral

2022-09-22 18:26

1 Answers

Of course, there's a symbol x.Only formulas appear before you give a symbol value.

from sympy import Symbol, Integral

x = Symbol('x')
f = (x**2+1)**(0.5)
g = Integral(f,x).doit()
g.evalf()

g.evalf(subs={x:2})

2.9578857150892


2022-09-22 18:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.