rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
lin_evol_opt_fd_Hessian_der.m
1 function Hessian_der = lin_evol_opt_fd_Hessian_der(model, model_data, mu,h)
2 %function U_der = lin_evol_opt_fd_Hessian(model, model_data, mu,h)
3 %
4 % function caluculating the third derivative of a function, by a
5 % sensitivity PDE for the first derivative and then finite differences for
6 % the second derivative of the first derivative :-)
7 %
8 % Markus Dihlmann 20.06.2011
9 
10 if isempty(mu)
11  mu = get_mu(model);
12 end
13 
14 old_mu = get_mu(model);
15 
16 if (nargin<4)
17  h=0.001; %stepsize
18 end
19 
20 
21 compute_derivative_old = model.compute_derivative_info;
22 
23 model.compute_derivative_info =1;
24 
25 
26 H= lin_evol_opt_fd_Hessian(model, model_data, mu,h);
27 
28 n_params=size(H,1);
29 
30 Hessian_der = cell(size(H,1)^2,n_params);
31 
32 
33 for k=1:n_params
34  mu(k) = mu(k) + h;
35  model = set_mu(model, mu);
36  Hh = lin_evol_opt_fd_Hessian(model, model_data,mu,h);
37  for i=1:n_params
38  for j=1:n_params
39  Hessian_der{(i-1)*n_params+j,k} = (-H{i,j}+Hh{i,j})./h;
40  end
41  end
42  mu(k) = mu(k) - h;
43  model = set_mu(model,mu);
44 end
45 
46 model = set_mu(model, old_mu);
47 model.compute_derivative_info = compute_derivative_old;