Numerical Mathematics and Computing, 5th Ed. - Sample Mathematica Codes

Numerical Mathematics and Computing
Fifth Edition
Ward Cheney & David Kincaid
Sample Mathematica Codes

In the following table, each line/entry contains the code file name, the page number where it can be found in the textbook, and a brief description. Click on the program name to display the source code, which can be downloaded.
Chapter 1: Introduction
sineplot 20 Plots of partial series for sin(x)
sin 20 Sine series expansion and plot
series 22, 27 Taylor series expansions
Chapter 2: Number Representation and Errors
numbers 52 Examples of numbers in different bases
precision 66, 81 Machine precision and accuracy
Chapter 3: Locating Roots of Equations
bisect 98-99 Bisection example
newt 108-109 Newton's method example
newt_sys 115 Newton's method for system of equations
secant 128 Examples associated with Secant
Chapter 4: Interpolation and Numerical Differentiation
newt_interp1 145 Newton interpolation polynomial example (5 data points)
newt_interp2 152 Newton interpolation polynomial example (4 data points)
newt_interp_sin 155 Newton interpolation (sin(x) at 10 equidistant ponts)
inv_interp 157 Newton inverse interpolation example
runge_fcn 171-172 Newton interpolation Runge function
derivative 186,189 Newton interpolation example 1
Chapter 5: Numerical Integration
error_integral1 202 Numerical integration: error integral
sine_integral 209 Numerical integration: sine integral
error_integral2 213 Numerical integration: exp(-x*x)
bernoulli 226 Bernoulli polynomials
Chapter 6: More on Numerical Integration
cos-exp 240-241 Numerical integration example: cos(2x)/exp(x)
cp6-2-8 260 Computer Problem 6.2.8
Chapter 7: Systems of Linear Equations
lin_sys1 266 Linear system first example
lin_sys2 290 Linear system second example
Chapter 8: More on Systems of Linear Equations
lu_factor 329 LU factorization
char_poly 358 Characteristic polynomial example
null 359 Null space example
timing 360 Timing example
eigen 360 Eigenvalue/eigenvector example
schur 363 Schur form example
svd 368 Singular Value Decomposition example
Chapter 9: Approximation by Spline Functions
cubic_spline1 402 Cubic spline example 1
cubic_spline2 408 Cubic spline example 2
bezier 434 Bezier polynomial example
Chapter 10: Ordinary Differential Equations
explicit 443 Explicit solution of an ODE
practial 444 Practial ODE example
ode1 450 Numerical solution of an ODE
ode2 452 Numerical solution of an ODE
ode3 463 Numerical solution of an ODE
ode4 476 Numerical solution of an ODE
Chapter 11: Systems of Ordinary Differential Equations
ode_sys1 488,494 Analytic/numerical solution systems of ODE 1
ode_2nd_order 501 Second order IVP
ode_high_order 503 High order IVP
ode_sys2 515 Analytic/numerical solution systems of ODE 2
Chapter 12: Smoothing of Data and the Method of Least Squares
ls_fit 523-524 Linear least squares fit for polynomials
np_ls_fit 526 Least squares fit of a non-polynomial function
cheby 532 Plot of Chebyshev polynomials
p_inv1 552 Minimal solution using pseudo-inverse of matrices
p_inv2 554 Find pseudo-inverse in case of loss in rank
Chapter 13: Monte Carlo Methods and Simulation
ran_num_exps 564 Examples using random numbers
Chapter 14: Boundary Value Problems for Ordinary Differential Equations
bvp1 607 Two-point boundary-value problem example 1
bvp2 607-608 Two-point boundary-value problem example 2
Chapter 15: Partial Differential Equations
heat 623 Parabolic PDE: solve heat eqn. & plot
wave 634-635 Hyperbolic PDE: solve wave eqn. & plot
Chapter 16: Minimization of Functions
min_val1 658 Minimizing multivariate functions
min_val2 659 Find local minimum of a function
taylor_series 675 Taylor series in two variables
Chapter 17: Linear Programming
lin_prog1 694 Maximize subject to inequality constraints
lin_prog2 698 Minimize subject to inequality constraints
lin_prog3 713 Minimize subject to equality constraints
lin_prog4 715 Minimize subject to inequality constraints

Addditional programs can be found at the textbook's anonymous ftp site:

[Home] [Features] [TOC] [Purchase] [Sample Code] [Web] [Manuals] [Errata] [Links]

  Last updated: 5/20/2003