# Objective

Given a dimension of an SI unit, convert the Lorentz-Heaviside version of a Planck unit $$\1\$$ into SI metric.

# What is a Planck unit?

Planck units are a set of units of measurement. It defines five fundamental constants of the universe as dimensionless $$\1\$$.

# What is a dimension?

There are five types of fundamental dimension: L, M, T, Q, and Θ (U+0398; Greek Capital Letter Theta).

L stands for length and corresponds to SI unit m (meter).

M stands for mass and corresponds to SI unit kg (kilogram).

T stands for time and corresponds to SI unit s (second).

Q stands for electric charge and corresponds to SI unit C (Coulomb).

Θ stands for temperature and corresponds to SI unit K (Kelvin).

A dimension is a multiplicative combination of these. For example, SI unit V (volt) is same as kg·m²·C/s⁴ and thus corresponds to dimension L²MQ/T⁴.

# Planck to SI

$$\1\$$ as Planck unit can be converted to SI metric as follows:

$$1 = 5.72938×10^{−35} \space [\text{m}] = 6.13971×10^{−9} \space [\text{kg}] = 1.91112×10^{−43} \space [\text{s}] = 5.29082×10^{−19} \space [\text{C}] = 3.99674×10^{31} \space [\text{K}]$$

# Input and Output

A dimension is given as the input. Its type and format doesn't matter. In particular, it can be an size-5 array of signed integers, each integer representing the exponent of a fundamental dimension.

The Planck unit $$\1\$$ is to be converted to the SI unit that corresponds to the inputted dimension, and then outputted. The output type and format doesn't matter.

# Examples

Let's say the input format is a tuple of five integers, representing L, M, T, Q, and Θ, respectively.

For example, If the input is $$\(2,1,-1,-2,0)\$$, it corresponds to SI unit Ohm, and thus:

$$1 = \frac{(5.72938×10^{−35})^2 × (6.13971×10^{−9})}{(1.91112×10^{−43})×(5.29082×10^{−19})^2} \space [\text{Ω}]$$

So the output is approximately $$\376.730\$$.

For another example, if the input is $$\(-2,-1,3,0,1)\$$, it corresponds to SI unit K/W, and thus:

$$1 = \frac{(1.91112×10^{−43})^3 × (3.99674×10^{31})}{(5.72938×10^{−35})^2 × (6.13971×10^{−9})} \space [\text{K/W}]$$

So the output is approximately $$\1.38424×10^{−20}\$$.

Note that, if the input is $$\(0,0,0,0,0)\$$, the output must be $$\1\$$.

• How much precision do we need in the constants? I assume that if we use them as is, it's five digits as given. But, if our solution computes them via their logs or inverses, how accurate do we need to get? – xnor Mar 28 '20 at 8:28
• @xnor At least 5 digits, as you say. (This is why I hate floating-point numbers.) – Dannyu NDos Mar 28 '20 at 8:36
• Yeah, floats are that worst. Do you mean give digits in the numbers we use, or five digits in the result in produces? for example, if my answer computes $5.72938×10^{−35}$ as 10**-34.241892, where can I cut off the 34.241892? If I cut it off to five decimal places as 34.24189, then the result of 5.72941129637e-35 isn't quite accurate to five places. Sorry to be so finicky here, but this does seem to matter for answers I'm trying. – xnor Mar 28 '20 at 9:58
• @xnor Rounding to six significant digits is acceptable. – Dannyu NDos Mar 28 '20 at 20:02
• Regarding (0,0,0,0,0) producing 1: Literally "1", or a floating point representation of "1", e.g., "1.00000"? – Eric Towers Mar 30 '20 at 21:55

# 05AB1E, 31 29 bytes

•¿NkˆSSÀ¯j5ÄΣDt₁ñµ•8ô6°/₃-*O°


Try it online!

-2 thanks to @Kevin Cruijssen

inspired by @xnor.

explanation:

•¿NkˆSSÀ¯j5ÄΣDt₁ñµ•8ô6°/₃- compressed list [-34.241893, -8.211853000000005, -42.718713, -18.276477999999997, -82.33983, -94.999995]
* multiply by the implicit input (e.g. [-68.48378600000001, -8.211852999999998, 42.718713, 36.552955999999995, 0.0])
O sum (e.g. 2.576029999999996)
° raise 10 to the power of that (e.g. 376.729821659)


# Old Solution, 3635 34 bytes

"7Q/Gy"Ç₃-*O°•7“µ$₁$´*h$Ć²E•6ôImP*  -1 thanks to @Expired Data Try it online! explanation: "7Q/Gy"Ç₃- compressed list [-40,-14,-48,-24,26] * multiply (vectorize) with the implicit input - [-80, -14, 48, 48, 0] O sum - 2 ° 10^ - 100 •7“µ$₁$´*h$Ć²E• compressed number 572938613971191112529082399674
6ô split into groups of length 6 - [572938,613971,191112,529082,399674]
I push input to the stack, to get [2, 1, -1, -2, 0] [572938,613971,191112,529082,399674] 100
m power (vectorize) - [328257951844, 613971, 5.232533802168362e-6, 3.5723502030270884e-12, 1]
P product - 3.7672911312918473
* multiply - 376.72911312918473, and then implicitly output

• •;sê •2ô58- can be "7Q/Gy"Ç₃- for -1 – Expired Data Mar 28 '20 at 16:05
• thanks! how did you find it? I also need to update to TIO link – Command Master Mar 28 '20 at 16:44
• Well 95 is a 1 byte built in as opposed to 58 which is two and integer lists can be represented as strings and converted from ASCII if they're all in the range you need – Expired Data Mar 28 '20 at 19:24
• You can remove the s before the * in your 31-byte version. – Kevin Cruijssen Mar 30 '20 at 8:16
• 29 bytes by also using ₃- instead of 53- with a different compressed integer. – Kevin Cruijssen Mar 30 '20 at 8:28

# Python 3, 118 $$\\cdots\$$ 85 80 bytes

Saved a whopping 29 bytes thanks to Surculose Sputum!!!
Saved 4 bytes thanks to Arnauld!!!
Saved 5 bytes thanks to xnor!!!

lambda a,b,c,d,e:399674e26**e/174539e29**a/162874e3**b/523253e37**c/189007e13**d


Try it online!

• 116 bytes haha – RGS Mar 28 '20 at 2:47
• 89 bytes by doing it the vanilla way :) – Surculose Sputum Mar 28 '20 at 4:52
• Not as short as Surculose Sputum's direct solution, but another idea is to convert the problem to addition by working in log-space: Try it online! I don't know though how many digits of precision are needed in the list since the challenge doesn't say. Along similar lines, we could probably save bytes by changing some multiplications to divisions in the direct solution. – xnor Mar 28 '20 at 8:24
• @xnor Wow! You've totally blown my mind. Have to have way more coffee and see if I can figure out what's going there. :D – Noodle9 Mar 28 '20 at 11:02
• @SurculoseSputum The beauty (and oft shortness) of simplicity. Sweet - thanks! :-) – Noodle9 Mar 28 '20 at 11:03

## Frink, 76 bytes

f[a,b,z,d,e]:=l_P^a m_P^b(4π)^((a-b+z-e)/2)t_P^z(ℏ c epsilon0)^(d/2)T_P^e


Example usage:

f[2,1,-1,-2,0]
376.73031366686987155 m^2 s^-3 kg A^-2 (electric_resistance)
f[-2,-1,3,0,1]
1.3842382138391631282e-20 m^-2 s^3 kg^-1 K (thermal_resistance)


(As a bonus, it outputs a description of the unit of the result!)

Frink has the constants plancklength, planckmass, plancktime, and plancktemperature built in, with abbreviations l_P, m_P, t_P, and T_P respectively. Unfortunately, these are the Gaussian versions of the units, and the challenge specifies that we must use the Lorentz-Heaviside versions. This is a factor of $$\\sqrt{4\pi}\$$ conversion for each unit, which is consolidated into the (4π)^((a-b+z-e)/2) expression in the solution. (This expression is placed in the middle of the code to save a byte by letting us remove the space between m_P^b and t_P^z.)

Incidentally, 4π is exactly as long as 4pi in UTF-8, so it doesn't actually save any bytes -- it just looks fancier. :P

Finally, Frink inexplicably lacks the built-in unit planckcharge, so we calculate the Lorentz-Heaviside version directly ourselves as (ℏ c epsilon0)^(1/2) (this time, ℏ actually saves a byte over hbar!).

# Fortran (2008), 133 bytes

At least for this challenge there should be a Fortran solution.

Takes input as integer array.

real(real64)function h(I)
use iso_fortran_env
integer I(5)
h=product([572938d-40,613971d-14,191112d-48,529082d-24,399674d26]**I)
end


A slightly longer and less accurate function uses the logarithm (stolen from @xnor):

real(real64)function f(I)
use iso_fortran_env
integer I(5)
f=exp(sum([-7884487d-5,-1890850d-5,-9836347d-5,-42083140d-5,7276562d-5]*I))
end

• Would be awesome if you could solve this one with Fortran! :D – Noodle9 Mar 28 '20 at 11:11
• Thank you for the tip – mcocdawc Mar 28 '20 at 11:53
• You can save a few bytes by getting rid of the decimal points (e.g. 5.72938d-35 ~> 572938d-40). – Arnauld Mar 28 '20 at 15:41
• Thank you very much – mcocdawc Mar 28 '20 at 16:08

# Jelly,  35  34 bytes

“~VHð¡ȷ‘I⁵*×“®ƬØʋ¥4ẋİ8nCaḌ’bȷ6¤*⁸P


A monadic Link accepting a list of the five exponents, [L, M, T, Q, Θ], which yields a floating-point number.

Try it online!

### How?

“~VHð¡ȷ‘I⁵*×“®ƬØʋ¥4ẋİ8nCaḌ’bȷ6¤*⁸P - Link: list of numbers       [L, M, T, Q, Θ]
“~VHð¡ȷ‘                           - list of code-page indices   [126, 86, 72, 24, 0, 26]
I                          - differences                 [-40,-14,-48,-24,26]
⁵                         - ten                         10
*                        - exponentiate                [1e-40, 1e-14, 1e-48, 1e-24, 1e26]
“®ƬØʋ¥4ẋİ8nCaḌ’        -   base 250 number           572938613971191112529082399674
ȷ6     -   10^6                      1000000
b       -   convert from base         [572938,613971,191112,529082,399674]
×                       - multiply (vectorises)       [5.72938e-35,6.13971e-09,1.91112e-43,5.29082e-19,3.99674e31]
⁸  - chain's left argument       [L, M, T, Q, Θ]
*   - exponentiate                [5.72938e-35^L,6.13971e-09^M,1.91112e-43^T,5.29082e-19^Q,3.99674e31^Θ]
P - product                     5.72938e-35^L×6.13971e-09^M×1.91112e-43^T×5.29082e-19^Q×3.99674e31^Θ

• 34 bytes by using STDIN Ɠ instead of first argument ⁸, enabling you to use _³ for -100 instead of the _48. – Kevin Cruijssen Mar 30 '20 at 19:54
• @KevinCruijssen Nice & thanks; I'm going to do 34 a different way though... – Jonathan Allan Mar 30 '20 at 22:02
• Ah, using differences. Yeah, that's also a way. :) – Kevin Cruijssen Mar 31 '20 at 6:28

# Perl 5-pa, 84 80 bytes

@Arnauld and I both realized that you can save bytes by removing the decimal points.

$\=1;map$\*=$_**$F[$i++],572938E-40,6.13971E-9,191112E-48,529082E-24,399674E26}{  Try it online! • I was actually just working on that when you posted. – Xcali Mar 28 '20 at 15:41 # dc, 85817875 70 bytes 16iFFk1F875AI15^*?^35C8BI18^*?^/9B5431E?^/3C1109I1E^*?^/1A3ADDIA^*?^/p  Try it online! Or try a test suite that shows the sample cases listed in the challenge. (This is a bash script that runs the dc program on each test data set in turn.) Saved 4 bytes by removing the decimal points, thanks to @Arnauld. Had to add 1 byte also though, because I had inadvertently omitted a digit in one of the constants. Saved 3 more bytes by changing constants to hexadecimal. Thanks to @Noodle9 for pointing out that using division instead of multiplication can shorten this. That, plus careful attention to how many significant digits were needed throughout, yielded a savings of 5 additional bytes. Input on stdin, one number per line, in base 16, in the following order: Θ L M T Q  This is the OP's order except the last one there is moved to the first position instead. (The challenge says, "A dimension is given as the input. Its type and format doesn't matter." Also, hexadecimal input won't make a difference in practice given the problem domain, because we're not going to have a dimensional exponent outside the range -9 to 9. And this is allowed anyway by "Yes, I/O in unary, binary, octal, decimal or hexadecimal should be acceptable by default", which got the required support of at least 5 net votes, and at least twice as many upvotes as downvotes -- in this case, 20 upvotes, 8 downvotes, and 12 net votes.) Output on stdout, in base 10 as usual, with lots of decimal places :) . If you try this out, note that when you enter negative numbers in dc, they're written with an initial _ character instead of -, since - is reserved for the binary subtraction operator. And don't forget to put Θ first, and to enter them all in hexadecimal! (Output is still in decimal.) # JavaScript (ES7), 81 76 bytes Saved 5 bytes thanks to @Noodle9 Seems like the direct formula is the shortest way... ¯\_(ツ)_/¯ Takes input as 5 distinct arguments. (a,b,c,d,e)=>399674e26**e/174539e29**a/162874e3**b/523253e37**c/189007e13**d  Try it online! # JavaScript (ES7), 86 bytes Using reduce() adds 5 10 bytes. Takes input as an array. a=>a.reduce((p,c,i)=>p*([572938e8,613971e34,191112,529082e24,399674e74][i]/1e48)**c,1)  Try it online! • – Noodle9 Mar 29 '20 at 0:13 # Mathematica, 260 bytes Using a different method than the OP's. In particular, Table 2 at https://en.wikipedia.org/wiki/Planck_units#Definition Many opportunities for cleanup (e.g., shrink name to c, saving 6 bytes), but seems pointless. Newlines and indenting are inessential and are only present for presentation. Two spaces are required, at the end of the BoltzmannConstant line and at the end of the ElectricConstant line. convert=Function[{L,M,T,Q,t}, N[UnitConvert[ Quantity["BoltzmannConstant"]^-t Sqrt[ (4Pi)^(L-M+T-t) Quantity["SpeedOfLight"]^(-3L+M-5T+Q+5t) Quantity["ElectricConstant"]^Q Quantity["GravitationalConstant"]^(L-M+T-t) Quantity["ReducedPlanckConstant"]^(L+M+T+Q+t) ] ],6] ]  Checking: convert[2, 1, -1, -2, 0] (* 376.730 kg m^2/(s^3A^2) *) (* FullForm: Quantity[376.730, ("Kilograms" ("Meters")^2)/(("Amperes")^2 ("Seconds")^3)] *) convert[-2, -1, 3, 0, 1] (* 1.3842\[Times]10^-20 s^3K/(kg m^2) *) (* FullForm: Quantity[1.3842\[Times]10^-20, ("Kelvins"*"Seconds"^3)/("Kilograms"*"Meters"^2)] *) convert[0, 0, 0, 0, 0] (* 1.00000 *)  Notice that this code uses a curated source of consensus scientific values of the constants, and the output will change as those values change. Of relevance to the Challenge (and exemplified in the above samples), the gravitational constant is only 6.674 30(15) *10^(-11) m^3 /(kg s^2), so is only known to four significant digits. This impacts the precision of length, mass, and time (except in combinations where this term cancels) in the Challenge, although the Challenge does not acknowledge this limitation of precision in those constants. # PowerShell, 124 101 bytes -23 bytes thanks to mazzy $t=1
$args|%{$t/=[math]::pow((174539e29,162874e3,523253e37,189007e13, 2502039161917e-44)[$i++],$_)}
\$t

• – mazzy Apr 2 '20 at 3:55
• It looks nice. I don't see any good reason to use 1/const and const in the same expression at the same time, unless it shortens the expression. – mazzy Apr 2 '20 at 10:30

# Java 8, 118 bytes

Math M=null;(a,b,c,d,e)->M.pow(399674e26,e)/M.pow(174539e29,a)/M.pow(162874e3,b)/M.pow(523253e37,c)/M.pow(189007e13,d)


Port of @Noodle9's Python answer, so make sure to upvote him!!

Try it online.

# TI-83 Basic, 62 tokens

Using list operations:

prod({5.72938ᴇ−35,6.13971ᴇ−9,1.91112ᴇ−43,5.29082ᴇ−19,3.99674ᴇ31}^Ans


where

prod(                 Multiply all list elements together (1 token)
{ ... }          Constants in list (59 tokens)
^         Power using 2 lists as arguments (1 token)
Ans      Input list stored in answer variable (1 token)


Example:

| {2,1,-1,-2,0}    | Give input
|    {2 1 -1 -2 0} |
| prgmPLANCK       | Run program
|      376.7291131 | Result


Second example unfortunately returns 0, because of insufficient precision on calculator.

# Fortran (GFortran), 95 90 bytes

READ*,I,J,K,L,M
PRINT*,399674D26**M/174539D29**I/162874D3**J/523253D37**K/189007D13**L
END


Try it online!

Input on stdin, output on stdout.

Thanks to @Noodle9 for saving 5 bytes by pointing out that using division instead of multiplication can shorten this.

• – Noodle9 Mar 30 '20 at 10:45
• @Noodle9 -- Thank you! This same idea shortened my dc solution too. – Mitchell Spector Mar 31 '20 at 5:54