ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 11 Feb 2017 18:50:36 -0600defining multivariate piecewise functionhttp://ask.sagemath.org/question/36567/defining-multivariate-piecewise-function/I need to define some function like `f(x,y) = x * sin(y)/y if y != 0, x otherwise`, such that `f` can be differentiated. Is there a way to do so? Thanks!Sat, 11 Feb 2017 07:24:14 -0600http://ask.sagemath.org/question/36567/defining-multivariate-piecewise-function/Answer by paulmasson for <p>I need to define some function like <code>f(x,y) = x * sin(y)/y if y != 0, x otherwise</code>, such that <code>f</code> can be differentiated. Is there a way to do so? Thanks!</p>
http://ask.sagemath.org/question/36567/defining-multivariate-piecewise-function/?answer=36578#post-id-36578`piecewise` currently only supports a single variable, but in your case you could factor out the `x` and define
f(x,y) = x * piecewise([[(-oo,0), sin(y)/y], [[0,0], 1], [(0,oo), sin(y)/y]])
The square brackets around the origin denote a closed domain to ensure that point is included. Sat, 11 Feb 2017 18:50:36 -0600http://ask.sagemath.org/question/36567/defining-multivariate-piecewise-function/?answer=36578#post-id-36578