# Interesting Square(root) fac

I decided to refresh my knowledge in Algebra again this year, and while studying, I noticed some interesting things about square roots and squares. It's funny how you can learn about these concepts early on and still find new, fascinating details when you take a closer look.

First off, did you know that the square root of 2 is irrational? That means it can't be expressed as a fraction of two integers. No matter how hard you try, you won't be able to write it down as a nice, neat fraction like 1/2 or 3/4. It just keeps going on and on without repeating—kind of like that one friend who always has another story to tell. For example, if you try to calculate the square root of 2 using a calculator, you'll get an approximation like 1.414213..., but it never ends or repeats.

```python
√2	  # Output: 1.4142135623730951
```

Another cool thing I came across is how square numbers always end in specific digits. If you square any whole number, the result will always end in 0, 1, 4, 5, 6, or 9. Pretty wild, right? So, if you see a number that ends in 2, 3, 7, or 8, you can be sure it's not a perfect square. For example, 16 (4 squared) ends in 6, and 25 (5 squared) ends in 5, but numbers like 23 or 78 aren't squares because they don't end in the right digits.&#x20;

```markdown
$`\sqrt{3x-1}+(1+x)^2`$
```

<figure><img src="https://1180114700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAk4kX7gCdOEwl5TE7zo0%2Fuploads%2FX95vV6CaVuVqPTswBM65%2FScreenshot%202025-01-20%20at%201.51.12%E2%80%AFPM.png?alt=media&#x26;token=f90e9672-1565-4173-bf04-eac79ad75270" alt=""><figcaption></figcaption></figure>

Let me quickly explain the function above:

* n2mod10 calculates the last digit of the square of nnn.
* The possible last digits of perfect squares in base 10 are {0,1,4,5,6,9}\\{0, 1, 4, 5, 6, 9\\}{0,1,4,5,6,9}.
* The function returns 1 (true) if the last digit of n2n^2n2 is in this set and 0 (false) otherwise.

Now, here's where things get a little more abstract. The square root of a negative number isn't a real number. Instead, it falls into the world of imaginary numbers, which use the symbol 'i' to represent the square root of -1. So, while you won't find the square root of -9 on the number line, you can still work with it in the complex number system. For example, the square root of -9 is written as 3i, meaning 3 times the imaginary unit i.

```python
import cmath
print(cmath.sqrt(-9))  # Output: 3j
```

Speaking of interesting, the Pythagorean theorem is another place where square roots make an appearance. You know the classic formula: a^2 + b^2 = c^2. This handy little equation lets us find the length of a side in a right triangle, and square roots are the key to making it work. For example, if you have a right triangle with sides of length 3 and 4, the hypotenuse will be 32+42=9+16=25=5\sqrt{3^2 + 4^2} = \sqrt{9 + 16} = \sqrt{25} = 5.

```python
def pythagorean_theorem(a, b):
    return math.sqrt(a**2 + b**2)

print(pythagorean_theorem(3, 4))  # Output: 5.0
```

Finally, a fun fact: the square root function isn't defined for negative numbers in the real number system, but once you jump into the complex number system, the possibilities open up. It's like stepping into a whole new mathematical universe where numbers can do things you never imagined.

So, there you have it—just a few interesting tidbits about squares and square roots that I stumbled upon while brushing up on Algebra. Math can be pretty cool when you take the time to explore it!
