-1

リーマン定義 (左と右の規則) を使用してf(x)=sin(x)からa=0までの積分を計算するプログラムのコーディングに助けが必要b=2*piです。これは何日も手作業で行うことができますが、python でコーディングする方法がまったくわかりません。

4

2 に答える 2

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)
于 2013-09-26T16:31:23.993 に答える
0

私の経験から、wiki から方程式を見ることは、python に変換するのに役立ちました。いくつかの wiki ページを次に示します。

リーマン定義

微積分の基本定理

数値積分

また、Python の数学モジュールはこれに役立ちます。

パイソン数学

これらを確認した後、Python 言語の他の数学方程式の例をいくつか見て、数学関数のいくつかを統合する方法を理解してください。

于 2013-09-26T16:25:17.673 に答える