I have a list of 3 pairs of integers, for each pair i
I want to replace the one having the smallest absolute value with xi
and the other one with its sign. Like this:
In: {{-5, 1}, {7, -3}, {4, 4}}
Out: {{-1, x2}, {1, x3}, {x4, 1}} (*for the last one {1, x4} would be fine as well*)
My attempt is this, I fear it's a bit too convoluted:
list = {{-5,1},{7,-3},{4,4}}
list = MapThread[#1 /. #2 -> #3 &, {list, If[Total[#] > 0, Min[#], Max[#]] & /@ list, {x1, x2, x3}}];
list = Map[If[NumericQ[#], Sign[#], #] &, list, {2}];
I'm using this in a fractal related problem, so what's the most optimized way?
x1, x2, x3
normalized and feeded to NMinimize. They tell in which half plane to look for the next circle $\endgroup$