[{"id":247043,"date":"2026-05-26T12:59:53","date_gmt":"2026-05-26T17:59:53","guid":{"rendered":"https:\/\/www.johndcook.com\/blog\/?p=247043"},"modified":"2026-05-26T12:59:53","modified_gmt":"2026-05-26T17:59:53","slug":"calculating-expected-normal-range","status":"publish","type":"post","link":"https:\/\/www.johndcook.com\/blog\/2026\/05\/26\/calculating-expected-normal-range\/","title":{"rendered":"Calculating the expected range of normal samples"},"content":{"rendered":"<p>The <a href=\"https:\/\/www.johndcook.com\/blog\/2026\/05\/26\/expected-iq-spread-on-a-jury\/\">previous post<\/a> looked at the expected IQ range in a jury of 12. This post will look more generally at computing the expected range of\u00a0<em>n<\/em> samples from a\u00a0<em>N<\/em>(0, 1) random variable. This will give the expected range in units of \u03c3, i.e. multiply the results by \u03c3 if your \u03c3 isn&#8217;t 1.<\/p>\n<p>As mentioned in the previous post, the expected range is given by<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.johndcook.com\/normal_range.svg\" alt=\"d_n = 2n \\int_{-\\infty}^\\infty \\Phi(x)^{n-1} \\, x\\,\\phi(x) \\, dx\" width=\"249\" height=\"45\" \/><\/p>\n<p>where \u03c6 and \u03a6 are the PDF and CDF of a standard normal. The integral can be calculated in closed form for\u00a0<em>n<\/em> \u2264 5, but in general it requires numerical integration [1].<\/p>\n<p>The following Python code can compute <em>d<\/em><sub><em>n<\/em><\/sub>.<\/p>\n<pre>\r\nfrom scipy.stats import norm\r\nfrom scipy.integrate import quad\r\nimport numpy as np\r\n\r\ndef d(n):\r\n    integrand = lambda x: x*norm.pdf(x)*norm.cdf(x)**(n-1)\r\n    res, info = quad(integrand, -np.inf, np.inf)\r\n    return 2*n*res\r\n<\/pre>\n<p>For large <em>n<\/em> we have the asymptotic approximation<\/p>\n<p><img class='aligncenter' src='https:\/\/www.johndcook.com\/normal_range2.svg' alt='d_n = 2 \\Phi^{-1}\\left( \\frac{n \\,\u2013\\, 0.375}{ n + 0.25} \\right)' style='background-color:white' height='48' width='178' \/><\/p>\n<p>which we could implement in Python by<\/p>\n<pre>\r\ndef approx(n):\r\n    return 2*norm.ppf((n - 0.375)\/(n + 0.25))\r\n<\/pre>\n<p>For very large <em>n<\/em> the asymptotic expression may be more accurate than the integral due to numerical integration error. <\/p>\n<p>Here are a few example values.<\/p>\n<pre>\r\n|-----+-------|\r\n|   n |   d_n |\r\n|-----+-------|\r\n|   2 | 1.128 |\r\n|   3 | 1.693 |\r\n|   5 | 2.326 |\r\n|  10 | 3.078 |\r\n|  12 | 3.258 |\r\n|  23 | 3.858 |\r\n|  50 | 4.498 |\r\n| 100 | 5.015 |\r\n|-----+-------|\r\n<\/pre>\n<p>[1] Order Statistics by H. A. David. John Wiley &amp; Sons. 1970.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The previous post looked at the expected IQ range in a jury of 12. This post will look more generally at computing the expected range of\u00a0n samples from a\u00a0N(0, 1) random variable. This will give the expected range in units of \u03c3, i.e. multiply the results by \u03c3 if your \u03c3 isn&#8217;t 1. As mentioned [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[5],"tags":[105],"class_list":["post-247043","post","type-post","status-publish","format-standard","hentry","category-computing","tag-probability"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247043","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/comments?post=247043"}],"version-history":[{"count":0,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247043\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/media?parent=247043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/categories?post=247043"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/tags?post=247043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}},{"id":247041,"date":"2026-05-26T08:50:51","date_gmt":"2026-05-26T13:50:51","guid":{"rendered":"https:\/\/www.johndcook.com\/blog\/?p=247041"},"modified":"2026-05-26T13:01:40","modified_gmt":"2026-05-26T18:01:40","slug":"expected-iq-spread-on-a-jury","status":"publish","type":"post","link":"https:\/\/www.johndcook.com\/blog\/2026\/05\/26\/expected-iq-spread-on-a-jury\/","title":{"rendered":"Expected IQ spread on a jury"},"content":{"rendered":"<p>There&#8217;s been some discussion online lately about how a large difference in IQ makes it difficult for two people to communicate. There have been studies that confirm this effect. The difficulty is not insurmountable, but it takes deliberate effort to overcome.<\/p>\n<p>Someone dismissed this communication difficulty by pointing out that the expected difference in IQ between two individuals is around 17, suggesting that most communication is between people who differ by more than one standard deviation in IQ. But this calculation assumes people are chosen at random, which they usually are not. People tend to live around and work around others of similar intelligence.<\/p>\n<p>However, a jury\u00a0<em>is<\/em> a random sample. It&#8217;s not a perfect random sample. For one thing, it starts with a random sample of people who are registered to vote, or who have a drivers license, not all individuals. Furthermore, the pool of potential jurors is reduced to a jury through the process of <em>voir dire<\/em>, which is not random.<\/p>\n<p>For this post I will make the simplifying assumption that a jury is a random sample from a population with normally distributed IQ with standard deviation \u03c3 = 15. The mean doesn&#8217;t matter here, but you could assume it&#8217;s 100 if you&#8217;d like.<\/p>\n<p>By symmetry, the expected range of <em>n<\/em> samples from a normal random variable is twice the maximum. For\u00a0<em>n<\/em> = 12 the range is about 3.26\u03c3, which corresponds to nearly <strong>50 IQ points<\/strong>.<\/p>\n<p>This suggests there&#8217;s usually a big spread of IQ on a jury. Even if IQ doesn&#8217;t measure intelligence, it measures\u00a0<em>something<\/em>, and that something varies a lot over 12 people chosen at random [1].<\/p>\n<h2>Related posts<\/h2>\n<ul>\n<li class=\"link\"><a href=\"https:\/\/www.johndcook.com\/blog\/explaining-probability-to-a-jury\/\">Explaining probability to a jury<\/a><\/li>\n<li class=\"link\"><a href=\"https:\/\/www.johndcook.com\/blog\/expert-testimony\/\">Expert testimony<\/a><\/li>\n<li class=\"link\"><a href=\"https:\/\/www.johndcook.com\/blog\/2016\/01\/12\/seven-questions-a-statistician-could-answer-for-a-lawyer\/\">Seven questions a statistician can answer for a lawyer<\/a><\/li>\n<\/ul>\n<p>[1] In case you&#8217;re interested in the technical details, the expected range of\u00a0<em>n<\/em> samples from a standard normal random variable is given by<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" style=\"background-color: white;\" src=\"https:\/\/www.johndcook.com\/normal_range.svg\" alt=\"d_n = 2n \\int_{-\\infty}^\\infty \\Phi(x)^{n-1} \\, x\\,\\phi(x) \\, dx\" width=\"249\" height=\"45\" \/><\/p>\n<p>where \u03c6 and \u03a6 are the PDF and CDF of a standard normal. Multiply this by \u03c3 to get the range of a normal random variable with standard deviation \u03c3. As for how to calculate <em>d<\/em><sub><em>n<\/em><\/sub>, see the <a href=\"https:\/\/www.johndcook.com\/blog\/2026\/05\/26\/calculating-expected-normal-range\/\">next post<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There&#8217;s been some discussion online lately about how a large difference in IQ makes it difficult for two people to communicate. There have been studies that confirm this effect. The difficulty is not insurmountable, but it takes deliberate effort to overcome. Someone dismissed this communication difficulty by pointing out that the expected difference in IQ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[9],"tags":[105],"class_list":["post-247041","post","type-post","status-publish","format-standard","hentry","category-math","tag-probability"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/comments?post=247041"}],"version-history":[{"count":0,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247041\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/media?parent=247041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/categories?post=247041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/tags?post=247041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}},{"id":247039,"date":"2026-05-23T10:09:34","date_gmt":"2026-05-23T15:09:34","guid":{"rendered":"https:\/\/www.johndcook.com\/blog\/?p=247039"},"modified":"2026-05-23T10:09:34","modified_gmt":"2026-05-23T15:09:34","slug":"hilbert-transform-as-an-infinite-matrix","status":"publish","type":"post","link":"https:\/\/www.johndcook.com\/blog\/2026\/05\/23\/hilbert-transform-as-an-infinite-matrix\/","title":{"rendered":"Hilbert transform as an infinite matrix"},"content":{"rendered":"<p>The previous post linked to a post I wrote a few years ago about the <a href=\"https:\/\/www.johndcook.com\/blog\/2022\/04\/13\/hilbert-fourier\/\">Hilbert transform and Fourier series<\/a>. That post says that if the Fourier series of a function is<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium\" style=\"background-color: white;\" src=\"https:\/\/www.johndcook.com\/hilbert_fourier1.svg\" alt=\"f(t) = \\sum_{n=1}^\\infty \\left\\{ a_n \\sin(nt) + b_n\\cos(nt) \\right\\}\" width=\"268\" height=\"49\" \/><\/p>\n<p>then the Fourier series of its Hilbert transform is<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium\" style=\"background-color: white;\" src=\"https:\/\/www.johndcook.com\/hilbert_fourier2.svg\" alt=\"f_H(x) = \\sum_{n=1}^\\infty \\left\\{ -b_n \\sin(nx) + a_n\\cos(nx) \\right\\}\" width=\"303\" height=\"49\" \/><\/p>\n<p>When I looked back at that post I thought about how if you thought of the Fourier coefficients as elements of an infinite vector then the Hilbert transform can be represented as multiplying by an infinite block matrix.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium\" style=\"background-color: white;\" src=\"https:\/\/www.johndcook.com\/hilbert_transform_matrix.svg\" alt=\"\\left[ \\begin{array}{cc|cc|cc|c} 0 &amp; -1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; \\cdots \\\\ 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; \\cdots \\\\ \\hline 0 &amp; 0 &amp; 0 &amp; -1 &amp; 0 &amp; 0 &amp; \\cdots \\\\ 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; \\cdots \\\\ \\hline 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; -1 &amp; \\cdots \\\\ 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; \\cdots \\\\ \\hline \\vdots &amp; \\vdots &amp; \\vdots &amp; \\vdots &amp; \\vdots &amp; \\vdots &amp; \\ddots \\end{array} \\right] \\left[ \\begin{array}{c} a_1 \\\\ b_1 \\\\ \\hline a_2 \\\\ b_2 \\\\ \\hline a_3 \\\\ b_3 \\\\ \\hline \\vdots \\end{array} \\right]\" width=\"363\" height=\"183\" \/><\/p>\n<p>I rarely see infinite matrices except in older math books. Apparently they were more fashionable a few decades ago than they are now. I suppose the notation falls between two stools, too concrete for some tastes and not concrete enough for others. The former folks would prefer something like\u00a0<em>H<\/em> and the latter would prefer the sum above.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The previous post linked to a post I wrote a few years ago about the Hilbert transform and Fourier series. That post says that if the Fourier series of a function is then the Fourier series of its Hilbert transform is When I looked back at that post I thought about how if you thought [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[9],"tags":[178,198],"class_list":["post-247039","post","type-post","status-publish","format-standard","hentry","category-math","tag-fourier-analysis","tag-linear-algebra"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/comments?post=247039"}],"version-history":[{"count":0,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247039\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/media?parent=247039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/categories?post=247039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/tags?post=247039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}},{"id":247038,"date":"2026-05-23T08:57:21","date_gmt":"2026-05-23T13:57:21","guid":{"rendered":"https:\/\/www.johndcook.com\/blog\/?p=247038"},"modified":"2026-05-23T08:57:21","modified_gmt":"2026-05-23T13:57:21","slug":"real-and-imaginary-parts","status":"publish","type":"post","link":"https:\/\/www.johndcook.com\/blog\/2026\/05\/23\/real-and-imaginary-parts\/","title":{"rendered":"Real and imaginary parts"},"content":{"rendered":"<p>The previous post announced some <a href=\"https:\/\/www.johndcook.com\/complex_real.html\">notes<\/a> I wrote up based on an article by Henry Baker implementing functions of a complex variable in terms of functions of a real variable. That is, it finds functions <em>u<\/em>(<em>x<\/em>, <em>y<\/em>) and <em>v<\/em>(<em>x<\/em>, <em>y<\/em>) such that<\/p>\n<p style=\"padding-left: 40px;\"><em>f<\/em>(<em>x<\/em> + <em>iy<\/em>) = <em>u<\/em>(<em>x<\/em>, <em>y<\/em>) + <em>i<\/em> <em>v<\/em>(<em>x<\/em>, <em>y<\/em>)<\/p>\n<p>where\u00a0<em>x<\/em>,\u00a0<em>y<\/em>,\u00a0<em>u<\/em>, and <em>v<\/em>\u00a0are all real-valued. Not only that, but if\u00a0<em>f<\/em> is an elementary function, so are\u00a0<em>u<\/em> and\u00a0<em>v<\/em>. Here &#8220;elementary&#8221; has a technical meaning, but essentially it means functions that you could evaluate on a scientific calculator. A couple of the functions might be unfamiliar, such as sgn and atan2, but there are no functions like the gamma function that are defined in terms of integrals.<\/p>\n<p>One application of Baker&#8217;s equations would be to bootstrap a math library that doesn&#8217;t support complex numbers into one that does. But the equations could be useful in pure math when you&#8217;d like to have a convenient expression for the real or imaginary part of a function.<\/p>\n<p>The real and imaginary parts of a complex analytic function are harmonic functions. So the functions on the right hand side of Baker&#8217;s equations satisfy <a href=\"https:\/\/www.johndcook.com\/blog\/2022\/11\/22\/dirichlet\/\">Laplace&#8217;s equation<\/a>:<\/p>\n<p style=\"padding-left: 40px;\"><em>u<\/em><sub><em>xx<\/em><\/sub> + <em>u<\/em><sub><em>yy<\/em><\/sub> = 0<\/p>\n<p>and<\/p>\n<p style=\"padding-left: 40px;\"><em>v<\/em><sub><em>xx<\/em><\/sub> + <em>v<\/em><sub><em>yy<\/em><\/sub> = 0.<\/p>\n<p>Furthermore, the functions\u00a0<em>u<\/em> and\u00a0<em>v<\/em> form harmonic conjugate pairs, meaning each is the <a href=\"https:\/\/www.johndcook.com\/blog\/2022\/04\/13\/hilbert-fourier\/\">Hilbert transform<\/a> of the other.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The previous post announced some notes I wrote up based on an article by Henry Baker implementing functions of a complex variable in terms of functions of a real variable. That is, it finds functions u(x, y) and v(x, y) such that f(x + iy) = u(x, y) + i v(x, y) where\u00a0x,\u00a0y,\u00a0u, and v\u00a0are [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[9],"tags":[181,47],"class_list":["post-247038","post","type-post","status-publish","format-standard","hentry","category-math","tag-complex-analysis","tag-differential-equations"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247038","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/comments?post=247038"}],"version-history":[{"count":0,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247038\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/media?parent=247038"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/categories?post=247038"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/tags?post=247038"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}},{"id":247036,"date":"2026-05-22T22:24:10","date_gmt":"2026-05-23T03:24:10","guid":{"rendered":"https:\/\/www.johndcook.com\/blog\/?p=247036"},"modified":"2026-05-23T09:19:43","modified_gmt":"2026-05-23T14:19:43","slug":"complex-functions-real-parts","status":"publish","type":"post","link":"https:\/\/www.johndcook.com\/blog\/2026\/05\/22\/complex-functions-real-parts\/","title":{"rendered":"Building complex functions out of real parts"},"content":{"rendered":"<p><a href=\"https:\/\/www.johndcook.com\/blog\/2026\/03\/27\/complex-argument\/\">A couple months ago<\/a> I wrote about how to compute the sine and cosine of a complex number using only real functions of real variables using the equations<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/www.johndcook.com\/complex_sincos1.svg\" alt=\"\\begin{align*} \\sin(x + iy) &amp;= \\sin x \\cosh y + i \\cos x \\sinh y \\\\ \\cos(x + iy) &amp;= \\cos x \\cosh y - i \\sin x \\sinh y \\\\ \\end{align*}\" width=\"324\" height=\"47\" \/><\/p>\n<p>You can do something analogous for all the elementary functions, though some of the equations are quite a bit more complicated than the ones above. See the equations <a href=\"https:\/\/www.johndcook.com\/complex_real.html\">here<\/a>.<\/p>\n<p>The equations come from a paper by Henry G. Baker, cited in the linked page. I wrote up Baker&#8217;s equations in LaTeX, then used ChatGPT to generate Python code from the LaTeX to numerically verify the equations and my typesetting of them. This caught a few typos on my part.<\/p>\n<p>The test code evaluated the equations at points from each quadrant. All matched NumPy, implying that Baker and NumPy use the same branch cuts on inverse functions.<\/p>\n<p style=\"text-align: center;\">***<\/p>\n<p>This post is part of a thread that has gone on for a few days. Maybe it&#8217;s the last post in the thread; we&#8217;ll see.<\/p>\n<p>It all started with a post on <a href=\"https:\/\/www.johndcook.com\/blog\/2026\/05\/19\/zagiers-equation\/\">Markov&#8217;s equation<\/a><\/p>\n<p style=\"padding-left: 40px;\"><em>x<\/em>\u00b2 +\u00a0<em>y<\/em>\u00b2 +\u00a0<em>z<\/em>\u00b2 = 3 <em>xyz<\/em><\/p>\n<p>and an approximation to the equation that has a closed-form solution. That led to the identity<\/p>\n<p style=\"padding-left: 40px;\">cosh( arccosh(<em>a<\/em>) + arccosh(<em>b<\/em>) ) =\u00a0<em>ab<\/em>\u00a0+ \u221a(<em>a<\/em>\u00b2 \u2212 1) \u221a(<em>b<\/em>\u00b2 \u2212 1).<\/p>\n<p>The approximation to Markov&#8217;s equation only needed the identity to be valid for real\u00a0<em>a<\/em> and\u00a0<em>b<\/em> greater than 1. But when I <a href=\"https:\/\/www.johndcook.com\/blog\/2026\/05\/19\/closer-look-at-an-identity\/\">looked closer<\/a> at the identity I found several complications with branch cuts. The identity doesn&#8217;t hold everywhere using the principle branch of the square root function. But if you <a href=\"https:\/\/www.johndcook.com\/blog\/2026\/05\/19\/square-root-of-x-squared-minus-one\/\">define<\/a> \u221a(<em>z<\/em>\u00b2 \u2212 1) to have a branch cut along [\u22121, 1] then the equation holds everywhere in the complex plane. And that led to my writing up some <a href=\"https:\/\/www.johndcook.com\/inverse.html\">notes<\/a> on how to define all the elementary inverse functions in terms of log.<\/p>\n<p>Someone reading these posts suggested I look at a paper that mentioned &#8220;couth&#8221; and &#8220;uncouth&#8221; function pairs, which led to <a href=\"https:\/\/www.johndcook.com\/blog\/2026\/05\/21\/couth-and-uncouth-function-pairs\/\">this post<\/a> and its <a href=\"https:\/\/www.johndcook.com\/blog\/2026\/05\/21\/circular-hyperbolic-rotations\/\">warm up<\/a>.<\/p>\n<p>I find all this interesting because it&#8217;s an advanced perspective on a questions that are latent in an intro calculus class. What <em>exactly<\/em> do functions like arccos mean and why where they defined as they were? These are fairly deep and interesting questions that are swept under the rug, and swept there for good reason. A calculus class has to cover an enormous amount of material and there&#8217;s no time to dwell on fine points. Some of my favorite posts look back leisurely on things that go by in a blur when you&#8217;re a student.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A couple months ago I wrote about how to compute the sine and cosine of a complex number using only real functions of real variables using the equations You can do something analogous for all the elementary functions, though some of the equations are quite a bit more complicated than the ones above. See the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[9],"tags":[181],"class_list":["post-247036","post","type-post","status-publish","format-standard","hentry","category-math","tag-complex-analysis"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247036","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/comments?post=247036"}],"version-history":[{"count":0,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247036\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/media?parent=247036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/categories?post=247036"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/tags?post=247036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}},{"id":247031,"date":"2026-05-21T12:31:13","date_gmt":"2026-05-21T17:31:13","guid":{"rendered":"https:\/\/www.johndcook.com\/blog\/?p=247031"},"modified":"2026-05-22T06:31:38","modified_gmt":"2026-05-22T11:31:38","slug":"couth-and-uncouth-function-pairs","status":"publish","type":"post","link":"https:\/\/www.johndcook.com\/blog\/2026\/05\/21\/couth-and-uncouth-function-pairs\/","title":{"rendered":"Couth and uncouth function pairs"},"content":{"rendered":"<p>&#8220;You can&#8217;t always get what you want. But sometimes you get what you need.&#8221; \u2014 The Rolling Stones<\/p>\n<p>Circular functions and hyperbolic functions aren&#8217;t invertible, but we invert them anyway. These functions map many points in the domain to each point in the range, and we invert them by mapping a point in the range back to\u00a0<em>some<\/em> point in the domain. Often this works as expected, but sometimes it doesn&#8217;t.<\/p>\n<p>In the <a href=\"https:\/\/www.johndcook.com\/blog\/2026\/05\/21\/circular-hyperbolic-rotations\/\">previous post<\/a> I said<\/p>\n<blockquote><p>You can relate each trig function &#8220;foo&#8221; with its hyperbolic counterpart &#8220;fooh&#8221; by applying one of the functions to\u00a0<em>iz<\/em> then multiplying by a constant <em>c<\/em> that depends on foo:\u00a0<em>c<\/em> =\u00a0<em>i<\/em> for sin and tan,\u00a0<em>c<\/em> = 1 for cos and sec, and\u00a0<em>c<\/em> = \u2212<em>i<\/em> for csc and cot.<\/p><\/blockquote>\n<p>In symbols,<\/p>\n<p style=\"padding-left: 40px;\"><em>c<\/em> foo(<em>z<\/em>) = fooh(<em>iz<\/em>).<\/p>\n<p>Let&#8217;s suppose foo and fooh are invertible, ignoring any complications, and solve foo(<em>z<\/em>) =\u00a0<em>w<\/em> for\u00a0<em>z<\/em>. We get<\/p>\n<p style=\"padding-left: 40px;\"><em>i<\/em> foo<sup>\u22121<\/sup>(<em>w<\/em>) = fooh<sup>\u22121<\/sup>(<em>cw<\/em>)<\/p>\n<p>or using &#8220;arc&#8221; nomenclature for inverse functions<\/p>\n<p style=\"padding-left: 40px;\"><em>i<\/em> arcfoo(<em>w<\/em>) = arcfooh(<em>cw<\/em>).<\/p>\n<p>When the naive calculation above holds, except possibly at a finite number of points, we say the pair (foo, fooh) is\u00a0<strong>couth<\/strong>. Otherwise we say the pair is\u00a0<strong>uncouth<\/strong>. These term were coined by Robert Corless and his coauthors in their paper [1].<\/p>\n<p>Whether the pair (foo, fooh) is couth depends not only on foo and fooh, but also on the details of how arcfoo and arcfooh are defined.<\/p>\n<p>In Python&#8217;s NumPy library, the pairs (sin, sinh) and (tan, tanh) are couth, but the pair (cos, cosh) is uncouth.<\/p>\n<p>Numpy doesn&#8217;t define the reciprocal functions sec, sech, csc, csch, cot, and coth. I used to find that annoying, but I&#8217;m beginning to think that was wise. These functions cause problems. For example, there may be two reasonable ways to define these functions, one of which forms a couth pair and one of which forms an uncouth pair.<\/p>\n<p>For example, how should you define cot and coth? There would be no disagreement over the definition<\/p>\n<pre>cot = lambda x: 1\/tan(x)<\/pre>\n<p>but there are at least two definitions of inverse coth that you&#8217;ll find in practice:<\/p>\n<pre>\r\narccot = lambda z: 0.5*pi - arctan(z)\r\narccot = lambda z: arctan(1\/z).\r\n<\/pre>\n<p>Both definitions have their advantages, but the former is uncouth while the latter is couth. You can verify that both definitions are the same at <em>z<\/em> = 1 but not at <em>z<\/em> = &minus;1.<\/p>\n<p>With the following definitions, the pairs (cos, cosh) and (sec, sech) are uncouth and the rest are couth.<\/p>\n<pre>\r\nfrom numpy import *\r\n\r\ncsc     = lambda x: 1\/sin(x)\r\nsec     = lambda x: 1\/cos(x)\r\ncot     = lambda x: 1\/tan(x)\r\ncsch    = lambda x: 1\/sinh(x)\r\nsech    = lambda x: 1\/cosh(x)\r\ncoth    = lambda x: 1\/tanh(x)\r\n\r\narccot  = lambda z: arctan(1\/z)\r\narcsec  = lambda z: arccos(1\/z)\r\narccsc  = lambda z: arcsin(1\/z)\r\narccoth = lambda z: arctanh(1\/z)\r\narcsech = lambda z: arccosh(1\/z)\r\narccsch = lambda z: arcsinh(1\/z)\r\n<\/pre>\n<p>[1] &#8220;According to Abramowitz and Stegun&#8221; or arccoth needn&#8217;t be uncouth. Robert M. Corless <em>et al<\/em>. ACM SIGSAM Bulletin, Volume 34, Issue 2, pp 58 &#8211; 65 https:\/\/doi.org\/10.1145\/362001.362023<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;You can&#8217;t always get what you want. But sometimes you get what you need.&#8221; \u2014 The Rolling Stones Circular functions and hyperbolic functions aren&#8217;t invertible, but we invert them anyway. These functions map many points in the domain to each point in the range, and we invert them by mapping a point in the range [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[9],"tags":[181,129],"class_list":["post-247031","post","type-post","status-publish","format-standard","hentry","category-math","tag-complex-analysis","tag-special-functions"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/comments?post=247031"}],"version-history":[{"count":0,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247031\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/media?parent=247031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/categories?post=247031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/tags?post=247031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}},{"id":247032,"date":"2026-05-21T10:53:56","date_gmt":"2026-05-21T15:53:56","guid":{"rendered":"https:\/\/www.johndcook.com\/blog\/?p=247032"},"modified":"2026-05-21T12:56:32","modified_gmt":"2026-05-21T17:56:32","slug":"circular-hyperbolic-rotations","status":"publish","type":"post","link":"https:\/\/www.johndcook.com\/blog\/2026\/05\/21\/circular-hyperbolic-rotations\/","title":{"rendered":"Circular and hyperbolic functions differ by rotations"},"content":{"rendered":"<p>The difference between a circular function and a hyperbolic function is a rotation or two.<\/p>\n<p>For example, cosh(<em>z<\/em>) = cos(<em>iz<\/em>). You can read that as saying that to find the hyperbolic cosine of <em>z<\/em>, first you rotate\u00a0<em>z<\/em> a quarter turn to the left (i.e. multiply by <em>i<\/em>) and then take the cosine.<\/p>\n<p>For another example, sinh(<em>z<\/em>) = \u2212<em>i<\/em> sin(<em>iz<\/em>). This says that you can calculate the hyperbolic sine of\u00a0<em>z<\/em> by rotating\u00a0<em>z<\/em> to the left, taking the sine, and then rotating to the right.<\/p>\n<p>You can relate each trig function &#8220;foo&#8221; with its hyperbolic counterpart &#8220;fooh&#8221; by applying one of the functions to\u00a0<em>iz<\/em> then multiplying by a constant <em>c<\/em> that depends on foo:\u00a0<em>c<\/em> =\u00a0<em>i<\/em> for sin and tan,\u00a0<em>c<\/em> = 1 for cos and sec, and\u00a0<em>c<\/em> = \u2212<em>i<\/em> for csc and cot.<\/p>\n<p>Note that if the constant for foo is\u00a0<em>c<\/em>, the constant for 1\/foo is 1\/<em>c<\/em>. So, for example, the constant for tan is\u00a0<em>i<\/em> and the constant for cot is 1\/<em>i<\/em> = \u2212<em>i<\/em>.<\/p>\n<p>We have four groups of equations, depending on whether the left side of the equation is foo(<em>iz<\/em>), fooh(<em>iz<\/em>), foo(<em>z<\/em>), or fooh(<em>z<\/em>).<\/p>\n<p>This post was written as a warm-up for the <a href=\"https:\/\/www.johndcook.com\/blog\/2026\/05\/21\/couth-and-uncouth-function-pairs\/\">next post<\/a> on couth and uncouth function pairs.<\/p>\n<h2>foo(iz)<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium\" src=\"https:\/\/www.johndcook.com\/fooiz2.png\" width=\"320\" height=\"291\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" style=\"background-color: white;\" src=\"https:\/\/www.johndcook.com\/fooiz.svg\" alt=\"\\begin{align*} \\sin(iz) &amp; = \\phantom{-}i\\sinh(z) \\\\ \\cos(iz) &amp; = \\phantom{-i}\\cosh(z) \\\\ \\tan(iz) &amp; = \\phantom{-}i\\tanh(z) \\\\ \\csc(iz) &amp; = -i\\text{csch}(z) \\\\ \\sec(iz) &amp; = \\phantom{-i}\\text{sech}(z) \\\\ \\cot(iz) &amp; = -i\\coth(z) \\\\ \\end{align*}\" width=\"163\" height=\"163\" \/><\/p>\n<h2>fooh(iz)<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium aligncenter\" src=\"https:\/\/www.johndcook.com\/foohiz2.png\" width=\"320\" height=\"291\" \/><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" style=\"background-color: white;\" src=\"https:\/\/www.johndcook.com\/foohiz.svg\" alt=\"\\begin{align*} \\sinh(iz) &amp; = \\phantom{-}i\\sin(z) \\\\ \\cosh(iz) &amp; = \\phantom{-i}\\cos(z) \\\\ \\tanh(iz) &amp; = \\phantom{-}i\\tan(z) \\\\ \\text{csch}(iz) &amp; = -i\\csc(z) \\\\ \\text{sech}(iz) &amp; = \\phantom{-i}\\sec(z) \\\\ \\coth(iz) &amp; = -i\\cot(z) \\\\ \\end{align*}\" width=\"163\" height=\"163\" \/><\/p>\n<h2>foo(z)<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium\" src=\"https:\/\/www.johndcook.com\/fooz2.png\" width=\"320\" height=\"297\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" style=\"background-color: white;\" src=\"https:\/\/www.johndcook.com\/fooz.svg\" alt=\"\\begin{align*} \\sin(z) &amp; = -i\\sinh(iz) \\\\ \\cos(z) &amp; = \\phantom{-i}\\cosh(iz) \\\\ \\tan(z) &amp; = -i\\tanh(iz) \\\\ \\csc(z) &amp; = \\phantom{-}i\\text{csch}(iz) \\\\ \\sec(z) &amp; = \\phantom{-i}\\text{sech}(iz) \\\\ \\cot(z) &amp; = \\phantom{-}i\\coth(iz) \\\\ \\end{align*}\" width=\"163\" height=\"163\" \/><\/p>\n<h2>fooh(z)<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium\" src=\"https:\/\/www.johndcook.com\/foohz2.png\" width=\"320\" height=\"296\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" style=\"background-color: white;\" src=\"https:\/\/www.johndcook.com\/fooh.svg\" alt=\"\\begin{align*} \\sinh(z) &amp; = -i\\sin(iz) \\\\ \\cosh(z) &amp; = \\phantom{-i}\\cos(iz) \\\\ \\tanh(z) &amp; = -i\\tan(iz) \\\\ \\text{csch}(z) &amp; = \\phantom{-}i\\csc(iz) \\\\ \\text{sech}(z) &amp; = \\phantom{-i}\\sec(iz) \\\\ \\coth(z) &amp; = \\phantom{-}i\\cot(iz) \\\\ \\end{align*} \" width=\"163\" height=\"163\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The difference between a circular function and a hyperbolic function is a rotation or two. For example, cosh(z) = cos(iz). You can read that as saying that to find the hyperbolic cosine of z, first you rotate\u00a0z a quarter turn to the left (i.e. multiply by i) and then take the cosine. For another example, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[9],"tags":[],"class_list":["post-247032","post","type-post","status-publish","format-standard","hentry","category-math"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247032","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/comments?post=247032"}],"version-history":[{"count":0,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247032\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/media?parent=247032"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/categories?post=247032"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/tags?post=247032"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}},{"id":247029,"date":"2026-05-19T19:49:50","date_gmt":"2026-05-20T00:49:50","guid":{"rendered":"https:\/\/www.johndcook.com\/blog\/?p=247029"},"modified":"2026-05-21T14:04:16","modified_gmt":"2026-05-21T19:04:16","slug":"square-root-of-x-squared-minus-one","status":"publish","type":"post","link":"https:\/\/www.johndcook.com\/blog\/2026\/05\/19\/square-root-of-x-squared-minus-one\/","title":{"rendered":"Square root of x\u00b2 \u2212 1"},"content":{"rendered":"<p>How should we define \u221a(<em>z<\/em>\u00b2 \u2212 1)? Well, you could square <em>z<\/em>, subtract 1, and take the square root. What else would you do?!<\/p>\n<p>The question turns out to be more subtle than it looks.<\/p>\n<p>When\u00a0<em>x<\/em> is a non-negative real number, \u221a<em>x<\/em> is defined to be the non-negative real number whose square is\u00a0<em>x<\/em>. When\u00a0<em>x<\/em> is a complex number \u221a<em>x<\/em> is defined to be <strong>a<\/strong> function that extends \u221a<em>x<\/em> from the real line to the complex plane by analytic continuation. But we can&#8217;t extend \u221a<em>x<\/em> as an analytic function to the entire complex plane \u2102. We have to choose to make a &#8220;cut&#8221; somewhere, and the conventional choice is to make a cut along the negative real axis.<\/p>\n<h2>Using the principal branch<\/h2>\n<p>The &#8220;principal branch&#8221; of the square root function is defined to be the unique function that analytically extends \u221a<em>x<\/em> from the positive reals to \u2102 \\ (\u2212\u221e, 0].<\/p>\n<p>Assume for now that by \u221a<em>x<\/em> we mean the principal branch of the square root function. Now what does \u221a(<em>z<\/em>\u00b2 \u2212 1) mean? It\u00a0<em>could<\/em> mean just what we said at the top of the post: we square\u00a0<em>z<\/em>, subtract 1, and apply the (principal branch of the) square root function. If we do that, we must exclude those values of <em>z<\/em> such that (<em>z<\/em>\u00b2 \u2212 1) is negative. This means we have to cut out the imaginary axis and the interval [\u22121, 1].<\/p>\n<p>This is what Mathematica will do when asked to evaluate <code>Sqrt[z^2 - 1]<\/code>. The command<\/p>\n<pre>ComplexPlot[Sqrt[z^2 - 1], {z, -2 - 2 I, 2 + 2 I}]<\/pre>\n<p>makes the branch cuts clear by abrupt changes in color.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium\" src=\"https:\/\/www.johndcook.com\/sqrt_branch1.png\" width=\"480\" height=\"483\" \/><\/p>\n<h2>A different approach<\/h2>\n<p>Now let&#8217;s take a different approach. Consider the function \u221a(<em>z<\/em>\u00b2 \u2212 1) as a whole. Do not think of it procedurally as above, first squaring <em>z<\/em> etc. Instead, think of a it as a black box that takes in <em>z<\/em> and returns a complex number whose square is <em>z<\/em>\u00b2 \u2212 1.<\/p>\n<p>This function has an obvious definition for <em>z<\/em> &gt; 1. And we can extend this function, via analytic continuation, to more of the complex plane. We can do this <em>directly<\/em>, not by extending the square root function. But as before, we cannot extend the function analytically to all of \u2102. We have to cut something out. A common choice is to cut out [\u22121, 1]. This eliminates the need for a branch cut along the imaginary axis.<\/p>\n<p>The function<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" style=\"background-color: white;\" src=\"https:\/\/www.johndcook.com\/cosh_sum5.svg\" alt=\"f(z) = \\exp\\left( \\tfrac{1}{2}\\left( \\log(z - 1) + \\log(z + 1) \\right) \\right)\" width=\"320\" height=\"36\" \/><\/p>\n<p>extends \u221a(<em>z<\/em>\u00b2 \u2212 1) the way we want [1].<\/p>\n<p>The Mathematica code<\/p>\n<pre>ComplexPlot[Exp[(1\/2) (Log[z - 1 ] + Log[z + 1])], {z, -2 - 2 I, 2 + 2 I}]<\/pre>\n<p>shows that our function is now continuous across the imaginary axis, though there&#8217;s still a discontinuity as you cross [\u22121, 1].<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium\" src=\"https:\/\/www.johndcook.com\/sqrt_branch2.png\" width=\"480\" height=\"483\" \/><\/p>\n<p>We used this analytic extension of \u221a(<em>z<\/em>\u00b2 \u2212 1) in the <a href=\"https:\/\/www.johndcook.com\/blog\/2026\/05\/19\/closer-look-at-an-identity\/\">previous post<\/a> to eliminate branch cuts in an identity.<\/p>\n<h2>Related posts<\/h2>\n<ul>\n<li class=\"link\"><a href=\"https:\/\/www.johndcook.com\/blog\/2026\/03\/09\/trig-composition-table\/\">Trig composition table<\/a><\/li>\n<li class=\"link\"><a href=\"https:\/\/www.johndcook.com\/blog\/2026\/03\/10\/sinh-arccosh\/\">sinh( arccosh(x) )<\/a><\/li>\n<li class=\"link\"><a href=\"https:\/\/www.johndcook.com\/blog\/2025\/03\/03\/mathematica-contour-plot\/\">Duplicating a hand-drawn plot<\/a><\/li>\n<\/ul>\n<p>[1] The principal branch of the logarithm has a cut along the negative real axis. Why does our square root function, defined using log, not have a branch cut along the negative axis?<\/p>\n<p>First of all, the log function, and Mathematica&#8217;s implementation of it <code>Log[]<\/code>, isn&#8217;t undefined on (\u2212\u221e, 1), it just isn&#8217;t continuous there. The function still has a value. By convention, the value is taken to be the limit of log(<em>z<\/em>) approaching <em>z<\/em>\u00a0from above, i.e. from the 2nd quadrant.<\/p>\n<p>Second, the value of (log(<em>z<\/em> &#8211; 1) + log(<em>z<\/em> + 1))\/2 differs by a factor of 2\u03c0<em>i<\/em> when approaching a value <em>z<\/em> &lt; \u22121 from above versus from below. This factor goes away when taking the exponential. So our function\u00a0<em>f<\/em>(<em>z<\/em>) is analytic across (\u2212\u221e, 1) even though the log functions in its definition are not.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How should we define \u221a(z\u00b2 \u2212 1)? Well, you could square z, subtract 1, and take the square root. What else would you do?! The question turns out to be more subtle than it looks. When\u00a0x is a non-negative real number, \u221ax is defined to be the non-negative real number whose square is\u00a0x. When\u00a0x is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[9],"tags":[181],"class_list":["post-247029","post","type-post","status-publish","format-standard","hentry","category-math","tag-complex-analysis"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247029","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/comments?post=247029"}],"version-history":[{"count":0,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247029\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/media?parent=247029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/categories?post=247029"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/tags?post=247029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}},{"id":247027,"date":"2026-05-19T18:37:31","date_gmt":"2026-05-19T23:37:31","guid":{"rendered":"https:\/\/www.johndcook.com\/blog\/?p=247027"},"modified":"2026-05-19T19:38:25","modified_gmt":"2026-05-20T00:38:25","slug":"closer-look-at-an-identity","status":"publish","type":"post","link":"https:\/\/www.johndcook.com\/blog\/2026\/05\/19\/closer-look-at-an-identity\/","title":{"rendered":"Closer look at an identity"},"content":{"rendered":"<p>The previous post derived the identity<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" style=\"background-color: white;\" src=\"https:\/\/www.johndcook.com\/cosh_sum1.svg\" alt=\"\\cosh\\Big( \\operatorname{arccosh}(x) + \\operatorname{arccosh}(y)\\Big) = xy + \\sqrt{x^2 -1} \\sqrt{y^2 -1}\" width=\"452\" height=\"38\" \/><\/p>\n<p>and said in a footnote that the identity holds at least for\u00a0<em>x<\/em> &gt; 1 and\u00a0<em>y<\/em> &gt; 1. That&#8217;s true, but let&#8217;s see why the footnote is necessary.<\/p>\n<p>Let&#8217;s have Mathematica plot<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" style=\"background-color: white;\" src=\"https:\/\/www.johndcook.com\/cosh_sum2.svg\" alt=\"\\left| \\cosh\\Big( \\operatorname{arccosh}(x) + \\operatorname{arccosh}(y)\\Big) - xy - \\sqrt{x^2 -1} \\sqrt{y^2 -1} \\right|\" width=\"461\" height=\"48\" \/><\/p>\n<p>The plot will be 0 where the identity above holds.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium\" src=\"https:\/\/www.johndcook.com\/coshacosh1.png\" width=\"480\" height=\"399\" \/><\/p>\n<p>The plot is indeed flat for\u00a0<em>x<\/em> &gt; 1 and\u00a0<em>y<\/em> &gt; 1, and more, but not everywhere.<\/p>\n<p>If we combine the two square roots<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" style=\"background-color: white;\" src=\"https:\/\/www.johndcook.com\/cosh_sum3.svg\" alt=\"\\left| \\cosh\\Big( \\operatorname{arccosh}(x) + \\operatorname{arccosh}(y)\\Big) - xy - \\sqrt{(x^2 -1) (y^2 -1)} \\right|\" width=\"479\" height=\"48\" \/><\/p>\n<p>and plot again we still get a valid identity for\u00a0<em>x<\/em> &gt; 1 and\u00a0<em>y<\/em> &gt; 1, but the plot changes.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium\" src=\"https:\/\/www.johndcook.com\/coshacosh2.png\" width=\"480\" height=\"399\" \/><\/p>\n<p>This is because \u221a<em>a<\/em> \u221a<em>b<\/em> does not necessarily equal \u221a(<em>ab<\/em>) when the arguments may be negative.<\/p>\n<p>The square root function and the arccosh function are not naturally single-valued functions. They require branch cuts to force them to be single-valued, and the two functions require <em>different<\/em> branch cuts. I go into this in some detail <a href=\"https:\/\/www.johndcook.com\/blog\/2026\/03\/10\/sinh-arccosh\/\">here<\/a>.<\/p>\n<p>There is a way to reformulate our identity so that it holds everywhere. If we replace<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" style=\"background-color: white;\" src=\"https:\/\/www.johndcook.com\/cosh_sum4.svg\" alt=\"\\sqrt{z^2 - 1}\" width=\"63\" height=\"24\" \/><\/p>\n<p>with<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" style=\"background-color: white;\" src=\"https:\/\/www.johndcook.com\/cosh_sum5.svg\" alt=\"f(z) = \\exp\\left( \\tfrac{1}{2}\\left( \\log(z - 1) + \\log(z + 1) \\right) \\right)\" width=\"320\" height=\"36\" \/><\/p>\n<p>which is equivalent for <em>z<\/em> &gt; 1, the corresponding identity holds everywhere.<\/p>\n<p>We can verify this with the following Mathematica code.<\/p>\n<pre>f[z_] := Exp[(1\/2) (Log[z - 1 ] + Log[z + 1])]\r\nFullSimplify[Cosh[ArcCosh[x] + ArcCosh[y]] - x y - f[x] f[y]]\r\n<\/pre>\n<p>This returns 0.<\/p>\n<p>By contrast, the code<\/p>\n<pre>FullSimplify[\r\n Cosh[ArcCosh[x] + ArcCosh[y]] - x y - Sqrt[x^2 - 1] Sqrt[y^2 - 1]]<\/pre>\n<p>simply returns its input with no simplification, unless we add restrictions on <em>x<\/em> and <em>y<\/em>. The code<\/p>\n<pre>FullSimplify[\r\n Cosh[ArcCosh[x] + ArcCosh[y]] - x y - Sqrt[x^2 - 1] Sqrt[y^2 - 1], \r\n Assumptions -&gt; {x &gt; -1 &amp;&amp; y &gt; -1}]\r\n<\/pre>\n<p>does return 0.<\/p>\n<h2>Related posts<\/h2>\n<ul>\n<li class=\"link\"><a href=\"https:\/\/www.johndcook.com\/blog\/2026\/03\/12\/arccos\/\">Inverse cosine<\/a><\/li>\n<li class=\"link\"><a href=\"https:\/\/www.johndcook.com\/blog\/2016\/12\/17\/branch-cuts-and-common-lisp\/\">Branch cuts and Common Lisp<\/a><\/li>\n<li class=\"link\"><a href=\"https:\/\/www.johndcook.com\/blog\/2025\/01\/22\/duplicating-hankel-plot-from-as\/\">Duplicating a plot from A &amp; S<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The previous post derived the identity and said in a footnote that the identity holds at least for\u00a0x &gt; 1 and\u00a0y &gt; 1. That&#8217;s true, but let&#8217;s see why the footnote is necessary. Let&#8217;s have Mathematica plot The plot will be 0 where the identity above holds. The plot is indeed flat for\u00a0x &gt; 1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[9],"tags":[181,87],"class_list":["post-247027","post","type-post","status-publish","format-standard","hentry","category-math","tag-complex-analysis","tag-mathematica"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/comments?post=247027"}],"version-history":[{"count":0,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247027\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/media?parent=247027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/categories?post=247027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/tags?post=247027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}},{"id":247025,"date":"2026-05-19T07:09:54","date_gmt":"2026-05-19T12:09:54","guid":{"rendered":"https:\/\/www.johndcook.com\/blog\/?p=247025"},"modified":"2026-05-19T11:51:38","modified_gmt":"2026-05-19T16:51:38","slug":"zagiers-equation","status":"publish","type":"post","link":"https:\/\/www.johndcook.com\/blog\/2026\/05\/19\/zagiers-equation\/","title":{"rendered":"Approximating Markov&#8217;s equation"},"content":{"rendered":"<p>Markov numbers are integer solutions to<\/p>\n<p style=\"padding-left: 40px;\"><em>x<\/em>\u00b2 +\u00a0<em>y<\/em>\u00b2 +\u00a0<em>z<\/em>\u00b2 = 3<em>xyz<\/em>.<\/p>\n<p>The Wikipedia article on Markov numbers mentions that Don Zagier studied Markov numbers by looking the approximating equation<\/p>\n<p style=\"padding-left: 40px;\"><em>x<\/em>\u00b2 +\u00a0<em>y<\/em>\u00b2 +\u00a0<em>z<\/em>\u00b2 = 3<em>xyz<\/em>\u00a0+ 4\/9<\/p>\n<p>which is equivalent to<\/p>\n<p style=\"padding-left: 40px;\"><em>f<\/em>(<em>x<\/em>) +\u00a0<em>f<\/em>(<em>y<\/em>) = <em>f<\/em>(<em>z<\/em>)<\/p>\n<p>where\u00a0<em>f<\/em>(<em>t<\/em>) is defined as arccosh(3<em>t<\/em>\/2). It wasn&#8217;t clear to me why the two previous equations are equivalent, so I&#8217;m writing this post to show that they are equivalent.<\/p>\n<h2>Examples<\/h2>\n<p>Before showing the equivalence of Zagier&#8217;s two equations, let&#8217;s look at an example that shows solutions to his second equation approximate solutions to Markov&#8217;s equation.<\/p>\n<p>The following code verifies that (5, 13, 194) is a solution to Markov&#8217;s equation.<\/p>\n<pre>x, y, z = 5, 13, 194\r\nassert(x**2 + y**2 + z**2 == 3*x*y*z)\r\n<\/pre>\n<p>With the same\u00a0<em>x<\/em> and\u00a0<em>y<\/em> above, let&#8217;s show that the\u00a0<em>z<\/em> in Zagier&#8217;s second equation is close to the\u00a0<em>z<\/em> above.<\/p>\n<pre>from math import cosh, acosh\r\n\r\nf = lambda t: acosh(3*t\/2)\r\ng = lambda t: cosh(t)*2\/3\r\nz = g(f(x) + f(y))\r\nprint(z)\r\n<\/pre>\n<p>This gives <em>z<\/em> = 194.0023, which is close to the value of <em>z<\/em> in the Markov triple above.<\/p>\n<h2>Applying Osborn&#8217;s rule<\/h2>\n<p>Now suppose<\/p>\n<p style=\"padding-left: 40px;\"><em>f<\/em>(<em>x<\/em>) +\u00a0<em>f<\/em>(<em>y<\/em>) = <em>f<\/em>(<em>z<\/em>)<\/p>\n<p>which expands to<\/p>\n<p style=\"padding-left: 40px;\">arccosh(3<em>x<\/em>\/2) + arccosh(3<em>y<\/em>\/2)\u00a0 = arccosh(3<em>z<\/em>\/2).<\/p>\n<p>It seems sensible to apply cosh to both sides. Is there some identity for cosh of a sum? Maybe you recall the equation for cosine of a sum:<\/p>\n<p style=\"padding-left: 40px;\">cos(<em>a<\/em> +\u00a0<em>b<\/em>) = cos(<em>a<\/em>) cos(<em>b<\/em>) \u2212 sin(<em>a<\/em>) sin(<em>b<\/em>).<\/p>\n<p>Then <a href=\"https:\/\/www.johndcook.com\/blog\/2024\/08\/20\/osborn-rule\/\">Osborn&#8217;s rule<\/a> says the corresponding hyperbolic identity is<\/p>\n<p style=\"padding-left: 40px;\">cosh(<em>a<\/em> +\u00a0<em>b<\/em>) = cosh(<em>a<\/em>) cosh(<em>b<\/em>) \u2212 sinh(<em>a<\/em>) sinh(<em>b<\/em>).<\/p>\n<p>Osborn&#8217;s rule also says that the analog of the familiar identity<\/p>\n<p style=\"padding-left: 40px;\">sin\u00b2(<em>a<\/em>) + cos\u00b2(<em>b<\/em>) = 1<\/p>\n<p>is<\/p>\n<p style=\"padding-left: 40px;\">sinh\u00b2(<em>a<\/em>) = cosh\u00b2(<em>b<\/em>) \u2212 1.<\/p>\n<p>From these two hyperbolic identities we can show that [1]<\/p>\n<p style=\"padding-left: 40px;\">cosh( arccosh(<em>a<\/em>) + arccosh(<em>b<\/em>) ) =\u00a0<em>ab<\/em> + \u221a(<em>a<\/em>\u00b2 \u2212 1) \u221a(<em>b<\/em>\u00b2 \u2212 1).<\/p>\n<h2>Slug it out<\/h2>\n<p>The identity derived above is the tool we need to reduce our task to routine algebra.<\/p>\n<p>If<\/p>\n<p style=\"padding-left: 40px;\">arccosh(3<em>x<\/em>\/2) + arccosh(3<em>y<\/em>\/2)\u00a0 = arccosh(3<em>z<\/em>\/2)<\/p>\n<p>then<\/p>\n<p style=\"padding-left: 40px;\">(3<em>x<\/em>\/2)\u00a0 (3<em>y<\/em>\/2)\u00a0 + \u221a((3<em>x<\/em>\/2)\u00b2 \u2212 1) \u221a((3<em>y<\/em>\/2)\u00b2 \u2212 1) = 3<em>z<\/em> \/ 2<\/p>\n<p>which simplifies to Zagier&#8217;s equation<\/p>\n<p style=\"padding-left: 40px;\"><em>x<\/em>\u00b2 +\u00a0<em>y<\/em>\u00b2 +\u00a0<em>z<\/em>\u00b2 = 3<em>xyz<\/em> + 4\/9.<\/p>\n<h2>Related posts<\/h2>\n<ul>\n<li class=\"link\"><a href=\"https:\/\/www.johndcook.com\/blog\/2023\/09\/22\/prime-weeds\/\">Primes and weeds<\/a><\/li>\n<li class=\"link\"><a href=\"https:\/\/www.johndcook.com\/blog\/2026\/03\/10\/sinh-arccosh\/\">sinh( arccosh(x) )<\/a><\/li>\n<li class=\"link\"><a href=\"https:\/\/www.johndcook.com\/blog\/2022\/01\/08\/diophantine\/\">Three paths converge<\/a><\/li>\n<\/ul>\n<p>[1] The equation holds at least for <em>x<\/em> &gt; 1 and\u00a0<em>y<\/em> &gt; 1, which is enough for this post. More general arguments run into complications due to branch cuts.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Markov numbers are integer solutions to x\u00b2 +\u00a0y\u00b2 +\u00a0z\u00b2 = 3xyz. The Wikipedia article on Markov numbers mentions that Don Zagier studied Markov numbers by looking the approximating equation x\u00b2 +\u00a0y\u00b2 +\u00a0z\u00b2 = 3xyz\u00a0+ 4\/9 which is equivalent to f(x) +\u00a0f(y) = f(z) where\u00a0f(t) is defined as arccosh(3t\/2). It wasn&#8217;t clear to me why the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[9],"tags":[],"class_list":["post-247025","post","type-post","status-publish","format-standard","hentry","category-math"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247025","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/comments?post=247025"}],"version-history":[{"count":0,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/posts\/247025\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/media?parent=247025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/categories?post=247025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.johndcook.com\/blog\/wp-json\/wp\/v2\/tags?post=247025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}]