Question

Check the file: Questions.pdf

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

function X = newtonraphson(f,df,R,h)
X = []; % variable to store solution
tol = 0.0001; % max error tolerance between two consecutive values in loop
for i=R(1):h:R(2)
    % This loop iterates between the extremes of given range through
    % prescribed increments-sub intervals. At a particular sub-interval, if
    % it is found that function value at the ends of the sub-interval
    % changes its sign, then a point inside that interval is chosen as the
    % initial value for iteration. If values at both ends are of the same
    % sign, then its derivative is checked. If the derivatives differ in
    % sign, then midpoint of the interval is taken, and both the halfs of
    % the sub-interval are verified the same way. The sub-interval is
    % omitted if both the values of function as well as value of
    % derivatives are the same in the sub-interval. Once the initial guess
    % is obtained, Newton Raphson method is used to find the solution, and
    % the program proceeds towards the next sub-interval
    range = [i i+h];
    flag = 0;
    while flag == 0
       if ((f(range(1))<0)&&(f(range(2))>=0)) || ((f(range(1))>0)&&(f(range(2))<=0))
            x0 = mean(range); % function has different signs in the interval ends. Hence midpoint is selected
            flag = 1;
       else % funtion has same sign in the interval ends
            if ((df(range(1))<0)&&(df(range(2))>0)) || ((df(range(1))>0)&&(df(range(2))<0))
                % here, function derivative has different signs in the interval
                % ends
               
                if ((df(range(1))<0)&&(df(mean(range))>0)) || ((df(range(1))>0)&&(df(mean(range))<0))
                   % here, function derivative has different signs in the first
                   % end of interval and the middle of interval
                   range(2) = mean(range);
                else
                   range(1) = mean(range);
                end
                if abs(range(1)-range(2))<=tol
                   flag = 2;
                else
                   flag = 0;
                end
               
            else % here, derivatives are also of the same sign
                % the interval is skipped and another interval is selected
                flag = 2;
            end
       end
      
    end...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Assisting Tutor

Related Homework Solutions

Monte Carlo Method Problems
Homework Solution
$78.00
Mathematics
Finance
Monte Carlo Method
Prices
Stocks
Annual Return
Volatility
Matrices
Matlab
Factors
Average Values
Statements
Customers
Trading Days
Programming
Algorithms
Disorders Of The Blood And Blood-Forming Organs
Homework Solution
$10.00
Health Administration
Carcinoma
Hemoglobin
ICD-9-Codes
Breast
Pulmonary Disease
Biopsy
Axillary Lymph Node
Peripheral Vein
Hospital
Infusion
Coagulation Factors
Hemophilia
Rheumatoid Arthritis
Identifying Hazards
Homework Solution
$40.00
Business
Administration
Environmental Contamination
Organizations
Financial Strength
Hazards
Finance
Economy
Probability
Impacts
Variations
Rating
Tables
Rows
Columns
International Relations Discussion (650 words)
Homework Solution
$20.00
Administration
International Relations
Discussion
Female Leaders
Gender Stereotypes
Marketing
Leadership Skills
Government
Politics
Indira Gandhi
Angela Merkel
Hillary Clinton
Awards
Ceremonies
Social Activities
Get help from a qualified tutor
Live Chats