# Calculate the aspect ratio of the Nepal flag Above is the picture of the flag of the country Nepal. Pretty cool.

What's cooler, is the aspect ratio, which is defined under the constitution as: That formula in copyable form:

$$1 : \frac{6136891429688-306253616715\sqrt{2}-\sqrt{118-48\sqrt{2}}(934861968+20332617192\sqrt{2})}{4506606337686}$$

Your task is to output at least the first 113 digits of the decimal expansion, in any format of your choosing. These digits are:

1.2190103378294521845700248699309885665950123333195645737170955981267389324534409006970256858120588676151695966441

These digits form can be found in sequence A230582.

This constant is algebraic, specifically quartic. In particular it is the least root of 243356742235044x⁴ - 1325568548812608x³ + 2700899847521244x² - 2439951444086880x + 824634725389225.

This is code-golf, so shortest answer wins.

Related: Let's draw the flag of Nepal

• -1 For most languages (I think), the best solution is to print the number rather than calculating it, since the formula itself takes a lot of characters and few languages support 113-digit floating point numbers. Even for languages that are able to calculate 113 or more digits, I believe the formula can still be trivially implemented. Aug 5 at 20:14
• I think the key may be that the formula isn't arbitrary, and there is a method of construction described here that leads to those values.
– xnor
Aug 5 at 20:16
• gzip shortens it to 90 bytes, but I'm having a hard time getting my terminal to actually accept it, since the gzip output contains null bytes and unpaired CRs. Aug 5 at 20:27
• Here's a formula from the thumbnail of this video.
– xnor
Aug 5 at 20:28
• I was the one who created the OEIS entry A235082. It was my first contribution there. Aug 8 at 6:00

# Python 3, 100 bytes

from sympy import*
r=sqrt(2)
print(N((4-3/((7*r-3-sqrt(59-24*r))*(23-9*r)*16/9/(33-20*r)+r))/3,113))


Try it online!

This is longer than compressed hardcoding and definitely golfable, but I want to share a formula I simplified from one in this thumbnail of this video:

\begin{aligned} v &= \frac{16 \cdot (7\sqrt{2}-3-\sqrt{59-24\sqrt{2}}) \cdot (23-9\sqrt{2})}{9 \cdot (33-20\sqrt{2})} \\ \text{ratio} &= \frac{4}{3}-\frac{1}{v+r} \end{aligned}

92 bytes

from sympy import*
r=5-sqrt(8)
print(N((4-6/((29-7*r-sqrt(48*r-4))*(8/r/9+8)/r+5-r))/3,113))


Try it online!

95 bytes (@dingledooper)

from sympy import*
r=sqrt(2)
print(N((4-3/((7*r-3-sqrt(59-24*r))*(6384+2608*r)/2601+r))/3,113))


Try it online!

• 118-48*r can be 16*c-10, for instance.
– Neil
Aug 5 at 21:17
• @Neil It can even be c*c+36
– xnor
Aug 5 at 21:18
• If you write 3*(33-20*r) as (20*c-61) then you can inline r into c.
– Neil
Aug 5 at 21:28
• With both (20*c-61) and c*c+36 it also comes out at 104 bytes: Try it online!
– Neil
Aug 5 at 21:40
• Although you can still save 2 more bytes by using (20*c-61) yourself.
– Neil
Aug 5 at 21:45

# Vyxal, 48 bytes

»ʀ⌈S«A0ẇ⟨Ė^Ṗ*«)Πṙvp≈›≥›BĖ≥ẇ₈ḋẇβẋV¼»16↵τyNY∆Ph⁺°Ḟ


Try it Online!

Solves the stated polynomial.

»...»              # Giant number
τ          # Decompress from base
16↵           # 10^16
yNY       # Negate every other term to get coefficients
∆P     # Solve polynomial
h    # First root
⁺°Ḟ # Format to 113 decimal places


# Charcoal, 52 bytes

1.”)¶⌊G U9ι[abN↧Ｑ∧≡⁻w⁼Ka5↧χ±ν∕§G\U⊙Gφ2Ｓ4↖gλo0θ｜Sψ◨N➙


Try it online! Link is to verbose version of code, for what it's worth. Explanation: Prints 1. separately, because that improves the string compression of the remaining 112 digits.

120 bytes to actually calculate the 113 digits:

≔Ｘχ¹¹²θ≔▷math.isqrt⊗×θθη1.✂Ｉ÷⁻⁻×Ｉ”)¶↷ωrＮL@”θ×Ｉ”)⧴↧≔Ｍmχ”η÷×▷math.isqrt⁻×¹¹⁸×θθ×⁴⁸×θη⁺×Ｉ”)¶u⁰»～”θ×Ｉ”)¶↗v⌊Hq”ηθＩ”)″“▷←ι2⊖”¹


Attempt This Online! Link is to verbose version of code. Explanation:

≔Ｘχ¹¹²θ


Effectively set the calculation precision to 112 digits after the decimal point by multiplying everything by 10¹¹².

≔▷math.isqrt⊗×θθη


Calculate the square root of 2 to that precision.

1.


Output the 1. separately as it's easier.

✂Ｉ÷⁻⁻×Ｉ”...”θ×Ｉ”...”η÷×▷math.isqrt⁻×¹¹⁸×θθ×⁴⁸×θη⁺×Ｉ”...”θ×Ｉ”...”ηθＩ”...”¹


Calculate and output the 112 digits after the decimal point, using compressed strings for the large numbers.

105 96 81 80 72 71 bytes by importing sympy and using a golfed version of @xnor's original sympy answer:

≔⁻⁸▷sympy.sqrt¹⁸θ≔∕×⁻×²⁰θ⁶¹⁺⁺⁶θＸ⁻×¹⁶θχ·⁵⁻×⁹⁶θ³²η▷sympy.N⟦∕∕⁺⁸η⁶⁺¹∕ηθ¹¹³


Try it online! Link is to verbose version of code. Explanation:

≔⁻⁸▷sympy.sqrt¹⁸θ


Save $$\ 8 - \sqrt { 18 } \$$ in a variable.

≔∕×⁻×²⁰θ⁶¹⁺⁺⁶θＸ⁻×¹⁶θχ·⁵⁻×⁹⁶θ³²η


Save $$\ \frac { 3 ( 33 - 20 \sqrt 2 ) ( 14 - 3 \sqrt 2 + \sqrt { 118 - 48 \sqrt 2 } ) } { 32 ( 23 - 9 \sqrt 2 ) } \$$ in a variable. $$\ 3 ( 33 - 20 \sqrt 2 ) = 20 ( 8 - \sqrt { 18 } ) - 61 \$$, $$\ 14 - 3 \sqrt 2 = 6 + 8 - \sqrt { 18 } \$$, $$\ 118 - 48 \sqrt 2 = 16 ( 8 - \sqrt { 18 } ) - 10 \$$ and $$\ 32 ( 23 - 9 \sqrt 2 ) = 96 ( 8 - \sqrt { 18 } ) - 32 \$$. Also, I can use Power(, 0.5) instead of sympy.sqrt on an expression based on $$\ \sqrt 2 \$$.

▷sympy.N⟦∕∕⁺⁸η⁶⁺¹∕ηθ¹¹³


Calculate the desired result.

# Wolfram Language (Mathematica), 6962 57 bytes

Saved so many bytes thanks to the comment of @Greg Martin and the comment of @att

Try it online!

r=√2;4/3-199/(r+(7r-3-√(59-24r))(23/9-r)16/(33-20r))

• You can save a few bytes by removing the * symbols and changing where the 9s are: r=√2;(4-3/(r+(7r-3-√(59-24r))(23/9-r)16/(33-20r)))/3 Aug 6 at 7:25
• @GregMartin It does look weird having the 16 between the ) and / instead of between the + and ( though...
– Neil
Aug 6 at 8:48
• 57: r=√2;4/3-199/(r+(7r-3-√(59-24r))(23/9-r)16/(33-20r))
– att
Oct 22 at 9:08

# Python 3, 80 bytes

Obligatory compressed hardcoding method. See @xnor's answer for an actual mathematical computation.

print(1.2,*b'Zg%R^4-F\0VcbUB;2{!_@9%F_;QIY -"(Z\0EFD:x:VL_@)',sep='')


Try it online!

"%,}#:g6F.mR}}1o|7{n[TK%::,QFb_xTj3br9F;As}^_2]S%}Soe()xyYB".bytes{|i|$><<(i-25)%100}  Try it online! Prints the digits of the decimal expansion, in any format. I interpret that to mean the decimal point is not required. It would cost a few bytes to add it in. This simply decodes the ASCII codes of each character in the magic string to a number between 35-25=10 and 125-25=100, takes a modulo to convert the 100 into 0 where necessary, and prints the output, concatenated. # Nibbles, 50 bytes (100 nibbles) "1."$ ~3a4898772b89091168fc7c6102ed1580a718bf8643e9be1c097cfadb7db934a09ad75c14a79b0262ce77978b500e9


Attempt This Online!

Same approach as Neil's first Charcoal answer.
Nibbles can only handle integers, so outputting the initial 1. and the decimal digits separately is essential.

# Python 3, 109 bytes

print(f"1.{0x3a4898772b89091168fc7c6102ed1580a718bf8643e9be1c097cfadb7db934a09ad75c14a79b0262ce77978b500e9}")


Try it online!

Stores the decimal part in hex (thanks @xnor).

# Thunno 2j, 52 bytes

»¥\!ĖẸæṭṙ|«ɦ⁾‘cạḍ¬ṣ“},ịḤ)ṣ3_ßịạ⁷ƇR×XẏṢḋyi¡ẹ¿pĿ⁴8»1.


Try it online!

Just a compressed number with 1. prepended.

# 05AB1E, 53 bytes

•4₅XÃ¯Máô|û¡Žü%ÔÖ7àþ}iÙ°fàp!LÙÔ‡ĀΣH₁ù¸ê_+0×B<È„u•„1.ì


Try it online.

Explanation:

Straight-forward hard-coded approach. 05AB1E also only has 16 bits floating point precision anyway.

•4₅XÃ¯Máô|û¡Žü%ÔÖ7àþ}iÙ°fàp!LÙÔ‡ĀΣH₁ù¸ê_+0×B<È„u•
# Push compressed integer 2190103378294521845700248699309885665950123333195645737170955981267389324534409006970256858120588676151695966441
„1.ì  # Prepend "1." in front of it
# (after which the result is output implicitly)


See this 05AB1E tip of mine (section How to compress large integers?) to understand how the compression works.

# CellTail, 133 Bytes

I=1,219010337,829452184,570024869,930988566,595012333,319564573,717095598,126738932,453440900,697025685,812058867,615169596,6441;O=N;


Outputs as a list of numbers, starting with the integer component.

I="Try it online!";O=C;

# Jelly, 53 bytes

“µŻ5(_PṛØY⁺Ɲ>Ŀḣ¦ḲḶaİçẸẒḋƙ⁷\ø%Sfø*ḤÑ[F]€ȮĠṆ5]Ẇ⁶rȦ’⁾1.;


Try it online!

Straightforward hardcoding of the digits after the decimal point as a base-250 integer, then prepend "1."

Any calculation would have to be done using integers and fixed point arithmetic which is almost certainly longer than this.

Alternatively, Python and sympy can be used within Jelly. Here’s one version using @xnor’s Python code:

# Jelly, 99 bytes

“YSZprint(ZN((4-3/((7*Y-3-S59-24*Y))*(23-9*Y)*16/9/(33-20*Y)+Y))/3,113))“S2)“Zsqrt(“sympy.”ṣḢ\$j¥/ŒV


Try it online!

And here’s an approach that uses sympy to solve the aquatic equation in the OEIS, as suggested by @UnrelatedString:

# Jelly, 113 bytes

“ẏ0P|Ẓ+“¥j^⁸øżk“½ÇṂY;Sṙ“®ẋ~⁽h¹“£]iyi7ṭ’NÐeŒṘ“print(sympy.N(from_base(“,sympy.poly('x')).all_roots(),113))”jŒV


Try it online!

• I have no idea how to use sympy, but is there any chance using the quartic coefficients on the OEIS page could come out shorter with those being base compressed? Oct 22 at 9:18
• @UnrelatedString I’ve added an implementation of that (based on Jelly’s Ær code). I’ve base-250 encoded the coefficients, but there’s quite a lot of Python code required so it’s still quite long. Unfortunately, Ær itself converts to a standard Python float so can’t be used here for arbitrary precision calculations. Oct 22 at 19:05

# VyxalṪ, 52 bytes

‛1.»⟑]"Ȯ⁋æ≥ǔ}¼√ḋ¾d¯₴÷≤„~-↳§*≤4_⌐↳¯→ḟS∆Y↵Ḃ¥zjλ…°qẆ∷9»


String sum magic! La la la!

Ties with Thunno 2 and Charcoal. This seems optimal.

Try it Online!

## Explanation

‛1.»⟑]"Ȯ⁋æ≥ǔ}¼√ḋ¾d¯₴÷≤„~-↳§*≤4_⌐↳¯→ḟS∆Y↵Ḃ¥zjλ…°qẆ∷9»­⁡​‎‎⁪⁡⁪⁠⁪⁡⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁪‏‏​⁡⁠⁡‌⁢​‎‎⁪⁡⁪⁠⁪⁤⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁡⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁢⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁣⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁤⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁡⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁢⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁣⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁤⁪‏⁠‎⁪⁡⁪⁠⁪⁤⁡⁪‏⁠‎⁪⁡⁪⁠⁪⁤⁢⁪‏⁠‎⁪⁡⁪⁠⁪⁤⁣⁪‏⁠‎⁪⁡⁪⁠⁪⁤⁤⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁡⁡⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁡⁢⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁡⁣⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁡⁤⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁢⁡⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁢⁢⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁢⁣⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁢⁤⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁣⁡⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁣⁢⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁣⁣⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁣⁤⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁤⁡⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁤⁢⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁤⁣⁪‏⁠‎⁪⁡⁪⁠⁪⁢⁤⁤⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁡⁡⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁡⁢⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁡⁣⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁡⁤⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁢⁡⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁢⁢⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁢⁣⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁢⁤⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁣⁡⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁣⁢⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁣⁣⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁣⁤⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁤⁡⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁤⁢⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁤⁣⁪‏⁠‎⁪⁡⁪⁠⁪⁣⁤⁤⁪‏⁠‎⁪⁡⁪⁠⁪⁤⁡⁡⁪‏⁠‎⁪⁡⁪⁠⁪⁤⁡⁢⁪‏⁠‎⁪⁡⁪⁠⁪⁤⁡⁣⁪‏⁠‎⁪⁡⁪⁠⁪⁤⁡⁤⁪‏‏​⁡⁠⁡‌⁣​‎‏​⁢⁠⁡‌­
‛1.                                                   # ‎⁡The two character string "1.".
»⟑]"Ȯ⁋æ≥ǔ}¼√ḋ¾d¯₴÷≤„~-↳§*≤4_⌐↳¯→ḟS∆Y↵Ḃ¥zjλ…°qẆ∷9»  # ‎⁢The compressed number 2190103378294521845700248699309885665950123333195645737170955981267389324534409006970256858120588676151695966441.
# ‎⁣Due to some niece witchcraft, the Ṫ flag sums the string and the number to get the constant and then implicitly prints the result. String sum magic! La la la!
💎


Created with the help of Luminespire.

# dc, 78 bytes

16iFFk594DB3BD338 2v474E23564B*-2v4BBEB1DE8*37B8DC90+76 2v30*-v*-41946AB7E96/p


It's a straight calculation, but with the constants specified in hexadecimal for brevity

Explanation:

16i                         # input in base 16
FFx                         # 255-digit precision
594DB3BD338 2v474E23564B*-  # 6136891429688 - 306253616715√2
2v4BBEB1DE8*37B8DC90+       # 934861968 + 20332617192√2
76 2v30*-v                  # √(118 - 48√2)
*-                          # complete the numerator
41946AB7E96/p               # divide by 4506606337686 and print


Output:

1.2190103378294521845700248699309885665950123333195645737170955981267\
389324534409006970256858120588676151695966441384905283150985491649927\
585413642430469766180971720219688119745626955249584071432721758804516\
12949021847336692342653120129739301327854858381983


# JavaScript (Node.js), 104 bytes

a=>'1.'+0x3a4898772b89091168fc7c6102ed1580a718bf8643e9be1c097cfadb7db934a09ad75c14a79b0262ce77978b500e9n
`

Try it online!

Quite but not completely trivial