# Solutions

## Question 1

> `1`. Simplify the following expressions:

> $\frac{3}{\sqrt{3}}$:


```python
import sympy as sym

expression = sym.S(3) / sym.sqrt(3)
sym.simplify(expression)
```




$\displaystyle \sqrt{3}$



> $\frac{2 ^ {78}}{2 ^ {12}2^{-32}}$:


```python
sym.S(2) ** 78 / (sym.S(2) ** 12 * sym.S(2) ** (-32))
```




$\displaystyle 316912650057057350374175801344$



> $8^0$:


```python
sym.S(8) ** 0
```




$\displaystyle 1$



> $a^4b^{-2}+a^{3}b^{2}+a^{4}b^0$:


```python
a = sym.Symbol("a")
b = sym.Symbol("b")
sym.factor(a ** 4 * b ** (-2) + a ** 3 * b ** 2 + a ** 4 * b ** 0)
```




$\displaystyle \frac{a^{3} \left(a b^{2} + a + b^{4}\right)}{b^{2}}$



## Question 2

> `2`. Solve the following equations:

> $x + 3 = -1$:


```python
x = sym.Symbol("x")
equation = sym.Eq(x + 3, -1)
sym.solveset(equation, x)
```




$\displaystyle \left\{-4\right\}$



> $3 x ^ 2 - 2 x = 5$:


```python
equation = sym.Eq(3 * x ** 2 - 2 * x, 5)
sym.solveset(equation, x)
```




$\displaystyle \left\{-1, \frac{5}{3}\right\}$



> $x (x - 1) (x + 3) = 0$:


```python
equation = sym.Eq(x * (x - 1) * (x + 3), 0)
sym.solveset(equation, x)
```




$\displaystyle \left\{-3, 0, 1\right\}$



> $4 x ^3 + 7x - 24 = 1$:


```python
equation = sym.Eq(4 * x ** 3 + 7 * x - 24, 1)
sym.solveset(equation, x)
```




$\displaystyle \left\{- \frac{7}{12 \sqrt[3]{\frac{25}{8} + \frac{\sqrt{51654}}{72}}} + \sqrt[3]{\frac{25}{8} + \frac{\sqrt{51654}}{72}}, - \frac{\sqrt[3]{\frac{25}{8} + \frac{\sqrt{51654}}{72}}}{2} + \frac{7}{24 \sqrt[3]{\frac{25}{8} + \frac{\sqrt{51654}}{72}}} + i \left(\frac{7 \sqrt{3}}{24 \sqrt[3]{\frac{25}{8} + \frac{\sqrt{51654}}{72}}} + \frac{\sqrt{3} \sqrt[3]{\frac{25}{8} + \frac{\sqrt{51654}}{72}}}{2}\right), - \frac{\sqrt[3]{\frac{25}{8} + \frac{\sqrt{51654}}{72}}}{2} + \frac{7}{24 \sqrt[3]{\frac{25}{8} + \frac{\sqrt{51654}}{72}}} + i \left(- \frac{\sqrt{3} \sqrt[3]{\frac{25}{8} + \frac{\sqrt{51654}}{72}}}{2} - \frac{7 \sqrt{3}}{24 \sqrt[3]{\frac{25}{8} + \frac{\sqrt{51654}}{72}}}\right)\right\}$



## Question 3

> `3`. Consider the equation: $x ^ 2 + 4 - y = \frac{1}{y}$:

> Find the solution to this equation for $x$.


```python
y = sym.Symbol("y")
equation = sym.Eq(x ** 2 + 4 - y, 1 / y)
solution = sym.solveset(equation, x)
solution
```




$\displaystyle \left\{- \sqrt{\frac{y^{2} - 4 y + 1}{y}}, \sqrt{\frac{y^{2} - 4 y + 1}{y}}\right\}$



> Obtain the specific solution when $y = 5$. Do this in two ways:
> substitute the value in to your equation and substitute the value in to
> your solution.


```python
solution.subs({y: 5})
```




$\displaystyle \left\{- \frac{\sqrt{30}}{5}, \frac{\sqrt{30}}{5}\right\}$




```python
solution = sym.solveset(equation.subs({y: 5}), x)
solution
```




$\displaystyle \left\{- \frac{\sqrt{30}}{5}, \frac{\sqrt{30}}{5}\right\}$



## Question 4

> `4`. Consider the quadratic: $f(x)=4x ^ 2 + 16x + 25$:

> Calculate the discriminant of the quadratic equation $4x ^ 2 + 16x + 25 =
> 0$. What does this tell us about the solutions to the equation? What
> does this tell us about the graph of $f(x)$?


```python
quadratic = 4 * x ** 2 + 16 * x + 25
sym.discriminant(quadratic)
```




$\displaystyle -144$



 
This is negative so we know that the equation does not have any real solutions and
hence the graph does not cross the x-axis. 
Since the coefficient of $x^2$ is positive it means that the graph is above 
the $y=0$ line.


> By completing the square, show that the minimum point of $f(x)$ is
> $\left(-2, 9\right)$


```python
a, b, c = sym.Symbol("a"), sym.Symbol("b"), sym.Symbol("c")
completed_square = a * (x - b) ** 2 + c
sym.expand(completed_square)
```




$\displaystyle a b^{2} - 2 a b x + a x^{2} + c$



This gives $a=4$.


```python
completed_square = completed_square.subs({a: 4})
sym.expand(completed_square)
```




$\displaystyle 4 b^{2} - 8 b x + c + 4 x^{2}$



Comparing the coefficients of $x$ we have the equation:

$$
  - 8 b = 16
$$


```python
equation = sym.Eq(-8 * b, 16)
sym.solveset(equation, b)
```




$\displaystyle \left\{-2\right\}$



Substituting:


```python
completed_square = completed_square.subs({b: -2})
sym.expand(completed_square)
```




$\displaystyle c + 4 x^{2} + 16 x + 16$



Comparing the coefficients of $x^0$ this gives:

$$c+16=25$$


```python
equation = sym.Eq(c + 16, 25)
sym.solveset(equation, c)
```




$\displaystyle \left\{9\right\}$




```python
completed_square = completed_square.subs({c: 9})
completed_square
```




$\displaystyle 4 \left(x + 2\right)^{2} + 9$



The lowest value of $f(x)$ is for $x=-2$ which gives: $f(-2)=9$ as expected.

## Question 5

> `5`. Consider the quadratic: $f(x)=-3x ^ 2 + 24x - 97$:

> Calculate the discriminant of the quadratic equation $-3x ^ 2 + 24x - 97 =
> 0$. What does this tell us about the solutions to the equation? What
> does this tell us about the graph of $f(x)$?


```python
quadratic = -3 * x ** 2 + 24 * x - 97
sym.discriminant(quadratic)
```




$\displaystyle -588$



This is negative so we know that the equation does not have any real solutions and
hence the graph does not cross the x-axis. 
Since the coefficient of $x^2$ is negative it means that the graph is below 
the $y=0$ line.


> By completing the square, show that the maximum point of $f(x)$ is
> $\left(4, -49\right)$


```python
a, b, c = sym.Symbol("a"), sym.Symbol("b"), sym.Symbol("c")
completed_square = a * (x - b) ** 2 + c
sym.expand(completed_square)
```




$\displaystyle a b^{2} - 2 a b x + a x^{2} + c$



This gives $a=-3$.


```python
completed_square = completed_square.subs({a: -3})
sym.expand(completed_square)
```




$\displaystyle - 3 b^{2} + 6 b x + c - 3 x^{2}$



Comparing the coefficients of $x$ we have the equation:

$$
  6 b = 24
$$


```python
equation = sym.Eq(6 * b, 24)
sym.solveset(equation, b)
```




$\displaystyle \left\{4\right\}$



Substituting:


```python
completed_square = completed_square.subs({b: 4})
sym.expand(completed_square)
```




$\displaystyle c - 3 x^{2} + 24 x - 48$



Comparing the coefficients of $x^0$ this gives:

$$c-48=-97$$


```python
equation = sym.Eq(c - 48, -97)
sym.solveset(equation, c)
```




$\displaystyle \left\{-49\right\}$




```python
completed_square = completed_square.subs({c: -49})
completed_square
```




$\displaystyle - 3 \left(x - 4\right)^{2} - 49$



The highest value of $f(x)$ is for $x=4$ which gives: $f(4)=-49$ as expected.

`6`. Consider the function $f(x) = x^ 2 + a x + b$.

> Given that $f(0) = 0$ and $f(3) = 0$ obtain the values of $a$ and $b$.

Substituting 0 in to $f$ gives:


```python
expression = x ** 2 + a * x + b
expression.subs({x: 0})
```




$\displaystyle b$



This implies that $b=0$. Substituting back in to the expression:


```python
expression = expression.subs({b: 0})
expression
```




$\displaystyle a x + x^{2}$



Substituting $x=3$ in to this expression gives:


```python
expression.subs({x: 3})
```




$\displaystyle 3 a + 9$



This gives the equation:

$$
    3 a + 9 = 0
$$


```python
sym.solveset(expression.subs({x: 3}), a)
```




$\displaystyle \left\{-3\right\}$



Our expression is thus:


```python
expression = expression.subs({a: -3})
expression
```




$\displaystyle x^{2} - 3 x$



> By completing the square confirm that graph of $f(x)$ has a line of symmetry
> at $x=\frac{3}{2}$


```python
completed_square = a * (x - b) ** 2 + c
sym.expand(completed_square)
```




$\displaystyle a b^{2} - 2 a b x + a x^{2} + c$



We see that $a=1$ and. Substituting:


```python
completed_square = completed_square.subs({a: 1})
sym.expand(completed_square)
```




$\displaystyle b^{2} - 2 b x + c + x^{2}$



This gives:

$$
    -2b=-3
$$


```python
equation = sym.Eq(-2 * b, -3)
sym.solveset(equation, b)
```




$\displaystyle \left\{\frac{3}{2}\right\}$



Substituting:


```python
completed_square = completed_square.subs({b: sym.S(3) / 2})
sym.expand(completed_square)
```




$\displaystyle c + x^{2} - 3 x + \frac{9}{4}$



Which gives:

$$
    c + 9 / 4 = 0
$$


```python
equation = sym.Eq(c + sym.S(9) / 4, 0)
sym.solveset(equation, c)
```




$\displaystyle \left\{- \frac{9}{4}\right\}$



Substituting:


```python
completed_square = completed_square.subs({c: -sym.S(9) / 4})
completed_square
```




$\displaystyle \left(x - \frac{3}{2}\right)^{2} - \frac{9}{4}$



Thus $x=3/2$ is a line of symmetry.

ec7a3ed76462fa4cf7c00d56927a67f0cd965058
ipynb
Jupyter Notebook
book/tools-for-mathematics/02-algebra/solutions/.main.md.bcp.ipynb
daffidwilde/pfm
dcf38faccee3c212c8394c36f4c093a2916d283e
MIT
book/tools-for-mathematics/02-algebra/solutions/.main.md.bcp.ipynb
daffidwilde/pfm
dcf38faccee3c212c8394c36f4c093a2916d283e
MIT
book/tools-for-mathematics/02-algebra/solutions/.main.md.bcp.ipynb
daffidwilde/pfm
dcf38faccee3c212c8394c36f4c093a2916d283e
MIT
Qwen/Qwen-72B
1. YES
2. YES