




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Complete lab reports of computational Engineering-I
Typology: Schemes and Mind Maps
1 / 110
This page cannot be seen from the preview
Don't miss anything!





























































































Sr No. Experiment Title 1 Introduction to Python/MATLAB Programming 2 Round-off and Approximation Error 3 Root Finding for Nonlinear Equations (Bracketing Methods) 4 Root Finding for Nonlinear Equations (Open Methods) 5 Finite Difference Techniques for Numerical Approximations 6 Solution of Differential Equations (Runge-Kutta Methods) 7 Numerical Evaluation of Integrals (Trapezoidal & Simpson’s Rules) 8 Implementation of Lagrange’s Interpolation 9 Implementation of Least Square Regression 10 Numerical Approaches to Solve Elliptic PDEs 11 Numerical Approaches to Solve Parabolic PDEs (Explicit Methods) 12 Numerical Approaches to Solve Parabolic PDEs (Implicit Methods) 13 Solution of Linear Equations by Gauss-Seidel/Jacobi Method
Name Mirza Muhammad Aslam baig Registration No. 2022-UET-NFC-FD-MECh- 59 Session 2022 Course Code ME- 353 Course Title Computational Engineering 1 Course Instructor Engr. Khizar Siddique Section B Group B Date (^) of Submission June 18, 2025
MATLAB (short for MATrix LABoratory) is widely used in engineering for numerical computing. It supports matrix operations, algorithm development, and data visualization. Learning the basics sets the stage for applying numerical methods in later experiments.
In programming, we use: Variables to store and manipulate data Conditionals (if-else) for decision-making Loops (for, while) for repetitive tasks Functions for modular, reusable code blocks Plotting functions for visualization of results These tools help engineers model and solve mathematical problems efficiently.
Start ↓ Declare Variables ↓ Perform Arithmetic & Logical Checks ↓ Create & Use Function ↓ Use Loop to Print Values ↓ Plot Sine Wave ↓ End
% Basic MATLAB Program a = 12; b = 8; disp(['Addition: ', num2str(a
out = x * y; end % Plotting sin(x) x = linspace(0, 2*pi, 100); y = sin(x); plot(x, y); xlabel('x- axis'); ylabel('sin(x)'); title('Sine Wave'); grid on;
Addition: 20 A is greater than B Loop from 1 to 5: 1 2 3 4 5 Multiplication Result: 15
Arithmetic: 12+8=2012 + 8 = 2012+8= Multiplication (via function): 5×3=155 \times 3 = 155×3= Sine Function: sin(x) values are calculated using MATLAB’s
built-in sin() function over a range
1
Name Mirza Muhammad Aslam baig Registration No. 2022-UET-NFC-FD-MECh- 59 Session 2022 Course Code ME- 353 Course Title Computational Engineering 1 Course Instructor Engr. Khizar Siddique Section B Group B Date (^) of Submission June 18, 2025
1
This experiment demonstrates the occurrence of round-off and approximation errors in numerical computation using MATLAB. Due to the finite representation of real numbers in digital systems, computations often involve small errors. We used different approximations of π and evaluated both absolute and relative errors. A log-scale plot illustrated how error decreases with increased precision. This experiment builds a foundational understanding of accuracy and error propagation in numerical methods.
In digital computations, real numbers are stored with limited precision. This introduces round-off and approximation errors, which can accumulate in large- scale calculations.
To calculate and analyze the absolute and relative errors caused by using different approximations of π, and visualize how precision affects numerical accuracy using MATLAB.
1
True value of π: pi Approximations: 3.1, 3.14, 3.
Start ↓ Define true value (π) ↓ Define approximations ↓ Compute errors (absolute & relative) ↓ Display results ↓ Plot error vs precision ↓ End
1 % Experiment 2 - Round-off and Approximation Error in MATLAB % True value of pi true_val = pi; % Approximated values of pi approximations = [3.1, 3.14, 3.1416]; % Number of significant digits in each approximation digits = [2, 4, 6]; % Calculating absolute and relative errors abs_errors = abs(true_val - approximations); rel_errors = abs((true_val - approximations) ./ true_val); % Displaying results fprintf('Approx\t\tAbsolute Error\t\tRelative Error\n'); for i = 1:length(approximations) fprintf('%.4f\t\t%.10f\t\t%.10f\n', approximations(i), abs_errors(i), rel_errors(i)); end % Plotting absolute error vs digits of precision figure; semilogy(digits, abs_errors, 'o-', 'LineWidth', 1.5, 'MarkerSize', 8); xlabel('Digits of Precision'); ylabel('Absolute Error (log scale)'); title('Absolute Error vs Number of Digits in Approximation'); grid on;
Approx Abs Error Rel Error 3.1000 0.0415926536 0. 3.1400 0.0015926536 0. 3.1416 0.0000073464 0.
1
141592653589793 ≈0.
− ≈2.338× 10 −
This experiment demonstrated how even small differences in number precision can lead to significant error changes. The plot confirmed that error drops exponentially as approximation improves. In numerical modeling, such small inaccuracies can propagate and compound, especially in iterative or sensitive computations.
Use built-in constants like pi for accurate results Prefer higher precision approximations Track relative error when values are large
The experiment successfully highlighted the presence and impact of round-off and approximation errors in MATLAB computations. By analyzing different levels of precision, we observed how errors shrink as more digits are used. This understanding is essential when implementing accurate and reliable numerical algorithms in
1 engineering simulations.
1
This experiment applies the Bisection Method, a fundamental bracketing technique used to find the root of nonlinear equations. MATLAB was used to implement the method for the function f(x)=𝑥^3 −x−2, which has a root between 1 and 2. The error at each iteration was recorded and plotted on a logarithmic scale. The method successfully converged to the correct root within a predefined tolerance, demonstrating its reliability and simplicity. Results are presented with MATLAB code, output, and error analysis.
Finding roots of nonlinear equations is essential in many engineering problems. Analytical solutions are often impossible, requiring numerical methods like the Bisection Method.
To implement the Bisection Method in MATLAB to find the root of f(x)=𝑥^3 −x−2 and analyze convergence through a plotted error graph.
Bracketing methods are simple and robust techniques for solving
2 equations of the form f(x)=0, where: