formatting changes

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2022-12-29 18:45:04 +05:30
parent 077e1aa9bb
commit 99aafe0de8
4 changed files with 60 additions and 44 deletions

View File

@@ -22,28 +22,35 @@
#include <math.h>
#include <stdio.h>
#define EPSILON 0.0000001
#define f(x) ((352 * x * x * x) - (64 * x * x) + (198 * x) - 36)
#define f1(x) ((1056 * x * x) - (128 * x) + 198)
double newtonRaphson(double x) {
double h = f(x) / f1(x);
if (f(x) == 0 || fabs(h) < EPSILON)
return x;
return newtonRaphson(x - h);
}
int main() {
printf("Root for f(x) = 352x^3 - 64x^2 + 198x - 36 is %lf",
newtonRaphson(-4));
}
#+end_src
* Program for nding roots of f(x) = 0 using bisection method
#+LATEX: \clearpage
* Program for finding roots of f(x) = 0 using bisection method
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src C :tangle 2.c :results output :exports both :wrap src text
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define EPSILON 0.0000001
#define f(x) ((352 * x * x * x) - (64 * x * x) + (198 * x) - 36)
double bisection(double a, double b) {
double x;
if (f(a) * f(b) > 0) {
@@ -58,6 +65,7 @@ double bisection(double a, double b) {
return bisection(x, b);
return bisection(a, x);
}
int main() {
printf("Root for f(x) = 352x^3 - 64x^2 + 198x - 36 is %lf",
bisection(1.6, -4));
@@ -72,7 +80,9 @@ int main() {
#include <math.h>
#include <stdio.h>
#define EPSILON 0.0000001
#define f(x) ((352 * x * x * x) - (64 * x * x) + (198 * x) - 36)
double secant(double a, double b) {
double x1;
x1 = (a * f(b) - b * f(a)) / (f(b) - f(a));
@@ -80,6 +90,7 @@ double secant(double a, double b) {
return x1;
return secant(b, x1);
}
int main() {
printf("Root for f(x) = 352x^3 - 64x^2 + 198x - 36 is %lf", secant(1.6, -4));
}
@@ -206,6 +217,8 @@ Enter interpolation point x: 999
Interpolated value for 999.000000 is 9525764925.000002.
#+end_src
#+LATEX: \clearpage
* Program for solving numerical integration by trapezoidal method.
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src C :tangle 6.c :results output :exports both :wrap src text
@@ -234,6 +247,8 @@ int main() {
}
#+end_src
#+LATEX: \clearpage
* Program for solving numerical integration by Simpson's 1/3 rule.
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src C :tangle 7.c :results output :exports both :wrap src text
@@ -351,14 +366,18 @@ int main() {
for (int j = 0; j < ORDER; j++)
printf("%lf ", inv[i][j + ORDER]);
printf("\n");
free(inv[i]);
free(matrix[i]);
}
free(inv);
free(matrix);
}
#+end_src
#+LATEX: \clearpage
* Program for finding eigen values using power method.
#+ATTR_LATEX: :options frame=single,breaklines=true
#+begin_src C :tangle 10.c :results output :exports both :wrap src text
@@ -421,6 +440,7 @@ int main() {
printf("%lf ", egn[i]);
free(matrix[i]);
}
free(egn);
free(matrix);
}

BIN
file.pdf

Binary file not shown.

View File

@@ -1,8 +1,8 @@
\newgeometry{left=1.5in,right=1.5in}
\begin{titlepage}
\vspace*{1.6in}
\vspace*{1.2in}
\begin{center}
{\fontsize{20}{24}\selectfont \textbf{\emph{Computational Mathematics Lab}}}
{\fontsize{20}{24}\selectfont \textbf{\emph{Computational Methods Lab}}}
\end{center}
\vspace{0.3in}
\hspace{0.3in}
@@ -17,7 +17,7 @@
Student: AMNEESH SINGH\\
Enrollment: 14114803121\\
Semester: III\\
Group: 3I6
Group: I6
\end{minipage}
\begin{center}

44
toc.tex
View File

@@ -1,44 +1,40 @@
\begin{center}
\fontsize{15}{18}\selectfont \textbf{
DATA STRUCTURES LAB\\
COMPUTATIONAL METHODS LAB\\
PRACTICAL RECORD
}
\end{center}
\vspace{0.5cm}
\begin{table}[h]
\begin{tabular}{lcl}
Paper Code & : & e\\
Paper Code & : & ES-251\\
Name of the student & : & Amneesh Singh\\
University Enrollment number & : & 14114803121\\
Branch & : & Information Technology\\
Group & : & 3I6
Group & : & I6
\end{tabular}
\end{table}
\vspace{0.5cm}
\textbf{PRACTICAL DETAILS}
Experiments according to the lab syllabus prescribed by GGSIPU
\vspace{0.5cm}
\begin{table}[h]
\renewcommand{\arraystretch}{2.5}
\begin{tabular}{|p{0.6cm}|p{8cm}|p{2cm}|p{2cm}|p{2cm}|p{1cm}|} \hline
Exp. No. & Experiment Name & Performance Date & Date Checked & Remarks & Marks \\ \hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \\ \hline
\end{tabular}
\fontsize{11}{12}\selectfont{
\renewcommand{\arraystretch}{2.5}
\begin{tabular}{|p{0.6cm}|p{8cm}|p{2cm}|p{2cm}|p{2cm}|p{1cm}|} \hline
\textbf{Exp. No.} & \textbf{Experiment Name} & \textbf{Performance Date} & \textbf{Date Checked} & \textbf{Remarks} & \textbf{Marks} \\ \hline \hline
1 & Program for finding roots of f(x) = 0 using Newton Raphson Method & & & & \\ \hline
2 & Program for finding roots of f(x) = 0 using Bisection Method & & & & \\ \hline
3 & Program for finding roots of f(x) = 0 using Secant Method & & & & \\ \hline
4 & Program to implement Langrange Interpolation & & & & \\ \hline
5 & Program to implement Newton's Divided Difference formula & & & & \\ \hline
6 & Program for solving numerical integration by trapezoidal method & & & & \\ \hline
7 & Program for solving numerical integration by Simpson's 1/3 rule & & & & \\ \hline
8 & Program for solving numerical integration by Simpson's 3/8 rule & & & & \\ \hline
9 & Program for finding inverse of linear equations using Gauss Jordan method & & & & \\ \hline
10 & Program for finding eigen values using power method & & & & \\ \hline
11 & Program for solving ordinary differential equation using Renge Kutta method & & & & \\ \hline
\end{tabular}
}
\end{table}