# Limit of piecewise function

This exact question has been asked before (8 years ago, 2 years ago). So here goes, perhaps things have changed?

```
f(x) = piecewise([[(0,1),x],[[1,2],x/2]])
limit(f(x),x=1/2)
```

(Note that I'm not even looking at the point where the discontinuity occurs.)

I get the following error message

```
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/var/folders/mt/4xjm_x515mxdjkm49zmplt240000gq/T/ipykernel_84420/3847661288.py in <module>
----> 1 limit(f(x),x=Integer(1)/Integer(2))
/private/var/tmp/sage-9.6-current/local/var/lib/sage/venv-python3.10.3/lib/python3.10/site-packages/sage/calculus/calculus.py in limit(ex, dir, taylor, algorithm, **argv)
1409 if algorithm == 'maxima':
1410 if dir is None:
-> 1411 l = maxima.sr_limit(ex, v, a)
1412 elif dir in dir_plus:
1413 l = maxima.sr_limit(ex, v, a, 'plus')
/private/var/tmp/sage-9.6-current/local/var/lib/sage/venv-python3.10.3/lib/python3.10/site-packages/sage/interfaces/maxima_lib.py in sr_limit(self, expr, v, a, dir)
985 elif dir == "minus":
986 L.append(max_minus)
--> 987 return max_to_sr(maxima_eval(([max_limit], L)))
988 except RuntimeError as error:
989 s = str(error)
/private/var/tmp/sage-9.6-current/local/var/lib/sage/venv-python3.10.3/lib/python3.10/site-packages/sage/interfaces/maxima_lib.py in max_to_sr(expr)
1708 op=max_op_dict[op_max]
1709 max_args=cdr(expr)
-> 1710 args=[max_to_sr(a) for a in max_args]
1711 return op(*args)
1712 elif expr.symbolp():
/private/var/tmp/sage-9.6-current/local/var/lib/sage/venv-python3.10.3/lib/python3.10/site-packages/sage/interfaces/maxima_lib.py in <listcomp>(.0)
1708 op=max_op_dict[op_max]
1709 max_args=cdr(expr)
-> 1710 args=[max_to_sr(a) for a in max_args]
1711 return op(*args)
1712 elif expr.symbolp():
/private/var/tmp/sage-9.6-current/local/var/lib/sage/venv-python3.10.3/lib/python3.10/site-packages/sage/interfaces/maxima_lib.py in max_to_sr(expr)
1709 max_args=cdr(expr)
1710 args=[max_to_sr(a) for a in max_args]
-> 1711 return op(*args)
1712 elif expr.symbolp():
1713 if not(expr in max_sym_dict):
TypeError: PiecewiseFunction.__call__() takes 2 positional arguments but 3 were given
```

Correct conversion of piecewise functions to maxima is not implemented.

And there is a bug in libgiac conversion