我需要幫助編寫一個程序,該程序將使用黎曼定義(左和右規則)來計算f(x)=sin(x)
從a=0
到b=2*pi
的積分。我可以手工做幾天,但我沒有想法如何使用python進行編碼。Riemann sum in python
-1
A
回答
0
根據我的經驗,從wiki中查找方程式幫助我翻譯成python。這裏有幾個wiki頁面:
Fundamental theorem of calculus
而且,蟒蛇的數學模塊將幫助您完成此:
經過檢查這些,看看其他數學方程的一些例子Python語言來理解如何集成一些數學函數。
1
你看看這個代碼:http://statmath.org/calculate_area.pdf
# Calcuate the area under a curve
#
# Example Function y = x^2
#
# This program integrates the function from x1 to x2
# x2 must be greater than x1, otherwise the program will print an error message.
#
x1 = float(input('x1='))
x2 = float (input('x2='))
if x1 > x2:
print('The calculated area will be negative')
# Compute delta_x for the integration interval
#
delta_x = ((x2-x1)/1000)
j = abs ((x2-x1)/delta_x)
i = int (j)
print('i =', i)
# initialize
n=0
A= 0.0
x = x1
# Begin Numerical Integration
while n < i:
delta_A = x**2 * delta_x
x = x + delta_x
A = A + delta_A
n = n+1
print('Area Under the Curve =', A)
+0
這使得我需要做得更清楚。我只需要爲每個方法創建一個循環(左和右)。 –
相關問題
- 1. cuda triple riemann sum
- 2. Riemann Sum,梯形法則C
- 3. Bytearray sum in python
- 4. 來自Riemann sum in scipy.signal.convolve的人工製品
- 5. 與Riemann Sum中點Java的集成
- 6. sum sum amont in mysql
- 7. $ sum in MongoDB query
- 8. Sum in angular js loop
- 9. 在sage/sympy/Python中的Riemann Theta函數?
- 10. 使用SUM CASE和IN IN SQL
- 11. 在python sum()python
- 12. 斐波那契Sum in(Java)
- 13. ssrs sum text function in textbox
- 14. Python字典sum
- 15. Python CSV和SUM
- 16. ZeroDivisionError:float division` in python
- 17. python random sum quiz
- 18. Python:溢出Sum
- 19. Python - Sum 4D Array
- 20. python sum函數forloop
- 21. python sum matrix列表
- 22. SQL使用sum命令和「in」子句
- 23. 錯誤Subset sum in O(n^2)
- 24. SELECT * FROM表WHERE`id` in ...和where sum()less
- 25. Sql sum and show results in many列
- 26. groupby和sum in service angular 2/4
- 27. Vector3 in Meep in Python
- 28. python中的sum timedeltas
- 29. Python詞典列表[int:tuple] Sum
- 30. Riemann概率密度的總和
,你能否告訴我們到目前爲止你已經嘗試了什麼?代碼示例? – amitparikh
如果您可以手動完成,請執行您所做的每一步並將其轉換爲Python代碼。 – dornhege
你有沒有看到這個問題?它看起來非常相似。 http://stackoverflow.com/questions/17687756/numerical-integration-with-riemann-sum-python – sk8asd123