From 2fd3a7b32e554d021915ebbd3b6f00dd2b80ff16 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sun, 1 Nov 2020 10:34:56 -0500 Subject: Recompile docs with new (more precise) dzaima/BQN number formatting --- docs/tutorial/expression.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'docs/tutorial/expression.html') diff --git a/docs/tutorial/expression.html b/docs/tutorial/expression.html index d1a1d32a..07b8c4f0 100644 --- a/docs/tutorial/expression.html +++ b/docs/tutorial/expression.html @@ -33,7 +33,7 @@

Shown above are a few arithmetic operations. BQN manages to pass as a normal programming language for three lines so far. That's a big accomplishment for BQN! Earth's a confusing place!

The number of spaces between primitive functions like + and - and their arguments doesn't matter: you can use as much or as little as you like. No spaces inside numbers, of course.

↗️
    2 × π
-6.28318530717959
+6.283185307179586
     9 ÷ 2
 4.5
     ÷ 
@@ -71,9 +71,9 @@
     3  2
 9
      1   # There's no constant for e but you can get it this way
-2.71828182845905
+2.718281828459045
      2.3
-9.97418245481472
+9.974182454814718
 
@@ -92,7 +92,7 @@

You could use Power to take square roots and n-th roots, but BQN also provides the primitive for this purpose. If no left argument is provided, then it is the Square Root function; with a left argument it is called Root and raises the right argument to the power of one divided by the left argument.

↗️
     2
-1.4142135623731
+1.4142135623730951
     3  27
 3
 
@@ -112,7 +112,7 @@

I bet if you try hard you'll remember how much you hated learning to do exponentiation before multiplication and division before addition and subtraction. Didn't I tell you Earth was a confusing place? BQN treats all functions—not just primitives but the ones you'll define as well—the same way. They are evaluated from right to left, and parentheses can be used to group subexpressions that have to be evaluated before being used as arguments.

For a longer example, here's an expression for the volume of a sphere with radius 2.

↗️
    (4÷3) × π × 23
-33.5103216382911
+33.510321638291124
 

The evaluation order is shown below, with the function on the first line evaluated first, then × on the next, and so on. The effect of the parentheses is that ÷ is evaluated before the leftmost ×.

@@ -159,9 +159,9 @@

One or two arguments?

What about functions without a left argument? Let's find an equation with lots of square roots in it… looks good.

↗️
     3 + 2 × 2
-2.4142135623731
+2.414213562373095
     1 + 2
-2.4142135623731
+2.414213562373095
 

They are the same, and now you can't say that BQN is the most complicated thing on this particular page! Just to make sure, we can find the difference by subtracting them, but we need to put the left argument in parentheses:

↗️
    (3 + 2×√2) - 1+√2
@@ -317,7 +317,7 @@
 

The most important use for Undo in arithmetic is the logarithm, written . That's all a logarithm is: it undoes the Power function! With no left argument is the natural logarithm. If there's a left argument then Undo considers it part of the function to be undone. The result in this case is that with two arguments is the logarithm of the right argument with base given by the left one.

↗️
     10
-2.30258509299405
+2.302585092994046
     2  32    # Log base 2
 5
     2  2  32
-- 
cgit v1.2.3