This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Adic < Numeric | |
def initialize adic, precision, arg = 0, ord = 0 | |
@adic, @precision = adic, precision | |
@modulus = adic ** precision | |
@int, @ord = if arg.zero? | |
[0, :infty] | |
else | |
while arg % adic == 0 | |
arg /= adic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$radix ||= 10 # 2 <= $radix <= 36 | |
$adic ||= 10**4 # 2 <= $adic | |
$delim ||= ',' # or '|', etc. | |
$type ||= :arch # or :adic | |
$prec ||= 44 # default precision | |
$term_order ||= :gr # or :lex | |
def scale; $adic ** $prec; end # default scale | |
def prec_2; (scale - 1).size 2; end # default precision in bits | |
def prec_calc; ($prec / $adic.log).ceil; end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>p-adic</title> | |
<script type="text/javascript"> | |
window.onload = function(){ | |
var ctx = document.getElementById('z_p').getContext('2d') | |
var scale = 256 | |
ctx.translate(512, 512) | |
ctx.scale(scale, scale) | |
ctx.lineWidth = 1/scale |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Real | |
def log | |
return if zero? | |
_ = self | |
return (- _).log if _ < zero | |
if _ > 2 or _ < unity | |
e = 0 | |
e, _ = e + 1, _ / 2 while _ > 2 | |
e, _ = e - 1, _ * 2 while _ < 1 | |
_.log + e * 2.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"> | |
MathJax.Hub.Config({extensions:["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js","TeX/autobold.js"],jax:["input/TeX","output/HTML-CSS"],tex2jax:{inlineMath:[['$','$'],['\\(','\\)']],displayMath:[['$$','$$'],['\\[','\\]']],processEscapes:true}}); | |
</script> | |
</head> | |
<body> | |
\begin{array}{rcrcrcrclcrcr} | |
& & & & \mathrm{b} &=& \log 2 &=& e^{ \log\log 2} &=& -0.3665\cdots\ \mathrm{X}&=& 0.6931\cdots\\ | |
& & \mathrm{B} &=& 2^3 \ \mathrm{b} &=& 2^3 \log 2 &=& e^{3 \log 2 + \log\log 2} &=& 1.7129\cdots\ \mathrm{X}&=& 5.5451\cdots\\ | |
\mathrm{kB} &=& 2^{10} \ \mathrm{B} &=& 2^{13} \ \mathrm{b} &=& 2^{13} \log 2 &=& e^{13 \log 2 + \log\log 2} &=& 8.6444\cdots\ \mathrm{X}&=& 5678.2617\cdots\\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tropical.rb | |
# an implementation of complex numbers with tropical flavor | |
# | |
# self == e^{ord + 2 \pi i arg} | |
class Class | |
def get *args, &block | |
(new *args, &block).identity | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def not_implemented | |
puts "#{inspect} : #{self.class}" | |
raise NotImplementedError | |
end | |
$radix ||= 10 # 2 <= $radix <= 36 | |
$adic ||= 10**4 # 2 <= $adic | |
$delim ||= ',' # or '|', etc. | |
$type ||= :arch # or :adic | |
$prec ||= 4 # default precision |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width"> | |
<script> | |
var d = 99.6290 - Math.log(1e3), c, p = Date.parse, n = Date.now | |
onload = function() { | |
var t = location.hash.slice(1).split(',').filter(p).map(p) | |
t.push(n()) | |
t.unshift(-13.772e9 * 365.25 * 24 * 3600 * 1e3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width, user-scalable=no"> | |
<meta charset="UTF-8"> | |
<title>Natural Calc</title> | |
<style> | |
body { | |
width: 100%; | |
position: fixed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width, user-scalable=no"> | |
<meta charset="UTF-8"> | |
<title>Natural Calc</title> | |
<style> | |
html, body { | |
width: 100%; | |
height: 100%; |
OlderNewer