Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
277 views
in Technique[技术] by (71.8m points)

math - Integration of sin x dx problem in python programming implementation

I want to implement this integration in Python:

Equation

So far I did the code below but it is not making sense. What am I doing wrong?

import sympy as sm
x=sm.Symbol('x')
x=sm.integrate(math.sin(x)**2, 2*x)
question from:https://stackoverflow.com/questions/65862611/integration-of-sin-x-dx-problem-in-python-programming-implementation

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Referencing the other answers you don't need to use trigintegrate but you do need to supply the integration limits when calling integrate if it is a definite integral:

In [31]: from sympy import integrate, sin, oo, Symbol

In [32]: x = Symbol('x')

In [33]: integrate(sin(x**2), (x, 0, oo))
Out[33]: 
√2?√π
─────
  4  

In [34]: _.n()
Out[34]: 0.626657068657750

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...