Maniruzzaman Akash's Blog

Maniruzzaman Akash, A programmer, A web programmer, a helpful person to share knowledge and everything..

  • Home
  • Programming
    • C Programming
    • Java Programming
    • C++ Programming
    • C# Programming
    • Python Programming
    • Data Structure
  • Web
    • HTML
    • CSS
    • Javascript
    • PHP
    • AJAX
    • XML
  • FrameWork
    • Bootstrap(CSS)
    • Laravel 5(PHP)
  • Database
    • MySQL
    • Oracle
    • SQL Server
  • Android
    • Android Development
  • Mathematics
    • Numerical Methods
  • Others
    • My Articles
    • Download Ebooks
    • Mathematics
    • Difference Between
  • Contact
Showing posts with label Numerical Methods. Show all posts
C Programming MatLab Code Numerical Methods Simulation and Modeling

Mid Square Method Code implementation in C and MatLab

Wednesday, October 11, 2017 By Maniruzzaman Akash 7 Comments

Mid Square Method Code implementation in C and MatLab:

Problem:

Mid square method, mid square random number generator Code in MatLab and C or C++.

Continue reading
Share:
Views:
Numerical Methods

Numerical method Codes simple MatLab implementation

Monday, June 12, 2017 By Maniruzzaman Akash 0 Comments

Numerical method Codes simple MatLab implementation

In this tutorial, we;ll learn about following MAT LAB works of Numerical Methods.

  1. Numerical Method Simpson 1/3 MatLab Code implementation
  2. Numerical Method Simpson 3/8  MatLab Code implementation
  3. Numerical Method Gauss Elimination MatLab Code Implementation
  4. Numerical Method Gauss Elimination MatLab Code Implementation:
  5. Numerical Method Gauss Zordan MatLab Code Implementation
  6. Numerical Method Gauss Cramers Rule MatLab Code Implementation
  7. Numerical Method Newton Raphson MatLab Code Implementation
  8. Numerical Method Fixed Point Iteration MatLab Code Implementation
  9. Numerical Method False Position Method MatLab Code Implementation
  10. Numerical Method Bisection Method MatLab Code Implementation
Continue reading
Share:
Views:
Numerical Methods

Numerical Methods 20 Multiple Choice Questions and Answers

By Maniruzzaman Akash 2 Comments

Numerical Methods Question and Fill in the Blanks



In which of the following method, we approximate the curve of solution by the tangent in each interval.

a.       Picard’s method
b.      Euler’s method
c.       Newton’s method
d.      Runge Kutta method

Ans- B

Continue reading
Share:
Views:
Numerical Methods

False Position method code implementation in Matlab

Tuesday, May 2, 2017 By Maniruzzaman Akash 2 Comments

False Position method code implementation in Matlab

Problem of False position method:
Find the root of the following function where function = 5 * x^4 - 2.7 * x^2 - 2*x + 0.5 
User can take upper limit, lower limit and exact integral.


Code Implementation:



%Function
f = @(x) 5 * x^4 - 2.7 * x^2 - 2*x + 0.5;
l = input('Enter Lower Limit : ');
u = input('Enter Upper Limit : ');
previous_approximation = 0;

f_l = feval(f, l);
f_u = feval(f, u);
root = u -((f_u * (l-u))/ (f_l - f_u));
given_absoulte_error = input('Enter absolute error : ');
absolute_error = abs((root - previous_approximation) / root ) * 100;
previous_approximation = root;

while(absolute_error > given_absoulte_error)
    f_l = feval(f, l);
    f_u = feval(f, u);
    f_root = feval(f, root);
    
    if(f_l * f_root > 0)
        l = root;
    else
        u = root;
    end;
    
    f_l = feval(f, l);
    f_u = feval(f, u);
    
    
    root = u -((f_u * (l-u))/ (f_l - f_u));
    absolute_error = abs((root - previous_approximation) / root ) * 100;
    previous_approximation = root;
    
    fprintf('Root %f Error %f\n', root, absolute_error);
    
end;

disp('-------------------------------');
fprintf('Final Root = %f and absolute error = %f', root, absolute_error);
Continue reading
Share:
Views:
Numerical Methods

Bisection Code implementation in Matlab

By Maniruzzaman Akash 0 Comments

Bisection Code implementation in Matlab

Find the root of the following function using bisection method where user ca take upper, lower limit and exact integral from user. Function is  x^2 - 3;

You can use any function here..

f = @(x) x^2 - 3;
l = input('Enter Lower Limit : ');
u = input('Enter Upper Limit : ');
prev_approximation = 0;

root = (l + u)/2;
f_root = feval(f, root);
given_absoulte_error = input('Enter absolute error : ');
absolute_error = abs((root - prev_approximation) / root) * 100;
disp(absolute_error);

fprintf('\nStep a\tb\tf(a)\tf(b)\troot\tError_abs\n');
while(absolute_error > given_absoulte_error)
    f_root = feval(f, root);
    f_l = feval(f, l);
    f_u = feval(f, u);
    
    if(f_l * f_root > 0)
        l = root;
    else
        u = root;
    end;
    
    root = (l + u)/2;
    absolute_error = abs((root - prev_approximation) / root) * 100;
    prev_approximation = root;
    
    fprintf('Step %f Error %f\n', root, absolute_error);
    fprintf('\nStep a\tb\tf(a)\tf(b)\troot\tError_abs\n');
    
end;

disp('-------------------------------');
fprintf('Final Root = %f and absolute error = %f', root, absolute_error);
Continue reading
Share:
Views:
Numerical Methods

Simpsons 1/3 Code implementation in Matlab using dynamic parts

By Maniruzzaman Akash 0 Comments

Simpsons 1/3 Code implementation in Matlab using dynamic parts



Solution of Simpson 1/3 using dynamic segment of the polynomial


f = @ (x)  0.2+25*x-200*x^2+675*x^3-900*x^4+400*x^5;

n = input('Enter how many parts do you want? : ');
a = input('Enter lower limit : ');
b = input('Enter Upper Limit : ');

part = (b - a)/n;
array = [0,0,0,0,0,0,0,0,0,0,0];


for i=1:n
    if(i == 1)
        array(i) = a;
    else
        array(i) = array(i-1) + part;
    end;
end;




result = 0;
for i=1:n+1
    x = i-1;
    if(x==0 || x == n)
        result = result + feval(f,array(i));
    end
    if(x~=0 || x~=n)
       if(rem(x,2)==0)
           result = result + 2*feval(f,array(i));
       else
           result = result + 4*feval(f,array(i));
       end
    end
end



I = (b-a) * (result /(3 * n));

fprintf('\nIntegral is : %f\n', I);

exact_integral = 1.640533;
E = abs((exact_integral - I)/exact_integral) * 100;

fprintf('\nTrue Error = %f\n', E);


Continue reading
Share:
Views:
Numerical Methods

Traphezoidal rules code implementation in Matlab- Dynamic parts

By Maniruzzaman Akash 0 Comments

Traphezoidal rules code implementation in Matlab- Dynamic parts

Find the integral for the above function get upper limit and lower limit from user--
f = @ (x) 0.2 + 25*x - 200*(x^2) + 675*(x^3) -900*(x^4) + 400*(x^5);

In this problem, you can take divide the polynomial in mutiple parts. In this solution, this upto in 10 parts in array. You can do it more as your need.


f = @ (x) 0.2 + 25*x - 200*(x^2) + 675*(x^3) -900*(x^4) + 400*(x^5);


n = input('Enter how many parts do you want? : ');
a = input('Enter lower limit : ');
b = input('Enter Upper Limit : ');

part = (b - a)/n;
array = [0,0,0,0,0,0,0,0,0,0,0];


if(n == 2)
    array(1) = a;
    array(2) = b;
else
    for i=1:n
        if(i == 1)
            array(i) = a;
        else
            array(i) = array(i-1) + part;
        end;
    end;
end;



result = 0;

for i=1:n+1
    x = i-1;
    if(x==0 || x == n)
        result = result + feval(f,array(i));
    end
    if(x~=0 || x~=n)
        result = result + 2*feval(f,array(i));
    end
end

I = (result / 2*n) * (b - a);

fprintf('Integral is = %f\n', I);

exact_integral = 1.640533;
E = abs((exact_integral - I)/exact_integral) * 100;

fprintf('\nTrue Error = %f\n', E);

Continue reading
Share:
Views:
Numerical Methods

Simpson's 3/8 rules code implementation in MatLab

By Maniruzzaman Akash 0 Comments


Problem of Simpson's 3/8 Rules :


Find the integral of the function, f = @ (x) 0.2 + 25*x - 200*(x^2) + 675*(x^3) -900*(x^4) + 400*(x^5); where lower limit = 0, upper limit = .8 and exact integral is = 1.640533


Solution of Simpson 3/8 rules in Matlab:

----------------------------------------
f = @ (x) 0.2 + 25*x - 200*(x^2) + 675*(x^3) -900*(x^4) + 400*(x^5);

a = input('Enter lower limit : ');
b = input('Enter upper limit limit : ');

x0 = a;
x1 = (b-a)/3;
x2 = 2 * x1;
x3 = b;

fx0 = feval(f, x0);
fx1 = feval(f, x1);
fx2 = feval(f, x2);
fx3 = feval(f, x3);

I = (b - a) * ((fx0 + 3*(fx1 + fx2) + fx3)/8);

exact_integral = input('Enter Exact Integral : ');
E = abs((exact_integral - I)/exact_integral) * 100;
fprintf('\nIntegral = %f\n', I);
fprintf('\nTrue Error = %f\n', E);
----------------------------------------


Continue reading
Share:
Views:
Numerical Methods

Simpson's 1/3 Code in Matlab

Monday, April 24, 2017 By Maniruzzaman Akash 0 Comments

Simpson's 1/3 rules Code implementation in MatLab

Simpson's 1/3 rule

From Book of Steven Chopra -
Aside from applying the trapezoidal rule with finer segmentation, another way to obtain a more accurate estimate of an integral is to use higher-order polynomials to connect the points. 

For example, 
If there is an extra point midway between f(a) and f(b), the three points can be connected with a parabola.
 If there are two points equally spaced between f(a) and f(b), the four points can be connected with a third-order polynomial. The formulas that result from taking the integrals under these polynomials are called Simpson’s rules.

Simpson’s 1/3 Rule to find integral is :

Simpson's 1/3 rules Code implementation in MatLab


Simpson's 1/3 rules Code implementation in MatLab

Question is:
f (x) = 0.2 + 25x - 200x2 + 675x3 - 900x4 + 400x5
from a 5 0 to b 5 0.8. Recall that the exact integral is 1.640533. Find the Integral and exact error

Solution in normal numerical mathematics of Simpson's 1/3 rules:

f(0) =  0.2 
f(0.4) = 2.456 
f(0.8) = 0.232
Therefore,above figure equation can be used to compute
I = (0.8 - 0) * (0.2 + 4*(2.456) + 0.232)/6
   = 1.367467

which represents an exact error of
E = 1.640533 - 1.367467
   =  0.2730667 
Et =  16.6%

Solution in matlab coding of Simpson's 1/3 rules:


% Author : Maniruzzaman Akash
% Code   : Simpsons 1/3 Rules Code in Matlab Implementation

% Function 
f = @ (x)  .2+ 25*x - 200*x^2+675*x^3-900*x^4+400*x^5;

disp('Press 1 for set values ');
disp('Press 2 for see results ');
disp('Press 0 for exit the program ');
disp('---------------------------------');

isInputGiven = false;
while(1)
    choose = input('Give your choose option: ');
    if(choose == 1)
        a = input('Enter lower limit : ');

        b = input('Enter upper limit : ');
        
        exact_integral = input('Enter exact integral : ');

        x0 = a; 
        x1 = (b-a)/2; 
        x2 = b; 


        fx0 = feval(f,x0);
        fx1 = feval(f,x1);
        fx2 = feval(f,x2);

        integral = ((fx0 + (4*fx1) + fx2)/6 * (b-a));
        isInputGiven = true;
    end;
    
    if(choose == 2)
        if(isInputGiven == true)
            integral_output = sprintf('Integral is = %0.5f',integral);
            disp(integral_output);
            
            exact_error = ((exact_integral - integral)/exact_integral) * 100 ;
            exact_error_output = sprintf('Exact Error = %0.5f',exact_error);
            disp(exact_error_output);
        end;
    end;
    
    if(choose == 0)
        disp('Exiting the code..');
        exit(0);
    end;
end;

Output Of the above code will look like:

Simpson's 1/3 rules Code implementation in MatLab

Simpson's 1/3 rules Code implementation in MatLab



Simpson 3/8 is just as the problem. Just Equation is the different for that math and change in equation in code also.
Thanks.
Continue reading
Share:
Views:
Older Posts Home
Subscribe to: Posts ( Atom )

Popular Posts

  • Numerical Methods 20 Multiple Choice Questions and Answers
  • Consider a hypothetical 32-bit microprocessor having 32-bit instructions: Solutions
  • List and briefly define two approaches to dealing with multiple interrupts
  • The hypothetical machine has two I/O instructions: 0011= Load AC fro I/O 0111= Store AC to I/O Solutions
  • What are the characteristics of Digital IC's?-Solution
  • Mid Square Method Code implementation in C and MatLab
  • List and briefly define the possible states that define an instruction execution
  • BFS, DFS, DLS in Tree implementation in C
  • Download Laravel Offline Documentation as HTML
  • Simpson's 1/3 Code in Matlab

Category

Advanced PHP Android Developement Articles Artificial Intelligenece Blogger Tips Blogging Career Bootstrap Offline Documentation Bootstrap Templates C Programming Computer Architecture Data Structure Difference Between Download Documentation Download Ebook Download Free Blog Template Earning Money Electrical Electronics Guest Posts HTML Java Programming Laravel Laravel Bangla Tutorial MatLab Code My Videos MySQL Database Numerical Methods Offline Documentation Recent Topics Simulation and Modeling Unity Game Development Web Design Web Development

LIKE ME ON FACEBOOK

TAGS

  • Advanced PHP (3)
  • Android Developement (5)
  • Articles (6)
  • Artificial Intelligenece (3)
  • Blogger Tips (5)
  • Blogging Career (1)
  • Bootstrap Offline Documentation (1)
  • Bootstrap Templates (1)
  • C Programming (14)
  • Computer Architecture (5)
  • Data Structure (11)
  • Difference Between (1)
  • Download Documentation (2)
  • Download Ebook (3)
  • Download Free Blog Template (2)
  • Earning Money (1)
  • Electrical Electronics (1)
  • Guest Posts (1)
  • HTML (4)
  • Java Programming (2)
  • Laravel (3)
  • Laravel Bangla Tutorial (1)
  • MatLab Code (2)
  • My Videos (3)
  • MySQL Database (7)
  • Numerical Methods (9)
  • Offline Documentation (1)
  • Recent Topics (1)
  • Simulation and Modeling (2)
  • Unity Game Development (3)
  • Web Design (3)
  • Web Development (1)

Join Google+

Maniruzzaman Akash
View my complete profile

Join With Me

Site Visitors

Best Sites For a programmer

  • URI Online Judge Solution By Me
  • StackOverFlow
  • W3 School
  • Git Hub - Store your Every Document

Popular Posts

  • What are the characteristics of Digital IC's?-Solution
  • The hypothetical machine has two I/O instructions: 0011= Load AC fro I/O 0111= Store AC to I/O Solutions
  • Consider a hypothetical 32-bit microprocessor having 32-bit instructions: Solutions
  • How to import Excel,CSV file in Laravel And insert data in database
  • List and briefly define the possible states that define an instruction execution
  • What is Blue Whale Game ? Why people suicide?
  • List and briefly define two approaches to dealing with multiple interrupts
  • ফিফা ওয়ার্ল্ড কাপ ২০১৮ শিডিউল এবং সমস্ত আপডেট- FIFA World Cup 2018 - Bangladesh Time Schedule
  • BFS, DFS, DLS in Tree implementation in C
  • Numerical Methods 20 Multiple Choice Questions and Answers

Earn Money From Your site

Translate To your language

Categories

Advanced PHP (3) Android Developement (5) Articles (6) Artificial Intelligenece (3) Blogger Tips (5) Blogging Career (1) Bootstrap Offline Documentation (1) Bootstrap Templates (1) C Programming (14) Computer Architecture (5) Data Structure (11) Difference Between (1) Download Documentation (2) Download Ebook (3) Download Free Blog Template (2) Earning Money (1) Electrical Electronics (1) Guest Posts (1) HTML (4) Java Programming (2) Laravel (3) Laravel Bangla Tutorial (1) MatLab Code (2) My Videos (3) MySQL Database (7) Numerical Methods (9) Offline Documentation (1) Recent Topics (1) Simulation and Modeling (2) Unity Game Development (3) Web Design (3) Web Development (1)

Subscribe To This Site To Get Latest Article On Programming or web

Posts
Atom
Posts
All Comments
Atom
All Comments
© 2016 Maniruzzaman Akash's Blog | All rights reserved
Developed By Maniruzzaman Akash Created By Responsive Blogger Templates | Distributed By Gooyaabi Templates