Home Robotics C++ Physics II AP Physics B Electronics AP Java Astronomy Independent Study Summer Session Contests  About
                                                       

Some Math Methods

 

 

Name

Description

Abs

Returns the absolute value of a specified number.

Cos

Returns the cosine of the specified angle. Angle must be in radians

Max

Returns the larger of two specified numbers.

Min

Returns the smaller of two numbers.

Round

Rounds a value to the nearest integer.

Sin

Returns the sine of the specified angle.   Angle must be in radians

Sqrt

Returns the square root of a specified number.

Tan

Returns the tangent of the specified angle. Angle must be in radians

Truncate

Calculates the integral part of a number.

 

Math.sqrt

 

Imports System.Windows.Forms
Module Module1

    Sub Main()
        Dim root As Double = Math.Sqrt(2) ' calculate the square root of 2
        ' display the results in a message dialog
        MessageBox.Show("The square root of 2 is " & root, "The Square Root of 2")
    End Sub

End Module



Math.max

 

Imports System.Windows.Forms
Module Module1

    Sub Main()
        Dim number1 As Integer = 37
        Dim number2 As Integer = 45
        Dim largest As Integer
        largest = Math.Max(number1, number2)
        MessageBox.Show("The largest of " & num1 & " and " & unm22 & " is " & largest, "Math.max")
    End Sub

End Module

 

 

Math.min

 

Imports System.Windows.Forms
Module Module1

    Sub Main()
      Dim num1 As Integer = 37
      Dim num2 As Integer = 45
      Dim smallest As Integer
      smallest = Math.Min(num1, num2)
      MessageBox.Show("The smallest of " & num1 & " and " & num2 & " is " & smallest, "Math.min")
End Sub

End Module

 

 

Math.Round

Imports System.Windows.Forms
Module Module1

    Sub Main()
      Dim num1 As Double = 45.6789
      Dim Rnd As Integer = Math.Round(num1)
      MessageBox.Show("The effect of using Math.Round on 45.6789 is: " & Rnd, "Math.Round")
End Sub

End Module
 

Math.Truncate

Imports System.Windows.Forms
Module Module1

    Sub Main()
      Dim num1 As Double = 45.6789
      Dim A As Integer = Math.Truncate(num1)
      MessageBox.Show("The effect of using Math.Truncate on 45.6789 is: " & A, "Math.Truncate")
    End Sub

End Module


Math.Abs

Imports System.Windows.Forms
Module Module1

    Sub Main()
        Dim num1 As Double = -45.6789
        Dim A As Double = Math.Abs(num1)
        MessageBox.Show("The effect of using Math.Abs on -45.6789 is: " & A, "Math.Abs")
    End Sub

End Module


Math.Sin

Imports System.Windows.Forms
Module Module1

    Sub Main()
        Dim x As Double = 3.1416 / 4
        Dim y As Double = Math.Sin(x)

        MessageBox.Show("The Sin of pi/4 is : " & y, "Math.Sin")
    End Sub

End Module
 

Math.Cos

Imports System.Windows.Forms
Module Module1

    Sub Main()
        Dim x As Double = 3.1416 / 4
        Dim y As Double = Math.Cos(x)

        MessageBox.Show("The Cos of pi/4 is : " & y, "Math.Cos")
    End Sub

End Module

Math.Tan

Imports System.Windows.Forms
Module Module1

    Sub Main()
        Dim x As Double = 3.1416 / 4
        Dim y As Double = Math.Tan(x)

        MessageBox.Show("The Tan of pi/4 is : " & y, "Math.Tan")
    End Sub

End Module

Note: The Tan should be 1 - the rest result from inaccuracies in numerical calculations - discuss in detail in my numerical methods course second semester