# Revision history [back]

Consider a system of linear equations with an absolute value:

%display typeset

var('x y a b')
f=[1+y-a*abs_symbolic(x)==x, b*x==y]; f


$\newcommand{\Bold}{\mathbf{#1}}\left[-a {\left| x \right|} + y + 1 = x, b x = y\right]$

We attempt to solve the system assuming $x>0$ and then $x<0$:

assume(x>0)

solve(f, [x, y])


$$\newcommand{\Bold}{\mathbf{#1}}\left[\left[x = \frac{1}{a - b + 1}, y = \frac{b}{a - b + 1}\right]\right]$$

# to avoid conflict with the previous assumption (use assumptions() to list all current symbolic assumptions)
forget()
assume(x<0)

solve(f, [x, y])


$$\newcommand{\Bold}{\mathbf{#1}}\left[\left[x = -\frac{1}{a + b - 1}, y = -\frac{b}{a + b - 1}\right]\right]$$

As you point out, there seems to be a bug if we do this straightforwardly:

forget()
solve(f, [x, y])


gives TypeError: cannot coerce arguments: no canonical coercion from <type 'list'> to Symbolic Ring.

Consider a system of linear equations with an absolute value:

%display typeset

var('x y a b')
f=[1+y-a*abs_symbolic(x)==x, b*x==y]; f


$\newcommand{\Bold}{\mathbf{#1}}\left[-a {\left| x \right|} + y + 1 = x, b x = y\right]$

We attempt to solve the system assuming $x>0$ and then $x<0$:

assume(x>0)

solve(f, [x, y])


$$\newcommand{\Bold}{\mathbf{#1}}\left[\left[x = \frac{1}{a - b + 1}, y = \frac{b}{a - b + 1}\right]\right]$$

# use forget() to avoid conflict with the previous assumption (use assumptions() to list see all current symbolic assumptions)
forget()
assume(x<0)

solve(f, [x, y])


$$\newcommand{\Bold}{\mathbf{#1}}\left[\left[x = -\frac{1}{a + b - 1}, y = -\frac{b}{a + b - 1}\right]\right]$$

As you point out, there seems to be a bug if we do this straightforwardly:

forget()
solve(f, [x, y])


gives TypeError: cannot coerce arguments: no canonical coercion from <type 'list'> to Symbolic Ring.

Consider a system of linear equations with an absolute value:

%display typeset
var('x y a b')
f=[1+y-a*abs_symbolic(x)==x, b*x==y]; f


$\newcommand{\Bold}{\mathbf{#1}}\left[-a {\left| x \right|} + y + 1 = x, b x = y\right]$

We attempt to solve the system assuming $x>0$ and then $x<0$:

assume(x>0)

solve(f, [x, y])


$$\newcommand{\Bold}{\mathbf{#1}}\left[\left[x = \frac{1}{a - b + 1}, y = \frac{b}{a - b + 1}\right]\right]$$

# use forget() to avoid conflict with the previous assumption (use assumptions() to see all current symbolic assumptions)
forget()
assume(x<0)

solve(f, [x, y])


$$\newcommand{\Bold}{\mathbf{#1}}\left[\left[x = -\frac{1}{a + b - 1}, y = -\frac{b}{a + b - 1}\right]\right]$$

As you point out, there seems to be a bug if we do this straightforwardly:

forget()
solve(f, [x, y])


gives TypeError: cannot coerce arguments: no canonical coercion from <type 'list'> to Symbolic Ring.