-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
177 lines (168 loc) · 7.85 KB
/
index.html
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head><title>Inf -- a calculator that can handle infinite and infinitesimal numbers</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body onload = "set_up();">
<h1>Inf</h1>
<p>Inf is a calculator that can handle infinite and infinitesimal numbers.
Type an expression at the : prompt and hit Enter. For more documentation, scroll down. </p>
<div id="debug"></div>
<div id="debug2"></div>
<div id="terminal" style="width:100%; height:600px;"></div>
<script src="Terminal.js" type="text/javascript"></script>
<script src="Lexer.js" type="text/javascript"></script>
<script src="Parser.js" type="text/javascript"></script>
<script src="Num.js" type="text/javascript"></script>
<script src="Complex.js" type="text/javascript"></script>
<script src="Rational.js" type="text/javascript"></script>
<script src="LeviCivita.js" type="text/javascript"></script>
<script src="Test.js" type="text/javascript"></script>
<script type="text/javascript">
function set_up() {
var lexer = new com.lightandmatter.Lexer({});
var parser = new com.lightandmatter.Parser({});
var terminal = new com.lightandmatter.Terminal({
'container':document.getElementById("terminal"),
'prompt':': ',
'response':(function(terminal) {
parser.parse(lexer.tokens,lexer.props);
//return "Your input was "+parser.to_debug_string()+' -->> '+parser.toString();
return parser.toString();
}),
'when_changed':(function(t) {
// document.getElementById("debug").innerHTML="Debugging: "+lexer.toString();
lexer.change_text(t);
})
});
if ( window.location.search == "?test" ) { // doesn't work in IE
var r=com.lightandmatter.Test(document.getElementById("debug2"),lexer,parser);
document.getElementById("debug").innerHTML += "Passed "+r[0]+"/"+r[1]+" tests."
}
}
</script>
<h2>About Inf</h2>
<h3>Basic use</h3>
<p>
Inf is a calculator that can handle infinite and infinitesimal numbers.
</p>
<p>
Special constants and variables:
</p>
<ul>
<li> d -- an infinitesimally small number
<li> pi -- the ratio of a circle's circumference to its diameter
<li> i -- the square root of -1
</ul>
<p>
Built-in operators:
</p>
<ul>
<li> +, -, *, / -- arithmetic
<li> ^ -- exponentiation
<li> <, >, == -- comparisons (note the double equals sign to test for equality)
<li> ()[]{} -- All three styles of parentheses can be used.
</ul>
<p>
Built-in functions:
</p>
<ul>
<li> sin, cos, tan
<li> asin, acos, atan
<li> sqrt, abs
<li> exp, ln
</ul>
<p>
Inf represents infinite and infinitesimal quantities as <a href="http://en.wikipedia.org/wiki/Levi-Civita_field">Levi-Civita numbers</a>.
Calculus students often get the impression that the notion of an infinite or infinitesimal number can never be defined in any rigorous or
self-consistent way. That's not true. Tullio Levi-Civita defined the Levi-Civita numbers around 1900, so it's been known for over a
century that there were rigorously definable number systems that included infinities.
Great mathematicians like Newton, Gauss, and Euler used
infinitesimals, and now that modern mathematicians have put them on a more rigorous footing, there's
no reason to shy away from them.
To learn more about the application of infinitesimals
to calculus, see my <a href="http://www.lightandmatter.com/calc/">free calculus book</a>.
If you've ended up here because the calculus book tells you about the calculator, one thing you should realize is that the Levi-Civita
numbers used by Inf are not the full hyperreal number system referred to in the book. They are a subset of them, in the same way
that the rational numbers are a subset of the real numbers. This is why certain calculations give an error
in the calculator, even though they are well defined in the hyperreals.
</p>
<p>
The Levi-Civita numbers obey all the same <a href="http://en.wikipedia.org/wiki/First-order_logic">elementary</a> axioms of arithmetic as the real numbers.
If you try evaluating the expression 1/0, you'll see that it comes up as undefined, not an infinite number. This is because one of the elementary
axioms of arithmetic is that division by zero is undefined. To get an infinite result, you could do something like 1/d, where d is the symbol
built in to the calculator to represent one particular infinitesimal number. Another thing that
can be proved from the elementary axioms of arithmetic is that if x is greater than zero, then 2x is greater than x. This applies to
Levi-Civita numbers as well, so infinite and infinitesimal numbers have to come in different sizes. In particular, there isn't
anything in the Levi-Civita system that plays the role of ∞, which is usually used as a generic symbol for infinity.
</p>
<p>
Here are some examples you can try in the calculator to get a feeling for how all this works:
</p>
<ul>
<li> 1/0 ... undefined
<li> d>0 ... true
<li> d<10^-10 ... true, because in fact d is smaller than any positive real number
<li> d^2<d ... true, showing that we have different sizes of infinitesimals
<li> d^2>0 ... true, because even though d^2 is infinitesimally small compared to d, it's still no zero
<li> sqrt(d)
<li> sqrt(d)>d ... true
<li> 1/d ... gives an infinite result
<li> 2/d>1/d ... true, because 2/d is a bigger infinity than 1/d
<li> 2/d+1>2/d ... and an even bigger infinity
<li> 1/(1-d) ... is calculated using the <a href="http://en.wikipedia.org/wiki/Geometric_series">geometric series</a>, up to a certain level of precision
<li> exp(d) ... is calculated using a <a href="http://en.wikipedia.org/wiki/Taylor_series">Taylor series</a>
<li> exp(1/d) ... is undefined in the Levi-Civita system
</ul>
<p>
The undefined result for exp(1/d) is an example of how the Levi-Civita numbers are a smaller system than the hyperreals,
which were defined by Abraham Robinson around 1960. The hyperreals match the properties of the real numbers even better than the Levi-Civita numbers do.
For example, the exponential function can take a positive infinite argument in the hyperreal system, but that doesn't work in the Levi-Civita
numbers. However, the hyperreals cannot be conveniently represented on a computer.
</p>
<h3>Fancy features</h3>
<p>
More special variables:
</p>
<ul>
<li> levi_civita_n -- sets the number of terms to maintain in series expansions of Levi-Civita numbers
<li> precision -- sets the number of digits of precision to print in output
</ul>
<p>
More built-in operators:
</p>
<ul>
<li> ; -- separates multiple statements on the same line
<li> , -- builds arrays, e.g., (1,2)
<li> = -- assigns the expression on the right to the variable named on the left-hand side
</ul>
<p>
More built-in functions:
</p>
<ul>
<li> floor, ceil -- round down or up to an integer
<li> array -- converts a Levi-Civita number, complex number, or rational number to a representation in terms of an array
</ul>
<p>
User-defined functions:
</p>
<ul>
<li> f x = x^2
</ul>
<p>
In Firefox, you can use up-arrow and down-arrow to get back lines you've typed in previously. Depending on your browser,
it may also be possible to accomplish this using control-P and control-N.
</p>
<h2>Open source</h2>
<p>
Inf is open source software by <a href="http://www.lightandmatter.com/area4author.html">Ben Crowell</a>
and Mustafa Khafateh. It's under the GPL v. 2 license. Since it's all written in client-side javascript,
you can see the source code simply by doing "view source" in your browser; actually most of the code is in separate
modules pointed to from the html source code, but you can view those through your browser as well by pointing it at each
URL. Alternatively, you can access it via a web browser or git, at <a href="http://github.com/bcrowell/inf">via github</a>.
</p>
<p>
<a href="?test">This link</a> runs a test suite in your browser.
</p>
</body>
</html>