0. FUNCTION APPROXIMATION


Index

Example 0: Compute Exp(x) and the approximation 1+x, as well as the error estimate x^2/2.

Problem 0: Compute Log(1+x) and the approximation x, as well as the error estimate x^2/2.


Example 0. Compute Exp(x) and the approximation 1+x, as well as the error estimate x^2/2.

Object, Property and settings:

Object		Property 	Setting
Form		Name            frmExpApx  		
		Caption		"Function Approximation"
Label		Name            Label1                
	  	Alignment       1  'Right Justify 
		Caption		"x:"
		TabIndex        0
TextBox 	Name		txtXvalue  
		TabIndex        1 
		Text            ".5"  
Label		Name            Label2
		Alignment       1  'Right Justify 
		Caption         "Exp(x):" 
		TabIndex        2 
Label 		Name		lblExponential  
		BorderStyle     1  'Fixed Single 
		TabIndex        3 
		Caption         "  'Blank
Line 		Name		Line1  
Label		Name            Label3
		Alignment       1  'Right Justify 
		Caption         "Exp(x) - (1+x):" 
		TabIndex        4 
Label 		Name		lblDifference  
		BorderStyle     1  'Fixed Single 
		TabIndex        5
Label 		Name 		Label4  
		Alignment       1  'Right Justify 
		Caption         "(x^2)/2:" 
		TabIndex        6 
Label 		Name		lblPolynomial  
		BorderStyle     1  'Fixed Single 
		TabIndex        7 
CommandButton 	Name		cmdCompute  
		Caption         "&Compute" 
		Default         -1  'True 
		TabIndex        8 
CommandButton 	Name		cdmQuit  
		Caption         "&Quit" 
		TabIndex        9 

Event Procedures:

' In (Declarations) section of (General)

' Project Name:     Approximation of Exp(x) by 1+x
' Date:             May, 1996 
' Programmer:       R. Berman 
' Description:      This program evaluates Exp(x) and 1+x 
'                   and computes the difference. It also 
'                   computes the error estimate (x^2)/2.
'                   In this example, we will not concern 
'                   ourselves with datatypes, formatting 
'                   output, or errors which may occur if 
'                   the user gives inappropriate input.
' Version           Microsoft Visual Basic 4.0


Private Sub cmdCompute_Click() 

    ' Assign the value of Exp(x) and compute the 
    ' difference Exp(x) - (1+x) as well as the 
    ' error estimate x^2/2. 
    lblExponential.Caption = Exp(txtXvalue.Text) 
    lblDifference.Caption = _
	lblExponential.Caption - (1 + txtXValue.Text)
    lblPolynomial = txtXValue.Text ^ 2 / 2 

End Sub

Private Sub cdmQuit_Click() 

    End     	' End the Program 
     
End Sub 



Problem 0. Compute Log(1+x) and the approximation x, as well as the error estimate x^2/2.


Remark: You can add a graph of the functions to the form as follows. Add a PictureBox, then create the graph in any program capable of creating a Windows Metafile graphic. The following was achieved by creating the graph with Scientific Workplace 2.5 (using the Maple 5 Kernel), copying the graph, and pasting it into the PictureBox.