# Algebra Introduction

This section introduces the basic concepts of algebra, including variables, constants, and functions

## Functions

A function is a rule that takes one or more inputs and produces a single output. For example, the function $$f(x) = x + 1$$ takes a single input $$x$$, adds one to it, and produces a single output. In algebra, functions are written using symbols and formulas. For example, the function $$f(x) = x + 1$$ can be written as $$f:x \rightarrow x + 1$$. The input to a function is called the argument or input variable. The output is called the value or output variable.

Functions are often written using the following notation:

$y = f(x)$

The notation above is read as “$$y$$ equals $$f$$ of $$x$$” or “$$y$$ is a function of $$x$$”. The notation above is useful because it allows us to define a function without specifying its name. For example, we can define a function $$f$$ as follows:

$f(x) = x^2$

We can then use the function $$f$$ to compute the square of any number. For example, $$f(2) = 2^2 = 4$$ and $$f(3) = 3^2 = 9$$.

$\begin{split} \mathrm{f}(x) = \sqrt{x + {6}} \\ \mathrm{f}(6) = \sqrt{10 + {6}} \\ \mathrm{f}(6) = 4.0 \end{split}$
$\begin{split} \begin{gathered} f(x)=\frac{x-3}{x+2} \\ f(3)=\frac{3-3}{3+2}=\frac{0}{5}=0 \end{gathered} \end{split}$

### Domain and Range of a Function

The domain of a function is the set of all possible inputs to the function. The range of a function is the set of all possible outputs of the function. For example, the function $$f(x) = x^2$$ has a domain of all real numbers and a range of all non-negative real numbers. The domain of a function is often written as $$D(f)$$ and the range is often written as $$R(f)$$.

$\begin{split} y = f(x) \\ y = x^2 \end{split}$
import seaborn as sb

func = lambda x: x ** 2

x = [-1,-2,-3, -4, 1, 2, 3, 4]
y = [func(i) for i in x]

sb.lineplot(x=x, y=y)

<Axes: >


### Piecewise Functions

A piecewise function is a function that is defined by multiple sub-functions, each sub-function applying to a different interval of the main function’s domain. For example, the function $$f(x) = |x|$$ is defined by two sub-functions:

$\begin{split} f(x) = \begin{cases} x & \text{if } x \geq 0 \\ -x & \text{if } x < 0 \end{cases}\end{split}$

## Expoents

An exponent is a number that indicates how many times a base number is multiplied by itself. For example, $$2^3$$ is the same as $$2 \times 2 \times 2$$ and $$2^4$$ is the same as $$2 \times 2 \times 2 \times 2$$. The number $$2$$ is called the base and the number $$3$$ is called the exponent. Exponents are often written using the following notation:

$2^3 = 2 \times 2 \times 2 = 8$

The notation above is read as “two to the power of three” or “two cubed”.

### Negative Exponents

A negative exponent indicates that the base number should be divided by itself a certain number of times. For example, $$2^{-3}$$ is the same as $$\frac{1}{2^3}$$ and $$2^{-4}$$ is the same as $$\frac{1}{2^4}$$. The number $$2$$ is called the base and the number $$-3$$ is called the exponent. Negative exponents are often written using the following notation:

$2^{-3} = \frac{1}{2^3} = \frac{1}{8}$

The notation above is read as “two to the power of negative three” or “two to the power of minus three”.

### Fractional Exponents

A fractional exponent indicates that the base number should be multiplied by itself a certain number of times. For example, $$2^{\frac{1}{2}}$$ is the same as $$\sqrt{2}$$ and $$2^{\frac{1}{3}}$$ is the same as $$\sqrt[3]{2}$$. The number $$2$$ is called the base and the number $$\frac{1}{2}$$ is called the exponent. Fractional exponents are often written using the following notation:

$2^{\frac{1}{2}} = \sqrt{2} = 1.414213562373095$

The notation above is read as “two to the power of one half” or “two to the power of one over two”.

## Logarithms

A logarithm is the inverse of an exponent. For example, the logarithm of $$2^3$$ is $$3$$. The logarithm of a number $$x$$ to the base $$b$$ is written as $$\log_b(x)$$. For example, $$\log_2(8) = 3$$ because $$2^3 = 8$$.

### Common Logarithms

The common logarithm of a number $$x$$ is the logarithm of $$x$$ to the base $$10$$. The common logarithm of $$x$$ is written as $$\log(x)$$. For example, $$\log(100) = 2$$ because $$10^2 = 100$$.

### Natural Logarithms

The natural logarithm of a number $$x$$ is the logarithm of $$x$$ to the base $$e$$. The natural logarithm of $$x$$ is written as $$\ln(x)$$. For example, $$\ln(100) = 4.60517$$ because $$e^{4.60517} = 100$$.

## Polynomials

A polynomial is an expression consisting of variables and coefficients, that involves only the operations of addition, subtraction, multiplication, and non-negative integer exponents.

For example, $$x^2 + 2x + 1$$ is a polynomial because it consists of the variables $$x$$ and the coefficients $$1$$ and $$2$$.

The degree of a polynomial is the highest degree of its terms. For example, the polynomial $$x^2 + 2x + 1$$ has a degree of $$2$$ because its highest degree term is $$x^2$$.

## Proof by Induction

A proof by induction consists of two cases. The first, the base case, proves the statement for n = 0 without assuming any knowledge of other cases. The second case, the induction step, proves that if the statement holds for any given case n = k, then it must also hold for the next case n = k + 1. These two steps establish that the statement holds for every natural number n.