1
$\begingroup$

In my computer-aided-problem-solving class, I am asked to determine the height of a trough, through a root-finding method. I can choose between the bisection method, Newton's method or successive substitution. Whichever method I choose, I should determine the height via the method in MATLAB.

I have no idea how one of these methods is going to help me find the depth of the trough?

The following formula is given: $$V = L \left( r^2 \arccos\left(\frac{h}{r}\right) -h \sqrt{r^2-h^2}\right)$$

Where V is the volume of the trough, which has a value of $0.35\,\text{m}^3$.

$L$ is the length, which has the value of $3\,\text{m}$.

Finally the "radius" of the trough is $r=0.3\,\text{m}$.

I should give an answers with an accuracy of 6 digits.

I attached a picture of the trough.

Can someone help me with this?? Thanks

enter image description here

$\endgroup$
1
  • $\begingroup$ finally you have to solve $$0.35=3\cdot 0.3^2\arccos\left(\frac{h}{0.3}\right)-h\sqrt{0.3^2-h^2}$$ is this right? $\endgroup$ Feb 24, 2018 at 16:22

1 Answer 1

2
$\begingroup$

One approach would be to do it using Newton's method. We want to solve the equation $f(h)=0$, with

$$ f(h) = L\left( r^2 \arccos \left(\frac{h}{r}\right) - h\sqrt{r^2-h^2} \right) - V $$

With Newton's method, we start out with an initial value (e.g., $h_0 = 0$), and then iterate, until we converge:

$$ h_{n+1} = h_n - \frac{f(h_n)}{f'(h_n)}. $$

Here, $f'(h)$ represents the derivative, which happens to be $$ f'(h) = -2L\sqrt{r^2-h^2}, $$ in your case. If you will do this, you'll find $h=0.041306\,\text{m}$.

Here is the code:

% Parameters
V = 0.35;       % [m^3]
L = 3;          % [m]
r = 0.3;        % [m]

% Initial guess
h = 0;          % [m]

% Loop until convergence
hold = 1;
iter = 0; % Counter to limit # of iterations, in case of no convergence
while abs(h - hold) > 1e-7 && iter < 100
    % Compute the value of the function
    f = L*(r^2*acos(h/r) - h*sqrt(r^2-h^2)) - V;

    % Compute the derivative of the function
    fderiv = -2*L*sqrt(r^2-h^2);

    % Compute the Newton update
    hold = h;  % Remember old value for comparison
    h = h - f / fderiv;

    % Increase the counter for the number of iterations
    iter = iter + 1;

    % Show progress
    fprintf('Iteration %i, h = %.6f\n', iter, h);
end;

% Display result with an accuracy of 6 digits
fprintf('h = %.6f\n', h);  % h = 0.041306
$\endgroup$
3
  • $\begingroup$ Thankyou so much for the reaction! It indeed looks like a good idea to use Newton's method. Indeed when I type the code in matlab, I get the same answer, however, I only get to see 4 digits... how can I get 6 digits? Also, is there a possibility that I can get the iterations vs. the outcomes in a table? So that I can study the convergence behaviour? Thanks! $\endgroup$
    – Math420
    Feb 25, 2018 at 11:38
  • $\begingroup$ @R3E1W4 You're welcome. I added a line within the loop such that you can see the convergence. I don't understand why you only see 4 digits. The 6 in fprintf('h = %.6f\n', h); controls the number of digits, so if you need more digits, just change the 6 into a higher number. $\endgroup$
    – EdG
    Feb 25, 2018 at 14:31
  • $\begingroup$ It worked, thank you very much. I can complete my assignment now! $\endgroup$
    – Math420
    Feb 25, 2018 at 14:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .