# Rescaling list with negative entries using limits with same absolute value

Suppose I have a list of both positive and negative numbers:

list = {3, 0, -4, 15, 0.006, -1}


I want to rescale the function over the range $[-1, 1]$. However, simply inputting

rescList = Rescale[list, {Min@list, Max@list}, {-1, 1}]


would not give the desired result:

{-0.263158, -0.578947, -1., 1., -0.578316, -0.684211}


The values 15 and -4 would be equidistant in this scaling. Plus, positive values would become negative.

A working solution would be to find the maximum in absolute value and rescale with respect to that:

absMax = Max[Abs@list];
rescList = Rescale[list, {-absMax, absMax}, {-1, 1}]


But I was wondering if a solution is possible without this intermediate step (and, of course, without making the code too bulky by, say, something like rescList = Rescale[list, {-Max[Abs@list], Max[Abs@list]}, {-1, 1}]).

Your apparent target, rescList, is equivalent to:

list / Max@Abs@list


This can be symbolically derived from Rescale

Rescale[a, {-m, m}, {-1, 1}]

a/m


Also equivalent:

Normalize[list, Max@*Abs]

Rescale[Abs@list]*Sign[list]

Normalize[list, Norm[#, ∞] &]  (* thanks to J. M. *)

• Thank you, I still can't believe how I hadn't thought about just dividing by the max value. Anyway, I guess my question was more about "removing" the need for Max@Abs inside the code (to make it look better?). But I guess it's not really necessary. – Enzo Jul 26 '17 at 12:47
• @Enzo I'm sorry if this answer isn't satisfying. I'm not really sure what you're seeking. I added a form that uses Rescale and does away with Max, in case that is of some interest to you. I don't see how you can eliminate Abs in a non-contrived way as that seems intrinsic to your definition. – Mr.Wizard Jul 26 '17 at 12:56
• I wasn't criticizing your answer, I'm sorry if I gave that impression. In fact, it is exactly what I was looking for. My "issue" with Max and Abs was a purely aesthetical one, I was hoping for, maybe, some Rescale argument for that (Something like, for example, Rescale[x, Absolute] which I just made up). Just my mind wandering about, I'm afraid. – Enzo Jul 26 '17 at 13:07
• @Enzo Ah, I see, no problem. :-) – Mr.Wizard Jul 26 '17 at 13:08
• Normalize[list, Norm[#, ∞] &] ought to work as well. – J. M. will be back soon Jul 26 '17 at 13:16