diff --git a/.auctex-auto/documentation.el b/.auctex-auto/documentation.el new file mode 100644 index 0000000..f1109b4 --- /dev/null +++ b/.auctex-auto/documentation.el @@ -0,0 +1,74 @@ +;; -*- lexical-binding: t; -*- + +(TeX-add-style-hook + "documentation" + (lambda () + (TeX-add-to-alist 'LaTeX-provided-class-options + '(("article" "11pt"))) + (TeX-add-to-alist 'LaTeX-provided-package-options + '(("inputenc" "utf8") ("fontenc" "T1") ("graphicx" "") ("longtable" "") ("wrapfig" "") ("rotating" "") ("ulem" "normalem") ("amsmath" "") ("amssymb" "") ("capt-of" "") ("hyperref" "") ("calc" ""))) + (add-to-list 'LaTeX-verbatim-macros-with-braces-local "href") + (add-to-list 'LaTeX-verbatim-macros-with-braces-local "hyperimage") + (add-to-list 'LaTeX-verbatim-macros-with-braces-local "hyperbaseurl") + (add-to-list 'LaTeX-verbatim-macros-with-braces-local "nolinkurl") + (add-to-list 'LaTeX-verbatim-macros-with-braces-local "url") + (add-to-list 'LaTeX-verbatim-macros-with-braces-local "path") + (add-to-list 'LaTeX-verbatim-macros-with-delims-local "path") + (TeX-run-style-hooks + "latex2e" + "article" + "art11" + "inputenc" + "fontenc" + "graphicx" + "longtable" + "wrapfig" + "rotating" + "ulem" + "amsmath" + "amssymb" + "capt-of" + "hyperref" + "calc") + (TeX-add-symbols + '("cslcitation" 2) + '("cslbibitem" 2) + '("cslindent" 1) + '("cslrightinline" 1) + '("cslleftmargin" 1) + '("cslblock" 1) + "oldsection" + "oldsubsection" + "oldpar") + (LaTeX-add-labels + "sec:orga095243" + "sec:org4a38da4" + "sec:org784d853" + "sec:org8218260" + "sec:orgc92e0ac" + "sec:org80dbf09" + "sec:org7e75604" + "sec:org9f6d06d" + "sec:orga069e15" + "sec:orga095516" + "sec:org356a6b8" + "sec:orgd155bc9" + "sec:org20242c9" + "sec:orga43d4c9" + "sec:org4292208" + "sec:orgb038bbe" + "sec:orgf872e63" + "sec:orgd361433" + "sec:org7f48d68" + "sec:org700fda6" + "sec:org8334b01" + "sec:orga992d73" + "sec:orgab8c92c") + (LaTeX-add-environments + '("cslbibliography" 2)) + (LaTeX-add-lengths + "cslhangindent" + "csllabelsep" + "csllabelwidth")) + :latex) + diff --git a/documentation.aux b/documentation.aux new file mode 100644 index 0000000..c880bcc --- /dev/null +++ b/documentation.aux @@ -0,0 +1,45 @@ +\relax +\providecommand\hyper@newdestlabel[2]{} +\providecommand\HyField@AuxAddToFields[1]{} +\providecommand\HyField@AuxAddToCoFields[2]{} +\@writefile{toc}{\contentsline {section}{\numberline {1}Declaration of self reliance}{3}{section.1}\protected@file@percent } +\newlabel{sec:orga095243}{{1}{3}{Declaration of self reliance}{section.1}{}} +\@writefile{toc}{\contentsline {section}{\numberline {2}Task desciption}{4}{section.2}\protected@file@percent } +\newlabel{sec:org4a38da4}{{2}{4}{Task desciption}{section.2}{}} +\@writefile{toc}{\contentsline {section}{\numberline {3}Graphical representation of the software design}{5}{section.3}\protected@file@percent } +\newlabel{sec:org784d853}{{3}{5}{Graphical representation of the software design}{section.3}{}} +\@writefile{toc}{\contentsline {section}{\numberline {4}Theoretical explanation of the relationships}{6}{section.4}\protected@file@percent } +\newlabel{sec:org8218260}{{4}{6}{Theoretical explanation of the relationships}{section.4}{}} +\@writefile{toc}{\contentsline {subsection}{\numberline {4.1}\texttt {"integrate.h"}:}{6}{subsection.4.1}\protected@file@percent } +\newlabel{sec:orgc92e0ac}{{4.1}{6}{\texttt {"integrate.h"}:}{subsection.4.1}{}} +\@writefile{toc}{\contentsline {subsection}{\numberline {4.2}\texttt {"integrate.c"}:}{7}{subsection.4.2}\protected@file@percent } +\newlabel{sec:org80dbf09}{{4.2}{7}{\texttt {"integrate.c"}:}{subsection.4.2}{}} +\@writefile{toc}{\contentsline {subsubsection}{\numberline {4.2.1}Common argument checking (\texttt {bad\_args})}{9}{subsubsection.4.2.1}\protected@file@percent } +\newlabel{sec:org7e75604}{{4.2.1}{9}{Common argument checking (\texttt {bad\_args})}{subsubsection.4.2.1}{}} +\@writefile{toc}{\contentsline {subsubsection}{\numberline {4.2.2}Midpoint / rectangle method (\texttt {midpoint})}{9}{subsubsection.4.2.2}\protected@file@percent } +\newlabel{sec:org9f6d06d}{{4.2.2}{9}{Midpoint / rectangle method (\texttt {midpoint})}{subsubsection.4.2.2}{}} +\newlabel{sec:orga069e15}{{1}{9}{Midpoint / rectangle method (\texttt {midpoint})}{Item.1}{}} +\newlabel{sec:orga095516}{{2}{10}{Midpoint / rectangle method (\texttt {midpoint})}{Item.2}{}} +\@writefile{toc}{\contentsline {subsubsection}{\numberline {4.2.3}Trapezoid method (\texttt {trapezoid})}{10}{subsubsection.4.2.3}\protected@file@percent } +\newlabel{sec:org356a6b8}{{4.2.3}{10}{Trapezoid method (\texttt {trapezoid})}{subsubsection.4.2.3}{}} +\newlabel{sec:orgd155bc9}{{1}{10}{Trapezoid method (\texttt {trapezoid})}{Item.3}{}} +\newlabel{sec:org20242c9}{{2}{10}{Trapezoid method (\texttt {trapezoid})}{Item.4}{}} +\@writefile{toc}{\contentsline {subsubsection}{\numberline {4.2.4}Simpson 1/3 method (\texttt {simpson})}{11}{subsubsection.4.2.4}\protected@file@percent } +\newlabel{sec:orga43d4c9}{{4.2.4}{11}{Simpson 1/3 method (\texttt {simpson})}{subsubsection.4.2.4}{}} +\newlabel{sec:org4292208}{{1}{11}{Simpson 1/3 method (\texttt {simpson})}{Item.5}{}} +\newlabel{sec:orgb038bbe}{{2}{11}{Simpson 1/3 method (\texttt {simpson})}{Item.6}{}} +\@writefile{toc}{\contentsline {subsection}{\numberline {4.3}Performance-oriented aspects (embedded focus)}{12}{subsection.4.3}\protected@file@percent } +\newlabel{sec:orgf872e63}{{4.3}{12}{Performance-oriented aspects (embedded focus)}{subsection.4.3}{}} +\@writefile{toc}{\contentsline {section}{\numberline {5}Documentation of the reference examples used for testing}{13}{section.5}\protected@file@percent } +\newlabel{sec:orgd361433}{{5}{13}{Documentation of the reference examples used for testing}{section.5}{}} +\@writefile{toc}{\contentsline {subsection}{\numberline {5.1}Test integrand design}{14}{subsection.5.1}\protected@file@percent } +\newlabel{sec:org7f48d68}{{5.1}{14}{Test integrand design}{subsection.5.1}{}} +\@writefile{toc}{\contentsline {subsection}{\numberline {5.2}Test runner (\texttt {run\_one})}{15}{subsection.5.2}\protected@file@percent } +\newlabel{sec:org700fda6}{{5.2}{15}{Test runner (\texttt {run\_one})}{subsection.5.2}{}} +\@writefile{toc}{\contentsline {subsection}{\numberline {5.3}Reference examples in \texttt {main()}}{16}{subsection.5.3}\protected@file@percent } +\newlabel{sec:org8334b01}{{5.3}{16}{Reference examples in \texttt {main()}}{subsection.5.3}{}} +\@writefile{toc}{\contentsline {subsubsection}{\numberline {5.3.1}Results}{22}{subsubsection.5.3.1}\protected@file@percent } +\newlabel{sec:orga992d73}{{5.3.1}{22}{Results}{subsubsection.5.3.1}{}} +\@writefile{toc}{\contentsline {section}{\numberline {6}Bibliography}{23}{section.6}\protected@file@percent } +\newlabel{sec:orgab8c92c}{{6}{23}{Bibliography}{section.6}{}} +\gdef \@abspage@last{23} diff --git a/documentation.org b/documentation.org index dd4238c..04c2092 100644 --- a/documentation.org +++ b/documentation.org @@ -13,10 +13,22 @@ * Declaration of self reliance I hereby declare that I have written this thesis independently in accordance with § 35 para. 7 RaPO (Framework Examination Regulations for Universities of Applied Sciences in Bavaria, BayRS 2210-4-1-4-1-WFK), have not submitted it elsewhere for examination purposes, have not used any sources or aids other than those indicated, and have marked all direct and indirect quotations as such. +* Task desciption +Topic 5: Numerical integration methods +The aim of this task is to implement three variants of numerical approaches for calculating integrals +in a software module. +A function for the rectangle method, the trapezoid method, and the Simpson method should be designed and coded in a reusable module. +When defining the interface of the C functions, pay attention to reusability. +The task also includes developing a sample application to test the three variants. Select two examples of mathematical functions whose integrals are to be determined, with corresponding integration boundaries, and compare the three methods in terms of their precision. Test the limitations of the methods. Substantiate your results. +Explain the mathematical relationships underlying the methods in your paper. A graphical representation will help to illustrate the understanding of the relationships. +Optimize the source code as far as possible for performance-optimized use on an embedded controller. +The result of the task is a project that can be compiled with MS Studio, which enables the software module to be tested (suitable test cases, etc.) using a command line application, plus the documentation specified below. +Scope of relevant task-specific documentation +- Graphical representation of the software design and compact description of the key relationships (1 page) +- Theoretical explanation of the relationships (mathematical, algorithmic, etc.) that need to be taken into account here (2 pages) +- Documentation of the reference examples used for testing, with graphical representation and explanation of method limitations (2 pages) * Graphical representation of the software design - - #+BIND: org-latex-images-centered nil #+ATTR_LATEX: \textwidth :float nil [[./graphical-representation-white.drawio.png]] diff --git a/documentation.out b/documentation.out new file mode 100644 index 0000000..8fd44c2 --- /dev/null +++ b/documentation.out @@ -0,0 +1,17 @@ +\BOOKMARK [1][-]{section.1}{\376\377\000D\000e\000c\000l\000a\000r\000a\000t\000i\000o\000n\000\040\000o\000f\000\040\000s\000e\000l\000f\000\040\000r\000e\000l\000i\000a\000n\000c\000e}{}% 1 +\BOOKMARK [1][-]{section.2}{\376\377\000T\000a\000s\000k\000\040\000d\000e\000s\000c\000i\000p\000t\000i\000o\000n}{}% 2 +\BOOKMARK [1][-]{section.3}{\376\377\000G\000r\000a\000p\000h\000i\000c\000a\000l\000\040\000r\000e\000p\000r\000e\000s\000e\000n\000t\000a\000t\000i\000o\000n\000\040\000o\000f\000\040\000t\000h\000e\000\040\000s\000o\000f\000t\000w\000a\000r\000e\000\040\000d\000e\000s\000i\000g\000n}{}% 3 +\BOOKMARK [1][-]{section.4}{\376\377\000T\000h\000e\000o\000r\000e\000t\000i\000c\000a\000l\000\040\000e\000x\000p\000l\000a\000n\000a\000t\000i\000o\000n\000\040\000o\000f\000\040\000t\000h\000e\000\040\000r\000e\000l\000a\000t\000i\000o\000n\000s\000h\000i\000p\000s}{}% 4 +\BOOKMARK [2][-]{subsection.4.1}{\376\377\000"\000i\000n\000t\000e\000g\000r\000a\000t\000e\000.\000h\000"\000:}{section.4}% 5 +\BOOKMARK [2][-]{subsection.4.2}{\376\377\000"\000i\000n\000t\000e\000g\000r\000a\000t\000e\000.\000c\000"\000:}{section.4}% 6 +\BOOKMARK [3][-]{subsubsection.4.2.1}{\376\377\000C\000o\000m\000m\000o\000n\000\040\000a\000r\000g\000u\000m\000e\000n\000t\000\040\000c\000h\000e\000c\000k\000i\000n\000g\000\040\000\050\000b\000a\000d\000\137\000a\000r\000g\000s\000\051}{subsection.4.2}% 7 +\BOOKMARK [3][-]{subsubsection.4.2.2}{\376\377\000M\000i\000d\000p\000o\000i\000n\000t\000\040\000/\000\040\000r\000e\000c\000t\000a\000n\000g\000l\000e\000\040\000m\000e\000t\000h\000o\000d\000\040\000\050\000m\000i\000d\000p\000o\000i\000n\000t\000\051}{subsection.4.2}% 8 +\BOOKMARK [3][-]{subsubsection.4.2.3}{\376\377\000T\000r\000a\000p\000e\000z\000o\000i\000d\000\040\000m\000e\000t\000h\000o\000d\000\040\000\050\000t\000r\000a\000p\000e\000z\000o\000i\000d\000\051}{subsection.4.2}% 9 +\BOOKMARK [3][-]{subsubsection.4.2.4}{\376\377\000S\000i\000m\000p\000s\000o\000n\000\040\0001\000/\0003\000\040\000m\000e\000t\000h\000o\000d\000\040\000\050\000s\000i\000m\000p\000s\000o\000n\000\051}{subsection.4.2}% 10 +\BOOKMARK [2][-]{subsection.4.3}{\376\377\000P\000e\000r\000f\000o\000r\000m\000a\000n\000c\000e\000-\000o\000r\000i\000e\000n\000t\000e\000d\000\040\000a\000s\000p\000e\000c\000t\000s\000\040\000\050\000e\000m\000b\000e\000d\000d\000e\000d\000\040\000f\000o\000c\000u\000s\000\051}{section.4}% 11 +\BOOKMARK [1][-]{section.5}{\376\377\000D\000o\000c\000u\000m\000e\000n\000t\000a\000t\000i\000o\000n\000\040\000o\000f\000\040\000t\000h\000e\000\040\000r\000e\000f\000e\000r\000e\000n\000c\000e\000\040\000e\000x\000a\000m\000p\000l\000e\000s\000\040\000u\000s\000e\000d\000\040\000f\000o\000r\000\040\000t\000e\000s\000t\000i\000n\000g}{}% 12 +\BOOKMARK [2][-]{subsection.5.1}{\376\377\000T\000e\000s\000t\000\040\000i\000n\000t\000e\000g\000r\000a\000n\000d\000\040\000d\000e\000s\000i\000g\000n}{section.5}% 13 +\BOOKMARK [2][-]{subsection.5.2}{\376\377\000T\000e\000s\000t\000\040\000r\000u\000n\000n\000e\000r\000\040\000\050\000r\000u\000n\000\137\000o\000n\000e\000\051}{section.5}% 14 +\BOOKMARK [2][-]{subsection.5.3}{\376\377\000R\000e\000f\000e\000r\000e\000n\000c\000e\000\040\000e\000x\000a\000m\000p\000l\000e\000s\000\040\000i\000n\000\040\000m\000a\000i\000n\000\050\000\051}{section.5}% 15 +\BOOKMARK [3][-]{subsubsection.5.3.1}{\376\377\000R\000e\000s\000u\000l\000t\000s}{subsection.5.3}% 16 +\BOOKMARK [1][-]{section.6}{\376\377\000B\000i\000b\000l\000i\000o\000g\000r\000a\000p\000h\000y}{}% 17 diff --git a/documentation.pdf b/documentation.pdf index 71c0ac3..78fd937 100644 Binary files a/documentation.pdf and b/documentation.pdf differ diff --git a/documentation.synctex.gz b/documentation.synctex.gz new file mode 100644 index 0000000..de8e084 Binary files /dev/null and b/documentation.synctex.gz differ diff --git a/documentation.tex b/documentation.tex index 32f8c73..106c868 100644 --- a/documentation.tex +++ b/documentation.tex @@ -1,4 +1,4 @@ -% Created 2026-01-27 Di 15:08 +% Created 2026-01-27 Di 15:23 % Intended LaTeX compiler: pdflatex \documentclass[11pt]{article} \usepackage[utf8]{inputenc} @@ -61,19 +61,34 @@ \tableofcontents \section{Declaration of self reliance} -\label{sec:orgf1c5ba4} +\label{sec:orga095243} I hereby declare that I have written this thesis independently in accordance with § 35 para. 7 RaPO (Framework Examination Regulations for Universities of Applied Sciences in Bavaria, BayRS 2210-4-1-4-1-WFK), have not submitted it elsewhere for examination purposes, have not used any sources or aids other than those indicated, and have marked all direct and indirect quotations as such. +\section{Task desciption} +\label{sec:org4a38da4} +Topic 5: Numerical integration methods +The aim of this task is to implement three variants of numerical approaches for calculating integrals +in a software module. +A function for the rectangle method, the trapezoid method, and the Simpson method should be designed and coded in a reusable module. +When defining the interface of the C functions, pay attention to reusability. +The task also includes developing a sample application to test the three variants. Select two examples of mathematical functions whose integrals are to be determined, with corresponding integration boundaries, and compare the three methods in terms of their precision. Test the limitations of the methods. Substantiate your results. +Explain the mathematical relationships underlying the methods in your paper. A graphical representation will help to illustrate the understanding of the relationships. +Optimize the source code as far as possible for performance-optimized use on an embedded controller. +The result of the task is a project that can be compiled with MS Studio, which enables the software module to be tested (suitable test cases, etc.) using a command line application, plus the documentation specified below. +Scope of relevant task-specific documentation +\begin{itemize} +\item Graphical representation of the software design and compact description of the key relationships (1 page) +\item Theoretical explanation of the relationships (mathematical, algorithmic, etc.) that need to be taken into account here (2 pages) +\item Documentation of the reference examples used for testing, with graphical representation and explanation of method limitations (2 pages) +\end{itemize} \section{Graphical representation of the software design} -\label{sec:orgf50f0e3} - - +\label{sec:org784d853} \begin{center} \includegraphics[width=.9\linewidth]{./graphical-representation-white.drawio.png} \end{center} \section{Theoretical explanation of the relationships} -\label{sec:org15650c5} -\subsection{\texttt{"integrate.h"}:} -\label{sec:orgc09841a} +\label{sec:org8218260} +\oldsubsection{\texttt{"integrate.h"}:} +\label{sec:orgc92e0ac} Interface for \texttt{integrate.c} Module. Here is declared: \begin{itemize} @@ -112,7 +127,7 @@ integ_status_t simpson(integrand_f f, void *ctx, float a, float b, unsigned n, #endif // INTEGRATE_H_ \end{verbatim} \subsection{\texttt{"integrate.c"}:} -\label{sec:orgbe94578} +\label{sec:org80dbf09} Implements the three numerical integration algorithms (midpoint/rectangle, trapezoid, Simpson 1/3) behind the public interface from \texttt{integrate.h}, including argument validation and method-specific constraints. The file includes \texttt{integrate.h} and provides the concrete implementations of \texttt{midpoint()}, \texttt{trapezoid()}, and \texttt{simpson()}, each computing an approximation of $$I = \int_a^bf(x)dx$$ by sampling the integrand at specific points and summing weighted contributions. @@ -207,49 +222,49 @@ integ_status_t simpson(integrand_f f, void *ctx, float a, float b, unsigned n, } \end{verbatim} \subsubsection{Common argument checking (\texttt{bad\_args})} -\label{sec:org5576bb4} +\label{sec:org7e75604} A shared internal helper \texttt{bad\_args()} is implemented as \texttt{static inline} to reduce call overhead and to allow the compiler to inline it for performance on embedded targets. It returns an error condition if \texttt{f == NULL, out == NULL, n == 0} or the interval is invalid (the code checks \texttt{b > a}). If \texttt{bad\_args()} reports invalid inputs, each public integration function returns \texttt{INTEG\_ERR\_BAD\_ARGS} immediately. \subsubsection{Midpoint / rectangle method (\texttt{midpoint})} -\label{sec:orgb278e27} +\label{sec:org9f6d06d} \begin{enumerate} \item Mathematical idea -\label{sec:orgd41c3d4} +\label{sec:orga069e15} The interval [a,b] is split into n subintervals of equal width $$h=(b-a)/n$$, and each subinterval [xi,xi+1] is approximated by a rectangle whose height is the function value at the midpoint $$xi+h/2$$. The Formula is as follows: \cslcitation{1}{[1]} $$\approx h \sum_{i=1}^n f({x_{i-1}+x_i}/2)$$ \item Implementation details -\label{sec:orgebae471} +\label{sec:orga095516} The code computes \texttt{h}, initializes the first midpoint \texttt{x = a + 0.5fh}, then loops exactly \texttt{n} times, accumulating \texttt{sum = sum + f(x, ctx)} and stepping \texttt{x = x + h}. Finally, the result is written as \texttt{out = sum * h} and the function returns \texttt{INTEG\_OK}. \end{enumerate} \subsubsection{Trapezoid method (\texttt{trapezoid})} -\label{sec:orga8108f1} +\label{sec:org356a6b8} \begin{enumerate} \item Mathematical idea -\label{sec:org31aecc1} +\label{sec:orgd155bc9} Each subinterval is approximated by a trapezoid formed by the points $$(xi,f(xi))$$ and $$(xi+1,f(xi+1))$$, giving the composite trapezoid rule. This corresponds to the standard weighted sum \cslcitation{2}{[2]} $$ = h/2 (f(x_0)+2f(x_1)+\dots+2f(x_{n-1})+f(x_n))$$ \item Implementation details -\label{sec:org36dc554} +\label{sec:org20242c9} The code computes \texttt{h}, then initializes \texttt{sum = 0.5f*(f(a,ctx)+f(b,ctx))} to apply the half-weight to the endpoints. It iterates from the first interior node \texttt{x = a + h} for \texttt{i = 1..n-1}, adds each interior sample once (\texttt{sum = sum + f(x,ctx)}), then scales by \texttt{h} via \texttt{*out = sum * h}. \end{enumerate} \subsubsection{Simpson 1/3 method (\texttt{simpson})} -\label{sec:org6457a29} +\label{sec:orga43d4c9} \begin{enumerate} \item Mathematical idea -\label{sec:orgd9bfe20} +\label{sec:org4292208} Simpson's 1/3 rule approximates the function by piecewise quadratic polynomials over pairs of subintervals, which leads to alternating weights 4 and 2 for interior points. @@ -257,7 +272,7 @@ The composite Simpson rule requires an even number of subintervals nn so that th The formula is as such: \cslcitation{3}{[3]} $$ \approx (h/3) [f(x_0)+4f(x_1)+2f(x_2)+ \dots 2f(x_{n-2})+4f(x_{n-1})+f(x_n)]$$ \item Implementation details and constraint handling -\label{sec:org4ce84b4} +\label{sec:orgb038bbe} After basic argument validation, the function checks \texttt{if (n \& 1u)} and returns \texttt{INTEG\_ERR\_N\_EVEN\_REQUIRED} if \texttt{n} is odd, enforcing the ``even n'' requirement from the interface contract. @@ -266,7 +281,7 @@ The final formula implemented is \\ \texttt{out = (h/3)(f(a)+4*sum\_odd+2*sum\_even+f(b))}, which matches the documented Simpson weighting scheme. \end{enumerate} \subsection{Performance-oriented aspects (embedded focus)} -\label{sec:org5f114cd} +\label{sec:orgf872e63} The design avoids dynamic allocation and uses a caller-provided output pointer (\texttt{float *out}), which is predictable and typical for embedded C modules. @@ -275,25 +290,25 @@ Using \texttt{static inline} for \texttt{bad\_args} and keeping loop bodies simp When checking for evenness of \texttt{n} the simpson function uses \texttt{\& u1} instead of \texttt{\% 2}. It is not possible to substitue a \texttt{/2} for a \texttt{>{}>{}1} for the float variable type. Such tricks can not have been used for any values with the float type. \section{Documentation of the reference examples used for testing} -\label{sec:org2d1f7ee} +\label{sec:orgd361433} \texttt{"main.c"} is a small command-line test application that demonstrates how to use the reusable integration module by defining example integrand functions, calling all three numerical methods, and printing absolute errors against known exact results. The application includes \texttt{integrate.h} and uses standard library functionality (printing and absolute error via \texttt{fabsf}) to compare the numeric results to a known reference (``exact'') value. Its purpose is not to be a generic framework, but a compact test harness that exercises the module API and makes method limitations visible at runtime (e.g., Simpson's even-\texttt{n} requirement). \subsection{Test integrand design} -\label{sec:org3cbabb2} +\label{sec:org7f48d68} Parameterized quadratic via context pointer A small struct \texttt{quad\_t} stores coefficients \texttt{a2}, \texttt{a1}, \texttt{a0} for a quadratic polynomial $$f(x)=a_2x^2+a_1x+a_0$$, showing how the integrator's \texttt{void *ctx} can carry user-defined parameters without globals. The function \texttt{f\_quad(float x, void ctx)} casts \texttt{ctx} to \texttt{const quad\_t} and evaluates the polynomial, matching the generic \texttt{integrand\_f} interface expected by the integration module. \subsection{Test runner (\texttt{run\_one})} -\label{sec:org010d856} +\label{sec:org700fda6} The helper \texttt{run\_one(...)} calls \texttt{midpoint}, \texttt{trapezoid}, and \texttt{simpson} with the same function, bounds, and number of subintervals, storing results into three local floats (\texttt{r}, \texttt{t}, \texttt{s}). It prints the integration problem setup (function name, bounds, \texttt{n}), prints the exact reference value, and prints each method's absolute error using \texttt{fabsf(result - exact)} for a direct precision comparison. Simpson's status return is checked: if \texttt{simpson} returns \texttt{INTEG\_OK}, the Simpson result/error is printed, otherwise a message is printed indicating it was not computed because \texttt{n} must be even. \subsection{Reference examples in \texttt{main()}} -\label{sec:orgd2d9b7a} +\label{sec:org8334b01} Four concrete test cases are instantiated using \texttt{quad\_t} coefficients and passed to \texttt{run\_one}. They have been chosen in such a way that many edge cases are accounted for. @@ -487,9 +502,9 @@ int main(void) } \end{verbatim} \subsubsection{Results} -\label{sec:org8a0d097} +\label{sec:orga992d73} \section{Bibliography} -\label{sec:org8cd8f85} +\label{sec:orgab8c92c} \begin{cslbibliography}{0}{0} \cslbibitem{1}{\cslleftmargin{[1]}\cslrightinline{“Engineering at Alberta Courses Rectangle Method,” Jan. 2026. Available: \url{https://engcourses-uofa.ca/books/numericalanalysis/numerical-integration/rectangle-method}}} diff --git a/documentation.toc b/documentation.toc new file mode 100644 index 0000000..afa8e43 --- /dev/null +++ b/documentation.toc @@ -0,0 +1,17 @@ +\contentsline {section}{\numberline {1}Declaration of self reliance}{3}{section.1}% +\contentsline {section}{\numberline {2}Task desciption}{4}{section.2}% +\contentsline {section}{\numberline {3}Graphical representation of the software design}{5}{section.3}% +\contentsline {section}{\numberline {4}Theoretical explanation of the relationships}{6}{section.4}% +\contentsline {subsection}{\numberline {4.1}\texttt {"integrate.h"}:}{6}{subsection.4.1}% +\contentsline {subsection}{\numberline {4.2}\texttt {"integrate.c"}:}{7}{subsection.4.2}% +\contentsline {subsubsection}{\numberline {4.2.1}Common argument checking (\texttt {bad\_args})}{9}{subsubsection.4.2.1}% +\contentsline {subsubsection}{\numberline {4.2.2}Midpoint / rectangle method (\texttt {midpoint})}{9}{subsubsection.4.2.2}% +\contentsline {subsubsection}{\numberline {4.2.3}Trapezoid method (\texttt {trapezoid})}{10}{subsubsection.4.2.3}% +\contentsline {subsubsection}{\numberline {4.2.4}Simpson 1/3 method (\texttt {simpson})}{11}{subsubsection.4.2.4}% +\contentsline {subsection}{\numberline {4.3}Performance-oriented aspects (embedded focus)}{12}{subsection.4.3}% +\contentsline {section}{\numberline {5}Documentation of the reference examples used for testing}{13}{section.5}% +\contentsline {subsection}{\numberline {5.1}Test integrand design}{14}{subsection.5.1}% +\contentsline {subsection}{\numberline {5.2}Test runner (\texttt {run\_one})}{15}{subsection.5.2}% +\contentsline {subsection}{\numberline {5.3}Reference examples in \texttt {main()}}{16}{subsection.5.3}% +\contentsline {subsubsection}{\numberline {5.3.1}Results}{22}{subsubsection.5.3.1}% +\contentsline {section}{\numberline {6}Bibliography}{23}{section.6}%