Add rounding to maxmin route

This commit is contained in:
tsb1995 2019-12-20 13:45:04 -08:00
parent bb0af12cfb
commit 98f76f0cd3
4 changed files with 6 additions and 6 deletions

Binary file not shown.

8
app.py
View File

@ -117,8 +117,8 @@ def maxmin():
# Get input from form # Get input from form
f = request.form.get("function") f = request.form.get("function")
lb = sympify(request.form.get("lowerbound")) lb = round(sympify(request.form.get("lowerbound")), 3)
ub = sympify(request.form.get("upperbound")) ub = round(sympify(request.form.get("upperbound")), 3)
# Setup our symbols for SymPy # Setup our symbols for SymPy
f = setup_symbols(f) f = setup_symbols(f)
@ -126,7 +126,7 @@ def maxmin():
# Get Derivative, solve for real solutions, update candidates list # Get Derivative, solve for real solutions, update candidates list
fprime = f.diff(x) fprime = f.diff(x)
solutions = list() solutions = list()
solutions.append(f.subs(x,0)) solutions.append(round(f.subs(x,0), 3))
candidates = list() candidates = list()
for solution in solutions: for solution in solutions:
candidates.append(solution) candidates.append(solution)
@ -136,7 +136,7 @@ def maxmin():
# Fill values list with solutions # Fill values list with solutions
values = list() values = list()
for candidate in candidates: for candidate in candidates:
temp = f.subs(x, candidate) temp = round(f.subs(x, candidate), 3)
values.append(temp) values.append(temp)
# Find max/min of values # Find max/min of values