Is there a way to perform compile time arithmetic with explicit functions that respect dimensions? Here is a strawman example of arithmetic functions:
\mul{4}{7} % expands to 28
\mul{4}{6pt} % expands to 24pt
\mul{0.3}{\linewidth} % expand into some kind of anonymous length-like value
% storing 0.3 * the current value of \linewidth.
\add{0.3pt}{0.2pt} % expands to 0.5pt
For instance, the following document uses scalar multiplication with widths:
% !TEX TS-program = lualatex
% \usepackage{lipsum}
\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{TimesNewRoman}
\setsansfont[Ligatures=TeX]{Arial}
\begin{document}
\hspace*{0.5 \linewidth}
\begin{minipage}{0.4 \linewidth}
The quick brown fox jumped
over the lazy dog
\end{minipage}
\end{document}
The notation 0.4 \linewidth is convenient and easy to read, but isn't composable. For instance, using \begin{minipage}{0.4 {0.8 \linewidth}} instead produces the error:
! Illegal unit of measure (pt inserted).
<to be read again>
{
l.15 \begin{minipage}{0.4 {0.8 \linewidth}}
Using \usepackage{calc} doesn't make the 0.4 {0.8 \linewidth} construction valid, either.
Is there a way to perform arithmetic explicitly?
NB: this questions differs from this one here because it's asking for the most explicit way to perform arithmetic, rather than the most convenient.

\dimexprisn't explicit enough? Or features fromexpl3? – Jan 18 '19 at 21:31% !TEX TS-program = lualatexif you are using luatex then of course you have the full Lua math expression language available at all times. So you have arithmetic, trig, square roots etc. – David Carlisle Jan 18 '19 at 22:35