Here’s a simple VB.NET program to calculate the sine of an angle using the Taylor series expansion:
<code class="language-vb">Module SineSeriesFunction Sine(x As Double, terms As Integer) As Double Dim sineValue As Double = 0.0 For n As Integer = 0 To terms - 1 Dim term As Double = Math.Pow(-1, n) * Math.Pow(x, 2 * n + 1) / Factorial(2 * n + 1) sineValue += term Next Return sineValue End Function
Function Factorial(n As Integer) As Double Dim result As Double = 1 For i As Integer = 2 To n result *= i Next Return result End Function
Sub Main() Dim angle As Double = Math.PI / 4 ' 45 degrees Dim terms As Integer = 10 Console.WriteLine("Sine of 45 degrees: " & Sine(angle, terms)) End Sub End Module
</code>
This program defines the sine function using Taylor series and calculates the sine of 45 degrees using 10 terms of the series.
Copyright © 2026 eLLeNow.com All Rights Reserved.