I'm writing a piece of code and I want to simplify a bunch of if/else statements.(adsbygoogle = window.adsbygoogle || []).push({});

I needf:{-1,1}x{-1,1}-->{1,2,3,4}with

f(1,-1)=1

f(1,1)=2

f(-1,1)=3

f(-1,-1)=4

Can anyone think of a mathematical function that will give me the desired output?

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# If possible, I'd like a function f(i,j)=k defined as follows

Loading...

Similar Threads - possible function defined | Date |
---|---|

I Map possible values of a set with a condition to the naturals | Mar 5, 2018 |

B The number of possible combinations with a constraint | Jan 29, 2018 |

I Is long division for a non-polynomic function possible? | Mar 4, 2016 |

Possible function y=f(x) if data points are given. | May 26, 2013 |

Possible to evaluate the gamma function analytically? | Nov 22, 2003 |

**Physics Forums - The Fusion of Science and Community**