Root-Finding in MATLAB | Lecture 20 | Numerical Methods for Engineering

Поділитися
Вставка
  • Опубліковано 25 гру 2024

КОМЕНТАРІ • 11

  • @Prabh_ramgarhia001
    @Prabh_ramgarhia001 Місяць тому +1

    Satt shri akal❤

  • @joellekalonji
    @joellekalonji 2 роки тому +1

    how do you apply this for f(x)=×-tan(x)

  • @mathematicsdepartment5143
    @mathematicsdepartment5143 2 роки тому +1

    Can you give a example of find the roots using remainder theorem using in MATLAB

  • @LindaniSylvester
    @LindaniSylvester 2 місяці тому

    % Section 1: Input
    clc;
    format long;
    disp('Newton-Raphson Method for Root Finding');
    FSrt = input('Enter the function F(x) as a string: ', 's');
    % Convert the string function into a symbolic function
    F = str2sym(FSrt);
    % derivative of the function
    dF = diff(F, 'x');
    % Convert both the original function and derivative to MATLAB functions
    Fcn = matlabFunction(F);
    dFcn = matlabFunction(dF);
    % Section 2: Initial guess and convergence criteria
    xj = input('Enter the first approximation to the root (xj): ');
    crt = input('Enter the convergence criteria: ');
    % Initial number of iterations
    iteration = 0;
    % Section 3: Newton-Raphson Loop
    while abs(Fcn(xj)) > crt
    xj = xj - Fcn(xj) / dFcn(xj);
    % Display current iteration
    fprintf('Iteration %d: x = %f, F(x) = %f
    ', iteration, xj, Fcn(xj));
    % Increment iteration count
    iteration = iteration + 1;
    end
    % Output final result
    fprintf('The function %s has root %.5f with accuracy %.6f after %d iterations.
    ', FSrt, xj, crt, iteration);
    % Section 4: Plot the function and root
    x_values = linspace(xj-5, xj+5, 201);
    y_values = Fcn(x_values);
    % Plot the function and the root
    plot(x_values, y_values, 'b-', xj, Fcn(xj), 'ro');
    xlabel('x');
    ylabel('F(x)');
    title('Newton-Raphson Method');
    grid on;

  • @sashanksrinivasan4681
    @sashanksrinivasan4681 2 роки тому

    how do you obtain more than one roots?

  • @cemkarabulut2717
    @cemkarabulut2717 3 роки тому +2

    I have numeric analysis exam but I cant doing

  • @LindaniSylvester
    @LindaniSylvester 2 місяці тому

    syms x;
    FSrt=input("Enter the function as a string: ",'s');
    F(x)=str2sym(FSrt);% convert into a string
    Fnc=matlabFunction(F(x));% matlab function
    % Enter the x1;x2; convergence criteriaand maximum iteration
    x1=input('Enter the first approximation of the root: ');
    x2=input("Enter the second approximation of the root: ");
    crt=input("Enter the convergange criteria: ");
    max_iter=input("Enter the max iter of the root: ");
    %Initial values
    iter=1;
    xPrev=x1;% Previous x-value
    xCur=x2;% Current x-value
    while abs(Fnc(xCur))> crt && iter

  • @Abhishek_Soni_DIAT_Pune
    @Abhishek_Soni_DIAT_Pune 3 роки тому +1

    Thank you so much!

  • @mateeenkhalatbari2664
    @mateeenkhalatbari2664 2 роки тому

    how tf u make a something that takes 2 seconds to explain a 10 minute video?