Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/potato-development/sim-line-area
Simulation to compute area under a function between an upper and lower bound.
https://github.com/potato-development/sim-line-area
cpp makefile maths
Last synced: about 2 months ago
JSON representation
Simulation to compute area under a function between an upper and lower bound.
- Host: GitHub
- URL: https://github.com/potato-development/sim-line-area
- Owner: Potato-Development
- License: gpl-3.0
- Created: 2024-11-10T14:34:57.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-24T16:29:06.000Z (about 2 months ago)
- Last Synced: 2024-11-24T17:26:16.438Z (about 2 months ago)
- Topics: cpp, makefile, maths
- Language: C++
- Homepage:
- Size: 31.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sim-line-area
Converging area under a generic function between an upper and lower bound.![image](https://github.com/user-attachments/assets/935c9a7b-50dc-4e34-804a-e97d987820fb)
## Introduction
The program finds the **_area_** under (or over) a generic function, $f(x)$ and $a, b$ as the upper and lower bounds to find $S$. It uses $n$ slices of length $b-a$; increasing $n$ will increase the accuracy of $s$ as it converges to the real area. This leaves $n$ rectangles which **_overestimate_** $S$, each$$f(a + \frac{b}{n} k)$$
high, and
$$\frac{b-a}{n}$$
wide, where $k$ (1..=n) represents _which_ rectangle.
This leaves us with
$$
\sum_{k=1}^{n} f\left(a + \frac{b}{n} k\right) \cdot \frac{b}{n}
$$to find the total area, which evaluates to
$$
\sum_{k=1}^{n} \left((a + \frac{b}{n} k)m + c\right)\cdot \frac{b}{n}
$$for $y = mx + c$.
## Installation
Prebuilt binaries for `Linux amd64`, `Linux aarch64` and `Windows 64-bit` are provided in [releases](https://github.com/Potato-Development/linear-line-area/releases). If anyone can cross-compile for MacOS, that would be greatly appreciated; I build and compile on a Raspberry Pi.
If none of the binaries support your architecture, the binaries don't work, or you want to build from source, then clone the repo for the source code. The code is a single source file at:```
/path/to/linear-line-area/src/main.cpp
```It should compile with any toolchain without warnings. If you want to use my custom `Makefile`, you can find it in the project folder `/path/to/linear-line-area/Makefile`. Targets `all`, `clean`, and then individual targets for your architecture should be available. You may have to create the `target` folder yourself, please read the code carefully.