-
Notifications
You must be signed in to change notification settings - Fork 1
/
df_ch_vect.m
49 lines (42 loc) · 1.64 KB
/
df_ch_vect.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# THIS SOFTWARE COMES WITH NO WARRANTY WHATSOEVER, EXPRESSED OR IMPLIED.
# USE IT AT YOUR OWN RISK!
#
# By T.I. Toth, Cardiff University, U.K.; 1996-2002
#
#
# This routine computes the derivative of a function given in n equidistant
# sampling points x over the interval [a,b].
# First, the function values are computed at the Chebyshev coeffs.s by using
# the function cheb_linip(). Then, the Chebyshev coeffs. of the derivative
# are computed from those of the original function by means of cheb_der().
# Finally, the derivative function is evaluated at the same equidistant
# sampling points as the original function by applying chebev_vect().
#
# Input:
# x: row vector of the equidistant sampling points in the interval [a,b]
# with x(1)=a, x(n)=b, where n=length(x);
# f: row vector of the function values at x;
# m: the no. of Chebyshev coeffs. of the function f.
#
# Output:
# f_der: row vector of the values of the derivative of f at x.
#
# Internal variables:
# c_f: vector of the Chebyshev coeff.s of f;
# ch_der: vector of the Chebysev coeff.s of the derivative of f.
#
# External fct.s and procedures:
# cheb_linip(): computing the Chebyshev coeff.s;
# cheb_der(): computing the Chebyshev coeff.s of the derivative of f;
# chebev_vect(): evaluating the derivative of f at x.
function f_der=df_ch_vect(x,f,m)
n=length(x);
a=x(1);
b=x(n);
# Here the Chebyshev coeffs. of f will be computed:
c_f=cheb_linip(x,f,m);
# Now, the Chebyshev coeff.s of the derivative are computed from c_f:
ch_der=cheb_der(a,b,c_f,m);
# The derivative is evaluated at x:
f_der=chebev_vect(a,b,ch_der,x); # always a row vector
endfunction