| Thread Closed |
matlab:Chapra , ROOTS [ Bracketing Method] Help needed. |
Share Thread | Thread Tools |
| Feb27-08, 03:22 PM | #1 |
|
|
matlab:Chapra , ROOTS [ Bracketing Method] Help needed.
Hello guys can anyone help me solve this in matlab please ?
|
| Feb29-08, 09:42 AM | #2 |
|
|
What are you having trouble with? Understanding the algorithm or implementing in Matlab?
|
| Feb29-08, 03:30 PM | #3 |
|
|
Thanks for your reply. Im having trouble implementing the code into matlab and getting correct answers. May you guide me through please ?
|
| Feb29-08, 04:48 PM | #4 |
|
|
matlab:Chapra , ROOTS [ Bracketing Method] Help needed.
If I had to find a zero of a simple function, say, x^2-3, using bisection, this is what I would write.
Code:
% bisection.m
function bisection
% find root of x^2 - 3 on some interval
xa = 0; xb = 10; % search interval
for it = 1:20 % loop
xtest = xa + (xb-xa)/2; % mid point of interval
fa = f(xa); % left-interval function value
fb = f(xb); % right-interval function value
ftest = f(xtest); % mid-point function value
if sign(fa)*sign(ftest)<0 % if zero in left half
xb = xtest; % take left half of interval
elseif sign(ftest)*sign(fb)<0 % if zero in right half
xa = xtest; % take right half of interval
elseif ftest ==0 % if zero at mid-point
break % this is the zero
else %
error('multiple roots or no root') % may have no zero or multiple zeros
end
xit(it) = xtest; % store mid-points
end
figure;plot(xit) % plot mid-points, should converge to the root
function y = f(x) % function we're finding the root of
y = x^2-3;
|
| Mar1-08, 02:42 AM | #5 |
|
|
Thanx a lot.
2 questions: Q1) How do i input the equation ? Wherever it says "y = x^2-3" i replace it with the equation in the problem ? Q2) how do i get an error<0.00005 |
| Mar1-08, 10:00 AM | #6 |
|
|
|
| Oct7-10, 11:13 AM | #7 |
|
|
(1) Use a centered difference approximation O(h2) to estimate the second derivative of the function .
(a) Perform the evaluation at x = 2 using step sizes of h = 0.2 and 0.1. Compare your estimates with the true value of the second derivative. Interpret your results on the basis of the remainder term of the Taylor series expansion. (b) Write a Matlab program that evaluates the second derivative of the function (using a centered difference approximation O(h2)) on the interval [-4 , 4] with a step sizes of h = 0.2 and 0.1. Plot the second derivative of the function obtained by the centered difference method along with a graph obtained from a theoretical calculation. Submit the solution of part (a) as a hard copy. For part (b), submit a fully functional program to the blackboard, and submit a copy of the program and accompanying figures as a hardcopy. |
| Oct7-10, 11:16 AM | #8 |
|
|
(1) Use a centered difference approximation O(h2) to estimate the second derivative of the function .
(a) Perform the evaluation at x = 2 using step sizes of h = 0.2 and 0.1. Compare your estimates with the true value of the second derivative. Interpret your results on the basis of the remainder term of the Taylor series expansion. (b) Write a Matlab program that evaluates the second derivative of the function (using a centered difference approximation O(h2)) on the interval [-4 , 4] with a step sizes of h = 0.2 and 0.1. Plot the second derivative of the function obtained by the centered difference method along with a graph obtained from a theoretical calculation. Submit the solution of part (a) as a hard copy. For part (b), submit a fully functional program to the blackboard, and submit a copy of the program and accompanying figures as a hardcopy. |
| Thread Closed |
| Thread Tools | |
Similar Threads for: matlab:Chapra , ROOTS [ Bracketing Method] Help needed.
|
||||
| Thread | Forum | Replies | ||
| Finite Difference Method using Matlab | Math & Science Software | 28 | ||
| matlab:Chapra , Help needed. | Math & Science Software | 1 | ||
| The Method of Frobenius - Find roots of indicial EQ and 1st terms of series solution | Calculus & Beyond Homework | 1 | ||
| a method to compute roots other than sqrt. | General Math | 4 | ||
| Help needed fast :-S Characteristics of the power method and the inverse power method | Calculus & Beyond Homework | 1 | ||