This document describes solving a nonlinear equation to determine the time when a Saturn V rocket reaches the speed of sound using various numerical methods. Specifically, it compares the bisection method, linear interpolation method, Newton-Raphson method, Mueller's method, and the x=g(x) method. For each method, it provides the MATLAB script used to solve the equation and displays the solution time and number of iterations. The root found for all methods was approximately 70.878 seconds.
In MATLAB, a vector is created by assigning the elements of the vector to a variable. This can be done in several ways depending on the source of the information.
—Enter an explicit list of elements
—Load matrices from external data files
—Using built-in functions
—Using own functions in M-files
This presentation will be very helpful to learn about system of linear equations, and solving the system.It includes common terms related with the lesson and using of Cramer's rule.
Please download the PPT first and then navigate through slide with mouse clicks.
In MATLAB, a vector is created by assigning the elements of the vector to a variable. This can be done in several ways depending on the source of the information.
—Enter an explicit list of elements
—Load matrices from external data files
—Using built-in functions
—Using own functions in M-files
This presentation will be very helpful to learn about system of linear equations, and solving the system.It includes common terms related with the lesson and using of Cramer's rule.
Please download the PPT first and then navigate through slide with mouse clicks.
For a system involving two variables (x and y), each linear equation determines a line on the xy-plane. Because a solution to a linear system must satisfy all of the equations, the solution set is the intersection of these lines, and is hence either a line, a single point, or the empty set
FEM: Introduction and Weighted Residual MethodsMohammad Tawfik
What are weighted residual methods?
How to apply Galerkin Method to the finite element model?
#WikiCourses #Num001
https://wikicourses.wikispaces.com/TopicX+Approximate+Methods+-+Weighted+Residual+Methods
Finite Element Method is explained taking a simple example
Essential concepts in this technique are introduced
Top-down approach and bottom-up approach are used to present a holistic picture of FEM
For a system involving two variables (x and y), each linear equation determines a line on the xy-plane. Because a solution to a linear system must satisfy all of the equations, the solution set is the intersection of these lines, and is hence either a line, a single point, or the empty set
FEM: Introduction and Weighted Residual MethodsMohammad Tawfik
What are weighted residual methods?
How to apply Galerkin Method to the finite element model?
#WikiCourses #Num001
https://wikicourses.wikispaces.com/TopicX+Approximate+Methods+-+Weighted+Residual+Methods
Finite Element Method is explained taking a simple example
Essential concepts in this technique are introduced
Top-down approach and bottom-up approach are used to present a holistic picture of FEM
numeric analysis Bisection method. MATLAB provides tools to solve math. Using linear programing techniques we can easily solve system of equations. This file provides a running code of Bisection Method
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfaartechindia
Incorporate the SOR method in the multigridTest.m and apply the multigridTest.m, to
determine the effects of changes in
Pre-smoothing iterations
Post-smoothing iterations
Multigrid cycle type
Iterative method
Number of grids (or grid hierarchy)
% SOR (Successive Over-Relaxation)
n = input('Enter number of equations, n: ');
A = zeros(n,n+1);
x1 = zeros(1,n);
A=[5 -2 3 -1;-3 9 1 2;2 -1 -7 3];
x1 = [0 0 0];
tol = input('Enter tolerance, tol: ');
m = input('Enter maximum number of iterations, m: ');
w = input('Enter the parameter w (omega): ');
k = 1;
while k <= m
err = 0;
for i = 1 : n
s = 0;
for j = 1 : n
s = s-A(i,j)*x1(j);
end
s = w*(s+A(i,n+1))/A(i,i);
if abs(s) > err
err = abs(s);
end
x1(i) = x1(i)+s;
end
if err <= tol
break;
else
k = k+1;
end
end
fprintf('The solution vector after %d iterations is :\n', k);
for i = 1 : n
fprintf(' %11.8f \n', x1(i));
end
%% Multigrid test case with visulization
% Author: Ben Beaudry
clc; clear; close all
load A_b.mat;
A = full(A); % Unsparce matrix to show full power of Multigrid
pre = 2; % Number of presmoothing iterations
post = 2; % Number of postsmoothing iterations
% cycle = 1; % Type of multigrid cycle (1=V-cycle, 2=W-cycle, 3=F-cycle)
smooth = 1; % Smoother type (1=Jacobi, 2=Gauss-Seidel)
grids = 5; % Max grids in cycle
maxit = 10; % Max iterations of solver
tol = 1e-02; % Tolerance of solver
%% Solvers
% solve directly
t=cputime;
x_D = A\b;
fprintf('Direct Solve Time: %g Seconds\n',cputime-t)
% V-Cycle
t=cputime;
[x_V,res_V,it_V] = multigrid(A,b,pre,post,1,smooth,grids,maxit,tol);
fprintf('V-Cycle Solve Time: %g Seconds\n',cputime-t)
% W-Cycle
t=cputime;
[x_W,res_W,it_W] = multigrid(A,b,pre,post,2,smooth,grids,maxit,tol);
fprintf('W-Cycle Solve Time: %g Seconds\n',cputime-t)
% F-Cycle
t=cputime;
[x_F,res_F,it_F] = multigrid(A,b,pre,post,3,smooth,grids,maxit,tol);
fprintf('F-Cycle Solve Time: %g Seconds\n',cputime-t)
% max it for iterative methods
it = 100;
% Gauss-Siedel
t=cputime;
L = tril(A);
U = triu(A,1);
x_G = zeros(length(b),1);
res_G= zeros(it,1);
for g = 1:it
x_G = L\(b-U*x_G);
r = b - A * x_G;
res_G(g) = norm(r);
if res_G(g) < tol
break;
end
end
fprintf('Gauss-Seidel Solve Time: %g Seconds\n',cputime-t)
% Jacobi
t=cputime;
d = diag(A);
dinv = 1./d;
LU = tril(A,-1)+triu(A,1);
U = triu(A,1);
x_J = zeros(length(b),1);
res_J= zeros(it,1);
for j = 1:it
x_J = dinv.*(b-(LU*x_J));
r = b - A * x_J;
res_J(j) = norm(r);
if res_J(j) < tol
break;
end
end
fprintf('Jacobi Solve Time: %g Seconds\n',cputime-t)
%% Plotting
figure;
hold on
plot(1:g,res_G(1:g),'o-','DisplayName','Guass-Seidel')
plot(1:j,res_J(1:j),'o-','DisplayName','Jacobi')
plot(1:it_V,res_V(1:it_V),'o-','DisplayName','V-Cycle Multigrid')
plot(1:it_F,res_F(1:it_F),'o-','DisplayName','F-Cycle Multigrid')
plot(1:it_W,res_W(1:it_W),'o-','DisplayName','W-Cycle Multigrid')
set(gca,'XLim',[0 100]);
grid on
legend('location','best')
ylabel('Relative Convergance')
xlabel('Iterations')
title('Convergance of Numerical System')
hold off
MULTIGRID FUNC.
System dynamics 3rd edition palm solutions manualSextonMales
System dynamics 3rd edition palm solutions manual
Full download: https://goo.gl/7Z6QZ3
People also search:
system dynamics palm 3rd edition pdf
system dynamics palm 3rd edition solutions pdf
system dynamics palm 3rd edition free pdf
system dynamics palm pdf
system dynamics palm 3rd edition ebook
system dynamics 3rd edition ogata pdf
system dynamics palm 2nd edition solution manual
system dynamics palm 3rd edition academia
C program to find factorial of number using recursion as well as iteration ,
Calculate power of a number program in c using Recursion and Iteration, Write a C program to count digits of a number using Recursion and Iteration, Write a C program to find sum of first n natural numbers using Recursion, C program to print sum of digits of a given number using recursion ,Write a C program to find nth term in Fibonacci Series using Recursion, C program to find out the GCD (Greatest Common Divisor )of the two numbers using recursion,
Write a C program to find the first upper case letter in the given string using recursion, write C program to calculate length of the string using Recursion ,
Write a program in C to count number of divisors of a given number using recursion, Recursive program to check whether a given number is prime or composite,
C program to displays integers 100 through 1 using Recursion and Iteration, Write a program in C to convert a decimal number to binary using recursion,
Recursion Stack of factorial of 3 Recursion stack of 4th term of Fibonacci
To Compute GCD and LCM String Manipulation , Operations on string length, concatenation, reverse, counting, and copy of a string to another, Matrices, Matrix Addition, Subtraction, Multiplication, Transpose of n x m matrices, Inverse of a square matrix, Searching, Binary Search,GCD , LCM String Manipulation , Operations STRING,string length, concatenation, reverse, counting, copy of a string, Matrices, Matrix Addition, Subtraction, Multiplication, Transpose,n x m matrices, Inverse MATRIX,square matrix, Searching, Binary Search,C PROGRAM,C,PROGRAMMING,SIMPLE C, EXAMPLE C,LAB PROGRAMS,LAB, C EXERCISES,thiruvalluvar university,lab manual,c lab manual
Mid-Term Exam
Name___________________________________
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
Fill in the blank with one of the words or phrases listed below.
distributive real reciprocals absolute value opposite associative
inequality commutative whole algebraic expression exponent variable
1) The of a number is the distance between the number and 0 on the number line.
A) opposite B) whole
C) absolute value D) exponent
1)
Find an equation of the line. Write the equation using function notation.
2) Through (1, -3); perpendicular to f(x) = -4x - 3
A) f(x) =
1
4
x -
13
4
B) f(x) = -
1
4
x -
13
4
C) f(x) = -4x -
13
4
D) f(x) = 4x -
13
4
2)
Multiply or divide as indicated.
3)
60
-5
A) -22 B) 12 C) - 1
12
D) -12
3)
Write the sentence using mathematical symbols.
4) Two subtracted from x is 55.
A) 2 + x = 55 B) 2 - x = 55 C) x - 2 = 55 D) 55 - 2 = x
4)
Name the property illustrated by the statement.
5) (-10) + 10 = 0
A) associative property of addition B) additive identity property
C) commutative property of addition D) additive inverse property
5)
Tell whether the statement is true or false.
6) Every rational number is an integer.
A) True B) False
6)
Add or subtract as indicated.
7) -5 - 12
A) 7 B) -17 C) 17 D) -7
7)
1
Name the property illustrated by the statement.
8) (1 + 8) + 6 = 1 + (8 + 6)
A) distributive property
B) associative property of addition
C) commutative property of multiplication
D) associative property of multiplication
8)
Simplify the expression.
9) -(10v - 6) + 10(2v + 10)
A) 30v + 16 B) -10v + 94 C) 10v + 106 D) 30v + 4
9)
Solve the equation.
10) 5(x + 3) = 3[14 - 2(3 - x) + 10]
A) -39 B) 3 C) -13 D) 39
10)
List the elements of the set.
11) If A = {x|x is an odd integer} and B = {35, 37, 38, 40}, list the elements of A ∩ B.
A) {35, 37}
B) {x|x is an odd integer}
C) {x|x is an odd integer or x = 38 or x = 40}
D) { }
11)
Solve the inequality. Graph the solution set.
12) |x| ≥ 4
A) (-∞, -4] ∪ [4, ∞)
-6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6-6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6
B) [-4, 4]
-6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6-6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6
C) [4, ∞)
-6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6-6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6
D) (-∞, -4) ∪ (4, ∞)
-6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6-6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6
12)
Solve.
13) The sum of three consecutive even integers is 336. Find the integers.
A) 108, 110, 112 B) 110, 112, 114 C) 112, 114, 116 D) 111, 112, 113
13)
2
Solve the inequality. Write your solution in interval notation.
14) x ≥ 4 or x ≥ -2
A) (-∞, ∞) B) [4, ∞)
C) [-2, ∞) D) (-∞, -2] ∪ [4, ∞)
14)
Use the formula A = P 1 + r
n
nt
to find the amount requested.
15) A principal of $12,000 is invested in an account paying an annual interest rate of 4%. Find the
amount in the account after 3 years if the account is compounded quarterly.
A) $1521.9 B) $13,388.02 C) $13,498.37 D) $13,521.90
15)
Graph the solution set ...
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
We all have good and bad thoughts from time to time and situation to situation. We are bombarded daily with spiraling thoughts(both negative and positive) creating all-consuming feel , making us difficult to manage with associated suffering. Good thoughts are like our Mob Signal (Positive thought) amidst noise(negative thought) in the atmosphere. Negative thoughts like noise outweigh positive thoughts. These thoughts often create unwanted confusion, trouble, stress and frustration in our mind as well as chaos in our physical world. Negative thoughts are also known as “distorted thinking”.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Basic phrases for greeting and assisting costumers
NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false point,x=g(x)
1. Islamic Azad University
Qazvin Branch
Faculty of Industrial and Mechanics , Department of Mechanical
Engineering
Subject
Compare Some Algorithms for Solving Nonlinear Equation
Thesis Advisor
Dr.Marufi
By
Parham Sagharichi Ha
2. Assignment of Numerical Analysis Parham Sagharichi Ha
parhamsagharchi@gmail.com 1
Problem
The speed v of a Saturn V rocket in vertical flight near the surface of earth can
be approximated by
𝑣 = 𝑢 ln
𝑀0
𝑀0 − 𝑚̇ 𝑡
− 𝑔𝑡
𝑢 = 2510
𝑚
𝑠
= 𝑣𝑒𝑙𝑜𝑐𝑖𝑡𝑦 𝑜𝑓 𝑒𝑥ℎ𝑎𝑢𝑠𝑡 𝑟𝑒𝑙𝑎𝑡𝑖𝑣𝑒 𝑡𝑜 𝑡ℎ𝑒 𝑟𝑜𝑐𝑘𝑒𝑡
𝑀0 = 2.8 ∗ 106
𝑘𝑔 = 𝑚𝑎𝑠𝑠 𝑜𝑓 𝑟𝑜𝑐𝑘𝑒𝑡 𝑎𝑡 𝑙𝑖𝑓𝑡𝑜𝑓𝑓
𝑚̇ = 13.3 ∗ 103
𝑘𝑔
𝑠
= 𝑟𝑎𝑡𝑒 𝑜𝑓 𝑓𝑢𝑒𝑙 𝑐𝑜𝑛𝑠𝑢𝑚𝑝𝑡𝑖𝑜𝑛
𝑔 = 9.81
𝑚
𝑠2
= 𝑔𝑟𝑎𝑣𝑖𝑡𝑎𝑡𝑖𝑜𝑛𝑎𝑙 𝑎𝑐𝑐𝑒𝑙𝑒𝑟𝑎𝑡𝑖𝑜𝑛
𝑡 = 𝑡𝑖𝑚𝑒
Determine the time when the rocket reaches the speed of sound (335 m/s).
Solution
𝑢 𝑙𝑛
𝑀0
𝑀0 − 𝑚̇ 𝑡
− 𝑔𝑡 − 𝑣 = 0
Now we want to determine time in the above equation
3. Assignment of Numerical Analysis Parham Sagharichi Ha
parhamsagharchi@gmail.com 2
Matlab
1) Bisection Method
Script :
clc
close all
clear all
%%
% Subject : Bisect Algorithm
% Author: Parham Sagharichi Ha Email :
parhamsagharchi@gmail.com
%%
%-------------------S------T------A------R------T------------
-------------%
global tolerance
tolerance = 1e-4; % for example : 1e-4 = 10^-4
u = 2510;
M0 = 2.8*10^6;
mdot = 13.3*10^3;
g = 9.81;
v = 335;
xlower = 0;
xupper = 100;
myfun = @(t)(u.*log(M0./(M0-mdot.*t))-g.*t-v);
[root,iflag] = fbisect(myfun,xlower,xupper);
switch iflag
case -2
disp('Initial range does not only contain one root')
otherwise
disp([' Root = ' num2str(root) ...
' found in ' num2str(iflag) ' iterations'])
end
%---------------F------I------N------I------S------H---------
-------------%
4. Assignment of Numerical Analysis Parham Sagharichi Ha
parhamsagharchi@gmail.com 3
Function :
function [root,iflag] = fbisect(myfun,a,b)
if a>=b
disp(' attention b>a in [a b] ')
return
end
global tolerance
x = a:0.001:b;
y = feval(myfun,x);
fa = y(1);
fb = y(end);
ymax = max(y);
ymin = min(y);
figure
plot(x,y)
grid on
hold on
plot([a a],[ymin ymax])
plot([b b],[ymin ymax])
iflag = 0;
iterations = 0 ;
while (fa*fb<0) & (b-a)>tolerance
iterations = iterations + 1;
c = (a+b)/2;
fc = feval(myfun,c);
plot([c c],[ymin ymax])
pause
if fa*fc<0
b = c; fb = fc;
elseif fa*fc>0
a = c; fa = fc;
else
iflag = 1;
root = c
return
end
end
switch iterations
case 0
iflag = -2; root = NaN;
otherwise
iflag = iterations; root = c;
end
5. Assignment of Numerical Analysis Parham Sagharichi Ha
parhamsagharchi@gmail.com 4
Result :
Root = 70.8779 found in 20 iterations
2) Linear Interpolation (False Position) Method :
Script :
clc
close all
clear all
%%
% Subject : False Postion Algorithm
% Author: Parham Sagharichi Ha Email :
parhamsagharchi@gmail.com
%%
%-------------------S------T------A------R------T------------
-------------%
global tolerance
tolerance = 1e-4; % for example : 1e-4 = 10^-4
u = 2510;
M0 = 2.8*10^6;
mdot = 13.3*10^3;
g = 9.81;
v = 335;
xlower = 0;
xupper = 100;
myfun = @(t)(u.*log(M0./(M0-mdot.*t))-g.*t-v);
[root,iflag] = finter(myfun,xlower,xupper);
switch iflag
case -2
disp('Initial range does not only contain one root')
otherwise
disp([' Root = ' num2str(root) ...
' found in ' num2str(iflag) ' iterations'])
end
%---------------F------I------N------I------S------H---------
-------------%
6. Assignment of Numerical Analysis Parham Sagharichi Ha
parhamsagharchi@gmail.com 5
Function :
function [root,iflag] = finter(myfun,a,b)
if a>=b
disp(' attention b>a in [a b] ')
return
end
global tolerance
x = a:0.001:b;
y = feval(myfun,x);
fa = y(1);
fb = y(end);
ymax = max(y);
ymin = min(y);
figure
plot(x,y)
grid on
hold on
plot([a a],[ymin ymax])
plot([b b],[ymin ymax])
iflag = 0;
iterations = 0 ;
while (fa*fb<0) & (b-a)>tolerance
iterations = iterations + 1;
c = b - (fb)*(a-b)/(fa-fb);
fc = feval(myfun,c);
plot([c c],[ymin ymax])
pause
if fa*fc<0
b = c; fb = fc;
elseif fa*fc>0
a = c; fa = fc;
else
iflag = 1;
root = c
return
end
end
switch iterations
case 0
iflag = -2; root = NaN;
otherwise
7. Assignment of Numerical Analysis Parham Sagharichi Ha
parhamsagharchi@gmail.com 6
iflag = iterations; root = c;
end
Result :
Root = 70.878 found in 24 iterations
3) Newton-Raphson Method :
Script :
clc
close all
clear all
%%
% Subject : Newton_Raphson Algorithm
% Author: Parham Sagharichi Ha Email :
parhamsagharchi@gmail.com
%%
%-------------------S------T------A------R------T------------
-------------%
format short E
tolerance = 1e-4; % for example : 1e-4 = 10^-4
xlower = 0;
xupper = 100;
xguess = 45;
if (xguess>xupper)||(xlower>xguess)
disp(' error , repate again ')
return
end
xrange = xlower:0.1:xupper;
s = size(xrange);
u = 2510;
M0 = 2.8*10^6;
mdot = 13.3*10^3;
g = 9.81;
v = 335;
syms x
myfun = u.*log(M0./(M0-mdot.*x))-g.*x-v;
8. Assignment of Numerical Analysis Parham Sagharichi Ha
parhamsagharchi@gmail.com 7
u = 2510;
M0 = 2.8*10^6;
mdot = 13.3*10^3;
g = 9.81;
v = 335;
for i = 1:s(2);
y(i) = double(subs(myfun,[x],[xrange(i)]));
end
fa = y(1);
fb = y(end);
ymax = max(y);
ymin = min(y);
figure
plot(xrange,y)
grid on
hold on
plot([xlower xlower],[ymin ymax])
plot([xupper xupper],[ymin ymax])
plot([xlower xupper],[0 0])
iflag = 0;
iterations = 1 ;
f = double(subs(myfun,[x],xguess));
myfun_prime = jacobian(myfun,x);
fprime = double(subs(myfun_prime,[x],xguess));
xn = xguess;
xnew = xn - f/fprime;
plot([xn xn],[0 f])
pause
plot([xn xnew],[f 0])
while (abs(xnew-xn)>tolerance) & (iterations<30)
iterations = iterations + 1;
xn = xnew;
f = double(subs(myfun,[x],xn));
fprime = double(subs(myfun_prime,[x],xn));
xnew = xn - f/fprime;
root = xnew;
pause
plot([xn xn],[0 f])
pause
plot([xn xnew],[f 0])
end
9. Assignment of Numerical Analysis Parham Sagharichi Ha
parhamsagharchi@gmail.com 8
switch iterations
case 30
disp(' Not root found ');
otherwise
disp([' Root = ' num2str(root) ...
' found in ' num2str(iterations) ' iterations
'])
end
%---------------F------I------N------I------S------H---------
-------------%
Result :
Root = 70.878 found in 5 iterations
4) Mueller’s Method :
Script :
clc
close all
clear all
%%
% Subject : Mueller’s Algorithm
% Author: Parham Sagharichi Ha Email :
parhamsagharchi@gmail.com
%%
%-------------------S------T------A------R------T------------
-------------%
tolerance = 1e-4; % for example : 1e-4 = 10^-4
u = 2510;
M0 = 2.8*10^6;
mdot = 13.3*10^3;
g = 9.81;
v = 335;
xlower = 0;
xupper = 100;
10. Assignment of Numerical Analysis Parham Sagharichi Ha
parhamsagharchi@gmail.com 9
xguess = 45;
if (xguess>xupper)||(xlower>xguess)
disp(' error , repate again ')
return
end
myfun = @(t)(u.*log(M0./(M0-mdot.*t))-g.*t-v);
x = [xlower xguess xupper]';%[x2 x0 x1]
xe = xlower:0.1:xupper;
ye = feval(myfun,xe);
ymax = max(ye);
ymin = min(ye);
figure
plot(xe,ye)
grid on
hold on
rline = plot([xlower xlower],[ymin ymax]);
mline = plot([xguess xguess],[ymin ymax]);
fline = plot([xupper xupper],[ymin ymax]);
pause
iterations = 0;
while (true)
iterations = iterations +1;
y = feval(myfun,x);%[f2 f0 f1]
h1 = x(3)-x(2);
h2 = x(2)-x(1);
gamma = h2/h1;
c = y(2);
a = (gamma*y(3)-y(2)*(1+gamma)+y(1))/(gamma*h1^2*(1+gamma));
b = (y(3)-y(2)-a*h1^2)/h1;
if b>0
root = x(2)-(2*c)/(b+sqrt(b^2-4*a*c));
else
root = x(2)-(2*c)/(b-sqrt(b^2-4*a*c));
end
pause
rootline = plot([root root],[ymin ymax]);
if root>x(2)
x = [x(2) root x(3)];
else
x = [x(1) root x(2)];
end
pause
delete(rootline)
delete(rline)
delete(mline)
delete(fline)
11. Assignment of Numerical Analysis Parham Sagharichi Ha
parhamsagharchi@gmail.com 10
rline = plot([x(1) x(1)],[ymin ymax]);
mline = plot([x(2) x(2)],[ymin ymax]);
fline = plot([x(3) x(3)],[ymin ymax]);
if (abs(feval(myfun,root))<(10^-8))&(iterations<30)
break
end
end
switch iterations
case 30
disp(' Not root found ');
otherwise
disp([' Root = ' num2str(root) ...
' found in ' num2str(iterations) ' iterations
'])
end
Result :
Root = 70.878 found in 5 iterations
5) 𝑥 = 𝑔(𝑥) Method :
𝑢 𝑙𝑛
𝑀0
𝑀0 − 𝑚̇ 𝑡
− 𝑔𝑡 − 𝑣 = 0
First Equation :
𝑡 =
𝑢
𝑔
𝑙𝑛
𝑀0
𝑀0 − 𝑚̇ 𝑡
−
𝑣
𝑔
Second Equation :
𝑡 =
𝑀0
𝑚̇
(
exp (
𝑔𝑡 + 𝑣
𝑢
) − 1
exp (
𝑔𝑡 + 𝑣
𝑢
)
)
12. Assignment of Numerical Analysis Parham Sagharichi Ha
parhamsagharchi@gmail.com 11
Script :
clc
close all
clear all
%%
% Subject : x=g(x) Algorithm
% Author: Parham Sagharichi Ha Email :
parhamsagharchi@gmail.com
%%
%-------------------S------T------A------R------T------------
-------------%
tolerance = 1e-4; % for example : 1e-4 = 10^-4
u = 2510;
M0 = 2.8*10^6;
mdot = 13.3*10^3;
g = 9.81;
v = 335;
xlower = 0;
xupper = 100;
xguess = 45;
if (xguess>xupper)||(xlower>xguess)
disp(' error , repate again ')
return
end
myfun1 = @(t)((u/g).*log(M0./(M0-mdot.*t))-v/g);
myfun2 = @(t)((M0/mdot).*(exp((g.*t+v)/u)-
1)./exp((g.*t+v)/u));
xold1 = xguess;
xnew1 = feval(myfun1,xold1);
iterations1 = 0;
while (abs(xnew1-xold1)>tolerance)&(iterations1<30)
iterations1 = iterations1 + 1;
xold1 = xnew1;
xnew1 = feval(myfun1,xold1);
13. Assignment of Numerical Analysis Parham Sagharichi Ha
parhamsagharchi@gmail.com 12
end
root1 = xnew1(end);
switch iterations1
case 30
disp(' Not root found ');
otherwise
disp([' Root1 = ' num2str(root1) ...
' found in ' num2str(iterations1) ' iterations1
'])
end
xold2 = xguess;
xnew2 = feval(myfun2,xold2);
iterations2 = 0;
while (abs(xnew2-xold2)>tolerance)&(iterations2<30)
iterations2 = iterations2 + 1;
xold2 = xnew2;
xnew2 = feval(myfun2,xold2);
end
root2 = xnew2(end)
switch iterations2
case 30
disp(' Not root found ');
otherwise
disp([' Root2 = ' num2str(root2) ...
' found in ' num2str(iterations2) ' iterations2
'])
end
Result :
Not root found
root2 =
7.0878e+01
Root2 = 70.8779 found in 20 iterations2
References
Kiusalaas, J. (2009) Numerical Methods in Engineering with MATLAB®