- [1] ''TeX,LaTeX 入門'' - [2] ''Memo of latex'' - [3] ''Shu's Home'' - [4] ''pLaTeX2e 新ドキュメントクラス'' - [5] L[SUP[A]]T[SUB[E]]X... - [6] >>5 [[SVG]] とか使って書くようになるのかな、そのうち。。。 - [7] [CODE[[SUB[E]]]] は許せても [CODE[L[SUP[A]]]] は許しがたいなあ、なんか。 - [8] L[SUP[A]]T[SUB[E]]X2ε - [9] >>8 日本語フォントだと [CODE[ε]] が意味もなく[[斜体]]になるのがなんとも。 ([[JIS]] の変な[[例示字形]]のせいだ!) - [10] ''Fujita Shinsaku TeX/LaTeX Page'' : 縦書きとか訓点とか。。。 [11] [CITE[LaTeX でプレゼン]] ([[名無しさん]]) [12] [CITE[LaTeX でプレゼンテーション]] ([[名無しさん]]) [13] [CITE[Transforming XHTML to LaTeX and BibTeX]] ([[名無しさん]]) [14] ex7.m
clear;
clc;

%  Exercise #7: Root of a single nonlinear equation
%    Find the root of the nonlinear equation h(x) = tan(x) - x = 0, which is between pi/2 and 3pi/2, using the bisection method AND the false position (regula falsi) method. Show the estimated root for each iteration.

epsilon = 1e-4;
imax = 1e9;

%  interval_init = [1.00001 * (pi / 2), 0.99999 * (3 * pi / 2)];
interval_init = [1.001 * (pi / 2), 0.99 * (3 * pi / 2)];
xb = interval_init(1);
xh = interval_init(2);
x  = [xb : (xh - xb) / 10000 : xh];
h  = function_ex7(x);

%  a) Méthode de bisection
for i = 1:imax
    % Étape (1)
    xm = (xh + xb) / 2;

    % Étape (2)
    hxmhxb = function_ex7(xm) * function_ex7(xb);

    disp(['xm = ', num2str(xm), ' h(xm) * h(xb) = ', num2str(hxmhxb)]);

    if (hxmhxb > epsilon)
        xb = xm;
    elseif (hxmhxb < -epsilon)
        xh = xm;
    else
        disp(['h(x) = 0 --> x = ', num2str(xm), ' (i = ', num2str(i), ')']);
        break;
    end

end

imax_bisection  = i;
x0_bisection    = xm;


%  b) Méthode de "false position" (regula falsi)
xb = interval_init(1);
xh = interval_init(2);
for i = 1:imax

    xm = xb - (function_ex7(xb) * (xh - xb)) / (function_ex7(xh) - function_ex7(xb));
    hxm = function_ex7(xm);
%      disp(['xm = ', num2str(xm), ' h(xm) = ', num2str(hxm)]);

    disp(['i = ', num2str(i), ', xm = ', num2str(xm), ' h(xm) = ', num2str(hxm)]);
    if (hxm > epsilon)
        xb = xm;
    elseif (hxm < -epsilon)
        xh = xm;
    else
        disp(['h(x) = 0 --> x = ', num2str(xm), ' (i = ', num2str(i), ')']);
        break;
    end

end

imax_regulafalsi= i;
x0_regulafalsi  = xm;

figure(7);
    hold on;
    plot(x, h, '-b', 'DisplayName', 'tan(x) - x');
    plot(x0_bisection, 0, 'rd', 'DisplayName', ['Bisection (i_{max} = ', num2str(imax_bisection), ')']);
    plot(x0_regulafalsi, 0, 'rx', 'DisplayName', ['Regula Falsi (i_{max} = ', num2str(imax_regulafalsi), ')']);
    xlabel('x');
    ylabel('h');
    legend('show');
    legend('Location', 'NorthWest');
    axis([interval_init(1) interval_init(2) -10 10]);
    grid on;
    enhance_plot(0, 30, 5, 15, 0)
([[Mr.Anonymous]] [WEAK[2006-04-18 15:44:19 +00:00]])