add working button links
This commit is contained in:
parent
0073144e3d
commit
6f3626a013
Binary file not shown.
192
app.py
192
app.py
|
|
@ -1,9 +1,199 @@
|
|||
from flask import Flask, render_template
|
||||
from flask import Flask, render_template, request, redirect
|
||||
from sympy import *
|
||||
|
||||
from helpers import apology, login_required, lookup, usd
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/')
|
||||
def hello():
|
||||
return render_template('index.html')
|
||||
|
||||
@app.route('/differentiation', methods=['GET', 'POST'])
|
||||
def differentiation():
|
||||
if request.method == "POST":
|
||||
# Check if inputs were given
|
||||
if not request.form.get("function"):
|
||||
return apology("must provide a function", 400)
|
||||
f = request.form.get("function")
|
||||
x = symbols('x')
|
||||
f = sympify(f)
|
||||
|
||||
# Differentiate and return latex expressions
|
||||
fprime = latex(f.diff(x))
|
||||
value = latex(f)
|
||||
return render_template("differentiated.html", value=value, fprime=fprime)
|
||||
else:
|
||||
return render_template("differentiation.html")
|
||||
|
||||
@app.route("/integration", methods=["GET", "POST"])
|
||||
def integration():
|
||||
if request.method == "POST":
|
||||
# Check if inputs were given
|
||||
if not request.form.get("function"):
|
||||
return apology("must provide a function", 400)
|
||||
|
||||
# Integrate and return latex expressions
|
||||
f = request.form.get("function")
|
||||
x = symbols('x')
|
||||
f = sympify(f)
|
||||
fintegral = latex(f.integrate(x))
|
||||
value = latex(f)
|
||||
return render_template("integrated.html", value=value, fintegral=fintegral)
|
||||
else:
|
||||
return render_template("integration.html")
|
||||
|
||||
@app.route("/riemann", methods = ["GET", "POST"])
|
||||
def riemann():
|
||||
if request.method == "POST":
|
||||
# Check if inputs were given
|
||||
if not request.form.get("function"):
|
||||
return apology("must provide a function", 400)
|
||||
if not request.form.get("lowerbound"):
|
||||
return apology("must provide a lower bound", 400)
|
||||
if not request.form.get("upperbound"):
|
||||
return apology("must provide an upper bound", 400)
|
||||
if not request.form.get("subintervals"):
|
||||
return apology("must provide a number of subintervals", 400)
|
||||
if not request.form.get("sumtype"):
|
||||
return apology("must choose left or right", 400)
|
||||
|
||||
# Get inputs, check for validity and sympify
|
||||
f = request.form.get("function")
|
||||
sumtype = request.form.get("sumtype")
|
||||
lb = int(request.form.get("lowerbound"))
|
||||
ub = int(request.form.get("upperbound"))
|
||||
si = int(request.form.get("subintervals"))
|
||||
x = symbols('x')
|
||||
f = sympify(f)
|
||||
dx = (ub - lb) / si
|
||||
value = latex(f)
|
||||
|
||||
# Run through Riemann Sum algorithm, creatings lists for display
|
||||
# of inputs, outputs, and areas (their products)
|
||||
inputs = list()
|
||||
if sumtype == "1":
|
||||
for i in range(0, si):
|
||||
inputs.append(dx * (i))
|
||||
if sumtype == "2":
|
||||
for i in range(0, si):
|
||||
inputs.append(dx * (i + 1))
|
||||
outputs = list()
|
||||
for input in inputs:
|
||||
temp = f.subs(x, input)
|
||||
outputs.append(temp)
|
||||
rectangles = list()
|
||||
for output in outputs:
|
||||
temp = output * dx
|
||||
rectangles.append(temp)
|
||||
result = sum(rectangles)
|
||||
|
||||
# Choose template based on left or right sum
|
||||
if sumtype == "1":
|
||||
return render_template("summed.html", value=value, sumtype=sumtype, lb=lb, ub=ub, si=si, dx=dx,
|
||||
inputs=inputs, outputs=outputs, rectangles=rectangles, result=result)
|
||||
else:
|
||||
return render_template("rightSummed.html", value=value, sumtype=sumtype, lb=lb, ub=ub, si=si, dx=dx,
|
||||
inputs=inputs, outputs=outputs, rectangles=rectangles, result=result)
|
||||
else:
|
||||
return render_template("riemann.html")
|
||||
|
||||
@app.route("/maxmin", methods=["GET", "POST"])
|
||||
def maxmin():
|
||||
if request.method == "POST":
|
||||
# Check if inputs were given
|
||||
if not request.form.get("function"):
|
||||
return apology("must provide a function", 400)
|
||||
if not request.form.get("lowerbound"):
|
||||
return apology("must provide a lower bound", 400)
|
||||
if not request.form.get("upperbound"):
|
||||
return apology("must provide an upper bound", 400)
|
||||
|
||||
# Get input from form
|
||||
f = request.form.get("function")
|
||||
lb = sympify(request.form.get("lowerbound"))
|
||||
ub = sympify(request.form.get("upperbound"))
|
||||
|
||||
# Prep input for numpy / sympy
|
||||
x = symbols('x')
|
||||
f = sympify(f)
|
||||
|
||||
# Get Derivative, solve for real solutions, update candidates list
|
||||
fprime = f.diff(x)
|
||||
solutions = list()
|
||||
solutions.append(f.subs(x,0))
|
||||
candidates = list()
|
||||
for solution in solutions:
|
||||
candidates.append(solution)
|
||||
candidates.append(lb)
|
||||
candidates.append(ub)
|
||||
|
||||
# Fill values list with solutions
|
||||
values = list()
|
||||
for candidate in candidates:
|
||||
temp = f.subs(x, candidate)
|
||||
values.append(temp)
|
||||
|
||||
# Find max/min of values
|
||||
maximum = max(values)
|
||||
newvar = min(values)
|
||||
|
||||
# Turn all into latex
|
||||
value = latex(f)
|
||||
fprime = latex(fprime)
|
||||
for i, solution in enumerate(solutions):
|
||||
solutions[i] = latex(solution)
|
||||
return render_template("optimized.html", value=value, fprime=fprime, solutions=solutions, lb=lb, ub=ub,
|
||||
candidates=candidates, newvar=newvar, values=values, maximum=maximum)
|
||||
else:
|
||||
return render_template("maxmin.html")
|
||||
|
||||
@app.route("/aprox", methods=["GET", "POST"])
|
||||
def aprox():
|
||||
if request.method == "POST":
|
||||
# Check if inputs were given
|
||||
if not request.form.get("function"):
|
||||
return apology("must provide a function", 400)
|
||||
if not request.form.get("easy"):
|
||||
return apology("must provide an easy value", 400)
|
||||
if not request.form.get("hard"):
|
||||
return apology("must provide a difficult value", 400)
|
||||
|
||||
# Get inputs, sympify them, and check to see if valid
|
||||
f = request.form.get("function")
|
||||
a = request.form.get("easy")
|
||||
h = request.form.get("hard")
|
||||
x = symbols('x')
|
||||
f = sympify(f)
|
||||
a = sympify(a)
|
||||
h = sympify(h)
|
||||
if not a.is_number:
|
||||
return apology("easy value must be a number", 400)
|
||||
if not h.is_number:
|
||||
return apology("difficult value must be a number", 400)
|
||||
|
||||
# Run through Linearization algorithm
|
||||
fprime = f.diff(x)
|
||||
fa = f.subs(x, a)
|
||||
fprimea = fprime.subs(x, a)
|
||||
lh = fa + fprimea*(float(h)-float(a))
|
||||
|
||||
# Convert to latex for MathJax reading
|
||||
value = latex(f)
|
||||
fprime = latex(fprime)
|
||||
fa = latex(fa)
|
||||
lh = latex(lh)
|
||||
|
||||
return render_template("aproxd.html", value=value, fprime=fprime, a=a, h=h, fa=fa, fprimea=fprimea, lh=lh)
|
||||
else:
|
||||
return render_template("aprox.html")
|
||||
|
||||
def errorhandler(e):
|
||||
"""Handle error"""
|
||||
if not isinstance(e, HTTPException):
|
||||
e = InternalServerError()
|
||||
return apology(e.name, e.code)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
import requests
|
||||
import urllib.parse
|
||||
|
||||
from flask import redirect, render_template, request, session
|
||||
from functools import wraps
|
||||
|
||||
|
||||
def apology(message, code=400):
|
||||
"""Render message as an apology to user."""
|
||||
def escape(s):
|
||||
"""
|
||||
Escape special characters.
|
||||
|
||||
https://github.com/jacebrowning/memegen#special-characters
|
||||
"""
|
||||
for old, new in [("-", "--"), (" ", "-"), ("_", "__"), ("?", "~q"),
|
||||
("%", "~p"), ("#", "~h"), ("/", "~s"), ("\"", "''")]:
|
||||
s = s.replace(old, new)
|
||||
return s
|
||||
return render_template("apology.html", top=code, bottom=escape(message)), code
|
||||
|
||||
|
||||
def login_required(f):
|
||||
"""
|
||||
Decorate routes to require login.
|
||||
|
||||
http://flask.pocoo.org/docs/1.0/patterns/viewdecorators/
|
||||
"""
|
||||
@wraps(f)
|
||||
def decorated_function(*args, **kwargs):
|
||||
if session.get("user_id") is None:
|
||||
return redirect("/login")
|
||||
return f(*args, **kwargs)
|
||||
return decorated_function
|
||||
|
||||
|
||||
def lookup(symbol):
|
||||
"""Look up quote for symbol."""
|
||||
|
||||
# Contact API
|
||||
try:
|
||||
response = requests.get(f"https://api.iextrading.com/1.0/stock/{urllib.parse.quote_plus(symbol)}/quote")
|
||||
response.raise_for_status()
|
||||
except requests.RequestException:
|
||||
return None
|
||||
|
||||
# Parse response
|
||||
try:
|
||||
quote = response.json()
|
||||
return {
|
||||
"name": quote["companyName"],
|
||||
"price": float(quote["latestPrice"]),
|
||||
"symbol": quote["symbol"]
|
||||
}
|
||||
except (KeyError, TypeError, ValueError):
|
||||
return None
|
||||
|
||||
|
||||
def usd(value):
|
||||
"""Format value as USD."""
|
||||
return f"${value:,.2f}"
|
||||
115
requirements.txt
115
requirements.txt
|
|
@ -1,7 +1,120 @@
|
|||
absl-py==0.8.1
|
||||
astor==0.8.0
|
||||
attrs==19.2.0
|
||||
audioread==2.1.8
|
||||
Babel==2.7.0
|
||||
backcall==0.1.0
|
||||
bleach==3.1.0
|
||||
blinker==1.4
|
||||
certifi==2019.9.11
|
||||
cffi==1.13.0
|
||||
chardet==3.0.4
|
||||
Click==7.0
|
||||
colorama==0.4.1
|
||||
cs50==4.0.3
|
||||
cycler==0.10.0
|
||||
decorator==4.4.0
|
||||
defusedxml==0.6.0
|
||||
entrypoints==0.3
|
||||
Flask==1.1.1
|
||||
gunicorn==20.0.4
|
||||
Flask-BabelEx==0.9.3
|
||||
Flask-Login==0.4.1
|
||||
Flask-Mail==0.9.1
|
||||
Flask-Principal==0.4.0
|
||||
Flask-Security==3.0.0
|
||||
Flask-Session==0.3.1
|
||||
Flask-SQLAlchemy==2.4.1
|
||||
Flask-WTF==0.14.2
|
||||
gast==0.2.2
|
||||
google-pasta==0.1.7
|
||||
grpcio==1.24.1
|
||||
h5py==2.10.0
|
||||
idna==2.8
|
||||
importlib-metadata==0.23
|
||||
ipykernel==5.1.2
|
||||
ipython==7.8.0
|
||||
ipython-genutils==0.2.0
|
||||
ipywidgets==7.5.1
|
||||
itsdangerous==1.1.0
|
||||
jedi==0.15.1
|
||||
Jinja2==2.10.3
|
||||
joblib==0.14.0
|
||||
jsonschema==3.1.1
|
||||
jupyter==1.0.0
|
||||
jupyter-client==5.3.4
|
||||
jupyter-console==6.0.0
|
||||
jupyter-core==4.6.0
|
||||
kaggle==1.5.6
|
||||
Keras==2.3.1
|
||||
Keras-Applications==1.0.8
|
||||
Keras-Preprocessing==1.1.0
|
||||
kiwisolver==1.1.0
|
||||
latex2sympy==1.0.3
|
||||
librosa==0.7.1
|
||||
llvmlite==0.30.0
|
||||
Markdown==3.1.1
|
||||
MarkupSafe==1.1.1
|
||||
matplotlib==3.1.1
|
||||
mistune==0.8.4
|
||||
more-itertools==7.2.0
|
||||
mpmath==1.1.0
|
||||
nbconvert==5.6.0
|
||||
nbformat==4.4.0
|
||||
notebook==6.0.1
|
||||
numba==0.46.0
|
||||
numpy==1.17.2
|
||||
opt-einsum==3.1.0
|
||||
pandas==0.25.1
|
||||
pandocfilters==1.4.2
|
||||
parso==0.5.1
|
||||
passlib==1.7.2
|
||||
pickleshare==0.7.5
|
||||
prometheus-client==0.7.1
|
||||
prompt-toolkit==2.0.10
|
||||
protobuf==3.10.0
|
||||
pycparser==2.19
|
||||
Pygments==2.4.2
|
||||
pyparsing==2.4.2
|
||||
pyrsistent==0.15.4
|
||||
python-dateutil==2.8.0
|
||||
python-slugify==4.0.0
|
||||
python-speech-features==0.6
|
||||
pytz==2019.3
|
||||
pywin32==225
|
||||
pywinpty==0.5.5
|
||||
PyYAML==5.1.2
|
||||
pyzmq==18.1.0
|
||||
qtconsole==4.5.5
|
||||
requests==2.22.0
|
||||
resampy==0.2.2
|
||||
scikit-learn==0.21.3
|
||||
scipy==1.3.1
|
||||
Send2Trash==1.5.0
|
||||
six==1.12.0
|
||||
sklearn==0.0
|
||||
sklearn-pandas==1.8.0
|
||||
SoundFile==0.10.2
|
||||
speaklater==1.3
|
||||
SQLAlchemy==1.3.10
|
||||
sqlparse==0.3.0
|
||||
sympy==1.4
|
||||
tensorboard==2.0.0
|
||||
tensorflow==2.0.0
|
||||
tensorflow-estimator==2.0.0
|
||||
termcolor==1.1.0
|
||||
terminado==0.8.2
|
||||
testpath==0.4.2
|
||||
text-unidecode==1.3
|
||||
tornado==6.0.3
|
||||
tqdm==4.36.1
|
||||
traitlets==4.3.3
|
||||
urllib3==1.24.3
|
||||
virtualenv==16.7.8
|
||||
wcwidth==0.1.7
|
||||
webencodings==0.5.1
|
||||
Werkzeug==0.16.0
|
||||
widgetsnbextension==3.5.1
|
||||
wrapt==1.11.2
|
||||
WTForms==2.2.1
|
||||
xlrd==1.2.0
|
||||
zipp==0.6.0
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title %}
|
||||
Differentiation
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<p>Function you would like to Derive: </p>
|
||||
<p>Type math here: <span id="math-field"></span></p>
|
||||
<form action="/differentiation" method="post">
|
||||
<div class = "form-group">
|
||||
<input autocomplete="off" autofocus class="form-control" name="function" placeholder="Function" type="hidden" id="function" />
|
||||
</div>
|
||||
<p id="jp">Your Input Will Appear Here</p>
|
||||
<button class="btn btn-primary" type="submit" id="btn">Derive</button>
|
||||
</form>
|
||||
<script>
|
||||
let value = $("#function").val();
|
||||
$(document).ready(function(){
|
||||
$('#function').on('input', function() {
|
||||
let testvalue = $('#function').val();
|
||||
$('#jp').html("$f(x) = "+testvalue+"$");
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var mathFieldSpan = document.getElementById('math-field');
|
||||
var latexSpan = document.getElementById('latex');
|
||||
|
||||
var MQ = MathQuill.getInterface(2); // for backcompat
|
||||
var mathField = MQ.MathField(mathFieldSpan, {
|
||||
spaceBehavesLikeTab: true, // configurable
|
||||
handlers: {
|
||||
edit: function() { // useful event handlers
|
||||
latexSpan.textContent = mathField.latex(); // simple API
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var formInput = document.getElementById("function")
|
||||
$(document).ready(function(){
|
||||
$('#btn').click(function (evt) {
|
||||
document.getElementById("function").value = mathField.latex();
|
||||
})
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title %}
|
||||
Apology
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<img alt="{{ top }}" class="border" src="http://memegen.link/custom/{{ top | urlencode }}/{{ bottom | urlencode }}.jpg?alt=https://i.imgur.com/CsCgN7Ll.png" title="{{ top }}">
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title %}
|
||||
Approximation
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<span>Function you would like to Approximate:</span>
|
||||
<form action="/aprox" method="post">
|
||||
<div class = "form-group">
|
||||
<input autocomplete="off" autofocus class="form-control" name="function" placeholder="Function" type="text" id="function">
|
||||
</div>
|
||||
<p id="jp">Your Input Will Appear Here</p>
|
||||
<p>To create the Linearization of f at a, L(x) = f(a) + f'(a)(x-a), we need an easy to calculate value, a,
|
||||
and a difficult to find value for x</p>
|
||||
<div class = "form-group">
|
||||
<input autocomplete="off" autofocus class="form-control" name="easy" placeholder="Easy Value a" type="text" id="easy">
|
||||
<input autocomplete="off" autofocus class="form-control" name="hard" placeholder="Difficult Value for x" type="text" id="hard">
|
||||
</div>
|
||||
<button class="btn btn-primary" type="submit">Approximate</button>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
let value = $("#function").val();
|
||||
$(document).ready(function(){
|
||||
$('#function').on('input', function() {
|
||||
let testvalue = $('#function').val();
|
||||
$('#jp').html("$f(x) = "+testvalue+"$");
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title %}
|
||||
Differentiated
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div>
|
||||
<p>Your function is $f(x) = {{ value }}$</p>
|
||||
<p>Your Linear Approximation of $f(x)$ at $x = {{ h }}$ is ${{ lh }}$</p>
|
||||
</div>
|
||||
<table class="table" action="optimized">
|
||||
<tbody>
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 1</td>
|
||||
<td>Setup L(x)</td>
|
||||
</tr>
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>$L(x) = f({{ a }}) + f'({{ a }})(x-{{ a }})$</td>
|
||||
</tr>
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 2</td>
|
||||
<td>Take the Derivative</td>
|
||||
</tr>
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>$f'(x) = {{ fprime }}$</td>
|
||||
</tr>
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 3</td>
|
||||
<td>Plug in values</td>
|
||||
</tr>
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>$f({{ a }}) = {{ fa }}$</td>
|
||||
</tr>
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>$f'({{ a }}) = {{ fprimea }}$</td>
|
||||
</tr>
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>$L(x) = {{ fa }} + [{{ fprimea }}(x - {{ a }})]$</td>
|
||||
</tr>
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 4</td>
|
||||
<td>Use our $L(x)$ to approximate $f({{ h }})$</td>
|
||||
</tr>
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>$L({{ h }}) = {{ fa }} + [{{ fprimea }}({{ h }} - {{ a }})]$</td>
|
||||
</tr>
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td> $= {{ lh }}$</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title %}
|
||||
Differentiated
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div>
|
||||
<p>For $f(x) = {{ value }}$</p>
|
||||
<p>$f'(x) = {{ fprime }}$</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title %}
|
||||
Differentiation
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<p>Function you would like to Derive: </p>
|
||||
<form action="/differentiation" method="post">
|
||||
<div class = "form-group">
|
||||
<input autocomplete="off" autofocus class="form-control" name="function" placeholder="Function" type="text" id="function">
|
||||
</div>
|
||||
<p id="jp">Your Input Will Appear Here</p>
|
||||
<button class="btn btn-primary" type="submit">Differentiate</button>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
let value = $("#function").val();
|
||||
$(document).ready(function(){
|
||||
$('#function').on('input', function() {
|
||||
let testvalue = $('#function').val();
|
||||
$('#jp').html("$f(x) = "+testvalue+"$");
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title %}
|
||||
Differentiation
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<p>Function you would like to Derive: </p>
|
||||
<form action="/differentiation" method="post">
|
||||
<div class = "form-group">
|
||||
<input autocomplete="off" autofocus class="form-control" name="function" placeholder="Function" type="text" id="function">
|
||||
</div>
|
||||
<p id="jp">Your Input Will Appear Here</p>
|
||||
<button class="btn btn-primary" type="submit">Differentiate</button>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
let value = $("#function").val();
|
||||
$(document).ready(function(){
|
||||
$('#function').on('input', function() {
|
||||
let testvalue = $('#function').val();
|
||||
$('#jp').html("$f(x) = "+testvalue+"$");
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title %}
|
||||
Index
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<p>This is a website dedicated to making the lives of calculus students easier, if ever so slightly.</p>
|
||||
<P>All function inputs will be taken assuming 'x' as your variable. All other letters will be treated as constants</P>
|
||||
<p>That noted, you may enter terms for well known constants and they will likely be accounted for</p>
|
||||
<p>As an example you could enter the function $sin(\pi x)$ with the notation sin(pi*x)</p>
|
||||
<p>As a once struggling calculus student, I highly recommend this site be used either to check your work or as a tool
|
||||
to understand the steps behind those problems which you failed in solving alone</p>
|
||||
<p>Good luck!</p>
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title %}
|
||||
Integrated
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div>
|
||||
<p>Your Equation is: ${{ value }}$</p>
|
||||
<p>Your integral is: ${{ fintegral }}$</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title %}
|
||||
Integration
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<p>Function you would like to Integrate: </p>
|
||||
<form action="/integration" method="post">
|
||||
<div class = "form-group">
|
||||
<input autocomplete="off" autofocus class="form-control" name="function" placeholder="Function" type="text" id="function">
|
||||
</div>
|
||||
<p id="jp">Your Input Will Appear Here</p>
|
||||
<button class="btn btn-primary" type="submit">Integrate</button>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
let value = $("#function").val();
|
||||
$(document).ready(function(){
|
||||
$('#function').on('input', function() {
|
||||
let testvalue = $('#function').val();
|
||||
$('#jp').html("$f(x) = "+testvalue+"$");
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -43,7 +43,6 @@
|
|||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbar">
|
||||
{% if session.user_id %}
|
||||
<ul class="navbar-nav mr-auto mt-2">
|
||||
<li class="nav-item"><a class="nav-link" href="/differentiation">Differentiation</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/integration">Integration</a></li>
|
||||
|
|
@ -51,15 +50,14 @@
|
|||
<li class="nav-item"><a class="nav-link" href="/aprox">Linearization</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/riemann">Riemann</a></li>
|
||||
</ul>
|
||||
<ul class="navbar-nav ml-auto mt-2">
|
||||
<!-- <ul class="navbar-nav ml-auto mt-2">
|
||||
<li class="nav-item"><a class="nav-link" href="/logout">Log Out</a></li>
|
||||
</ul>
|
||||
{% else %}
|
||||
<ul class="navbar-nav ml-auto mt-2">
|
||||
</ul> -->
|
||||
|
||||
<!-- <ul class="navbar-nav ml-auto mt-2">
|
||||
<li class="nav-item"><a class="nav-link" href="/register">Register</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/login">Log In</a></li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
</ul> -->
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,84 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<!-- Required meta tags -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
|
||||
<!-- documentation at http://getbootstrap.com/docs/4.1/, alternative themes at https://bootswatch.com/ -->
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- https://favicon.io/emoji-favicons/money-mouth-face/ -->
|
||||
<link href="/static/favicon.ico" rel="icon">
|
||||
|
||||
<link href="/static/styles.css" rel="stylesheet">
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- MathJax Integration and configuration -->
|
||||
<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-MML-AM_CHTML' async></script>
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
|
||||
</script>
|
||||
|
||||
<!-- MathQuill Link -->
|
||||
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/mathquill/0.10.1/mathquill.min.css">`
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathquill/0.10.1/mathquill.min.js" type="text/javascript"></script>
|
||||
<script>var MQ = MathQuill.getInterface(2);</script>
|
||||
|
||||
<title>C$50 Math: {% block title %}{% endblock %}</title>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-expand-md navbar-light bg-light border">
|
||||
<a class="navbar-brand" href="/"><span class="blue">C</span><span class="red">$</span><span class="yellow">5</span><span class="green">0</span> <span class="red">Math</span></a>
|
||||
<button aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation" class="navbar-toggler" data-target="#navbar" data-toggle="collapse" type="button">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbar">
|
||||
{% if session.user_id %}
|
||||
<ul class="navbar-nav mr-auto mt-2">
|
||||
<li class="nav-item"><a class="nav-link" href="/differentiation">Differentiation</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/integration">Integration</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/maxmin">Max/Min</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/aprox">Linearization</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/riemann">Riemann</a></li>
|
||||
</ul>
|
||||
<ul class="navbar-nav ml-auto mt-2">
|
||||
<li class="nav-item"><a class="nav-link" href="/logout">Log Out</a></li>
|
||||
</ul>
|
||||
{% else %}
|
||||
<ul class="navbar-nav ml-auto mt-2">
|
||||
<li class="nav-item"><a class="nav-link" href="/register">Register</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/login">Log In</a></li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{% if get_flashed_messages() %}
|
||||
<header>
|
||||
<div class="alert alert-primary border text-center" role="alert">
|
||||
{{ get_flashed_messages() | join(" ") }}
|
||||
</div>
|
||||
</header>
|
||||
{% endif %}
|
||||
|
||||
<main class="container p-5">
|
||||
{% block main %}{% endblock %}
|
||||
</main>
|
||||
|
||||
<footer class="small text-center text-muted">
|
||||
Huge thanks to the staff at Harvard's <a href="https://cs50.harvard.edu/college/">CS50</a>.
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title %}
|
||||
Log In
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<form action="/login" method="post">
|
||||
<div class="form-group">
|
||||
<input autocomplete="off" autofocus class="form-control" name="username" placeholder="Username" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="form-control" name="password" placeholder="Password" type="password">
|
||||
</div>
|
||||
<button class="btn btn-primary" type="submit">Log In</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title %}
|
||||
Max/Min
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<span>Function you would like to Max/Min:</span>
|
||||
<form action="/maxmin" method="post">
|
||||
<div class = "form-group">
|
||||
<input autocomplete="off" autofocus class="form-control" name="function" placeholder="Function" type="text" id="function">
|
||||
</div>
|
||||
<p id="jp">Your Input Will Appear Here</p>
|
||||
<div class = "form-group">
|
||||
<input autocomplete="off" autofocus class="form-control" name="lowerbound" placeholder="Lowerbound" type="text" id="lowerbound">
|
||||
<input autocomplete="off" autofocus class="form-control" name="upperbound" placeholder="Upperbound" type="text" id="upperbound">
|
||||
</div>
|
||||
<button class="btn btn-primary" type="submit">Optimize</button>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
let value = $("#function").val();
|
||||
$(document).ready(function(){
|
||||
$('#function').on('input', function() {
|
||||
let testvalue = $('#function').val();
|
||||
$('#jp').html("$f(x) = "+testvalue+"$");
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
|
||||
});
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title %}
|
||||
Optimized
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div>
|
||||
<p>Your function is $f(x) = {{ value }}$</p>
|
||||
<p>Your maximum value is ${{ maximum }}$ and your minimum value is ${{ newvar }}$</p>
|
||||
</div>
|
||||
<table class="table table-hover" action="optimized">
|
||||
<tbody>
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 1</td>
|
||||
<td>Take the Derivative</td>
|
||||
</tr>
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>$f'(x) = {{ fprime }}$</td>
|
||||
</tr>
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 2</td>
|
||||
<td>Set $f'(x) = 0$</td>
|
||||
</tr>
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>$0 = {{ fprime }}$</td>
|
||||
</tr>
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 3</td>
|
||||
<td>Solve for $x$:</td>
|
||||
</tr>
|
||||
{% for solution in solutions %}
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>$x = {{ solution }}$</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 4</td>
|
||||
<td>Plug solutions and endpoints into $f(x)$:</td>
|
||||
</tr>
|
||||
{% for candidate in candidates %}
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>$f({{ candidate }}) = {{values[loop.index - 1]}}$</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 5</td>
|
||||
<td>Grab the highest and lowest values</td>
|
||||
</tr>
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>Your maximum value is ${{ maximum }}$</td>
|
||||
</tr>
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>Your minimum value is ${{ newvar }}$</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title %}
|
||||
Register
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<form action="/register" method="post" id="form">
|
||||
<div class="form-group">
|
||||
<input autocomplete="off" autofocus class="form-control" name="username" placeholder="Username" id="username" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="form-control" name="password" placeholder="Password" type="password">
|
||||
</div>
|
||||
<span id="availability"></span>
|
||||
<div class="form-group">
|
||||
<input class="form-control" name="confirmation" placeholder="confirm" type="password">
|
||||
</div>
|
||||
<button class="btn btn-primary" type="submit" id="btn">Register</button>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
var username = document.getElementById("username");
|
||||
$(document).ready(function(){
|
||||
$('#btn').click(function (evt) {
|
||||
evt.preventDefault();
|
||||
$.get("/check", {username:username.value}, function(data){
|
||||
if (data == false){
|
||||
alert("Username is Taken")
|
||||
}
|
||||
else {
|
||||
$('#form').submit();
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title %}
|
||||
Riemann
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<span>Function you would like to integrate:</span>
|
||||
<form action="/riemann" method="post">
|
||||
<div class = "form-group">
|
||||
<input autocomplete="off" autofocus class="form-control" name="function" placeholder="Function" type="text" id="function">
|
||||
</div>
|
||||
<p id="jp">Your Input Will Appear Here</p>
|
||||
<span>Range of values (a,b):</span>
|
||||
<div class = "form-group">
|
||||
<input autocomplete="off" autofocus class="form-control" name="lowerbound" placeholder="Lowerbound a" type="text" id="lowerbound">
|
||||
<input autocomplete="off" autofocus class="form-control" name="upperbound" placeholder="Upperbound b" type="text" id="upperbound">
|
||||
</div>
|
||||
<span>Amount of subintervals (how many rectangles?):</span>
|
||||
<div class="form-group">
|
||||
<input autocomplete="off" autofocus class="form-control" name="subintervals" placeholder="Subintervals" type="text" id="subintervals">
|
||||
</div>
|
||||
<div class="radio">
|
||||
<label><input type="radio" name="sumtype" checked value="1">Left Riemann Sum</label>
|
||||
</div>
|
||||
<div class="radio">
|
||||
<label><input type="radio" name="sumtype" value="2">Right Riemann Sum</label>
|
||||
</div>
|
||||
<button class="btn btn-primary" type="submit">Summation</button>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
let value = $("#function").val();
|
||||
$(document).ready(function(){
|
||||
$('#function').on('input', function() {
|
||||
let testvalue = $('#function').val();
|
||||
$('#jp').html("$f(x) = "+testvalue+"$");
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
|
||||
});
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title%}
|
||||
Summed
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<span>Approximating the integral of $f(x) = {{ value }}$ from ${{ lb }}$ to ${{ ub }}$ using ${{ si }}$ subintervals</span>
|
||||
<table class="table table-hover" action="optimized">
|
||||
<tbody>
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 1</td>
|
||||
<td>Calculate $\Delta x$</td>
|
||||
</tr>
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>$\Delta x = {{ dx }}$</td>
|
||||
</tr>
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 2</td>
|
||||
<td>Check values for $x_i$ (start at lowerbound a and add $\Delta x$ repeatedly)</td>
|
||||
</tr>
|
||||
{% for input in inputs %}
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>$f(x_{{ loop.index }}) = f({{ input }}) = {{ outputs[loop.index - 1] }}$</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 3</td>
|
||||
<td>Multiply $f(x_i)$ and $\Delta x$ for each subinterval</td>
|
||||
</tr>
|
||||
{% for rectangle in rectangles %}
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>$f(x_{{ loop.index}}) \Delta x = f({{ inputs[loop.index - 1]}})*{{ dx }} = {{ rectangle }}$</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 4</td>
|
||||
<td>Add up all products (rectangles) to get final approximation:</td>
|
||||
</tr>
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>The integral of $f(x) = {{ value }}$ from ${{ lb }}$ to ${{ ub }}$ is approximately equal to ${{ result }}$</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
{% extends "layout.html" %}
|
||||
|
||||
{% block title%}
|
||||
Summed
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<span>Approximating the integral of $f(x) = {{ value }}$ from ${{ lb }}$ to ${{ ub }}$ using ${{ si }}$ subintervals</span>
|
||||
<table class="table table-hover" action="optimized">
|
||||
<tbody>
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 1</td>
|
||||
<td>Calculate $\Delta x$</td>
|
||||
</tr>
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>$\Delta x = {{ dx }}$</td>
|
||||
</tr>
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 2</td>
|
||||
<td>Check values for $x_i$ (start at lowerbound a and add $\Delta x$ repeatedly)</td>
|
||||
</tr>
|
||||
{% for input in inputs %}
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>$f(x_{{ loop.index - 1 }}) = f({{ input }}) = {{ outputs[loop.index - 1] }}$</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 3</td>
|
||||
<td>Multiply $f(x_i)$ and $\Delta x$ for each subinterval</td>
|
||||
</tr>
|
||||
{% for rectangle in rectangles %}
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>$f(x_{{ loop.index - 1 }}) \Delta x = f({{ inputs[loop.index - 1]}})*{{ dx }} = {{ rectangle }}$</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr class="bg-dark text-white">
|
||||
<td>Step 4</td>
|
||||
<td>Add up all products (rectangles) to get final approximation:</td>
|
||||
</tr>
|
||||
<tr class="table-secondary">
|
||||
<td></td>
|
||||
<td>The integral of $f(x) = {{ value }}$ from ${{ lb }}$ to ${{ ub }}$ is approximately equal to ${{ result }}$</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
Loading…
Reference in New Issue