I have two questions regarding precision in MATLAB
1) Is double the data type with the most large number of digits for a float complex number?
2) How can the
Here's an example script comparing double
to symbolic/vpa
precision:
% Numeric approach
f_numeric = @(z) exp(z.^2);
Out_numeric = integral (f_numeric, 0, 1);
% Symbolic / vpa approach
syms x
f_symbolic(x) = exp(x^2);
Out_symbolic = int (f_symbolic, x, [0,1]);
% Comparison
fprintf('Numeric : %0.30f\n', Out_numeric)
fprintf('Symbolic : %s\n' , char (vpa (Out_symbolic, 32)))
fprintf('Converted: %0.30f\n', double (vpa (Out_symbolic, 32))) % back to double
Output on my machine (eps = 2.2204e-16):
Numeric : 1.462651745907181499717353290180
Symbolic : 1.462651745907181608804048586857
Converted: 1.462651745907181499717353290180
More generally:
>> fprintf(' %0.32f\n %s\n', 1/3, char (vpa ('1/3', 32)))
0.33333333333333331482961625624739
0.33333333333333333333333333333333