Homework 11

CHE 116: Numerical Methods and Statistics

4/12/2018


Homework Requirements:

  1. Write all equations in $\LaTeX$
  2. Simplify all expressions
  3. Put comments in your Python code
  4. Explain or show your work
  5. Follow the academic honesty guidelines in the syllabus

Answer each using Python and Markdown. First, state what type of optimization (2 points), the number of dimensions (1 point), if it's convex (1 points), and if there are bounds or constraints (2 points). Next, write out any constraints or rearrangements of equations in Markdown. For example, if you use root finding you should write out the expression for which you're finding roots (e.g., $x^2 = 4$ becomes $x^2 - 4 = 0$). Solve the problem ( 6 points) and then graph your solution (4 points). You must make a graph showing a graph of the equation and the otpimum point for each problem 16 points per problem. You must also print your numerical answer.

1.

Solve the following equation

$$ \sin x = \sqrt{x} \ln x $$

2.

Find the minimum value for this expression:

$$ x^4 - x^2 - x $$

3.

Find the positive root for this expression. Specify bounds in your call to the optimization function

$$ \frac{x^3(1 - x)}{x^2 - x + 2} = -\frac{1}{10} $$

4.

Take $p$ to be a probability. Find the maximum value for the following expression:

$$ p^{8} (1 - p)^{2} $$

5.

Minimize the following problem where $x$ and $y$ are bounded to lie between $-\pi$ and $\pi$.

$$ \cos 3.1x \sin 5.2y + \frac{(x + y - 2)^2}{250} $$

The following snippet will plot the function in 3D

import numpy as np
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt

def fxn_5(x, y):
    return 2 * np.cos(3.1 * x) * np.sin(5.2 * y) + (x + y - 2)**2 / 250
x = np.linspace(- np.pi, np.pi, 100)
y = np.linspace(-np.pi, np.pi, 100)
xx, yy = np.meshgrid(x, y, sparse=True)

z = fxn_5(xx, yy)

plt.contourf(x,y,z, cmap=cm.plasma)
plt.colorbar()
plt.show()

6.

Maximize the following equation subject to the following constraints $x_0 > 0$, $x_1 > 0$, $ x_0 + x_1 = 1$. You do not need to plot this.

$$ f(x_0, x_1) = e^{-(x_0 - 4)^2}e^{-(x_1 + 2)^2} $$

7.

Solve the following system of equations. Remember that if there are multiple solutions, it is non-convex. You do not need to plot this problem

$$ xy - z = 1 $$$$ x + z = -2 $$$$ x^2 -y + z = 3 $$