Repository: sympy/sympy

Issue:
octave/matlab codegen wrong for two argument zeta
`octave_code(zeta(x,n))` should give `zeta(n, x)`.

See: https://www.mathworks.com/help/symbolic/zeta.html

Discussion:

Patch:
diff --git a/sympy/printing/octave.py b/sympy/printing/octave.py
index b395d8c98e..79e93fada9 100644
--- a/sympy/printing/octave.py
+++ b/sympy/printing/octave.py
@@ -494,6 +494,14 @@ def _print_Piecewise(self, expr):
             return "\n".join(lines)
 
 
+    def _print_zeta(self, expr):
+        if len(expr.args) == 1:
+            return "zeta(%s)" % self._print(expr.args[0])
+        else:
+            # Matlab two argument zeta is not equivalent to SymPy's
+            return self._print_not_supported(expr)
+
+
     def indent_code(self, code):
         """Accepts a string of code or a list of code lines"""
 


Test patch:
diff --git a/sympy/printing/tests/test_octave.py b/sympy/printing/tests/test_octave.py
index a954675f6f..dd99fc5a4c 100644
--- a/sympy/printing/tests/test_octave.py
+++ b/sympy/printing/tests/test_octave.py
@@ -2,7 +2,7 @@
                         Tuple, Symbol)
 from sympy.core import EulerGamma, GoldenRatio, Catalan, Lambda, Mul, Pow
 from sympy.functions import (Piecewise, sqrt, ceiling, exp, sin, cos, LambertW,
-                             sinc, Max, Min, arg, im, re)
+                             sinc, Max, Min, arg, im, re, zeta)
 from sympy.utilities.pytest import raises
 from sympy.utilities.lambdify import implemented_function
 from sympy.matrices import (eye, Matrix, MatrixSymbol, Identity,
@@ -398,3 +398,8 @@ def test_MatrixElement_printing():
 
     F = C[0, 0].subs(C, A - B)
     assert mcode(F) == "(-B + A)(1, 1)"
+
+
+def test_zeta_printing_issue_14820():
+    assert octave_code(zeta(x)) == 'zeta(x)'
+    assert octave_code(zeta(x, y)) == '% Not supported in Octave:\n% zeta\nzeta(x, y)'