I have a problem when I try to separate the components of a 
multidimensional function. Example:

Given the 2D function of a 2D argument:
f(x) = [sqrt(x[1]), 2*x[2]]

I want to split it into two separate functions which are the components of 
the original 2D function. I thought that the obvious solution was:

f1(x) = f(x)[1]
f2(x) = f(x)[2]

The second function merely doubles the second component of its argument, as 
it should:
f2([2, 3])
--> 6.0

But the functions don't turn out to be completely decoupled: let's see what 
happens when we do

f2([-2, 3])
--> ERROR: DomainError
 in f2 at none:1

Even though the second function doesn't do sqrt and doesn't even depend on 
the first component of the argument, the first component of the original 
function is still checked and obviously returns an error. 

How do I decouple a 2D function?

Reply via email to