playground ^_^

146 days ago by maksbotan

x = var('x') 
       
f = cos(x)**2-sin(x) 
       
d = diff(f) 
       
       
-2*sin(x)*cos(x) - cos(x)
-2*sin(x)*cos(x) - cos(x)
zeros = solve([d==0], x) 
       
points = [] for n in xrange(-2, 2): a = pi/2 + 2*pi*n b = f(x=a) points.append(point((a,b))) 
       
plot([f]+points,(-5*pi,5*pi)) 
       
plot(lambda x: 1-cos(x)) 
       
 
       
plot([x+pi/2.0-cos(x), 1+sin(x), point((-pi/2.0, 0)), point((pi/2.0, 0))],(-2*pi,2*pi)) 
       
 
       
eq = 2*x**4-5*x**3-x**2+5*x+2 == 0 
       
eq 
       
\newcommand{\Bold}[1]{\mathbf{#1}}2 \, x^{4} - 5 \, x^{3} - x^{2} + 5 \, x + 2 = 0
\newcommand{\Bold}[1]{\mathbf{#1}}2 \, x^{4} - 5 \, x^{3} - x^{2} + 5 \, x + 2 = 0
solve([eq], x) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left[x = \left(-\frac{1}{2}\right), x = 2, x = -\frac{1}{2} \, \sqrt{5} + \frac{1}{2}, x = \frac{1}{2} \, \sqrt{5} + \frac{1}{2}\right]
\newcommand{\Bold}[1]{\mathbf{#1}}\left[x = \left(-\frac{1}{2}\right), x = 2, x = -\frac{1}{2} \, \sqrt{5} + \frac{1}{2}, x = \frac{1}{2} \, \sqrt{5} + \frac{1}{2}\right]
f = 2*x**2-2*x-2 
       
       
\newcommand{\Bold}[1]{\mathbf{#1}}2 \, x^{2} - 2 \, x - 2
\newcommand{\Bold}[1]{\mathbf{#1}}2 \, x^{2} - 2 \, x - 2
solve(f, x) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left[x = -\frac{1}{2} \, \sqrt{5} + \frac{1}{2}, x = \frac{1}{2} \, \sqrt{5} + \frac{1}{2}\right]
\newcommand{\Bold}[1]{\mathbf{#1}}\left[x = -\frac{1}{2} \, \sqrt{5} + \frac{1}{2}, x = \frac{1}{2} \, \sqrt{5} + \frac{1}{2}\right]
f = 5-x/2+sqrt(33-3*x) 
       
solve(f > 0, x) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left[\left[2 \, \sqrt{-x + 11} \sqrt{3} - x + 10 > 0\right]\right]
\newcommand{\Bold}[1]{\mathbf{#1}}\left[\left[2 \, \sqrt{-x + 11} \sqrt{3} - x + 10 > 0\right]\right]
solve(33-3*x > (x/2-5)**2, x) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left[\left[x > -4 \, \sqrt{3} + 4, x < 4 \, \sqrt{3} + 4\right]\right]
\newcommand{\Bold}[1]{\mathbf{#1}}\left[\left[x > -4 \, \sqrt{3} + 4, x < 4 \, \sqrt{3} + 4\right]\right]
solve(-x**2+8*x+32 > 0, x) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left[\left[x > -4 \, \sqrt{3} + 4, x < 4 \, \sqrt{3} + 4\right]\right]
\newcommand{\Bold}[1]{\mathbf{#1}}\left[\left[x > -4 \, \sqrt{3} + 4, x < 4 \, \sqrt{3} + 4\right]\right]
y = var('y') 
       
solve([(x+4)*(2/y+1/y^2)==9, x+10-3*(y+2)==4], (x, y)) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left[\left[x = \left(-1\right), y = \left(-\frac{1}{3}\right)\right], \left[x = 12, y = 4\right]\right]
\newcommand{\Bold}[1]{\mathbf{#1}}\left[\left[x = \left(-1\right), y = \left(-\frac{1}{3}\right)\right], \left[x = 12, y = 4\right]\right]
solve([(x+4)*(2/y+1/y^2)==9, x==3*y], (x, y)) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left[\left[x = \left(-1\right), y = \left(-\frac{1}{3}\right)\right], \left[x = 12, y = 4\right]\right]
\newcommand{\Bold}[1]{\mathbf{#1}}\left[\left[x = \left(-1\right), y = \left(-\frac{1}{3}\right)\right], \left[x = 12, y = 4\right]\right]
solve([3*y^2-11*y-4], y) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left[y = \left(-\frac{1}{3}\right), y = 4\right]
\newcommand{\Bold}[1]{\mathbf{#1}}\left[y = \left(-\frac{1}{3}\right), y = 4\right]
a, b, c, d = var('a b c d') 
       
e1 = not ((b and not c) xor (not (a and d))) 
       
e2 = not ((a and not c) xor (b and not d)) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}{\rm True}
\newcommand{\Bold}[1]{\mathbf{#1}}{\rm True}
e3 = not ((a and d) xor (b and c)) 
       
solve([e1 == False, e2 == True, e3 == False], (a, b, c, d)) 
       
import sage.logic.propcalc as propcalc 
       
e1 = propcalc.formula("(b&~c)<->~(a&d)") 
       
e2 = propcalc.formula("(a&~c)<->(b&~d)") 
       
Traceback (click to the left of this block for traceback)
...
__SAGE__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_13.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZTEgPSBwcm9wY2FsYy5mb3JtdWxhKCIoYiZ+Yyk8LT5+KGEmZCkiKQplMiA9IHByb3BjYWxjLmZvcm11bGEoIihhJn5jKTwtPjwiKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpHL4W6H/___code___.py", line 3, in <module>
    exec compile(u'e2 = propcalc.formula("(a&~c)<-><")
  File "", line 1, in <module>
    
  File "/sagenb/sage_install/sage-4.7/local/lib/python2.6/site-packages/sage/logic/propcalc.py", line 183, in formula
    parse_tree, vars_order = logicparser.parse(s)
  File "/sagenb/sage_install/sage-4.7/local/lib/python2.6/site-packages/sage/logic/logicparser.py", line 39, in parse
    toks, vars_order = tokenize(s)
  File "/sagenb/sage_install/sage-4.7/local/lib/python2.6/site-packages/sage/logic/logicparser.py", line 72, in tokenize
    elif(s[i:i + 2] == '->'):
KeyboardInterrupt
__SAGE__
e3 = propcalc.formula("(a&d)<->(b&c)")