Introduction#

I’m currently working on 5. A-level-further and 14. Quantum Mechanics.

For completed courses, see my LinkedIn certificates. Any questions, please email: jonny.tang745@education.nsw.gov.au

Project Euler (PE)

Jonny workbook started from Project Euler. Jonny loves coding and number theory, especially the PE-style (VS. CS-style) when he was 10YO. Therefore, Tom assisted him with guidance and searching hidden info and knowledge.

PE problems can be solved using multiple approaches and often involve a combination of techniques.

  • Sometimes, I face math problems while coding is easy, e.g. 99-Largest Exponential

  • Sometimes, I face computational (or programming) problems while math is easy, e.g. 187-Semiprimes (very time-consuming)

So, I need two streams of knowledge to solve PE: 1) Math: see PE-Hidden-Math where I present math by PE questions and math-topics; and 2) CS or Programming

Mathematics & FP(Functional Programming)/Language (updating)

In 2024, Jonny went through 4U math (HSC-NSW) once, Tom chose A-level math for Jonny’s review and progress, with a approach of computational coding for A-level math. In this workbook, Jonny worked on A-level and A-level further which are transitional-math between secondary and tertiary education.

Go along with A-level math, Tom summarised math, FP, and linguistics (natural languages). Tom advocates 6. Math-FP-Lang Combo in guiding kids learning.

CS-Python & Physics (updating)

I already finished these two courses in 2024 as below, and a physics in 2025 (planned). My notes are included in this workbook:

Others

Geography, Maps, Lottery math

For help

Ubuntu & SCE (Scientific Computing Environment)#

Ubuntu is the key in SCE. To build a SCE is the first step to learn programming, two ways:

  1. Cloud Computing - Google Colab, Cocalc(Rust, Julia, GNU Octave(vs.Matlab)), Binder - are good, but Colab and Binder require further installation (originally Python)

  2. Self-built - Docker’s images and containers (self-maintained not self-installation) are the best

    • I already build SageMath and IHaskell using Docker, both running ipynb

  3. Key to Science - reproducibility, so we need a managing Environment and Container

    1. Use one environment(or Container) per project! Creating environments to accommodate specific workflows/projects — and to do so early on

    2. Containers is better, which package tools with underlying operating system, are larger and more complicated than environments, but are more portable

Steps:

  1. install Ubuntu

  2. install Chrome

  3. git:sudo apt install git

    • download github project

      • git clone weblink

    • for github conflicted problem

      • git stash

      • git pull –rebase

      • git stash pop

  4. Install Docker

  5. Google Drive - rclone, now Dropbox

    • sudo -v ; curl https://rclone.org/install.sh | sudo bash

    • run “rclone config”, follow guide: https://rclone.org/drive/

    • run “sudo nano /etc/fuse.conf” Uncomment this line: user_allow_other

    • rclone mount gdrive: /home/tom/gdrive –allow-other –vfs-cache-mode full

    • automatic boot: 2 issues - connection & mount

      • Test rclone connection: rclone lsd remote:

      • sudo nano /etc/systemd/system/rclone-gdrive.service # see T430’s file

      • systemctl daemon-reload

      • sudo systemctl enable rclone-gdrive.service

      • sudo systemctl start rclone-gdrive.service

  6. uni-direction synchronize two folders rsync -avu --delete source_folder/ destination_folder/

    • for many PDFs in folder

  7. WineHQ for Foxit PDF

  8. My PC has two disks, I installed Ubuntu goes along original windows in the first disk (original sys). Now the second disk can’t seen as Ubuntu still hardly manage Microsoft Windows dynamic disk (LDM). Solutions:

    • ldmtool to read data in Ubuntu, or wait Ubuntu updates in the future

    • convert LDM to basic disk while lossing all data

  9. Basic commands & more:

    • ls -a ;  env  ;  pwd  ; rm ; echo > aa.hs (create file); nano aa.hs (edit file, Ctrl+X for quit)

    • run Ubuntu commands in GHCI, add :! ahead

    • remove top bar: sudo apt install gnome-shell-extension-manager, then search “hide top bar”

    • PDF arranger (App Center): edit PDF

    • printer brother driver

More

PL

While a qualified coder mastering 6 programming languages (PL), how to choose PLs is really a hard decision.

  1. We started this workbook using Python in VScode:

    • Python: we began from Python, then we moved to Math Tools, like MMA and SageMath(the second best CAS - computer algebra system).

    • diagrams: Coding diagrams

    • manim: Math Animation

    • handcalcs: render calculation as if it were written with a pencil: write the symbolic formula, then numeric substitutions, and then show result automatically

  2. Next, a PL with more FP? Ocaml? F#(Fsharp)? Scala? Haskell? Rust? Make a comparison:

    1. PL’s Coding-look in defining a Fibonacci;

    2. Which FP is best for mathematics? Haskell is NO.1, but I really don’t like Haskell;

    3. Math-related supports for these four languages;

    4. Balance between FP and OOP;

    5. Number of users in Project Euler for each PL;

    6. libgen supports for each PL;

    7. When the PL first appeared.

Math Tools

  1. Three large-scale mathematical software packages

    1. Numerical computing systems: floating point, accurate estimation, numerical analysis. Matlab, Octave

    2. CAS(Computer algebra system): exact computation, view \(\pi\) as a symbol instead of a decimal number, symbolic computation/computer algebra/computational algebra

    3. Statistical packages: SAS, R

  2. Mathematics and Self-Study Roadmaps

  3. Instead of Python, then we started Mathematica (Wolfram languages, MMA or Wolfram after):

    • We are running Wolfram in ipynb-file using VScode

    • Mathematica (.nb): the best CAS. Shall we convert .nb -> .ipynb ??

    • installing

  4. SageMath isn’t a pip-installable package, instead it’s large and requires C/Fortran/Python… lots of pre-installed environments

    • SageMath is the best open-source CAS

    • CoCalc (.ipynb) online platform includes all open-source computing environments, so surprising!!

    • Google Colab can also install SageMath, but with problems

    • or Docker + SageMath + JupyterLab to work with symbolic mathematics programmatically

    • Sage installed by miniconda is the best option

      • we can use self-built functions every time starting Sage, like s()

      • go to folder /home/tom/.sage, open file init.sage

    • Resources:

  5. Julia is the best for DE, and is also more FP than python - reason 1, reason 2

Organization & Management

  1. Website Management

    • Git and GitHub

  2. Project Management

    • Visual Studio Code

    • Jupyter notebooks (.ipynb): interactive computational notebooks, easy to prototype, create visualizations, interactive presentations

    • MarkDown and Latex: writing natural language and math formulus

  3. Citations and Bibliographies

    • Zotero: a free, easy-to-use tool to help you collect, organize, cite, and share research. I use Zotero to generate .bib files

(*Convert nb file into vsnb using the wl coding*)
Get["_static/Mathematica2VSCode.wl"] 
Needs["Mathematica2VSCode`"]
Mathematica2VSCode["aa.nb"]  (*path and specific MMA notebook*)
Output

OOP to FP#

We started workbook using Python in OOP (Object-oriented Programming) way, then we move to FP (Functional Programming) way in both MMA and Python.

Even though both Python and Wolfram are not pure FP, they do help us understand the FP way.

  • From my view, OOP coding is more natural language, FP is more math lanuage.

FP

  1. FP books

  2. Adabeat - Ease into

  3. PE solutions in Java, Python, Mathematica, Haskell: Nayuki use OOP in Python and FP in Haskell.

FP - languages

  1. FP in Python: a web-notebook for beginner.

  2. SageMath - FP4Mathematicians

  3. FP in Wolfram: official website.

Why no Matlab? To model and simulate dynamic systems

  • Simulink(Matlab) uses a signal flow-based or causal approach,

  • while Modelica uses an equation-based or acausal approach. – still OOP vs. FP

Haskell#

cabal init --interactive(Haskell project)

IHaskell in Ubuntu

  1. A. step-by-step to avoid skipping; B.if using IHaskell packages, the ipynb must locate in IHaskell folder

    • sudo apt-get install -y python3-pip git libtinfo-dev libzmq3-dev libcairo2-dev libpango1.0-dev libmagic-dev libblas-dev liblapack-dev

    • curl -sSL https://get.haskellstack.org/ | sh # install stack

    • export PATH=”/usr/local/bin:$PATH”

    • export PATH=”/home/tom/.local/bin:$PATH”

    • git clone gibiansky/IHaskell

    • cd IHaskell

    • pip3 install -r requirements.txt -break-system-packages # install Python requirements

    • stack install –fast # install ihaskell

    • ihaskell install –stack # install the Jupyter kernelspec with ihaskell

    • Restart PC and make sure Jupyter access fully

      • jupyter notebook –generate-config

      • nano ~/.jupyter/jupyter_notebook_config.py

      • add into:

      • c.NotebookApp.token = ‘’

      • c.NotebookApp.password = ‘’

      • c.NotebookApp.allow_origin = ‘*’

      • c.NotebookApp.allow_root = True

    • make sure lts = 22.10 (consist to Github version)

      • nano /home/tom/.stack/global-project/stack.yaml

    • In IHaskell folder, run stack exec jupyter -- notebook

      • or Click Jupyter icon at Dash

IHaskell in docker:

  1. IHaskell computation = Docker + Haskell + Jupyter (Docker building: 1. download zip, 2. go to Docker terminal, run "docker build -t ihaskell:latest .")

wsl2-Ubuntu-Haskell in windows:

  1. Microsoft Store -> search ‘Ubuntu’ and install (345 MB)

  2. Open Ubuntu in Windows, update by:

    • sudo apt update

    • sudo apt install build-essential -y

    • sudo apt install make -y

    • sudo apt install automake -y

windows-msys2-Haskell in powershell:

  1. Two lauch commands:

    • ghci is the interactive environment of the GHC compiler itself

    • stack ghci is the interactive environment of the Stack build tool: 1) automatically handles dependency and installation (VS. GHC and Cabal), 2) config to install packages C:\Users\tangc\AppData\Roaming\stack\global-project\stack.yaml

Image & Cross-citations#

Image-Hosting

All figures are synchronised in Tom’s GitHub folder ./NB_img/. Using codes to insert pic:

<img src="https://raw.githubusercontent.com/tomctang/NB_img/main/3bias.png" alt="Causality-confounder" width="500">

Markdown image center:

<div align=center>![Figure. Various treatments choice for OA](https://raw.githubusercontent.com/ctang83/NB_img/main/EPS_OAtreat.jpg){width=60%}

Cross-citations

Header automatically generate {#mathFP}, so[anytext](#mathFP) in citing

Between pages: [Discrete & Continuous](../10pe/02discrete_continuous.ipynb#discrete-continuous)(ipynb auto changed to html in website)