sage exercise 2

110 days ago by AleGallardo

factor(1311) 
       
3 * 19 * 23
3 * 19 * 23
1311/2451 
       
23/43
23/43
f(x)=abs(x) 
       
f(-10) 
       
10
10
solve([f(x)<=3], x) 
       
#0: solve_rat_ineq(ineq=abs(x) <= 3)
[[x == 3], [x == -3], [-3 < x, x < 3]]
#0: solve_rat_ineq(ineq=abs(x) <= 3)
[[x == 3], [x == -3], [-3 < x, x < 3]]
factor (10989) 
       
3^3 * 11 * 37
3^3 * 11 * 37
factor (12177) 
       
3^3 * 11 * 41
3^3 * 11 * 41
10989/12 
       
37/41
37/41
g(x)=abs(x) 
       
g(-1)=([abs(x-3)+3],x) 
       
Traceback (click to the left of this block for traceback)
...
ValueError: The name "-_sage_const_1" is not a valid Python identifier.
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("ZygtMSk9KFthYnMoeC0zKSszXSx4KQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpuKN56F/___code___.py", line 3, in <module>
    exec compile(u'__tmp__=var("-_sage_const_1"); g = symbolic_expression(([abs(x-_sage_const_3 )+_sage_const_3 ],x)).function(-_sage_const_1)
  File "", line 1, in <module>
    
  File "var.pyx", line 108, in sage.calculus.var.var (sage/calculus/var.c:687)
  File "ring.pyx", line 521, in sage.symbolic.ring.SymbolicRing.var (sage/symbolic/ring.cpp:6342)
  File "ring.pyx", line 560, in sage.symbolic.ring.SymbolicRing.var (sage/symbolic/ring.cpp:6069)
ValueError: The name "-_sage_const_1" is not a valid Python identifier.
solve ([abs(x-3)+3>=5],x) 
       
#0: solve_rat_ineq(ineq=abs(x-3)+3 >= 5)
[[x == 5], [x == 1], [5 < x], [x < 1]]
#0: solve_rat_ineq(ineq=abs(x-3)+3 >= 5)
[[x == 5], [x == 1], [5 < x], [x < 1]]