ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 18 Dec 2012 15:28:15 -0600Does a subtraction symbolic expression actually exist?https://ask.sagemath.org/question/9398/does-a-subtraction-symbolic-expression-actually-exist/Can someone please give me an example of a symbolic expression in sage of the subtraction variety? (by subtraction variety I mean using the subtraction operator)
Precisely: how can I create an object `o` of type `sage.symbolic.expression.Expression` such that `o.operator()` is `operator.sub`? It seems that subtraction expressions are always converted to additions.
For example:
sage: x = var('x')
sage: (x-1).operator()
<built-in function add>
rmp251Tue, 18 Dec 2012 15:28:15 -0600https://ask.sagemath.org/question/9398/subtract two data tableshttps://ask.sagemath.org/question/9218/subtract-two-data-tables/ ta1=[[1,1],[2,2],[3,3]]
ta2=[[1,1],[2,1],[3,1]]
ta1_j=[]
ta2_j=[]
for i,j in ta1:
ta1_j.append(j)
for i,j in ta2:
ta2_j.append(j)
ta3_j=[]
for i,j in zip(ta1_j,ta2_j):
ta3_j.append(i-j)
ta3_i=[]
for i,j in ta1:
ta3_i.append(i)
ta3=zip(ta3_i,ta3_j)
ta3
I want to subtract table2 from table1 in such way that X stays the same and only Y values are subtracted.
The above code works for me, but is there a nicer, better and easier way to subtract tables ?
b0f00narchWed, 08 Aug 2012 02:36:06 -0500https://ask.sagemath.org/question/9218/bool gives another unexpected resulthttps://ask.sagemath.org/question/8175/bool-gives-another-unexpected-result/Here is the output
sage: var('c,u,v',domain=RR);assume(v>0,u>0,c>u,c>v);
(c, u, v)
sage: assumptions()
[v > 0, u > 0, c > u, c > v]
sage: bool(c^2 - u*v >= 0)
False
sage: bool(c^2 - u^2 >= 0)
True
sage: bool(c^2 - v^2 >= 0)
True
I don't see how c^2 - v*u can not be larger than or equal to zero. Why does this happen? Is there a workaround?omoplataMon, 20 Jun 2011 15:23:48 -0500https://ask.sagemath.org/question/8175/