Add rounding to maxmin route
This commit is contained in:
parent
bb0af12cfb
commit
98f76f0cd3
Binary file not shown.
8
app.py
8
app.py
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,4 @@
|
||||||
<p>For $f(x) = {{ value }}$</p>
|
<p>For $f(x) = {{ value }}$</p>
|
||||||
<p>$f'(x) = {{ fprime }}$</p>
|
<p>$f'(x) = {{ fprime }}$</p>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -61,4 +61,4 @@
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue