Discrete Mathematics Assignment Solution: MAT2409, Semester 1, USQ

Verified

Added on  2023/04/24

|10
|1580
|134
Homework Assignment
AI Summary
This document presents a comprehensive solution to a Discrete Mathematics assignment, focusing on the application of Newton's iterative method to solve non-linear equations using MATLAB. The assignment involves the creation and utilization of the GraphBeta and NewtonFun functions. The GraphBeta function is used to plot the function f(β) = cosβcoshβ - 1, while the NewtonFun function, based on the provided Pract. 2, is employed to find the roots of the equation within specified domains. The betaFun function is defined to return both the function and its derivative. The solution then proceeds to determine the smallest four physically meaningful values of β by applying the NewtonFun function across different domains, confirming the accuracy of the roots using the GraphBeta function. The solution includes detailed explanations of the MATLAB code, function usage, and the iterative process, demonstrating the successful implementation of the Newton's method and its application in solving the given non-linear equation. The conclusion summarizes the successful implementation of the functions and their effectiveness in finding the roots of the given non-linear equation.
Document Page
Running Head: Discrete Mathematics 1
Discrete Mathematics
Name
Institution Affiliation
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
DISCRETE MATHEMATICS 2
Introduction
Modern science and engineering systems are complex in nature and are made up of several
complex components. The relationships between these parts are represented by complex
mathematical equations which must be solved. These equations range from the simple linear
forms to complex non-linear forms. Several methods are available for the solution of the
different equations. Herein, Newton’s iterative method is used to solve non-linear equations
through the use of functions defined in MATLAB, mainly the NewtonFun function. The Newton
method takes an initial approximation as the input and then gradually produces an improved
estimate in an iterative manner (Brookshaw, Butler, Spunde, & Roberts, 2018, p. 50). The
GraphBeta function is also used to plot f ( β ) =cosβcoshβ1over a specified domain of β to
confirm the accuracy of the NewtonFun in obtaining the roots of the function in the specified
domain.
1. The graphing function: GraphBeta
Graphingf ( β )=cosβcoshβ1over a specified domain of β using a function GraphBeta
(Brookshaw, Butler, Spunde, & Roberts, 2018, p. 168)
%This function graphs y=cos(beta).*cosh(beta)-1 versus beta over
%a specified domain
%inputs: beta=(density*length/rigidity)*omega^2 where omega is
% the natural frequency;
% x1= the desirable domain of beta
function [] = GraphBeta(beta)
%GRAPHBETA plots the graph of y=cos(beta).*cosh(beta)-1
%specifications of the domain of beta
x1=input('Specify the domain of Beta in the form [LowerLimit
UpperLimit]: ');
if isempty(x1)||~isrow(x1)|| numel(x1)~=2
Document Page
DISCRETE MATHEMATICS 3
error('The domain must be a row vector of the form
[LowerLimit UpperLimit]')
end
if x1(1,1)>x1(1,2)
error('The UpperLimit must be greater than the
LowerLimit')
end
if x1(1,1)<0
error('A suitable domain must be of positive real
numbers')
end
%defining beta and the function y=f(beta)=cos(beta).*cosh(beta)-
1;
beta=linspace(x1(1,1),x1(1,2));
y=cos(beta).*cosh(beta)-1;
%plot of the graph of f(beta) against beta
plot(beta,y)
xlabel('\beta');
ylabel('y = cos\betacosh\beta - 1');
title('A plot of y = cos\betacosh\beta - 1 vs \beta');
end
2. The NewtonFun function and the betaFun
Using the NewtonFun function from Pract. 2 as the base, solutions f ( β ) =cosβcoshβ1over
specified domains are obtained using the Newton’s method. The smallest four physically
meaningful values of the unknown 𝛽 are then deduced.
The betaFun function which returns f ( β )=cosβcoshβ1 and its derivative
f ' ( β )=cosβsinhβcoshβsinβ where β= ρ ω2 l
EI is represented byx is first defined.
𝑙 = length of the beam, m
𝜔 = frequency, sec^-1
𝐸𝐼 = rigidity of the bar,
𝜌 = density, m^3/kg
%The Script
Document Page
DISCRETE MATHEMATICS 4
function [betaAndDerivative]=betaFun(x)
% BETAFUN evaulates f(x) and its derivative f'(x).
% And returns betaAndDerivative=[f(x) ;f'(x)]
%the initial function in the form of f(x)=0
fxBeta = cos(x).*cosh(x)- 1;
%the derivative of the function
fxBetaDerivative = cos(x).*sinh(x) - cosh(x).*sin(x);
%output of betaFun
betaAndDerivative=[fxBeta ; fxBetaDerivative];
end
The NewtonFun function is then used to obtain the solution of β in equation cosβcoshβ =1
using Newton’s method (Brookshaw, Butler, Spunde, & Roberts, 2018, p. 50).
%The Script
%Solution of non-linear equations using Newton method
%Syntax: [xroots]=NewtonFun(betaFun,x0,maxiter)
%inputs: calling function betaFun- must enclosed in quotation
% as a charater string ie 'betaFun'
% beta0-the starting value, an approximation of beta
% maxIter-the number of times the loop will be iterated
% iterations stops once maxIter has been reached
%output: betaFinal-is the last desired final value of beta
function [betaFinal]=NewtonFun(betaFun,beta0,maxIter)
%Checking for correct entries of the inputs
if ~(exist('maxIter') && exist('beta0') && exist('betaFun'))
error('The input arguments are not properly defined');
end
%changing values of beta as estimation progresses
betaOld=beta0;
% Obtaining new estimates using for loop iteration
for i=1:maxIter
betaAndDerivative = feval(betaFun,betaOld);
betaIter = betaOld -
betaAndDerivative(1,:)./betaAndDerivative(2,:);
betaOld = betaIter;
end
%final desired output value
betaFinal = betaOld;
end
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
DISCRETE MATHEMATICS 5
3. The smallest four physically meaningful values of β
Physically meaningful values of βmust be greater than zero.
i. Considering the domain [0, 3) and letting the first approximate solution of the equation
be β=1.5i.e. the midpoint.
The GraphBeta function give the following graph within this range:
And the solution of the from NewtonFun is:
>> beta=NewtonFun('betaFun',1.5,100000)
beta =
8.2063e-05
This value of β is confirmed to be a correct root since cosβcoshβ 1=0;
cos ( 8.2063× 105 ) ×cosh ( 8.2063 ×105 )1=0which agrees with the solution as required. This
solution can also be seen to be correct as the x-intercept of the graph hence β=8.2063 ×105 in
the domain [0,3].
ii. Considering the domain [3, 6) and letting the first approximate solution of the equation
be β=4.5
Document Page
DISCRETE MATHEMATICS 6
GraphBeta function output
NewtonFun function output
>>beta=NewtonFun('betaFun',4.5,100000)
beta =
4.7300
The solution is confirmed to be a correct root in this domain since
cos ( 4.7300 ) cosh ( 4.7300 ) 1=0.002348 which agrees with the solution up to 2 decimal places
hence the solution is acceptable. From the graph above, it is also evident that the only x-intercept
in this domain is β=4.7300
iii. Considering the domain [6, 9) and letting the first approximate solution of the equation
be β=7.5 since it’s the midpoint (Hahn, 2019, p. 87).
Document Page
DISCRETE MATHEMATICS 7
GraphBeta function
NewtonFun fuction output
>> beta=NewtonFun('betaFun',7.5,100000)
beta =
7.8532
In this domain, the solution isβ=7.8532as ascertained from
cos ( 7.8532 ) ×cosh ( 7.8532 )1=0.005946which agrees with the solution to 2 decimal places
hence acceptable. This is further proved from the x-intercept of the graph in this domain which is
approximately 7.8532
iv. Considering the domain [9, 12) and letting the first approximate solution of the equation
be β=10 .5 since it’s the midpoint.
GraphBeta function
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
DISCRETE MATHEMATICS 8
NewtonFun function output
>>beta=NewtonFun('betaFun',10.5,100000)
beta =
10.9956
The solution β=10.9956gives only a rough estimate of the real solution but it’s correct as can be
seen from the graph of the function in the specified domain.
cos ( 10.9956 ) × cosh ( 10.9956 ) 1=0.23362
The above solutions are the smallest four physically meaningful solutions of β
Document Page
DISCRETE MATHEMATICS 9
Conclusion
In summary, the NewtonFun, betaFun and GraphBeta functions were created and tested to be
running successfully and producing the correct desirable roots and graphs. Indeed, the Newton’s
method of solving non-linear equation is iterative as is clearly evident from the use of for loop in
the NewtonFun function. The GraphBeta function produces graphs of the function over specified
domains to ascertain the correctness of the root calculated by the NewtonFun function in that
domain. This is done by obtaining the x-intercept of the graph in the specified domain. All the
created functions are successfully running and can therefore be modified appropriately and
reused for finding the solutions of other non-linear equations.
Document Page
DISCRETE MATHEMATICS 10
References
Brookshaw, L., Butler, H., Spunde, W., & Roberts, T. (2018). mat2409 High Performance
Numerical Computing (1st ed.). Queensland, Australia: The University of Southern
Queensland.
Hahn, B. (2019). Essential MATLAB for engineers and scientists (1st ed.). Cambridge, London:
Cambridge University Press.
chevron_up_icon
1 out of 10
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]