{
  "index": "1975-A-1",
  "type": "NT",
  "tag": [
    "NT",
    "ALG"
  ],
  "difficulty": "",
  "question": "A-1. Supposing that an integer \\( n \\) is the sum of two triangular numbers,\n\\[\nn=\\frac{a^{2}+a}{2}+\\frac{b^{2}+b}{2}\n\\]\nwrite \\( 4 n+1 \\) as the sum of two squares, \\( 4 n+1=x^{2}+y^{2} \\), and show how \\( x \\) and \\( y \\) can be expressed in terms of \\( a \\) and \\( b \\).\n\nShow that, conversely, if \\( 4 n+1=x^{2}+y^{2} \\), then \\( n \\) is the sum of two triangular numbers.\n[Of course, \\( a, b, x, y \\) are understood to be integers.]",
  "solution": "A-1.\nLet \\( n=\\left[\\left(a^{2}+a\\right) / 2\\right]+\\left[\\left(b^{2}+b\\right) / 2\\right] \\), with \\( a \\) and \\( b \\) integers. Then\n\\[\n4 n+1=2 a^{2}+2 a+2 b^{2}+2 b+1=(a+b+1)^{2}+(a-b)^{2} .\n\\]\n\nConversely, let \\( 4 n+1=x^{2}+y^{2} \\), with \\( x \\) and \\( y \\) integers. Then exactly one of \\( x \\) and \\( y \\) is odd and so \\( a=(x+y-1) / 2 \\) and \\( b=(x-y-1) / 2 \\) are integers. One easily verifies that\n\\[\n\\left[\\left(a^{2}+a\\right) / 2\\right]+\\left[\\left(b^{2}+b\\right) / 2\\right]=\\left(x^{2}+y^{2}-1\\right) / 4=n .\n\\]",
  "vars": [
    "n",
    "a",
    "b",
    "x",
    "y"
  ],
  "params": [],
  "sci_consts": [],
  "variants": {
    "descriptive_long": {
      "map": {
        "n": "totalsum",
        "a": "firstindex",
        "b": "secondindex",
        "x": "firstsquare",
        "y": "secondsquare"
      },
      "question": "A-1. Supposing that an integer \\( totalsum \\) is the sum of two triangular numbers,\n\\[\ntotalsum=\\frac{firstindex^{2}+firstindex}{2}+\\frac{secondindex^{2}+secondindex}{2}\n\\]\nwrite \\( 4 totalsum+1 \\) as the sum of two squares, \\( 4 totalsum+1=firstsquare^{2}+secondsquare^{2} \\), and show how \\( firstsquare \\) and \\( secondsquare \\) can be expressed in terms of \\( firstindex \\) and \\( secondindex \\).\n\nShow that, conversely, if \\( 4 totalsum+1=firstsquare^{2}+secondsquare^{2} \\), then \\( totalsum \\) is the sum of two triangular numbers.\n[Of course, \\( firstindex, secondindex, firstsquare, secondsquare \\) are understood to be integers.]",
      "solution": "A-1.\nLet \\( totalsum=\\left[\\left(firstindex^{2}+firstindex\\right) / 2\\right]+\\left[\\left(secondindex^{2}+secondindex\\right) / 2\\right] \\), with \\( firstindex \\) and \\( secondindex \\) integers. Then\n\\[\n4 totalsum+1=2 firstindex^{2}+2 firstindex+2 secondindex^{2}+2 secondindex+1=(firstindex+secondindex+1)^{2}+(firstindex-secondindex)^{2} .\n\\]\n\nConversely, let \\( 4 totalsum+1=firstsquare^{2}+secondsquare^{2} \\), with \\( firstsquare \\) and \\( secondsquare \\) integers. Then exactly one of \\( firstsquare \\) and \\( secondsquare \\) is odd and so \\( firstindex=(firstsquare+secondsquare-1) / 2 \\) and \\( secondindex=(firstsquare-secondsquare-1) / 2 \\) are integers. One easily verifies that\n\\[\n\\left[\\left(firstindex^{2}+firstindex\\right) / 2\\right]+\\left[\\left(secondindex^{2}+secondindex\\right) / 2\\right]=\\left(firstsquare^{2}+secondsquare^{2}-1\\right) / 4=totalsum .\n\\]"
    },
    "descriptive_long_confusing": {
      "map": {
        "n": "marshmallow",
        "a": "butterscotch",
        "b": "chandelier",
        "x": "raincloud",
        "y": "cinnamon"
      },
      "question": "A-1. Supposing that an integer \\( marshmallow \\) is the sum of two triangular numbers,\n\\[\nmarshmallow=\\frac{butterscotch^{2}+butterscotch}{2}+\\frac{chandelier^{2}+chandelier}{2}\n\\]\nwrite \\( 4 marshmallow+1 \\) as the sum of two squares, \\( 4 marshmallow+1=raincloud^{2}+cinnamon^{2} \\), and show how \\( raincloud \\) and \\( cinnamon \\) can be expressed in terms of \\( butterscotch \\) and \\( chandelier \\).\n\nShow that, conversely, if \\( 4 marshmallow+1=raincloud^{2}+cinnamon^{2} \\), then \\( marshmallow \\) is the sum of two triangular numbers.\n[Of course, \\( butterscotch, chandelier, raincloud, cinnamon \\) are understood to be integers.]",
      "solution": "A-1.\nLet \\( marshmallow=\\left[\\left(butterscotch^{2}+butterscotch\\right) / 2\\right]+\\left[\\left(chandelier^{2}+chandelier\\right) / 2\\right] \\), with \\( butterscotch \\) and \\( chandelier \\) integers. Then\n\\[\n4 marshmallow+1=2 butterscotch^{2}+2 butterscotch+2 chandelier^{2}+2 chandelier+1=(butterscotch+chandelier+1)^{2}+(butterscotch-chandelier)^{2} .\n\\]\n\nConversely, let \\( 4 marshmallow+1=raincloud^{2}+cinnamon^{2} \\), with \\( raincloud \\) and \\( cinnamon \\) integers. Then exactly one of \\( raincloud \\) and \\( cinnamon \\) is odd and so \\( butterscotch=(raincloud+cinnamon-1) / 2 \\) and \\( chandelier=(raincloud-cinnamon-1) / 2 \\) are integers. One easily verifies that\n\\[\n\\left[\\left(butterscotch^{2}+butterscotch\\right) / 2\\right]+\\left[\\left(chandelier^{2}+chandelier\\right) / 2\\right]=\\left(raincloud^{2}+cinnamon^{2}-1\\right) / 4=marshmallow .\n\\]"
    },
    "descriptive_long_misleading": {
      "map": {
        "n": "irrationalvalue",
        "a": "nonintegralone",
        "b": "nonintegraltwo",
        "x": "curvedaxis",
        "y": "straightaxis"
      },
      "question": "A-1. Supposing that an integer \\( irrationalvalue \\) is the sum of two triangular numbers,\n\\[\nirrationalvalue=\\frac{nonintegralone^{2}+nonintegralone}{2}+\\frac{nonintegraltwo^{2}+nonintegraltwo}{2}\n\\]\nwrite \\( 4\\,irrationalvalue+1 \\) as the sum of two squares, \\( 4\\,irrationalvalue+1=curvedaxis^{2}+straightaxis^{2} \\), and show how \\( curvedaxis \\) and \\( straightaxis \\) can be expressed in terms of \\( nonintegralone \\) and \\( nonintegraltwo \\).\n\nShow that, conversely, if \\( 4\\,irrationalvalue+1=curvedaxis^{2}+straightaxis^{2} \\), then \\( irrationalvalue \\) is the sum of two triangular numbers.\n[Of course, \\( nonintegralone, nonintegraltwo, curvedaxis, straightaxis \\) are understood to be integers.]",
      "solution": "A-1.\nLet \\( irrationalvalue=\\left[\\left(nonintegralone^{2}+nonintegralone\\right) / 2\\right]+\\left[\\left(nonintegraltwo^{2}+nonintegraltwo\\right) / 2\\right] \\), with \\( nonintegralone \\) and \\( nonintegraltwo \\) integers. Then\n\\[\n4\\,irrationalvalue+1=2\\,nonintegralone^{2}+2\\,nonintegralone+2\\,nonintegraltwo^{2}+2\\,nonintegraltwo+1=(nonintegralone+nonintegraltwo+1)^{2}+(nonintegralone-nonintegraltwo)^{2} .\n\\]\n\nConversely, let \\( 4\\,irrationalvalue+1=curvedaxis^{2}+straightaxis^{2} \\), with \\( curvedaxis \\) and \\( straightaxis \\) integers. Then exactly one of \\( curvedaxis \\) and \\( straightaxis \\) is odd and so \\( nonintegralone=(curvedaxis+straightaxis-1) / 2 \\) and \\( nonintegraltwo=(curvedaxis-straightaxis-1) / 2 \\) are integers. One easily verifies that\n\\[\n\\left[\\left(nonintegralone^{2}+nonintegralone\\right) / 2\\right]+\\left[\\left(nonintegraltwo^{2}+nonintegraltwo\\right) / 2\\right]=\\left(curvedaxis^{2}+straightaxis^{2}-1\\right) / 4=irrationalvalue .\n\\]"
    },
    "garbled_string": {
      "map": {
        "n": "qzxwvtnp",
        "a": "hjgrksla",
        "b": "mndftpqe",
        "x": "kslqmvra",
        "y": "pzhxncwu"
      },
      "question": "A-1. Supposing that an integer \\( qzxwvtnp \\) is the sum of two triangular numbers,\n\\[\nqzxwvtnp=\\frac{hjgrksla^{2}+hjgrksla}{2}+\\frac{mndftpqe^{2}+mndftpqe}{2}\n\\]\nwrite \\( 4 qzxwvtnp+1 \\) as the sum of two squares, \\( 4 qzxwvtnp+1=kslqmvra^{2}+pzhxncwu^{2} \\), and show how \\( kslqmvra \\) and \\( pzhxncwu \\) can be expressed in terms of \\( hjgrksla \\) and \\( mndftpqe \\).\n\nShow that, conversely, if \\( 4 qzxwvtnp+1=kslqmvra^{2}+pzhxncwu^{2} \\), then \\( qzxwvtnp \\) is the sum of two triangular numbers.\n[Of course, \\( hjgrksla, mndftpqe, kslqmvra, pzhxncwu \\) are understood to be integers.]",
      "solution": "A-1.\nLet \\( qzxwvtnp=\\left[\\left(hjgrksla^{2}+hjgrksla\\right) / 2\\right]+\\left[\\left(mndftpqe^{2}+mndftpqe\\right) / 2\\right] \\), with \\( hjgrksla \\) and \\( mndftpqe \\) integers. Then\n\\[\n4 qzxwvtnp+1=2 hjgrksla^{2}+2 hjgrksla+2 mndftpqe^{2}+2 mndftpqe+1=(hjgrksla+mndftpqe+1)^{2}+(hjgrksla-mndftpqe)^{2} .\n\\]\n\nConversely, let \\( 4 qzxwvtnp+1=kslqmvra^{2}+pzhxncwu^{2} \\), with \\( kslqmvra \\) and \\( pzhxncwu \\) integers. Then exactly one of \\( kslqmvra \\) and \\( pzhxncwu \\) is odd and so \\( hjgrksla=(kslqmvra+pzhxncwu-1) / 2 \\) and \\( mndftpqe=(kslqmvra-pzhxncwu-1) / 2 \\) are integers. One easily verifies that\n\\[\n\\left[\\left(hjgrksla^{2}+hjgrksla\\right) / 2\\right]+\\left[\\left(mndftpqe^{2}+mndftpqe\\right) / 2\\right]=\\left(kslqmvra^{2}+pzhxncwu^{2}-1\\right) / 4=qzxwvtnp .\n\\]"
    },
    "kernel_variant": {
      "question": "B-4.  Let an integer $K$ be representable as the sum of two triangular numbers\n\\[\nK=\\frac{p(p+1)}{2}+\\frac{q(q+1)}{2},\\qquad p,q\\in\\mathbb Z.\n\\]\n(a)  Show that\n\\[\n4K+1=r^{2}+s^{2}\n\\]\nfor some integers $r,s$, and give explicit formulas for $r$ and $s$ in terms of $p$ and $q$.\n\n(b)  Prove the converse: if integers $r,s$ satisfy $4K+1=r^{2}+s^{2}$, then $K$ can be written as the sum of two triangular numbers.\n\n(All variables are integral.)",
      "solution": "(a)  Start with\n\n  K = \\frac{p(p+1)}{2} + \\frac{q(q+1)}{2}.\n\nMultiply by 4 and add 1:\n\n  4K + 1 = 2p^2 + 2p + 2q^2 + 2q + 1 = (p+q+1)^2 + (q-p)^2.\n\nThus\n\n  4K+1 = s^2 + r^2,\n    where s = p + q + 1,  r = q - p.\n\n(b)  Conversely, suppose\n\n 4K+1 = r^2 + s^2,\n    with r,s ∈ ℤ.\n\nSince a square is 0 or 1 mod 4, r^2+s^2≡1 (mod 4) forces exactly one of r,s odd.  Relabel so the odd one is s, write s=2t+1, and define\n\n  p = (s + r - 1)/2 = t + r/2,\n  q = (s - r - 1)/2 = t - r/2.\n\nBecause r,s have opposite parity, p,q are integers.  A direct check gives\n\n  \\frac{p(p+1)}{2} + \\frac{q(q+1)}{2} = \\frac{r^2 + s^2 - 1}{4} = K,\n\nso K = T_p + T_q.  Hence K is a sum of two triangular numbers if and only if 4K+1 is a sum of two squares.",
      "_meta": {
        "core_steps": [
          "Write n = T_a + T_b with T_k = k(k+1)/2",
          "Compute 4n + 1 and factor it as (a+b+1)^2 + (a−b)^2",
          "Set x, y equal to those two squares to get 4n+1 = x^2 + y^2",
          "From x^2 + y^2 ≡ 1 (mod 4) deduce exactly one of x, y is odd, then solve a = (x+y−1)/2, b = (x−y−1)/2",
          "Check that the resulting a, b give back n = T_a + T_b"
        ],
        "mutable_slots": {
          "slot1": {
            "description": "names of the integers representing the triangular indices",
            "original": "a, b"
          },
          "slot2": {
            "description": "names of the integers representing the coordinates in the sum-of-squares",
            "original": "x, y"
          },
          "slot3": {
            "description": "assignment of the two expressions (a+b+1), (a−b) to x and y",
            "original": "x = a+b+1,  y = a−b"
          },
          "slot4": {
            "description": "sign in the difference term that gets squared (a−b vs b−a)",
            "original": "a−b"
          }
        }
      }
    }
  },
  "checked": true,
  "problem_type": "proof"
}