home > さまざまな言語で数値計算 > 数値積分 >

さまざまな言語で数値計算

Only Do What Only You Can Do

台形則

関数 $ f(x) $ の $ a, b $ 区間を $n$ 個に分割し, それらを台形で近似し面積を合計する.

例題として, $ 4/(1+x^2) $ を $0$ から $1$ まで積分し $\pi$ を求める.

VBScript

Option Explicit

Const PI = 3.14159265359
Const a = 0
Const b = 1

'台形則で積分
Dim n: n = 2
Dim i, j
For j = 1 To 10
    Dim h: h = (b - a) / n
    Dim s: s = 0
    Dim x: x = a
    For i = 1 To n - 1
        x = x + h
        s = s + f(x)
    Next
    s = h * ((f(a) + f(b)) / 2 + s)
    n = n * 2

    '結果を π と比較
    WScript.StdOut.Write Right(Space(2)  & j,                                   2) & " : "
    WScript.StdOut.Write Right(Space(13) & FormatNumber(s,      10, -1, 0, 0), 13) & ", "
    WScript.StdOut.Write Right(Space(13) & FormatNumber(s - PI, 10, -1, 0, 0), 13) & vbNewLine
Next

Private Function f(x)
    f = 4 / (1 + x * x)
End Function
Z:\>cscript //nologo Z:\0601.vbs
 1 :  3.1000000000, -0.0415926536
 2 :  3.1311764706, -0.0104161830
 3 :  3.1389884945, -0.0026041591
 4 :  3.1409416120, -0.0006510415
 5 :  3.1414298932, -0.0001627604
 6 :  3.1415519635, -0.0000406901
 7 :  3.1415824811, -0.0000101725
 8 :  3.1415901105, -0.0000025431
 9 :  3.1415920178, -0.0000006358
10 :  3.1415924946, -0.0000001589

JScript

var a = 0
var b = 1

// 台形則で積分
var n = 2;
for (var j = 1; j <= 10; j++)
{
    var h = (b - a) / n
    var s = 0
    var x = a
    for (var i = 1; i <= n - 1; i++)
    {
        x += h
        s += f(x)
    }
    s = h * ((f(a) + f(b)) / 2 + s)
    n *= 2

    // 結果を π と比較
    WScript.StdOut.Write(("  "            + j                        ).slice( -2) + " : ");
    WScript.StdOut.Write(("             " + s.toFixed(10)            ).slice(-13) + ", ");
    WScript.StdOut.Write(("             " + (s - Math.PI).toFixed(10)).slice(-13) + "\n" );
}

function f(x)
{
    return 4 / (1 + x * x)
}
Z:\>cscript //nologo Z:\0601.js
 1 :  3.1000000000, -0.0415926536
 2 :  3.1311764706, -0.0104161830
 3 :  3.1389884945, -0.0026041591
 4 :  3.1409416120, -0.0006510415
 5 :  3.1414298932, -0.0001627604
 6 :  3.1415519635, -0.0000406901
 7 :  3.1415824811, -0.0000101725
 8 :  3.1415901105, -0.0000025431
 9 :  3.1415920178, -0.0000006358
10 :  3.1415924946, -0.0000001589

PowerShell

function f($x)
{
    4 / (1 + $x * $x)
}

$a = 0
$b = 1

# 台形則で積分
$n = 2;
foreach ($j in 1..10)
{
    $h = ($b - $a) / $n
    $s = 0
    $x = $a
    foreach ($i in 1..($n - 1))
    {
        $x += $h
        $s += (f $x)
    }
    $s = $h * (((f $a) + (f $b)) / 2 + $s)
    $n *= 2

    # 結果を π と比較
    Write-Host ([String]::Format("{0,2:D} : {1,13:F10}, {2,13:F10}", $j, $s, $s - [Math]::PI))
}
Z:\>powershell -file Z:\0601.ps1
 1 :  3.1000000000, -0.0415926536
 2 :  3.1311764706, -0.0104161830
 3 :  3.1389884945, -0.0026041591
 4 :  3.1409416120, -0.0006510415
 5 :  3.1414298932, -0.0001627604
 6 :  3.1415519635, -0.0000406901
 7 :  3.1415824811, -0.0000101725
 8 :  3.1415901105, -0.0000025431
 9 :  3.1415920178, -0.0000006358
10 :  3.1415924946, -0.0000001589

Perl

use Math::Trig 'pi';

my $a = 0;
my $b = 1;

# 台形則で積分
my $n = 2;
for $j (1..10)
{
    my $h = ($b - $a) / $n;
    my $s = 0;
    my $x = $a;
    for $i (1..($n - 1))
    {
        $x += $h;
        $s += f($x);
    }
    $s = $h * ((f($a) + f($b)) / 2 + $s);
    $n *= 2;

    # 結果を π と比較
    printf("%2d : %13.10f, %13.10f\n", $j, $s, $s - pi);
}

sub f
{
    my ($x) = @_;
    4 / (1 + $x * $x);
}
Z:\>perl Z:\0601.pl
 1 :  3.1000000000, -0.0415926536
 2 :  3.1311764706, -0.0104161830
 3 :  3.1389884945, -0.0026041591
 4 :  3.1409416120, -0.0006510415
 5 :  3.1414298932, -0.0001627604
 6 :  3.1415519635, -0.0000406901
 7 :  3.1415824811, -0.0000101725
 8 :  3.1415901105, -0.0000025431
 9 :  3.1415920178, -0.0000006358
10 :  3.1415924946, -0.0000001589

PHP

<?php
$a = 0;
$b = 1;

# 台形則で積分
$n = 2;
foreach (range(1, 10) as $j)
{
    $h = ($b - $a) / $n;
    $s = 0;
    $x = $a;
    foreach (range(1, ($n - 1)) as $i)
    {
        $x += $h;
        $s += f($x);
    }
    $s = $h * ((f($a) + f($b)) / 2 + $s);
    $n *= 2;

    # 結果を π と比較
    printf("%2d : %13.10f, %13.10f\n", $j, $s, $s - M_PI);
}

function f($x)
{
    return 4 / (1 + $x * $x);
}
?>
Z:\>php Z:\0601.php
 1 :  3.1000000000, -0.0415926536
 2 :  3.1311764706, -0.0104161830
 3 :  3.1389884945, -0.0026041591
 4 :  3.1409416120, -0.0006510415
 5 :  3.1414298932, -0.0001627604
 6 :  3.1415519635, -0.0000406901
 7 :  3.1415824811, -0.0000101725
 8 :  3.1415901105, -0.0000025431
 9 :  3.1415920178, -0.0000006358
10 :  3.1415924946, -0.0000001589

Python

# coding: Shift_JIS

import math

def f(x):
    return 4 / (1 + x * x)

a = 0
b = 1

# 台形則で積分
n = 2
for j in range(1, 11):
    h = (b - a) / float(n)
    s = 0
    x = a
    for i in range(1, n):
        x += h
        s += f(x)
    s = h * ((f(a) + f(b)) / 2 + s)
    n *= 2

    # 結果を π と比較
    print "%2d : %13.10f, %13.10f" % (j, s, s - math.pi)
Z:\>python Z:\0601.py
 1 :  3.1000000000, -0.0415926536
 2 :  3.1311764706, -0.0104161830
 3 :  3.1389884945, -0.0026041591
 4 :  3.1409416120, -0.0006510415
 5 :  3.1414298932, -0.0001627604
 6 :  3.1415519635, -0.0000406901
 7 :  3.1415824811, -0.0000101725
 8 :  3.1415901105, -0.0000025431
 9 :  3.1415920178, -0.0000006358
10 :  3.1415924946, -0.0000001589

Ruby

def f(x)
    4 / (1 + x * x)
end

a = 0
b = 1

# 台形則で積分
n = 2
(1..10).each do |j|
    h = (b - a) / n.to_f
    s = 0
    x = a
    (1..(n - 1)).each do |i|
        x += h
        s += f(x)
    end
    s = h * ((f(a) + f(b)) / 2 + s)
    n *= 2

    # 結果を π と比較
    printf("%2d : %13.10f, %13.10f\n", j, s, s - Math::PI)
end
Z:\>ruby Z:\0601.rb
 1 :  3.1000000000, -0.0415926536
 2 :  3.1311764706, -0.0104161830
 3 :  3.1389884945, -0.0026041591
 4 :  3.1409416120, -0.0006510415
 5 :  3.1414298932, -0.0001627604
 6 :  3.1415519635, -0.0000406901
 7 :  3.1415824811, -0.0000101725
 8 :  3.1415901105, -0.0000025431
 9 :  3.1415920178, -0.0000006358
10 :  3.1415924946, -0.0000001589

Groovy

Pascal

program Pas0601(arg);
{$MODE delphi}

uses
    SysUtils, Math;

function f(x:Double):Double;
begin
    result := 4 / (1 + x * x);
end;

const
    a:Double = 0;
    b:Double = 1;
var
    n, i, j:Integer;
    h, s, x:Double;
begin
    // 台形則で積分
    n := 2;
    for j := 1 to 10 do
    begin
        h := (b - a) / n;
        s := 0;
        x := a;
        for i := 1 to n - 1 do
        begin
            x := x + h;
            s := s + f(x);
        end;
        s := h * ((f(a) + f(b)) / 2 + s);
        n := n * 2;

        // 結果を π と比較
        writeln(format('%2d : %13.10f, %13.10f', [j, s, s - PI]));
    end;
end.
Z:\>fpc -v0 -l- Pas0601.pp

Z:\>Pas0601
 1 :  3.1000000000, -0.0415926536
 2 :  3.1311764706, -0.0104161830
 3 :  3.1389884945, -0.0026041591
 4 :  3.1409416120, -0.0006510415
 5 :  3.1414298932, -0.0001627604
 6 :  3.1415519635, -0.0000406901
 7 :  3.1415824811, -0.0000101725
 8 :  3.1415901105, -0.0000025431
 9 :  3.1415920178, -0.0000006358
10 :  3.1415924946, -0.0000001589

Ada

with TEXT_IO, Ada.Long_Float_Text_IO, Ada.Integer_Text_IO, Ada.Numerics;
use  TEXT_IO, Ada.Long_Float_Text_IO, Ada.Integer_Text_IO, Ada.Numerics;

procedure Ada0601 is
    a : Constant Long_Float := 0.0;
    b : Constant Long_Float := 1.0;

    h, s, x : Long_Float;
    n : Integer;

    function f(x:Long_Float) return Long_Float is
    begin
        return 4.0 / (1.0 + x * x);
    end f;

begin
    -- 台形則で積分
    n := 2;
    for j in 1..10 loop
        h := (b - a) / Long_Float(n);
        s := 0.0;
        x := a;
        for i in 1..(n - 1) loop
            x := x + h;
            s := s + f(x);
        end loop;
        s := h * ((f(a) + f(b)) / 2.0 + s);
        n := n * 2;

        -- 結果を π と比較
        Put(j,                   Width=> 2);
        Put(" : ");
        Put(s ,                  Fore=>3, Aft=>10, Exp=>0);
        Put(", ");
        Put(s - Ada.Numerics.Pi, Fore=>3, Aft=>10, Exp=>0);
        New_Line;
    end loop;
end Ada0601;
xxxxxx@yyyyyy /Z
$ gnatmake Ada0601.adb

xxxxxx@yyyyyy /Z
$ Ada0601
 1 :   3.1000000000,  -0.0415926536
 2 :   3.1311764706,  -0.0104161830
 3 :   3.1389884945,  -0.0026041591
 4 :   3.1409416120,  -0.0006510415
 5 :   3.1414298932,  -0.0001627604
 6 :   3.1415519635,  -0.0000406901
 7 :   3.1415824811,  -0.0000101725
 8 :   3.1415901105,  -0.0000025431
 9 :   3.1415920178,  -0.0000006358
10 :   3.1415924946,  -0.0000001589

VB.NET

Module VB0601
    Public Sub Main()
        Const a As Double = 0
        Const b As Double = 1

        '台形則で積分
        Dim n As Integer = 2
        For j As Integer = 1 To 10
            Dim h As Double = (b - a) / n
            Dim s As Double = 0
            Dim x As Double = a
            For i As Integer = 1 To n - 1
                x += h
                s += f(x)
            Next
            s = h * ((f(a) + f(b)) / 2 + s)
            n *= 2

            '結果を π と比較
            Console.WriteLine(String.Format("{0,2:D} : {1,13:F10}, {2,13:F10}", j, s, s - Math.PI))
        Next
    End Sub

    Private Function f(ByVal x As Double) As Double
        Return 4 / (1 + x * x)
    End Function
End Module
Z:\>vbc -nologo VB0601.vb

Z:\>VB0601
 1 :  3.1000000000, -0.0415926536
 2 :  3.1311764706, -0.0104161830
 3 :  3.1389884945, -0.0026041591
 4 :  3.1409416120, -0.0006510415
 5 :  3.1414298932, -0.0001627604
 6 :  3.1415519635, -0.0000406901
 7 :  3.1415824811, -0.0000101725
 8 :  3.1415901105, -0.0000025431
 9 :  3.1415920178, -0.0000006358
10 :  3.1415924946, -0.0000001589

C#

using System;

public class CS0601
{
    private static double f(double x)
    {
        return 4 / (1 + x * x);
    }

    public static void Main()
    {
        const double a = 0;
        const double b = 1;

        // 台形則で積分
        int n = 2;
        for (int j = 1; j <= 10; j++)
        {
            double h = (b - a) / n;
            double s = 0;
            double x = a;
            for (int i = 1; i <= n - 1; i++)
            {
                x += h;
                s += f(x);
            }
            s = h * ((f(a) + f(b)) / 2 + s);
            n *= 2;

            // 結果を π と比較
            Console.WriteLine(string.Format("{0,2:D} : {1,13:F10}, {2,13:F10}", j, s, s - Math.PI));
        }
    }
}
Z:\>csc -nologo CS0601.cs

Z:\>CS0601
 1 :  3.1000000000, -0.0415926536
 2 :  3.1311764706, -0.0104161830
 3 :  3.1389884945, -0.0026041591
 4 :  3.1409416120, -0.0006510415
 5 :  3.1414298932, -0.0001627604
 6 :  3.1415519635, -0.0000406901
 7 :  3.1415824811, -0.0000101725
 8 :  3.1415901105, -0.0000025431
 9 :  3.1415920178, -0.0000006358
10 :  3.1415924946, -0.0000001589

Java

public class Java0601 {

    private static double f(double x) {
        return 4 / (1 + x * x);
    }

    public static void main(String []args) {
        final double a = 0;
        final double b = 1;

        // 台形則で積分
        int n = 2;
        for (int j = 1; j <= 10; j++) {
            double h = (b - a) / n;
            double s = 0;
            double x = a;
            for (int i = 1; i <= n - 1; i++) {
                x += h;
                s += f(x);
            }
            s = h * ((f(a) + f(b)) / 2 + s);
            n *= 2;

            // 結果を π と比較
            System.out.println(String.format("%2d : %13.10f, %13.10f", j, s, s - Math.PI));
        }
    }
}
Z:\>javac Java0601.java

Z:\>java Java0601
 1 :  3.1000000000, -0.0415926536
 2 :  3.1311764706, -0.0104161830
 3 :  3.1389884945, -0.0026041591
 4 :  3.1409416120, -0.0006510415
 5 :  3.1414298932, -0.0001627604
 6 :  3.1415519635, -0.0000406901
 7 :  3.1415824811, -0.0000101725
 8 :  3.1415901105, -0.0000025431
 9 :  3.1415920178, -0.0000006358
10 :  3.1415924946, -0.0000001589

C++

#include <iostream>
#include <iomanip>
#include <math>

using namespace std;

double f(double x)
{
    return 4 / (1 + x * x);
}

int main()
{
    const double a = 0;
    const double b = 1;

    // 台形則で積分
    int n = 2;
    for (int j = 1; j <= 10; j++)
    {
        double h = (b - a) / n;
        double s = 0;
        double x = a;
        for (int i = 1; i <= n - 1; i++)
        {
            x += h;
            s += f(x);
        }
        s = h * ((f(a) + f(b)) / 2 + s);
        n *= 2;

        // 結果を π と比較
        cout << setw(2)  << j << ":";
        cout << setw(13) << fixed << setprecision(10) << s        << ", ";
        cout << setw(13) << fixed << setprecision(10) << s - M_PI << endl;
    }

    return 0;
}
Z:\>bcc32 -q CP0601.cpp
cp0601.cpp:

Z:\>CP0601
 1: 3.1000000000, -0.0415926536
 2: 3.1311764706, -0.0104161830
 3: 3.1389884945, -0.0026041591
 4: 3.1409416120, -0.0006510415
 5: 3.1414298932, -0.0001627604
 6: 3.1415519635, -0.0000406901
 7: 3.1415824811, -0.0000101725
 8: 3.1415901105, -0.0000025431
 9: 3.1415920178, -0.0000006358
10: 3.1415924946, -0.0000001589

Objective-C

#import <Foundation/Foundation.h>
#import <math.h>

double f(double x)
{
    return 4 / (1 + x * x);
}

int main()
{
    const double a = 0;
    const double b = 1;

    // 台形則で積分
    int n = 2;
    int i, j;
    for (j = 1; j <= 10; j++)
    {
        double h = (b - a) / n;
        double s = 0;
        double x = a;
        for (i = 1; i <= n - 1; i++)
        {
            x += h;
            s += f(x);
        }
        s = h * ((f(a) + f(b)) / 2 + s);
        n *= 2;

        // 結果を π と比較
        printf("%2d : %13.10f, %13.10f\n", j, s, s - M_PI);
    }

    return 0;
}
xxxxxx@yyyyyy /Z
$ gcc -o OC0601 OC0601.m -lobjc -lgnustep-base -I $INCLUDE -L $LIB $CFLAGS

xxxxxx@yyyyyy /Z
$ OC0601
 1 :  3.1000000000, -0.0415926536
 2 :  3.1311764706, -0.0104161830
 3 :  3.1389884945, -0.0026041591
 4 :  3.1409416120, -0.0006510415
 5 :  3.1414298932, -0.0001627604
 6 :  3.1415519635, -0.0000406901
 7 :  3.1415824811, -0.0000101725
 8 :  3.1415901105, -0.0000025431
 9 :  3.1415920178, -0.0000006358
10 :  3.1415924946, -0.0000001589

D

import std.stdio;
import std.math;

void main(string[] args)
{
    const double a = 0;
    const double b = 1;

    // 台形則で積分
    int n = 2;
    for (int j = 1; j <= 10; j++)
    {
        double h = (b - a) / n;
        double s = 0;
        double x = a;
        for (int i = 1; i <= n - 1; i++)
        {
            x += h;
            s += f(x);
        }
        s = h * ((f(a) + f(b)) / 2 + s);
        n *= 2;

        // 結果を π と比較
        writefln("%2d : %13.10f, %13.10f", j, s, s - PI);
    }
}

double f(double x)
{
    return 4 / (1 + x * x);
}
Z:\>dmd D0601.d

Z:\>D0601
 1 :  3.1000000000, -0.0415926535
 2 :  3.1311764706, -0.0104161830
 3 :  3.1389884945, -0.0026041590
 4 :  3.1409416120, -0.0006510415
 5 :  3.1414298932, -0.0001627604
 6 :  3.1415519635, -0.0000406901
 7 :  3.1415824811, -0.0000101725
 8 :  3.1415901105, -0.0000025431
 9 :  3.1415920178, -0.0000006357
10 :  3.1415924946, -0.0000001589

Go

package main

import "fmt"
import "math"

func main() {
    const a = 0
    const b = 1

    // 台形則で積分
    var n int = 2
    for j := 1; j <= 10; j++ {
        var h float64 = (b - a) / float64(n)
        var s float64 = 0
        var x float64 = a
        for i := 1; i <= n - 1; i++ {
            x += h
            s += f(x)
        }
        s = h * ((f(a) + f(b)) / 2 + s)
        n *= 2

        // 結果を π と比較
        fmt.Printf("%2d : %13.10f, %13.10f\n", j, s, s - math.Pi)
    }
}

func f(x float64) float64 {
    return (4 / (1 + x * x))
}
Z:\>8g GO0601.go

Z:\>8l -o GO0601.exe GO0601.8

Z:\>GO0601
 1 :  3.1000000000, -0.0415926536
 2 :  3.1311764706, -0.0104161830
 3 :  3.1389884945, -0.0026041591
 4 :  3.1409416120, -0.0006510415
 5 :  3.1414298932, -0.0001627604
 6 :  3.1415519635, -0.0000406901
 7 :  3.1415824811, -0.0000101725
 8 :  3.1415901105, -0.0000025431
 9 :  3.1415920178, -0.0000006358
10 :  3.1415924946, -0.0000001589

Scala

object Scala0601 {
    def main(args: Array[String]) {
        val a:Double = 0
        val b:Double = 1

        // 台形則で積分
        var n:Int = 2
        for (j <- 1 to 10) {
            var h:Double = (b - a) / n
            var s:Double = 0
            var x:Double = a
            for (i <- 1 to (n - 1)) {
                x += h
                s += f(x)
            }
            s = h * ((f(a) + f(b)) / 2 + s)
            n *= 2

            // 結果を π と比較
            println("%3d : %13.10f, %13.10f".format(j, s, s - Math.PI))
        }
    }

    def f(x:Double):Double = {
        4 / (1 + x * x)
    }
}
Z:\>scala Scala0601.scala
  1 :  3.1000000000, -0.0415926536
  2 :  3.1311764706, -0.0104161830
  3 :  3.1389884945, -0.0026041591
  4 :  3.1409416120, -0.0006510415
  5 :  3.1414298932, -0.0001627604
  6 :  3.1415519635, -0.0000406901
  7 :  3.1415824811, -0.0000101725
  8 :  3.1415901105, -0.0000025431
  9 :  3.1415920178, -0.0000006358
 10 :  3.1415924946, -0.0000001589

F#

module Fs0601

open System

let f(x:double):double =
    4.0 / (1.0 + x * x)

let a:double = 0.0
let b:double = 1.0

// 台形則で積分
let mutable n = 2
for j in [1..10] do
    let         h:double = (b - a) / (double n)
    let mutable s:double = 0.0
    let mutable x:double = a

    for i in [1..(n - 1)] do
        x <- x + h
        s <- s + (f x)
    s <- h * (((f a) + (f b)) / 2.0 + s)
    n <- n * 2

    // 結果を π と比較
    printfn "%3d : %13.10f, %13.10f" j s (s - Math.PI)

exit 0
Z:\>fsi  --nologo --quiet Fs0601.fs
  1 :  3.1000000000, -0.0415926536
  2 :  3.1311764706, -0.0104161830
  3 :  3.1389884945, -0.0026041591
  4 :  3.1409416120, -0.0006510415
  5 :  3.1414298932, -0.0001627604
  6 :  3.1415519635, -0.0000406901
  7 :  3.1415824811, -0.0000101725
  8 :  3.1415901105, -0.0000025431
  9 :  3.1415920178, -0.0000006358
 10 :  3.1415924946, -0.0000001589

Clojure

(defn f[x]
    (/ 4 (+ 1 (* x x))))

(def a 0)
(def b 1)

; 台形則で積分
(doseq [j (range 1 11)]
    (def n (Math/pow 2 j))
    (def h (/ (- b a) n))
    (def x a)
    (def s 0)
    (doseq [i (range 1 n)]
        (def x (+ x h))
        (def s (+ s (f x))))
    (def t1 (double (* h (+ (/ (+ (f a) (f b)) 2) s))))
    (def t2 (- t1 (. Math PI)))
    ; 結果を π と比較
    (println (format "%2d : %13.10f, %13.10f" j t1 t2)))
Z:\>java -cp C:\ProgramFiles\clojure-1.5.1\clojure-1.5.1.jar clojure.main Clj0601.clj
 1 :  3.1000000000, -0.0415926536
 2 :  3.1311764706, -0.0104161830
 3 :  3.1389884945, -0.0026041591
 4 :  3.1409416120, -0.0006510415
 5 :  3.1414298932, -0.0001627604
 6 :  3.1415519635, -0.0000406901
 7 :  3.1415824811, -0.0000101725
 8 :  3.1415901105, -0.0000025431
 9 :  3.1415920178, -0.0000006358
10 :  3.1415924946, -0.0000001589

Haskell

import Text.Printf
import Control.Monad

f::Double->Double
f x = 4 / (1 + (x * x))

main = do
    forM_ ([1..10::Integer]) $ \j -> do
        let n = 2 ^ j
        let a = 0.0
        let b = 1.0
        let h = (b - a) / (fromIntegral n)
        -- 台形則で積分
        let w1 = sum $ map(\x -> f x) $ map(\i -> (fromIntegral i) * h + a) $ [1..(n - 1)]
        let w2 = ((f a) + (f b)) / 2
        let t1 = h * (w1 + w2)
        -- 結果を π と比較
        let t2 = t1 - pi
        printf "%3d : %13.10f, %13.10f\n" j t1 t2
Z:\>runghc Hs0601.hs
  1 :  3.1000000000, -0.0415926536
  2 :  3.1311764706, -0.0104161830
  3 :  3.1389884945, -0.0026041591
  4 :  3.1409416120, -0.0006510415
  5 :  3.1414298932, -0.0001627604
  6 :  3.1415519635, -0.0000406901
  7 :  3.1415824811, -0.0000101725
  8 :  3.1415901105, -0.0000025431
  9 :  3.1415920178, -0.0000006358
 10 :  3.1415924946, -0.0000001589
inserted by FC2 system