{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-04-16T00:12:35.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2026-04-16T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":45997,"title":"Evaluate the zeta function for complex arguments","description":"\u003chttps://www.mathworks.com/matlabcentral/cody/problems/45988 Cody Problem 45988\u003e involved computing the Riemann zeta function for real arguments greater than 1. Code that works for that problem can reveal the connection between pi and the values of the zeta function evaluated at positive even integers; this connection is explored in \u003chttps://www.mathworks.com/matlabcentral/cody/problems/45939-estimate-pi-from-certain-values-of-the-zeta-function Cody Problem 45939\u003e. However, to test the Riemann hypothesis--that all non-trivial zeros of the zeta function have a real part of 1/2, one needs to compute the zeta function for complex arguments.\r\n\r\nWrite a function to evaluate the zeta function for complex arguments.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 114px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 57px; transform-origin: 407px 57px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 84px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 42px; text-align: left; transform-origin: 384px 42px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/45988\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eCody Problem 45988\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 315.85px 7.8px; transform-origin: 315.85px 7.8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e involved computing the Riemann zeta function for real arguments greater than 1. Code that works for that problem can reveal the connection between \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003eπ\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 222.1px 7.8px; transform-origin: 222.1px 7.8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and the values of the zeta function evaluated at positive even integers; this connection is explored in\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.95px 7.8px; transform-origin: 1.95px 7.8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/45939-estimate-pi-from-certain-values-of-the-zeta-function\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eCody Problem 45939\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 217.433px 7.8px; transform-origin: 217.433px 7.8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. However, to test the Riemann hypothesis--that all non-trivial zeros of the zeta function have a real part of 1/2, one needs to compute the zeta function for complex arguments.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 213.017px 7.8px; transform-origin: 213.017px 7.8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function to evaluate the zeta function for complex arguments.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function z = zeta2(s)\r\n  z = f(s);\r\nend","test_suite":"%%\r\ns = 2;\r\nz_correct = pi^2/6;\r\nassert(abs(zeta2(s)-z_correct)/z_correct \u003c 1e-8)\r\n\r\n%%\r\ns = 1;\r\nassert(isinf(zeta2(s)))\r\n\r\n%%\r\ns = 1/2;\r\nz_correct = -1.460354508809587;\r\nassert(abs((zeta2(s)-z_correct)/z_correct) \u003c 1e-8)\r\n\r\n%%\r\ns = 0;\r\nz_correct = -0.5;\r\nassert(abs((zeta2(s)-z_correct)/z_correct) \u003c 1e-8)\r\n\r\n%%\r\ns = -1;\r\nz_correct = -1/12;\r\nassert(abs((zeta2(s)-z_correct)/z_correct) \u003c 1e-8)\r\n\r\n%%\r\ns = -2;\r\nz_correct = 0;\r\nassert(abs(zeta2(s)) \u003c 1e-12)\r\n\r\n%%\r\ns = 3+2*i;\r\nz_correct = 0.973041960418942 - 0.147695593000454i;\r\nassert(abs(real(zeta2(s))-real(z_correct))/real(z_correct) \u003c 1e-8) \r\nassert(abs((imag(zeta2(s))-imag(z_correct))/imag(z_correct)) \u003c 1e-8)\r\n\r\n%%\r\ns = -1+2*i;\r\nz_correct = 0.168915669770846 - 0.070515988908259i;\r\nassert(abs((real(zeta2(s))-real(z_correct))/real(z_correct)) \u003c 1e-8) \r\nassert(abs((imag(zeta2(s))-imag(z_correct))/imag(z_correct)) \u003c 1e-8)\r\n\r\n%%\r\ns = 0.75-3*i;\r\nz_correct = 0.580900396083837 + 0.095281202690117i;\r\nassert(abs(real(zeta2(s))-real(z_correct))/real(z_correct) \u003c 1e-8) \r\nassert(abs((imag(zeta2(s))-imag(z_correct))/imag(z_correct)) \u003c 1e-8)\r\n\r\n%%\r\ns = 5+2*i;\r\nz_correct = 1.001916538615071 - 0.034217062736354i;\r\nassert(abs((real(zeta2(s))-real(z_correct))/real(z_correct)) \u003c 1e-8) \r\nassert(abs((imag(zeta2(s))-imag(z_correct))/imag(z_correct)) \u003c 1e-8)\r\n\r\n%%\r\ns = 0.5+14.13472514173469379*i;\r\nassert(abs(real(zeta2(s))) \u003c 1e-12) \r\nassert(abs(imag(zeta2(s))) \u003c 1e-12)\r\n\r\n%%\r\ns = 0.5+21*i;\r\nz_correct = -0.005162064638102 - 0.024546964575122i;\r\nassert(abs((real(zeta2(s))-real(z_correct))/real(z_correct)) \u003c 1e-8) \r\nassert(abs((imag(zeta2(s))-imag(z_correct))/imag(z_correct)) \u003c 1e-8)\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":46909,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":12,"test_suite_updated_at":"2020-06-29T02:07:46.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-06-28T04:41:50.000Z","updated_at":"2026-01-09T13:36:37.000Z","published_at":"2020-06-28T05:14:18.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/45988\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody Problem 45988\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e involved computing the Riemann zeta function for real arguments greater than 1. Code that works for that problem can reveal the connection between \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"pi\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\pi\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e and the values of the zeta function evaluated at positive even integers; this connection is explored in\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/45939-estimate-pi-from-certain-values-of-the-zeta-function\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody Problem 45939\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. However, to test the Riemann hypothesis--that all non-trivial zeros of the zeta function have a real part of 1/2, one needs to compute the zeta function for complex arguments.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function to evaluate the zeta function for complex arguments.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":46025,"title":"Evaluate the gamma function","description":"The gamma function is a generalization of the factorial, and it appears in many applications such as evaluating certain integrals, working with probability distributions, and evaluating fractional derivatives. MATLAB includes the function gamma, but it accepts only real arguments.\r\nWrite a function that evaluates the gamma function for complex arguments.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 93.3333px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407.5px 46.6667px; transform-origin: 407.5px 46.6667px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63.3333px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384.5px 31.6667px; text-align: left; transform-origin: 384.5px 31.6667px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 12.0583px 7.66667px; transform-origin: 12.0583px 7.66667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 7.66667px; transform-origin: 1.94167px 7.66667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://mathworld.wolfram.com/GammaFunction.html\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003egamma function\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 302.642px 7.66667px; transform-origin: 302.642px 7.66667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is a generalization of the factorial, and it appears in many applications such as evaluating certain integrals, working with probability distributions, and evaluating fractional derivatives. MATLAB includes the function\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 7.66667px; transform-origin: 1.94167px 7.66667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 19.25px 7.66667px; transform-origin: 19.25px 7.66667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; perspective-origin: 19.25px 8px; transform-origin: 19.25px 8px; \"\u003egamma\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.88333px 7.66667px; transform-origin: 3.88333px 7.66667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, but it accepts only real arguments.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384.5px 10.5px; text-align: left; transform-origin: 384.5px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 232.467px 7.66667px; transform-origin: 232.467px 7.66667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function that evaluates the gamma function for complex arguments.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = gamma2(z)\r\n  y = f(z);\r\nend","test_suite":"%%\r\nz = 3+2i;\r\ny = gamma2(z);\r\ny_correct = -0.4226372863112003 + 0.871814255696503i;\r\nassert(abs((real(y)-real(y_correct))/real(y_correct)) \u003c 1e-6)\r\nassert(abs((imag(y)-imag(y_correct))/imag(y_correct)) \u003c 1e-6)\r\n\r\n%%\r\nz = 1+i;\r\ny = gamma2(z);\r\ny_correct = 0.4980156681183556 -0.1549498283018104i;\r\nassert(abs((real(y)-real(y_correct))/real(y_correct)) \u003c 1e-6)\r\nassert(abs((imag(y)-imag(y_correct))/imag(y_correct)) \u003c 1e-6)\r\n\r\n%%\r\nz = (1+i)/2;\r\ny = gamma2(z);\r\ny_correct = 0.818163995 - 0.7633138287i;\r\nassert(abs((real(y)-real(y_correct))/real(y_correct)) \u003c 1e-6)\r\nassert(abs((imag(y)-imag(y_correct))/imag(y_correct)) \u003c 1e-6)\r\n\r\n%%\r\nz = i;\r\ny = gamma2(z);\r\ny_correct = -0.154949828301810 - 0.4980156681183566i;\r\nassert(abs((real(y)-real(y_correct))/real(y_correct)) \u003c 1e-6)\r\nassert(abs((imag(y)-imag(y_correct))/imag(y_correct)) \u003c 1e-6)\r\n\r\n%%\r\nz = 5i;\r\ny = gamma2(z);\r\ny_correct = -0.00027170388350615125 + 0.0003399328988721375i;\r\nassert(abs((real(y)-real(y_correct))/real(y_correct)) \u003c 1e-6)\r\nassert(abs((imag(y)-imag(y_correct))/imag(y_correct)) \u003c 1e-6)\r\n\r\n%%\r\nz = 1/2 + 14.1i;\r\ny = gamma2(z);\r\ny_correct = -2.0555298837259187e-10 - 5.667644214210669e-10i;\r\nassert(abs((real(y)-real(y_correct))/real(y_correct)) \u003c 1e-6)\r\nassert(abs((imag(y)-imag(y_correct))/imag(y_correct)) \u003c 1e-6)\r\n\r\n%%\r\nz = -1+i;\r\ny = gamma2(z);\r\ny_correct = -0.1715329199082727 + 0.3264827482100833i;\r\nassert(abs((real(y)-real(y_correct))/real(y_correct)) \u003c 1e-6)\r\nassert(abs((imag(y)-imag(y_correct))/imag(y_correct)) \u003c 1e-6)\r\n\r\n%%\r\nz = -2-3i;\r\ny = gamma2(z);\r\ny_correct = -0.0001631724182726072 - 0.001128495917017955i;\r\nassert(abs((real(y)-real(y_correct))/real(y_correct)) \u003c 1e-6)\r\nassert(abs((imag(y)-imag(y_correct))/imag(y_correct)) \u003c 1e-6)\r\n\r\n%%\r\nz = 10*(rand+0.02);\r\ny_correct = gamma(z);\r\nassert(abs(gamma2(z)-y_correct)/y_correct \u003c 1e-6)\r\n\r\n%%\r\nfiletext = fileread('gamma2.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp') || contains(filetext, 'system'); \r\nassert(~illegal)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":9,"created_by":46909,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":20,"test_suite_updated_at":"2022-01-30T20:31:21.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-07-04T16:14:47.000Z","updated_at":"2026-01-09T11:39:54.000Z","published_at":"2020-07-05T04:43:57.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://mathworld.wolfram.com/GammaFunction.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003egamma function\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is a generalization of the factorial, and it appears in many applications such as evaluating certain integrals, working with probability distributions, and evaluating fractional derivatives. MATLAB includes the function\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003egamma\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, but it accepts only real arguments.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function that evaluates the gamma function for complex arguments.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":45997,"title":"Evaluate the zeta function for complex arguments","description":"\u003chttps://www.mathworks.com/matlabcentral/cody/problems/45988 Cody Problem 45988\u003e involved computing the Riemann zeta function for real arguments greater than 1. Code that works for that problem can reveal the connection between pi and the values of the zeta function evaluated at positive even integers; this connection is explored in \u003chttps://www.mathworks.com/matlabcentral/cody/problems/45939-estimate-pi-from-certain-values-of-the-zeta-function Cody Problem 45939\u003e. However, to test the Riemann hypothesis--that all non-trivial zeros of the zeta function have a real part of 1/2, one needs to compute the zeta function for complex arguments.\r\n\r\nWrite a function to evaluate the zeta function for complex arguments.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 114px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 57px; transform-origin: 407px 57px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 84px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 42px; text-align: left; transform-origin: 384px 42px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/45988\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eCody Problem 45988\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 315.85px 7.8px; transform-origin: 315.85px 7.8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e involved computing the Riemann zeta function for real arguments greater than 1. Code that works for that problem can reveal the connection between \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003eπ\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 222.1px 7.8px; transform-origin: 222.1px 7.8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and the values of the zeta function evaluated at positive even integers; this connection is explored in\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.95px 7.8px; transform-origin: 1.95px 7.8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/45939-estimate-pi-from-certain-values-of-the-zeta-function\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eCody Problem 45939\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 217.433px 7.8px; transform-origin: 217.433px 7.8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. However, to test the Riemann hypothesis--that all non-trivial zeros of the zeta function have a real part of 1/2, one needs to compute the zeta function for complex arguments.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 213.017px 7.8px; transform-origin: 213.017px 7.8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function to evaluate the zeta function for complex arguments.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function z = zeta2(s)\r\n  z = f(s);\r\nend","test_suite":"%%\r\ns = 2;\r\nz_correct = pi^2/6;\r\nassert(abs(zeta2(s)-z_correct)/z_correct \u003c 1e-8)\r\n\r\n%%\r\ns = 1;\r\nassert(isinf(zeta2(s)))\r\n\r\n%%\r\ns = 1/2;\r\nz_correct = -1.460354508809587;\r\nassert(abs((zeta2(s)-z_correct)/z_correct) \u003c 1e-8)\r\n\r\n%%\r\ns = 0;\r\nz_correct = -0.5;\r\nassert(abs((zeta2(s)-z_correct)/z_correct) \u003c 1e-8)\r\n\r\n%%\r\ns = -1;\r\nz_correct = -1/12;\r\nassert(abs((zeta2(s)-z_correct)/z_correct) \u003c 1e-8)\r\n\r\n%%\r\ns = -2;\r\nz_correct = 0;\r\nassert(abs(zeta2(s)) \u003c 1e-12)\r\n\r\n%%\r\ns = 3+2*i;\r\nz_correct = 0.973041960418942 - 0.147695593000454i;\r\nassert(abs(real(zeta2(s))-real(z_correct))/real(z_correct) \u003c 1e-8) \r\nassert(abs((imag(zeta2(s))-imag(z_correct))/imag(z_correct)) \u003c 1e-8)\r\n\r\n%%\r\ns = -1+2*i;\r\nz_correct = 0.168915669770846 - 0.070515988908259i;\r\nassert(abs((real(zeta2(s))-real(z_correct))/real(z_correct)) \u003c 1e-8) \r\nassert(abs((imag(zeta2(s))-imag(z_correct))/imag(z_correct)) \u003c 1e-8)\r\n\r\n%%\r\ns = 0.75-3*i;\r\nz_correct = 0.580900396083837 + 0.095281202690117i;\r\nassert(abs(real(zeta2(s))-real(z_correct))/real(z_correct) \u003c 1e-8) \r\nassert(abs((imag(zeta2(s))-imag(z_correct))/imag(z_correct)) \u003c 1e-8)\r\n\r\n%%\r\ns = 5+2*i;\r\nz_correct = 1.001916538615071 - 0.034217062736354i;\r\nassert(abs((real(zeta2(s))-real(z_correct))/real(z_correct)) \u003c 1e-8) \r\nassert(abs((imag(zeta2(s))-imag(z_correct))/imag(z_correct)) \u003c 1e-8)\r\n\r\n%%\r\ns = 0.5+14.13472514173469379*i;\r\nassert(abs(real(zeta2(s))) \u003c 1e-12) \r\nassert(abs(imag(zeta2(s))) \u003c 1e-12)\r\n\r\n%%\r\ns = 0.5+21*i;\r\nz_correct = -0.005162064638102 - 0.024546964575122i;\r\nassert(abs((real(zeta2(s))-real(z_correct))/real(z_correct)) \u003c 1e-8) \r\nassert(abs((imag(zeta2(s))-imag(z_correct))/imag(z_correct)) \u003c 1e-8)\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":46909,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":12,"test_suite_updated_at":"2020-06-29T02:07:46.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-06-28T04:41:50.000Z","updated_at":"2026-01-09T13:36:37.000Z","published_at":"2020-06-28T05:14:18.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/45988\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody Problem 45988\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e involved computing the Riemann zeta function for real arguments greater than 1. Code that works for that problem can reveal the connection between \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003cw:attr w:name=\\\"altTextString\\\" w:val=\\\"pi\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003e\\\\pi\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e and the values of the zeta function evaluated at positive even integers; this connection is explored in\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/45939-estimate-pi-from-certain-values-of-the-zeta-function\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eCody Problem 45939\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. However, to test the Riemann hypothesis--that all non-trivial zeros of the zeta function have a real part of 1/2, one needs to compute the zeta function for complex arguments.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function to evaluate the zeta function for complex arguments.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":46025,"title":"Evaluate the gamma function","description":"The gamma function is a generalization of the factorial, and it appears in many applications such as evaluating certain integrals, working with probability distributions, and evaluating fractional derivatives. MATLAB includes the function gamma, but it accepts only real arguments.\r\nWrite a function that evaluates the gamma function for complex arguments.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 93.3333px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407.5px 46.6667px; transform-origin: 407.5px 46.6667px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63.3333px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384.5px 31.6667px; text-align: left; transform-origin: 384.5px 31.6667px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 12.0583px 7.66667px; transform-origin: 12.0583px 7.66667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 7.66667px; transform-origin: 1.94167px 7.66667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://mathworld.wolfram.com/GammaFunction.html\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003egamma function\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 302.642px 7.66667px; transform-origin: 302.642px 7.66667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is a generalization of the factorial, and it appears in many applications such as evaluating certain integrals, working with probability distributions, and evaluating fractional derivatives. MATLAB includes the function\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 1.94167px 7.66667px; transform-origin: 1.94167px 7.66667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 19.25px 7.66667px; transform-origin: 19.25px 7.66667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-family: Menlo, Monaco, Consolas, \u0026quot;Courier New\u0026quot;, monospace; perspective-origin: 19.25px 8px; transform-origin: 19.25px 8px; \"\u003egamma\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 3.88333px 7.66667px; transform-origin: 3.88333px 7.66667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, but it accepts only real arguments.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384.5px 10.5px; text-align: left; transform-origin: 384.5px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 232.467px 7.66667px; transform-origin: 232.467px 7.66667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function that evaluates the gamma function for complex arguments.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = gamma2(z)\r\n  y = f(z);\r\nend","test_suite":"%%\r\nz = 3+2i;\r\ny = gamma2(z);\r\ny_correct = -0.4226372863112003 + 0.871814255696503i;\r\nassert(abs((real(y)-real(y_correct))/real(y_correct)) \u003c 1e-6)\r\nassert(abs((imag(y)-imag(y_correct))/imag(y_correct)) \u003c 1e-6)\r\n\r\n%%\r\nz = 1+i;\r\ny = gamma2(z);\r\ny_correct = 0.4980156681183556 -0.1549498283018104i;\r\nassert(abs((real(y)-real(y_correct))/real(y_correct)) \u003c 1e-6)\r\nassert(abs((imag(y)-imag(y_correct))/imag(y_correct)) \u003c 1e-6)\r\n\r\n%%\r\nz = (1+i)/2;\r\ny = gamma2(z);\r\ny_correct = 0.818163995 - 0.7633138287i;\r\nassert(abs((real(y)-real(y_correct))/real(y_correct)) \u003c 1e-6)\r\nassert(abs((imag(y)-imag(y_correct))/imag(y_correct)) \u003c 1e-6)\r\n\r\n%%\r\nz = i;\r\ny = gamma2(z);\r\ny_correct = -0.154949828301810 - 0.4980156681183566i;\r\nassert(abs((real(y)-real(y_correct))/real(y_correct)) \u003c 1e-6)\r\nassert(abs((imag(y)-imag(y_correct))/imag(y_correct)) \u003c 1e-6)\r\n\r\n%%\r\nz = 5i;\r\ny = gamma2(z);\r\ny_correct = -0.00027170388350615125 + 0.0003399328988721375i;\r\nassert(abs((real(y)-real(y_correct))/real(y_correct)) \u003c 1e-6)\r\nassert(abs((imag(y)-imag(y_correct))/imag(y_correct)) \u003c 1e-6)\r\n\r\n%%\r\nz = 1/2 + 14.1i;\r\ny = gamma2(z);\r\ny_correct = -2.0555298837259187e-10 - 5.667644214210669e-10i;\r\nassert(abs((real(y)-real(y_correct))/real(y_correct)) \u003c 1e-6)\r\nassert(abs((imag(y)-imag(y_correct))/imag(y_correct)) \u003c 1e-6)\r\n\r\n%%\r\nz = -1+i;\r\ny = gamma2(z);\r\ny_correct = -0.1715329199082727 + 0.3264827482100833i;\r\nassert(abs((real(y)-real(y_correct))/real(y_correct)) \u003c 1e-6)\r\nassert(abs((imag(y)-imag(y_correct))/imag(y_correct)) \u003c 1e-6)\r\n\r\n%%\r\nz = -2-3i;\r\ny = gamma2(z);\r\ny_correct = -0.0001631724182726072 - 0.001128495917017955i;\r\nassert(abs((real(y)-real(y_correct))/real(y_correct)) \u003c 1e-6)\r\nassert(abs((imag(y)-imag(y_correct))/imag(y_correct)) \u003c 1e-6)\r\n\r\n%%\r\nz = 10*(rand+0.02);\r\ny_correct = gamma(z);\r\nassert(abs(gamma2(z)-y_correct)/y_correct \u003c 1e-6)\r\n\r\n%%\r\nfiletext = fileread('gamma2.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp') || contains(filetext, 'system'); \r\nassert(~illegal)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":9,"created_by":46909,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":20,"test_suite_updated_at":"2022-01-30T20:31:21.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-07-04T16:14:47.000Z","updated_at":"2026-01-09T11:39:54.000Z","published_at":"2020-07-05T04:43:57.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://mathworld.wolfram.com/GammaFunction.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003egamma function\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is a generalization of the factorial, and it appears in many applications such as evaluating certain integrals, working with probability distributions, and evaluating fractional derivatives. MATLAB includes the function\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003egamma\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, but it accepts only real arguments.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function that evaluates the gamma function for complex arguments.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"term":"group:\"Special Functions\" difficulty_rating_bin:hard","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"group:\"Special Functions\" difficulty_rating_bin:hard","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"group":[["group:\"Special Functions\"","","\"","Special Functions","\""]],"difficulty_rating_bin":[["difficulty_rating_bin:hard","","","hard",""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fbf38aacf90\u003e":["Special Functions"],"#\u003cMathWorks::Search::Field:0x00007fbf38aacd10\u003e":["hard"]},"filters":{"#\u003cMathWorks::Search::Field:0x00007fbf38aa8850\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fbf38aad850\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fbf38aad5d0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fbf38aad350\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fbf38aad0d0\u003e":"group:\"Special Functions\" difficulty_rating_bin:hard"},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fbf38aad0d0\u003e":"group:\"Special Functions\" difficulty_rating_bin:hard"},"queried_facets":{"#\u003cMathWorks::Search::Field:0x00007fbf38aacf90\u003e":["Special Functions"],"#\u003cMathWorks::Search::Field:0x00007fbf38aacd10\u003e":["hard"]}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"cody-search","password":"78X075ddcV44","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"group:\"Special Functions\" difficulty_rating_bin:hard","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"group":[["group:\"Special Functions\"","","\"","Special Functions","\""]],"difficulty_rating_bin":[["difficulty_rating_bin:hard","","","hard",""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fbf38aacf90\u003e":["Special Functions"],"#\u003cMathWorks::Search::Field:0x00007fbf38aacd10\u003e":["hard"]},"filters":{"#\u003cMathWorks::Search::Field:0x00007fbf38aa8850\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fbf38aad850\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fbf38aad5d0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fbf38aad350\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fbf38aad0d0\u003e":"group:\"Special Functions\" difficulty_rating_bin:hard"},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fbf38aad0d0\u003e":"group:\"Special Functions\" difficulty_rating_bin:hard"},"queried_facets":{"#\u003cMathWorks::Search::Field:0x00007fbf38aacf90\u003e":["Special Functions"],"#\u003cMathWorks::Search::Field:0x00007fbf38aacd10\u003e":["hard"]}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":45997,"difficulty_rating":"medium-hard"},{"id":46025,"difficulty_rating":"medium-hard"}]}}