Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

poly zeros

51 views

Use this code for the half of the packet called Analyzing and Solving Polynomial Equations. All you need to do is edit line 1 with each new function on the left side of the equation. When you are done with all exercises, hide all the code and upload to Moodle.

f(x)=(x^3-2*x^2-3*x+6) show('the function is ',f(x)) zeros=solve(f(x)==0,x) zeros=[zeros[i].rhs() for i in [0..len(zeros)-1]] show('the zeros are ',zeros) p=plot(f(x),xmin=min(zeros)-1,xmax=max(zeros)+1) intercepts=[[i,0] for i in zeros if imag_part(i)==0] p+=list_plot(intercepts,size=30,color='red') p
the function is x32x23x+6\displaystyle x^{3} - 2 \, x^{2} - 3 \, x + 6
the zeros are [3\displaystyle -\sqrt{3}, 3\displaystyle \sqrt{3}, 2\displaystyle 2]
f(x)=(x^6-2*x^4-4*x^2+8) show('the function is ',f(x)) zeros=solve(f(x)==0,x) zeros=[zeros[i].rhs() for i in [0..len(zeros)-1]] show('the zeros are ',zeros) intercepts=[[i,0] for i in zeros if imag_part(i)==0] p=plot(f(x),xmin=min(zeros)-1,xmax=max(zeros)+1) intercepts=[[i,0] for i in zeros if imag_part(i)==0] p+=list_plot(intercepts,size=30,color='red') p
the function is x62x44x2+8\displaystyle x^{6} - 2 \, x^{4} - 4 \, x^{2} + 8
the zeros are [2\displaystyle -\sqrt{2}, 2\displaystyle \sqrt{2}, i2\displaystyle -i \, \sqrt{2}, i2\displaystyle i \, \sqrt{2}]
f(x)=(x^6+5*x^4-4*x^2-20) show('the function is ',f(x)) zeros=solve(f(x)==0,x) zeros=[zeros[i].rhs() for i in [0..len(zeros)-1]] show('the zeros are ',zeros) p=plot(f(x),xmin=min(zeros)-1,xmax=max(zeros)+1) intercepts=[[i,0] for i in zeros if imag_part(i)==0] p+=list_plot(intercepts,size=30,color='red') p
the function is x6+5x44x220\displaystyle x^{6} + 5 \, x^{4} - 4 \, x^{2} - 20
the zeros are [i5\displaystyle -i \, \sqrt{5}, i5\displaystyle i \, \sqrt{5}, i2\displaystyle -i \, \sqrt{2}, i2\displaystyle i \, \sqrt{2}, 2\displaystyle -\sqrt{2}, 2\displaystyle \sqrt{2}]
Error in lines 6-6 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute flags=compile_flags) in namespace, locals File "", line 1, in <module> File "/ext/sage/sage-8.3_1804/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 567, in wrapper return func(*args, **options) File "/ext/sage/sage-8.3_1804/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1941, in plot G = funcs.plot(*args, **original_opts) File "sage/symbolic/expression.pyx", line 12032, in sage.symbolic.expression.Expression.plot (build/cythonized/sage/symbolic/expression.cpp:68738) return plot(f, *args, **kwds) File "/ext/sage/sage-8.3_1804/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 567, in wrapper return func(*args, **options) File "/ext/sage/sage-8.3_1804/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1956, in plot G = _plot(funcs, (xmin, xmax), **kwds) File "/ext/sage/sage-8.3_1804/local/lib/python2.7/site-packages/sage/plot/plot.py", line 2077, in _plot funcs, ranges = setup_for_eval_on_grid(funcs, [xrange], options['plot_points']) File "/ext/sage/sage-8.3_1804/local/lib/python2.7/site-packages/sage/plot/misc.py", line 121, in setup_for_eval_on_grid ranges = [[float(z) for z in r] for r in ranges] File "sage/symbolic/expression.pyx", line 1428, in sage.symbolic.expression.Expression.__float__ (build/cythonized/sage/symbolic/expression.cpp:11836) raise TypeError("unable to simplify to float approximation") TypeError: unable to simplify to float approximation
f(x)=(x^6+5*x^4-4*x^2-20) show('the function is ',f(x)) zeros=solve(f(x)==0,x) zeros=[zeros[i].rhs() for i in [0..len(zeros)-1]] show('the zeros are ',zeros) p=plot(f(x),xmin=min(zeros)-1,xmax=max(zeros)+1) intercepts=[[i,0] for i in zeros if imag_part(i)==0] p+=list_plot(intercepts,size=30,color='red') p
the function is x6+5x44x220\displaystyle x^{6} + 5 \, x^{4} - 4 \, x^{2} - 20
the zeros are [i5\displaystyle -i \, \sqrt{5}, i5\displaystyle i \, \sqrt{5}, i2\displaystyle -i \, \sqrt{2}, i2\displaystyle i \, \sqrt{2}, 2\displaystyle -\sqrt{2}, 2\displaystyle \sqrt{2}]
Error in lines 6-6 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute flags=compile_flags) in namespace, locals File "", line 1, in <module> File "/ext/sage/sage-8.3_1804/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 567, in wrapper return func(*args, **options) File "/ext/sage/sage-8.3_1804/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1941, in plot G = funcs.plot(*args, **original_opts) File "sage/symbolic/expression.pyx", line 12032, in sage.symbolic.expression.Expression.plot (build/cythonized/sage/symbolic/expression.cpp:68738) return plot(f, *args, **kwds) File "/ext/sage/sage-8.3_1804/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 567, in wrapper return func(*args, **options) File "/ext/sage/sage-8.3_1804/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1956, in plot G = _plot(funcs, (xmin, xmax), **kwds) File "/ext/sage/sage-8.3_1804/local/lib/python2.7/site-packages/sage/plot/plot.py", line 2077, in _plot funcs, ranges = setup_for_eval_on_grid(funcs, [xrange], options['plot_points']) File "/ext/sage/sage-8.3_1804/local/lib/python2.7/site-packages/sage/plot/misc.py", line 121, in setup_for_eval_on_grid ranges = [[float(z) for z in r] for r in ranges] File "sage/symbolic/expression.pyx", line 1428, in sage.symbolic.expression.Expression.__float__ (build/cythonized/sage/symbolic/expression.cpp:11836) raise TypeError("unable to simplify to float approximation") TypeError: unable to simplify to float approximation
the function is x826x4+25\displaystyle x^{8} - 26 \, x^{4} + 25
the zeros are [i\displaystyle i, 1\displaystyle -1, i\displaystyle -i, 1\displaystyle 1, i5\displaystyle i \, \sqrt{5}, 5\displaystyle -\sqrt{5}, i5\displaystyle -i \, \sqrt{5}, 5\displaystyle \sqrt{5}]
the function is x45x236\displaystyle x^{4} - 5 \, x^{2} - 36
the zeros are [2i\displaystyle -2 i, 2i\displaystyle 2 i, 3\displaystyle -3, 3\displaystyle 3]
the function is x3+3x214x20\displaystyle x^{3} + 3 \, x^{2} - 14 \, x - 20
the zeros are [5+1\displaystyle -\sqrt{5} + 1, 5+1\displaystyle \sqrt{5} + 1, 5\displaystyle -5]
the function is x32x2+3x6\displaystyle x^{3} - 2 \, x^{2} + 3 \, x - 6
the zeros are [i3\displaystyle -i \, \sqrt{3}, i3\displaystyle i \, \sqrt{3}, 2\displaystyle 2]
the function is x414x2+45\displaystyle x^{4} - 14 \, x^{2} + 45
the zeros are [5\displaystyle -\sqrt{5}, 5\displaystyle \sqrt{5}, 3\displaystyle -3, 3\displaystyle 3]
the function is x46x2+8\displaystyle x^{4} - 6 \, x^{2} + 8
the zeros are [2\displaystyle -\sqrt{2}, 2\displaystyle \sqrt{2}, 2\displaystyle -2, 2\displaystyle 2]
the function is x43x218\displaystyle x^{4} - 3 \, x^{2} - 18
the zeros are [i3\displaystyle -i \, \sqrt{3}, i3\displaystyle i \, \sqrt{3}, 6\displaystyle -\sqrt{6}, 6\displaystyle \sqrt{6}]
the function is x31\displaystyle x^{3} - 1
the zeros are [12i312\displaystyle \frac{1}{2} i \, \sqrt{3} - \frac{1}{2}, 12i312\displaystyle -\frac{1}{2} i \, \sqrt{3} - \frac{1}{2}, 1\displaystyle 1]
the function is x3+3x2x3\displaystyle x^{3} + 3 \, x^{2} - x - 3
the zeros are [1\displaystyle 1, 1\displaystyle -1, 3\displaystyle -3]
the function is x5+2x4+11x3+22x2+24x+48\displaystyle x^{5} + 2 \, x^{4} + 11 \, x^{3} + 22 \, x^{2} + 24 \, x + 48
the zeros are [2i2\displaystyle -2 i \, \sqrt{2}, 2i2\displaystyle 2 i \, \sqrt{2}, 2\displaystyle -2, i3\displaystyle -i \, \sqrt{3}, i3\displaystyle i \, \sqrt{3}]
the function is x32x23x+6\displaystyle x^{3} - 2 \, x^{2} - 3 \, x + 6
the zeros are [3\displaystyle -\sqrt{3}, 3\displaystyle \sqrt{3}, 2\displaystyle 2]
the function is x62x44x2+8\displaystyle x^{6} - 2 \, x^{4} - 4 \, x^{2} + 8
the zeros are [2\displaystyle -\sqrt{2}, 2\displaystyle \sqrt{2}, i2\displaystyle -i \, \sqrt{2}, i2\displaystyle i \, \sqrt{2}]