#N88BASIC

'区分求積法 その1

Const CX = 320
Const CY = 200

'定義
Function F(x As Double) As Double
F = (Sin(x)+Sin(x*4)) * 100
End Function

'画面
Function GrI() As Long
Dim x As Long, y As Long
Dim f As Long

For x=0 To 640 Step 10
Line(x, 0)-(x, 400),1
Next

For y=0 To 400 Step 10
Line(0, y)-(640, y),1
Next

Line(CX,0)-(CX,399),5,B
Line(0,CY)-(639,CY),5,B
Line(0,0)-(639,399),5,B

For x=-320 To 320
If f=0 Then
Pset(CX+x, CY-F(x * 3.1416/180)), 7
f=1
Else
Line -(CX+x, CY-F(x * 3.1416/180)), 7
End If
Next

End Function

Function Sum(start As Double, send As Double, dx As Double) As Double
Dim i As Double

For i=start To send+dx Step dx
Line(CX+i,CY-0)-(CX+i+dx, CY-F(i * 3.1416/180)),4,BF
Sum = Sum + dx * F(i * 3.1416/180)
Locate 20, 25 : Print "i=";i, "sum=";Sum,,
Next
End Function


GrI()'初期
Sum(-100, 100, 0.01)



最終更新:2010年11月21日 02:42