/
mrump.jl
60 lines (49 loc) · 1.31 KB
/
mrump.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# ---
# jupyter:
# jupytext:
# formats: ipynb,jl:hydrogen
# text_representation:
# extension: .jl
# format_name: hydrogen
# format_version: '1.3'
# jupytext_version: 1.10.3
# kernelspec:
# display_name: Julia 1.8.2
# language: julia
# name: julia-1.8
# ---
# %% [markdown]
# https://twitter.com/snap_tck/status/1586506933439434752
# %%
mrump(a, b) = 333.75b^6 + a^2*(11a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5b^8
@show mrump(77617.0, 33096.0)
@show mrump(big"77617.0", big"33096.0")
@show mrump(big(77617), big(33096));
# %%
mrump_int(a, b) = (1335b^6 + 4a^2*(11a^2*b^2 - b^6 - 121*b^4 - 2) + 22b^8)/4
@show mrump_int(77617.0, 33096.0)
@show mrump_int(big"77617.0", big"33096.0")
@show mrump_int(big(77617), big(33096));
# %%
mrump_rat(a, b) = (1335//4)*b^6 + a^2*(11a^2*b^2 - b^6 - 121*b^4 - 2) + (22//4)*b^8
@show mrump_rat(77617.0, 33096.0)
@show mrump_rat(big"77617.0", big"33096.0")
@show mrump_rat(Int128(77617), Int128(33096))
@show mrump_rat(big(77617), big(33096));
# %%
precision(BigFloat)
# %%
setprecision(120) do
mrump(big"77617.0", big"33096.0")
end
# %%
setprecision(124) do
mrump(big"77617.0", big"33096.0")
end
# %%
@code_typed mrump(77617.0, 33096.0)
# %%
@code_typed mrump(big"77617.0", big"33096.0")
# %%
@code_typed mrump_rat(Int128(77617), Int128(33096))
# %%