I want to create a list of values from a piecewise function evaluated at points in a list. Is there a way to do this without using loops?
For example
z2 = Piecewise[{{x + y^2,x>3}},0]
z = z2/.{x->{1,2,3,4,5}, y->{4,6,3,1,2}}
I would like this to return
{0,0,0,5,9}
i.e.
{0,0,0,4 + 1^2, 5 + 2^2}.
If the function is not Piecewise
this works as I expected (want).
I know I can loop over all the lists to do this, but I would like a more elegant solution if one exists.
z2[{x_, y_}] = Piecewise[{{x+y^2, x>3}}, 0]; z2/@Transpose[{{1,2,3,4,5},{4,6,3,1,2}}]]
which gives you{0, 0, 0, 5, 9}
$\endgroup$