
Option Strict On
Imports System.IO
Module Module1
    Function f(ByVal n As Integer, ByVal x As Double) As Double
        If n = 0 Then
            Return 1
        ElseIf n = 1 Then
            Return 2 * x
        Else
            Return 2 * x * f(n - 1, x) - f(n - 2, x)
        End If
    End Function
    Sub Main()
        Dim output As StreamWriter
        output = New StreamWriter("output.csv")
        Dim n As Integer = 5
        Dim x, xmin, xmax, dx, a As Double
        xmin = -1
        xmax = 1
        dx = 0.1
        For i As Integer = 0 To CInt((xmax - xmin) / dx)
            x = xmin + i * dx
            a = f(n, x)
            Console.WriteLine("{0}   {1}", x, a)
            output.WriteLine("{0};{1}", x, a)
        Next i
        output.Close()
        Console.ReadLine()

    End Sub

End Module
