0% found this document useful (0 votes)
35 views4 pages

March 26 2008

The document discusses using Octave to solve problems related to splines and differential equations. It includes commands used in Octave and descriptions of user-defined spline functions. Plots are generated of the spline passing through given points and of the error between the spline derivative and a given function.

Uploaded by

api-3716660
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views4 pages

March 26 2008

The document discusses using Octave to solve problems related to splines and differential equations. It includes commands used in Octave and descriptions of user-defined spline functions. Plots are generated of the spline passing through given points and of the error between the spline derivative and a given function.

Uploaded by

api-3716660
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

hnson@hp matlab]$ ggv ../math543.

ps&
[1] 2955
[johnson@hp matlab]$ gedit natural_spline.m &
[2] 2962
[johnson@hp matlab]$ gedit ex_errorfunction.m
[johnson@hp matlab]$ octave -q
octave:1> help complete_spline
complete_spline is the user-defined function from the file
/home/johnson/m/mike/teaching/math543/matlab/complete_spline.m

[x,s]=complete_spline(xi,y,k,y_a,y_b) returns the pp (x,s), of degree k,


which represents the complete spline which satisfies the
interpolation conditions
s(xi(i))=y(i), s^(j)(a)=y_a(j), and s^(j)(b)=y_b(j)
note: k should be an odd integer greater than 1, the knot sequence
xi should be an increasing row vector, and y, y_a, y_b
should be a row vectors with length(y)=length(xi)>1,
length(y_a)=length(y_b)=(k-1)/2

additional help for built-in functions, operators, and variables


is available in the on-line version of the manual. use the command
`help -i <topic>' to search the manual index.

help and information about octave is also available on the www


at http://www.octave.org and via the [email protected]
mailing list.
octave:2> ex_errorfunction
the obtained spline s is represented by (x,s).
here is a plot of s.
debug> exit
here is a plot of the error between the derivative
of s and the function exp(-x^2).
octave:3> ex_errorfunction
the obtained spline s is represented by (x,s).
here is a plot of s.
debug> exit
here is a plot of the error between the derivative
of s and the function exp(-x^2).
octave:4> .01/64
ans = 0.00015625
octave:5> quit
[johnson@hp matlab]$ ls
bb2pp.m ex_quadrature.m pp_integ.m
b_spline.m ex_rgb_image.m pp_integ.m~
b_spline.m~ ex_seabed.m pp_knot_insert.m
check_bspline_deriv_formula.m ex_sound.m pp_mult.m
check_bspline_deriv_formula.m~ ex_splinecompare.m pp_val_fast.cc
cols2row.m ex_splinecompare.m~ pp_val_fast.o
complete_spline.m ex_splinecurve.m pp_val_fast.oct
dos_update ex_tensorproduct.m pp_val.m
ex_besselkernel.m ex_wave_equation.m quasi_interpolant.m
ex_boundaryeffects.m fast_discrete_conv.m readme
ex_bw_image.m hw5.m row2cols.m
ex_checkode.m hw5.m~ semi_discrete_2d_val.m
ex_cosfft.m hw6_1.m semi_discrete_val.m
ex_edge_detection.m hw6_1.m~ temp
ex_errorfunction.m hw6_3.m test1.m
ex_errorfunction.m~ hw6_3.m~ test2.m
ex_fftconv.m load_bmp.m test3.m
ex_j_omega.m natural_spline.m test4.m
ex_noboundaryeffects.m notaknot_spline.m test5.m
ex_odeconv.m periodic_spline.m test6.m
ex_odeconv.m~ pp_add.m trash.dat
ex_phifive.m pp_def_integ.m trash.m
ex_phifour.m pp_deriv.m trash.m~
[johnson@hp matlab]$ gedit ex_checkode.m
[johnson@hp matlab]$ octave -q
octave:1> ex_checkode
debug> who

*** dynamically linked functions:

lsode

*** currently compiled functions:

*** local user variables:

n xi __nargin__ a b y

debug> a
a = 0
debug> b
b = 5
debug> n
n = 20
debug> xi
xi =

columns 1 through 10:

0.00000 0.26316 0.52632 0.78947 1.05263 1.31579 1.57895 1.84211 2.10526


2.36842

columns 11 through 20:

2.63158 2.89474 3.15789 3.42105 3.68421 3.94737 4.21053 4.47368 4.73684


5.00000

debug> y
y =

columns 1 through 10:

0.00000 0.00302 0.02370 0.07792 0.17911 0.33850 0.56534 0.86632 1.24396


1.69412

columns 11 through 20:

2.20305 2.74470 3.27944 3.75492 4.10994 4.28086 4.20976 3.85221 3.18235


2.19344

debug> plot(xi,y,"*")
debug> ls
bb2pp.m ex_quadrature.m pp_integ.m~
b_spline.m ex_rgb_image.m pp_knot_insert.m
b_spline.m~ ex_seabed.m pp_mult.m
check_bspline_deriv_formula.m ex_sound.m pp_val_fast.cc
check_bspline_deriv_formula.m~ ex_splinecompare.m pp_val_fast.o
cols2row.m ex_splinecompare.m~ pp_val_fast.oct
complete_spline.m ex_splinecurve.m pp_val.m
dos_update ex_tensorproduct.m quasi_interpolant.m
ex_besselkernel.m ex_wave_equation.m readme
ex_boundaryeffects.m fast_discrete_conv.m row2cols.m
ex_bw_image.m hw5.m semi_discrete_2d_val.m
ex_checkode.m hw5.m~ semi_discrete_val.m
ex_checkode.m~ hw6_1.m temp
ex_cosfft.m hw6_1.m~ test1.m
ex_edge_detection.m hw6_3.m test2.m
ex_errorfunction.m hw6_3.m~ test3.m
ex_errorfunction.m~ load_bmp.m test4.m
ex_fftconv.m natural_spline.m test5.m
ex_j_omega.m notaknot_spline.m test6.m
ex_noboundaryeffects.m periodic_spline.m trash.dat
ex_odeconv.m pp_add.m trash.m
ex_odeconv.m~ pp_def_integ.m trash.m~
ex_phifive.m pp_deriv.m
ex_phifour.m pp_integ.m
debug> help notaknot_spline
notaknot_spline is the user-defined function from the file
/home/johnson/m/mike/teaching/math543/matlab/notaknot_spline.m

[x,s]=notaknot_spline(xi,y,k) returns the pp (x,s), of degree k,


which represents the not-a-knot spline which satisfies the
interpolation conditions s(xi(i))=y(i).
note: k should be an odd integer greater than 1, the knot sequence
xi should be an increasing row vector, and y
should be a row vector with length(y)=length(xi)>k.

additional help for built-in functions, operators, and variables


is available in the on-line version of the manual. use the command
`help -i <topic>' to search the manual index.

help and information about octave is also available on the www


at http://www.octave.org and via the [email protected]
mailing list.
debug> exit
here is a plot of the obtained spline passing thru the given points.
debug> z
error: `z' undefined near line 35 column 1
debug>
octave:1> ex_checkode
here is a plot of the obtained spline passing thru the given points.
debug> exit
here is a plot of the error (lhs-rhs) in the differential equation.
octave:2> ex_checkode
here is a plot of the obtained spline passing thru the given points.
debug> exit
here is a plot of the error (lhs-rhs) in the differential equation.
octave:3> quit
[johnson@hp matlab]$

You might also like