Skip to content

Instantly share code, notes, and snippets.

Created November 23, 2010 22:07
Octave script to generate MRB plots
% mrb_plots.m
% Octave script to generate MRB plots
%
% Author: John F. McGowan, Ph.D.
%
figure(1)
data = mrb_sequence(100);
plot(data);
figure(2)
for i=1:100
data_simple(i) = mrb_simple(i);
end
plot(data_simple);
% THE END
function [val] = mrb(n)
% to help compute the MRB constant
% [val] = mrb(n)
% n is number of elements in sum
% sum_i_n (-1)^i (i^(1/i) - 1)
%
% Author: John F. McGowan, Ph.D.
%
val = 0.0;
for i = 1:n
val = val + (-1.0)^i* (i^(1/i) - 1);
end
end % end function mrb
function [data] = mrb_sequence(N)
% [data] = mrb_sequence(N)
%
% generate sequence for m=1 to N
% sum_i_m (-1)^i (i^(1/i) - 1)
%
% To compute the MRB constant numerically in the Octave numerical
% programming environment
%
% Author: John F. McGowan, Ph.D.
%
for m=1:N
data(m) = mrb(m);
end
end % function mrb_sequence
function [val] = mrb_simple(n)
% to help compute the MRB constant
% [val] = mrb_simple(n)
% n is number of elements in sum
% sum_i_n (-1)^i (i^(1/i) )
%
% Author: John F. McGowan, Ph.D.
%
val = 0.0;
for i = 1:n
val = val + (-1.0)^i* (i^(1/i) );
end
end % end function mrb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment