List of Nix Math Library from Ground Zero series posts: Nix Trigonometric Math Library from Ground Zero Nix Logarithmic Math Library from Ground Zero (current post) (Cover image from: Wikipedia - Logarithm ) Origin Due to a somewhat absurd reason (calculating the physical distance between VPS to estimate network latency), I implemented a somewhat absurd trigonometric function library using Nix . After I published the trigonometric function library on GitHub , I found that someone actually used it! It seems my needs weren't too absurd after all. In the repository's Issues, a user suggested that I add some exponential/logarithmic function support to this math library , such as exp , ln , pow , and log . Since implementing these basic functions from scratch is also quite interesting,...
Building Custom Android Kernel with Nix
Preface The mobile phone I'm using today is Motorola Edge+ 2023, an Android phone. To better customize my phone's functionalities, I unlocked its bootloader, and obtained root privileges, in order to install LSPosed and various LSPosed based plugins. The root mechanism I'm using is KernelSU , which works by modifying the Linux kernel to grant and only grant root permissions to certain apps. Although KernelSU provides official GKI kernel images that work on most phones, I also flashed LineageOS onto my phone, which is not compatible with GKI images. Therefore, I have to compile my own kernel. Since modifying the kernel's binary image is difficult, we usually obtain the kernel source code under the GPLv2 license from the phone manufacturer, modify it according to KernelSU's official guide ,...

Nix Trigonometric Math Library from Ground Zero
List of Nix Math Library from Ground Zero series posts: Nix Trigonometric Math Library from Ground Zero (current post) Nix Logarithmic Math Library from Ground Zero (Cover image from: Wikipedia - Trigonometry ) Why I wanted to calculate the network latency between all my VPS nodes, and add the latency into the configuration file of Bird BGP daemon, so the network packets are forwarded through the lowest latency route. However, I have 17 nodes as of today, and I didn't want to manually run a ping command between each pair. So I came up with a solution: I can mark the latitudes and longitudes of the physical locations of my nodes, calculate the physical distance, and divide that by half the light speed to get the approximate latencies. I randomly sampled a few node pairs,...