SlideShare a Scribd company logo
1 of 10
Download to read offline
Ciaran Cox (1115773)
MA5605: Financial Computing 1 Assignment
0.1 Task 1: Newton’s Method
Newton’s method approximates a solution for f(x) = 0 by a series of iterations until enough accu-
racy is achieved. This sequence is computed by:
xi+1 = xi −
u(xi)
u (xi)
. for i = 0,1,2,3,...
The function in question is x5 +x−5 = 0, hence xi+1 = xi −(x5
i +xi −5)/(5x4 +1) for i ≥ 0. The
C file implemented (Appendix .1) approximates the solution to the function with 5 decimal points
of accuracy, with the user inputting the initial value of x. The C file (Appendix .2) tabulates the
iterations for initial values of x = 0 and x = 2 into a text file called ’tabulated results’, shown below.
Figure 1: tabulated results
Can see from the results in figure 1, that the same final value was achieved regardless of the initial
value of x. However the number iterations can vary depending on the initial value of x.
1
0.2 Task 2: Quadrature
The N-panel composite Simpsons rule for numerical quadrature is used to approximate an integral
in a interval [a,b] of a given function u(x) by;
SN(u) : =
N
∑
i=1
(
h
6
u(xi)+
4h
6
u(xi−1
2
)+
h
6
u(xi−1))
with h := (b−a)/N and xi := a+ih, so that
SN(u) → I(u) :=
b
a
u(x)dx as N → ∞
The C program simpsons.c (Appendix .3) requests x,y and N > 0 from the user, and prints out a
double precision approximation to the following function.
f(x,y) :=
y
x
sin(t)cost(t +2)dt
Running the C file table simpsons.c (Appendix .4) tabulates the results in to a separate text file, for
N ∈ 8,16,32,64,128,256,512 with the exact error (figure 2).
Figure 2: simpsons tabulated results
As N increases the error decreases and gives a higher decimal place of accuracy.
2
0.3 Task 3: Matrix algebra
Creating an N by N matrix A, with the entry in i-th row and j-th column being (i+ j)−1
. Let
y = (N,N −1,N −2,...1)T
∈ RN be a vector and define b = Ay. Then using the Gaussian elimina-
tion (without pivoting) algorithm given to solve Ax = b for x. The C file matrix.c (Appendix .5) im-
plements this and tabulates ||y−x||p
for p = 2 and p = ∞, into a text file called ’tabulated results’,
with the user’s choice of N.
Figure 3: matrix.c tabulated results
Tabulated above (Figure 3) is the output of C file matrix.c with a user input of 25. As N increases the
norms are moving away from 0, with the 2 norm diverging faster than the infinity norm. The choice
of N should not have an effect on the values of the norm, however due to computational restrictions
and decimal point accuracy, more N is increased further away from 0 the norms become.
3
.1 Newton’s Method C File
Figure 4: newton.c
4
.2 Tabulated Results for Newton C File
Figure 5: table newton.c
5
.3 Simpsons C file
Figure 6: simpsons.c (part A)
6
Figure 7: simpsons.c (part B)
7
.4 Tabulated results for Simpsons C file
Figure 8: table simpsons.c
8
.5 Matrix Algebra C file
Figure 9: matrix.c (part A)
9
Figure 10: matrix.c (part B)
10

More Related Content

What's hot

Lecture03 p1
Lecture03 p1Lecture03 p1
Lecture03 p1
aa11bb11
 
Intro to scan conversion
Intro to scan conversionIntro to scan conversion
Intro to scan conversion
Mohd Arif
 

What's hot (19)

Unit 3
Unit 3Unit 3
Unit 3
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
DDA algorithm
DDA algorithmDDA algorithm
DDA algorithm
 
Dda algorithm
Dda algorithmDda algorithm
Dda algorithm
 
1565 matrix01-ppt
1565 matrix01-ppt1565 matrix01-ppt
1565 matrix01-ppt
 
Lecture03 p1
Lecture03 p1Lecture03 p1
Lecture03 p1
 
Introduction to curve
Introduction to curveIntroduction to curve
Introduction to curve
 
Computer graphics presentation
Computer graphics presentationComputer graphics presentation
Computer graphics presentation
 
Lab lecture 1 line_algo
Lab lecture 1 line_algoLab lecture 1 line_algo
Lab lecture 1 line_algo
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer Graphics
 
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- ButkarComputer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
Computer Graphics - Introduction in Brief By: Prof. Manisha Waghmare- Butkar
 
Bresenham algorithm
Bresenham algorithmBresenham algorithm
Bresenham algorithm
 
Curve fitting
Curve fittingCurve fitting
Curve fitting
 
Intro to scan conversion
Intro to scan conversionIntro to scan conversion
Intro to scan conversion
 
Solution of matlab chapter 2
Solution of matlab chapter 2Solution of matlab chapter 2
Solution of matlab chapter 2
 
DDA (digital differential analyzer)
DDA (digital differential analyzer)DDA (digital differential analyzer)
DDA (digital differential analyzer)
 
ws2 Linear Equation
ws2 Linear Equationws2 Linear Equation
ws2 Linear Equation
 
Dda line algorithm presentatiion
Dda line algorithm presentatiionDda line algorithm presentatiion
Dda line algorithm presentatiion
 
Solution of matlab chapter 4
Solution of matlab chapter 4Solution of matlab chapter 4
Solution of matlab chapter 4
 

Viewers also liked

CV - Ing. Silvano Perrone
CV - Ing. Silvano PerroneCV - Ing. Silvano Perrone
CV - Ing. Silvano Perrone
Silvano Perrone
 

Viewers also liked (20)

Fórum 2016 - Automação de Centros de Logísticas no E-commerce – Panorama atua...
Fórum 2016 - Automação de Centros de Logísticas no E-commerce – Panorama atua...Fórum 2016 - Automação de Centros de Logísticas no E-commerce – Panorama atua...
Fórum 2016 - Automação de Centros de Logísticas no E-commerce – Panorama atua...
 
Greener and engaged people for Schiedam
Greener and engaged people for SchiedamGreener and engaged people for Schiedam
Greener and engaged people for Schiedam
 
Presentación del portafolio j
Presentación del portafolio jPresentación del portafolio j
Presentación del portafolio j
 
Smau2007: Il marketing liquido
Smau2007: Il marketing liquidoSmau2007: Il marketing liquido
Smau2007: Il marketing liquido
 
nativi digitali
 nativi digitali  nativi digitali
nativi digitali
 
місто тварин етапи реалізації
місто тварин етапи реалізаціїмісто тварин етапи реалізації
місто тварин етапи реалізації
 
Social Innovation? Different locations & same questions. A perspective from t...
Social Innovation? Different locations & same questions. A perspective from t...Social Innovation? Different locations & same questions. A perspective from t...
Social Innovation? Different locations & same questions. A perspective from t...
 
Innovazione è crescita | collaborazione, coworking e codesign
Innovazione è crescita | collaborazione, coworking e codesignInnovazione è crescita | collaborazione, coworking e codesign
Innovazione è crescita | collaborazione, coworking e codesign
 
Dr
DrDr
Dr
 
CV - Ing. Silvano Perrone
CV - Ing. Silvano PerroneCV - Ing. Silvano Perrone
CV - Ing. Silvano Perrone
 
Digital workplace och informationshantering i office 365
Digital workplace och informationshantering i office 365Digital workplace och informationshantering i office 365
Digital workplace och informationshantering i office 365
 
"Speech recognition" - Hidden Markov Models @ Papers We Love Bucharest
"Speech recognition" - Hidden Markov Models @ Papers We Love Bucharest"Speech recognition" - Hidden Markov Models @ Papers We Love Bucharest
"Speech recognition" - Hidden Markov Models @ Papers We Love Bucharest
 
Five Broadband Trends Shaping Communities, 19 September 2013
Five Broadband Trends Shaping Communities, 19 September 2013Five Broadband Trends Shaping Communities, 19 September 2013
Five Broadband Trends Shaping Communities, 19 September 2013
 
Web Travel 2.0... la storia continua
Web Travel 2.0... la storia continuaWeb Travel 2.0... la storia continua
Web Travel 2.0... la storia continua
 
Tourist Experience Design
Tourist Experience DesignTourist Experience Design
Tourist Experience Design
 
Office 365 Adoption User Group Chicagoland Chapter October 2016 Meeting Slides
Office 365 Adoption User Group Chicagoland Chapter October 2016 Meeting SlidesOffice 365 Adoption User Group Chicagoland Chapter October 2016 Meeting Slides
Office 365 Adoption User Group Chicagoland Chapter October 2016 Meeting Slides
 
Imagine milan
Imagine milan Imagine milan
Imagine milan
 
Action for age 2
Action for age 2Action for age 2
Action for age 2
 
Repicturing suburban neighborhood
Repicturing suburban neighborhood   Repicturing suburban neighborhood
Repicturing suburban neighborhood
 
Free design bank
Free design bankFree design bank
Free design bank
 

Similar to Assignment 1

Consider a l-D elastic bar problem defined on [0, 4]. The domain .pdf
Consider a l-D elastic bar problem defined on [0, 4]. The domain .pdfConsider a l-D elastic bar problem defined on [0, 4]. The domain .pdf
Consider a l-D elastic bar problem defined on [0, 4]. The domain .pdf
feroz544
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
anhlodge
 

Similar to Assignment 1 (20)

Jacobi iterative method
Jacobi iterative methodJacobi iterative method
Jacobi iterative method
 
Parallel algorithm in linear algebra
Parallel algorithm in linear algebraParallel algorithm in linear algebra
Parallel algorithm in linear algebra
 
Computer Network Homework Help
Computer Network Homework HelpComputer Network Homework Help
Computer Network Homework Help
 
On image intensities, eigenfaces and LDA
On image intensities, eigenfaces and LDAOn image intensities, eigenfaces and LDA
On image intensities, eigenfaces and LDA
 
Consider a l-D elastic bar problem defined on [0, 4]. The domain .pdf
Consider a l-D elastic bar problem defined on [0, 4]. The domain .pdfConsider a l-D elastic bar problem defined on [0, 4]. The domain .pdf
Consider a l-D elastic bar problem defined on [0, 4]. The domain .pdf
 
Online Maths Assignment Help
Online Maths Assignment HelpOnline Maths Assignment Help
Online Maths Assignment Help
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
 
Networking Assignment Help
Networking Assignment HelpNetworking Assignment Help
Networking Assignment Help
 
Signals and Systems Homework Help.pptx
Signals and Systems Homework Help.pptxSignals and Systems Homework Help.pptx
Signals and Systems Homework Help.pptx
 
Online Maths Assignment Help
Online Maths Assignment HelpOnline Maths Assignment Help
Online Maths Assignment Help
 
Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2Scilab for real dummies j.heikell - part 2
Scilab for real dummies j.heikell - part 2
 
Lecture50
Lecture50Lecture50
Lecture50
 
Lecture 07 graphing linear equations
Lecture 07 graphing linear equationsLecture 07 graphing linear equations
Lecture 07 graphing linear equations
 
DSP_FOEHU - MATLAB 01 - Discrete Time Signals and Systems
DSP_FOEHU - MATLAB 01 - Discrete Time Signals and SystemsDSP_FOEHU - MATLAB 01 - Discrete Time Signals and Systems
DSP_FOEHU - MATLAB 01 - Discrete Time Signals and Systems
 
05_AJMS_332_21.pdf
05_AJMS_332_21.pdf05_AJMS_332_21.pdf
05_AJMS_332_21.pdf
 
Linear Algebra.pptx
Linear Algebra.pptxLinear Algebra.pptx
Linear Algebra.pptx
 
Calculus Homework Help
Calculus Homework HelpCalculus Homework Help
Calculus Homework Help
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
 
Differential Equations Homework Help
Differential Equations Homework HelpDifferential Equations Homework Help
Differential Equations Homework Help
 
Calculus Assignment Help
Calculus Assignment HelpCalculus Assignment Help
Calculus Assignment Help
 

Assignment 1

  • 1. Ciaran Cox (1115773) MA5605: Financial Computing 1 Assignment 0.1 Task 1: Newton’s Method Newton’s method approximates a solution for f(x) = 0 by a series of iterations until enough accu- racy is achieved. This sequence is computed by: xi+1 = xi − u(xi) u (xi) . for i = 0,1,2,3,... The function in question is x5 +x−5 = 0, hence xi+1 = xi −(x5 i +xi −5)/(5x4 +1) for i ≥ 0. The C file implemented (Appendix .1) approximates the solution to the function with 5 decimal points of accuracy, with the user inputting the initial value of x. The C file (Appendix .2) tabulates the iterations for initial values of x = 0 and x = 2 into a text file called ’tabulated results’, shown below. Figure 1: tabulated results Can see from the results in figure 1, that the same final value was achieved regardless of the initial value of x. However the number iterations can vary depending on the initial value of x. 1
  • 2. 0.2 Task 2: Quadrature The N-panel composite Simpsons rule for numerical quadrature is used to approximate an integral in a interval [a,b] of a given function u(x) by; SN(u) : = N ∑ i=1 ( h 6 u(xi)+ 4h 6 u(xi−1 2 )+ h 6 u(xi−1)) with h := (b−a)/N and xi := a+ih, so that SN(u) → I(u) := b a u(x)dx as N → ∞ The C program simpsons.c (Appendix .3) requests x,y and N > 0 from the user, and prints out a double precision approximation to the following function. f(x,y) := y x sin(t)cost(t +2)dt Running the C file table simpsons.c (Appendix .4) tabulates the results in to a separate text file, for N ∈ 8,16,32,64,128,256,512 with the exact error (figure 2). Figure 2: simpsons tabulated results As N increases the error decreases and gives a higher decimal place of accuracy. 2
  • 3. 0.3 Task 3: Matrix algebra Creating an N by N matrix A, with the entry in i-th row and j-th column being (i+ j)−1 . Let y = (N,N −1,N −2,...1)T ∈ RN be a vector and define b = Ay. Then using the Gaussian elimina- tion (without pivoting) algorithm given to solve Ax = b for x. The C file matrix.c (Appendix .5) im- plements this and tabulates ||y−x||p for p = 2 and p = ∞, into a text file called ’tabulated results’, with the user’s choice of N. Figure 3: matrix.c tabulated results Tabulated above (Figure 3) is the output of C file matrix.c with a user input of 25. As N increases the norms are moving away from 0, with the 2 norm diverging faster than the infinity norm. The choice of N should not have an effect on the values of the norm, however due to computational restrictions and decimal point accuracy, more N is increased further away from 0 the norms become. 3
  • 4. .1 Newton’s Method C File Figure 4: newton.c 4
  • 5. .2 Tabulated Results for Newton C File Figure 5: table newton.c 5
  • 6. .3 Simpsons C file Figure 6: simpsons.c (part A) 6
  • 7. Figure 7: simpsons.c (part B) 7
  • 8. .4 Tabulated results for Simpsons C file Figure 8: table simpsons.c 8
  • 9. .5 Matrix Algebra C file Figure 9: matrix.c (part A) 9
  • 10. Figure 10: matrix.c (part B) 10