Skip to content

Commit b83f7fe

Browse files
committed
add sqinv() function
1 parent 3895d1f commit b83f7fe

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ GitHub](https://github.com/sponsors/victorpoughon). Thank you ❤️
138138

139139
## Future work
140140

141-
* Implement the "true inverse" of the square function: `sqinv(X) = sqrt(X) U -sqrt(X)`
142141
* Split full precision mode into two controls: input interpretation and display precision
143142
* Add `ans` variable (result of previous entry)
144143
* Add intersection operator or function

doc.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Arithmetic](https://www.ime.usp.br/~montanhe/unions.pdf).
77
An interval `[a, b]` represents the set of all numbers between and including a
88
and b. An interval union: `[a, b] U [c, d]` is a disjoint set of intervals.
99

10-
Interval *union* arithmetic is an extension of regular interval arithmetic that
10+
Interval _union_ arithmetic is an extension of regular interval arithmetic that
1111
is vastly superior, mostly because it remains closed while supporting division
1212
by intervals containing zero:
1313

@@ -96,6 +96,7 @@ bound. This design choice enables using arithmetic on interval bounds themselves
9696
| Hull | `hull(A)` | `➤ hull([1, 2] U [99, 100])`<br>`[1, 100]` |
9797
| Absolute value | `abs(A)` | `➤ abs([-10, 5])`<br>`[0, 10]` |
9898
| Square root | `sqrt(A)` | `➤ sqrt([9, 49])`<br>`[3, 7]` |
99+
| Square Inverse | `sqinv(A)` | `➤ sqinv([4, 64])`<br>`[-8, -2] U [2, 8]` |
99100
| Natural logarithm | `log(A)` | `➤ log([0, 1])`<br>`[-∞, 0]` |
100101
| Logarithm base 2 | `log2(A)` | `➤ log2([64, 1024])`<br>`[6, 10]` |
101102
| Logarithm base 10 | `log10(A)` | `➤ log10([0.0001, 1])`<br>`[-4, 0]` |
@@ -149,7 +150,6 @@ GitHub](https://github.com/sponsors/victorpoughon). Thank you&nbsp;❤️
149150

150151
## Future work
151152

152-
* Implement the "true inverse" of the square function: `sqinv(X) = sqrt(X) U -sqrt(X)`
153-
* Split full precision mode into two controls: input interpretation and display precision
154-
* Add `ans` variable (result of previous entry)
155-
* Add intersection operator or function
153+
- Split full precision mode into two controls: input interpretation and display precision
154+
- Add `ans` variable (result of previous entry)
155+
- Add intersection operator or function

index.html

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,54 +207,60 @@ <h2 id="supported-functions">Supported Functions</h2>
207207
style="text-align: left;"><code>➤ sqrt([9, 49])</code><br><code>[3, 7]</code></td>
208208
</tr>
209209
<tr class="odd">
210+
<td style="text-align: right;">Square Inverse</td>
211+
<td style="text-align: left;"><code>sqinv(A)</code></td>
212+
<td
213+
style="text-align: left;"><code>➤ sqinv([4, 64])</code><br><code>[-8, -2] U [2, 8]</code></td>
214+
</tr>
215+
<tr class="even">
210216
<td style="text-align: right;">Natural logarithm</td>
211217
<td style="text-align: left;"><code>log(A)</code></td>
212218
<td
213219
style="text-align: left;"><code>➤ log([0, 1])</code><br><code>[-∞, 0]</code></td>
214220
</tr>
215-
<tr class="even">
221+
<tr class="odd">
216222
<td style="text-align: right;">Logarithm base 2</td>
217223
<td style="text-align: left;"><code>log2(A)</code></td>
218224
<td
219225
style="text-align: left;"><code>➤ log2([64, 1024])</code><br><code>[6, 10]</code></td>
220226
</tr>
221-
<tr class="odd">
227+
<tr class="even">
222228
<td style="text-align: right;">Logarithm base 10</td>
223229
<td style="text-align: left;"><code>log10(A)</code></td>
224230
<td
225231
style="text-align: left;"><code>➤ log10([0.0001, 1])</code><br><code>[-4, 0]</code></td>
226232
</tr>
227-
<tr class="even">
233+
<tr class="odd">
228234
<td style="text-align: right;">Exponential</td>
229235
<td style="text-align: left;"><code>exp(A)</code></td>
230236
<td
231237
style="text-align: left;"><code>➤ exp([-∞, 0] U [1, 2])</code><br><code>[0, 1] U [2.718, 7.389]</code></td>
232238
</tr>
233-
<tr class="odd">
239+
<tr class="even">
234240
<td style="text-align: right;">Cosine</td>
235241
<td style="text-align: left;"><code>cos(A)</code></td>
236242
<td
237243
style="text-align: left;"><code>➤ cos([pi/3, pi])</code><br><code>[-1, 0.5]</code></td>
238244
</tr>
239-
<tr class="even">
245+
<tr class="odd">
240246
<td style="text-align: right;">Sine</td>
241247
<td style="text-align: left;"><code>sin(A)</code></td>
242248
<td
243249
style="text-align: left;"><code>➤ sin([pi/6, 5*pi/6])</code><br><code>[0.5, 1]</code></td>
244250
</tr>
245-
<tr class="odd">
251+
<tr class="even">
246252
<td style="text-align: right;">Tangent</td>
247253
<td style="text-align: left;"><code>tan(A)</code></td>
248254
<td
249255
style="text-align: left;"><code>➤ tan([pi/3, 2*pi/3])</code><br><code>[-∞, -1.732] U [1.732, +∞]</code></td>
250256
</tr>
251-
<tr class="even">
257+
<tr class="odd">
252258
<td style="text-align: right;">Minimum</td>
253259
<td style="text-align: left;"><code>min(A, B)</code></td>
254260
<td
255261
style="text-align: left;"><code>➤ min([1, 2], [0, 6])</code><br><code>[0, 2]</code></td>
256262
</tr>
257-
<tr class="odd">
263+
<tr class="even">
258264
<td style="text-align: right;">Maximum</td>
259265
<td style="text-align: left;"><code>max(A, B)</code></td>
260266
<td
@@ -307,6 +313,14 @@ <h2 id="open-source">Open Source</h2>
307313
you like my open-source work, please consider <a
308314
href="https://github.com/sponsors/victorpoughon">sponsoring me
309315
on GitHub</a>. Thank you ❤️</p>
316+
<h2 id="future-work">Future work</h2>
317+
<ul>
318+
<li>Split full precision mode into two controls: input
319+
interpretation and display precision</li>
320+
<li>Add <code>ans</code> variable (result of previous
321+
entry)</li>
322+
<li>Add intersection operator or function</li>
323+
</ul>
310324
</article>
311325
<script type="module" src="/src/main.ts"></script>
312326
</body>

src/functions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const externalFunctions: Record<string, ExternalFunction> = {
6464
cos: fixedArity(1, nsf.ucos),
6565
sin: fixedArity(1, nsf.usin),
6666
tan: fixedArity(1, nsf.utan),
67+
sqinv: fixedArity(1, nsf.sqinv),
6768

6869
// Binary
6970
min: fixedArity(2, nsf.umin),

0 commit comments

Comments
 (0)