testFractional.m 1.12 KB
Newer Older
1
2
3
4
5
6
7
8
function [tests] = testFractional()
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here
tests = functiontests(localfunctions);
end

function testDerivative(testCase)
t = sym("t");
9
t0 = 0.5;
10

11
12
13
14
15
16
	for p = [0.1 0.4 0.7 0.9]
		
		% define the analytic solution for the fractional derivative
		[y, m] = fractional.monomialFractionalDerivative( t, t0, 1, p);
		
		% compute the fractional derivative with the function
17
		f = fractional.derivative(m, p, t0, t);
18
19
20
21
22
23
24
25
26
27
28
29
30
31
		
		% evaluate both and compare them
		dt = 0.1;
		% skip the first value because there is a singularity that can not be computed by the
		% default symbolic evaluation. 
		% TODO@ferdinand: allow the quantity.Symbolic to use the limit function for the evaluation
		% at certain points.
		tDomain = quantity.EquidistantDomain("t", t0+dt, t0+1, "stepSize", dt);
		
		Y = quantity.Symbolic( y, tDomain);
		F = quantity.Symbolic( f, tDomain);
		
		testCase.verifyEqual( Y.on(), F.on(), 'AbsTol', 1e-15);
		
32
 		h = fractional.derivative(m, p, t0, t, 'type', 'C');
33
34
35
		H = quantity.Symbolic( h, tDomain);
 		testCase.verifyEqual( H.on(), Y.on(), 'AbsTol', 1e-15);
	end
36
end