comparison +rv/+time/BdfDerivative.m @ 1195:a4c00628a39d feature/rv

Add higher order approximations to BDFDerivative
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 07 Aug 2019 13:27:36 +0200
parents 010bb2677230
children
comparison
equal deleted inserted replaced
1194:bd5383809917 1195:a4c00628a39d
11 DvDt = (obj.coefficients(order,1)*v - sum(obj.coefficients(order,2:order+1).*v_prev,2))/dt; 11 DvDt = (obj.coefficients(order,1)*v - sum(obj.coefficients(order,2:order+1).*v_prev,2))/dt;
12 end 12 end
13 end 13 end
14 methods(Static) 14 methods(Static)
15 function c = getBdfCoefficients() 15 function c = getBdfCoefficients()
16 c = zeros(6,7); 16 c = zeros(9,10);
17 c(1,1) = 1; c(1,2) = 1; 17 c(1,1) = 1; c(1,2) = 1;
18 c(2,1) = 3/2; c(2,2) = 4/2; c(2,3) = -1/2; 18 c(2,1) = 3; c(2,2) = 4; c(2,3) = -1;
19 c(3,1) = 11/6; c(3,2) = 18/6; c(3,3) = -9/6; c(3,4) = 2/6; 19 c(3,1) = 11; c(3,2) = 18; c(3,3) = -9; c(3,4) = 2;
20 c(4,1) = 25/12; c(4,2) = 48/12; c(4,3) = -36/12; c(4,4) = 16/12; c(4,5) = -3/12; 20 c(4,1) = 25; c(4,2) = 48; c(4,3) = -36; c(4,4) = 16; c(4,5) = -3;
21 c(5,1) = 137/60; c(5,2) = 300/60; c(5,3) = -300/60; c(5,4) = 200/60; c(5,5) = -75/60; c(5,6) = 12/60; 21 c(5,1) = 137; c(5,2) = 300; c(5,3) = -300; c(5,4) = 200; c(5,5) = -75; c(5,6) = 12;
22 c(6,1) = 147/60; c(6,2) = 360/60; c(6,3) = -450/60; c(6,4) = 400/60; c(6,5) = -225/60; c(6,6) = 72/60; c(6,7) = -10/60; 22 c(6,1) = 147; c(6,2) = 360; c(6,3) = -450; c(6,4) = 400; c(6,5) = -225; c(6,6) = 72; c(6,7) = -10;
23 % Note: Higher orders than 6 are not stable, but can still be used as one-sided approximations of a derivatve
24 c(7,1) = 1089; c(7,2) = 2940; c(7,3) = -4410; c(7,4) = 4900; c(7,5) = -3675; c(7,6) = 1764; c(7,7) = -490; c(7,8) = 60;
25 c(8,1) = 2283; c(8,2) = 6720; c(8,3) = -11760; c(8,4) = 15680; c(8,5) = -14700; c(8,6) = 9408; c(8,7) = -3920; c(8,8) = 960; c(8,9) = -105;
26 c(9,1) = 7129; c(9,2) = 22680; c(9,3) = -45360; c(9,4) = 70560; c(9,5) = -79380; c(9,6) = 63504; c(9,7) = -35280; c(9,8) = 12960; c(9,9) = -2835; c(9,10) = 280;
27
28 % Scale coefficients
29 c(2,:) = c(2,:)/2;
30 c(3,:) = c(3,:)/6;
31 c(4,:) = c(4,:)/12;
32 c(5,:) = c(5,:)/60;
33 c(6,:) = c(6,:)/60;
34 c(7,:) = c(7,:)/420;
35 c(8,:) = c(8,:)/840;
36 c(9,:) = c(9,:)/2520;
23 end 37 end
24 end 38 end
25 end 39 end