# [05AB1E (legacy)](https://github.com/Adriandmen/05AB1E/blob/fb4a2ce2bce6660e1a680a74dd61b72c945e6c3b/docs/info.txt), 7 + 22 = 29 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)

### Polar to Cartesian (7 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)):

    .¾¹.½‚*

Loose inputs in the order \$\phi,r\$; outputs as a pair \$[x,y]\$.

[Try it online](https://tio.run/##MzBNTDJM/f9f79C@Qzv1Du191DBL6/9/XQM9S2NLU3MuEz0jYzNjIwA) or [verify all test cases](https://tio.run/##MzBNTDJM/V9Waa@k8KhtkoKSfWVQwqGV//UO7Tu0Tu/Q3kcNs7T@6/yPjtY10LM0tjQ11zHRMzI2MzaK1QELGZkbG@iYGhgYAPmGOiDSSMcUSBromVuYmhjoGOgZxsYCAA).

### Cartesian to Polar ([22 bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)):

    nOtI`’£×.aÇâ2(ÿ,ÿ)’.E‚

Input as a pair in the order \$[x,y]\$; outputs as a pair \$[r,\phi]\$.

[Try it online](https://tio.run/##MzBNTDJM/f8/z7/EM@FRw8xDiw9P10s83H54kZHG4f06h/drAgX1XB81zPr/P9pIz1RH11jPxCgWAA) or [verify all test cases](https://tio.run/##MzBNTDJM/V9Waa@k8KhtkoKSfeX/PP@SyoRHDTMPLT48XS/xcPvhRUYah/frHN6vCRTUc33UMOu/zv/oaCM9Ux1dYz0To1idaGMDAwMdXRMgCeQY6IBIXSM9AwsDc2MdEz1TEzMTS5CEnoG5gbmhDpSOjQUA).

**Explanation:**

<!-- language-all: lang-python -->

    .¾      # Calculate the cosine of the first (implicit) input ϕ
      ¹.½   # Also push the sine of the first input ϕ
         ‚  # Pair them together
          * # Multiply them to the second (implicit) input r
            # (after which the pair is output implicitly as result)

Although 05AB1E does have tangent, sine, and cosine builtins, it lacks arctan; arcsin; and arccos builtins (both with 1 or 2 arguments). So we'll use a Python eval for it instead (hence the use of the legacy version of 05AB1E)†:

    n       # Get the square of the values in the (implicit) input-pair [y,x]
     O      # Sum them together
      t     # Take the square root of that
    I       # Push the input-pair [x,y]
     `      # Pop and push both separated to the stack
      ’£×.aÇâ2(ÿ,ÿ)’
            # Push dictionary string "math.atan2(ÿ,ÿ)",
            # where the two `ÿ` are replaced with `y,x` respectively
       .E   # Evaluate and execute it as Python code
    ‚       # Pair it with the earlier calculated sqrt(y²+x²)
            # (after which it is output implicitly as result)

[See this 05AB1E tip of mine (section *How to use the dictionary?*)](https://codegolf.stackexchange.com/a/166851/52210) to understand why `’£×.aÇâ2(ÿ,ÿ)’` is `"math.atan2(ÿ,ÿ)"`.

† The new version of 05AB1E is possible as well, but `.E` is eval as Elixir instead of Python, in which case the `math.atan2(a,b)` would be `:math.atan2(a,b)`, which is 1 byte longer.