{
  "index": "1999-A-1",
  "type": "ALG",
  "tag": [
    "ALG"
  ],
  "difficulty": "",
  "question": "Find polynomials $f(x)$,$g(x)$, and $h(x)$, if they exist, such\nthat for all $x$,\n\\[\n|f(x)|-|g(x)|+h(x) = \\begin{cases} -1 & \\mbox{if $x<-1$} \\\\\n                     3x+2 & \\mbox{if $-1 \\leq x \\leq 0$} \\\\\n                     -2x+2 & \\mbox{if $x>0$.}\n                     \\end{cases}\n\\]",
  "solution": "Note that if $r(x)$ and $s(x)$ are any two functions, then\n\\[ \\max(r,s) = (r+s + |r-s|)/2.\\]\nTherefore, if $F(x)$ is the given function, we have\n\\begin{align*}\nF(x)\\ &= \\max\\{-3x-3,0\\}-\\max\\{5x,0\\}+3x+2 \\\\\n      &= (-3x-3+|3x+3|)/2 \\\\\n      & \\qquad - (5x + |5x|)/2 + 3x+2 \\\\\n      &= |(3x+3)/2| - |5x/2| -x + \\frac{1}{2},\n\\end{align*}\nso we may set $f(x)=(3x+3)/2$, $g(x) = 5x/2$, and $h(x)=-x+\\frac{1}{2}$.",
  "vars": [
    "x",
    "f",
    "g",
    "h",
    "r",
    "s",
    "F"
  ],
  "params": [],
  "sci_consts": [],
  "variants": {
    "descriptive_long": {
      "map": {
        "x": "variablex",
        "f": "polyfunf",
        "g": "polyfung",
        "h": "polyfunh",
        "r": "funcrr",
        "s": "funcss",
        "F": "bigfuncf"
      },
      "question": "Find polynomials $\\polyfunf(\\variablex)$, $\\polyfung(\\variablex)$, and $\\polyfunh(\\variablex)$, if they exist, such that for all $\\variablex$,\n\\[\n|\\polyfunf(\\variablex)|-|\\polyfung(\\variablex)|+\\polyfunh(\\variablex)=\\begin{cases}-1&\\mbox{if $\\variablex<-1$}\\\\3\\variablex+2&\\mbox{if $-1\\leq\\variablex\\leq0$}\\\\-2\\variablex+2&\\mbox{if $\\variablex>0$.}\\end{cases}\n\\]\n",
      "solution": "Note that if $\\funcrr(\\variablex)$ and $\\funcss(\\variablex)$ are any two functions, then\n\\[\\max(\\funcrr,\\funcss)=(\\funcrr+\\funcss+|\\funcrr-\\funcss|)/2.\\]\nTherefore, if $\\bigfuncf(\\variablex)$ is the given function, we have\n\\begin{align*}\n\\bigfuncf(\\variablex)\\ &=\\max\\{-3\\variablex-3,0\\}-\\max\\{5\\variablex,0\\}+3\\variablex+2\\\\\n&=(-3\\variablex-3+|3\\variablex+3|)/2\\\\\n&\\qquad-(5\\variablex+|5\\variablex|)/2+3\\variablex+2\\\\\n&=|(3\\variablex+3)/2|-|5\\variablex/2|-\\variablex+\\frac12,\n\\end{align*}\nso we may set $\\polyfunf(\\variablex)=(3\\variablex+3)/2$, $\\polyfung(\\variablex)=5\\variablex/2$, and $\\polyfunh(\\variablex)=-\\variablex+\\frac12$. "
    },
    "descriptive_long_confusing": {
      "map": {
        "x": "lanterns",
        "f": "moondust",
        "g": "treasure",
        "h": "sunshine",
        "r": "biscotti",
        "s": "pinecones",
        "F": "waterfall"
      },
      "question": "Find polynomials $moondust(lanterns)$,$treasure(lanterns)$, and $sunshine(lanterns)$, if they exist, such\nthat for all $lanterns$,\n\\[\n|moondust(lanterns)|-|treasure(lanterns)|+sunshine(lanterns) = \\begin{cases} -1 & \\mbox{if $lanterns<-1$} \\\\\n                     3lanterns+2 & \\mbox{if $-1 \\leq lanterns \\leq 0$} \\\\\n                     -2lanterns+2 & \\mbox{if $lanterns>0$.}\n                     \\end{cases}\n\\]",
      "solution": "Note that if $biscotti(lanterns)$ and $pinecones(lanterns)$ are any two functions, then\n\\[ \\max(biscotti,pinecones) = (biscotti+pinecones + |biscotti-pinecones|)/2.\\]\nTherefore, if $waterfall(lanterns)$ is the given function, we have\n\\begin{align*}\nwaterfall(lanterns)\\ &= \\max\\{-3lanterns-3,0\\}-\\max\\{5lanterns,0\\}+3lanterns+2 \\\\\n      &= (-3lanterns-3+|3lanterns+3|)/2 \\\\\n      & \\qquad - (5lanterns + |5lanterns|)/2 + 3lanterns+2 \\\\\n      &= |(3lanterns+3)/2| - |5lanterns/2| -lanterns + \\frac{1}{2},\n\\end{align*}\nso we may set $moondust(lanterns)=(3lanterns+3)/2$, $treasure(lanterns) = 5lanterns/2$, and $sunshine(lanterns)=-lanterns+\\frac{1}{2}$. "
    },
    "descriptive_long_misleading": {
      "map": {
        "x": "unchanging",
        "f": "antipoly",
        "g": "randomness",
        "h": "flatline",
        "r": "rigidity",
        "s": "stability",
        "F": "voidness"
      },
      "question": "Find polynomials $antipoly(unchanging)$,$randomness(unchanging)$, and $flatline(unchanging)$, if they exist, such\nthat for all $unchanging$,\n\\[\n|antipoly(unchanging)|-|randomness(unchanging)|+flatline(unchanging) = \\begin{cases} -1 & \\mbox{if $unchanging<-1$} \\\\\n                     3unchanging+2 & \\mbox{if $-1 \\leq unchanging \\leq 0$} \\\\\n                     -2unchanging+2 & \\mbox{if $unchanging>0$.}\n                     \\end{cases}\n\\]\n",
      "solution": "Note that if $rigidity(unchanging)$ and $stability(unchanging)$ are any two functions, then\n\\[ \\max(rigidity,stability) = (rigidity+stability + |rigidity-stability|)/2.\\]\nTherefore, if $voidness(unchanging)$ is the given function, we have\n\\begin{align*}\nvoidness(unchanging)\\ &= \\max\\{-3unchanging-3,0\\}-\\max\\{5unchanging,0\\}+3unchanging+2 \\\\\n      &= (-3unchanging-3+|3unchanging+3|)/2 \\\\\n      & \\qquad - (5unchanging + |5unchanging|)/2 + 3unchanging+2 \\\\\n      &= |(3unchanging+3)/2| - |5unchanging/2| -unchanging + \\frac{1}{2},\n\\end{align*}\nso we may set $antipoly(unchanging)=(3unchanging+3)/2$, $randomness(unchanging) = 5unchanging/2$, and $flatline(unchanging)=-unchanging+\\frac{1}{2}$.}"
    },
    "garbled_string": {
      "map": {
        "x": "lbgrtkhs",
        "f": "oqpdzmla",
        "g": "kbvtryhs",
        "h": "zjfdmnel",
        "r": "vxqcrlma",
        "s": "hjnptqwe",
        "F": "idwscrpt"
      },
      "question": "Find polynomials $oqpdzmla(lbgrtkhs)$,$kbvtryhs(lbgrtkhs)$, and $zjfdmnel(lbgrtkhs)$, if they exist, such\nthat for all $lbgrtkhs$,\n\\[\n|oqpdzmla(lbgrtkhs)|-|kbvtryhs(lbgrtkhs)|+zjfdmnel(lbgrtkhs) = \\begin{cases} -1 & \\mbox{if $lbgrtkhs<-1$} \\\\\n                     3lbgrtkhs+2 & \\mbox{if $-1 \\leq lbgrtkhs \\leq 0$} \\\\\n                     -2lbgrtkhs+2 & \\mbox{if $lbgrtkhs>0$.}\n                     \\end{cases}\n\\]",
      "solution": "Note that if $vxqcrlma(lbgrtkhs)$ and $hjnptqwe(lbgrtkhs)$ are any two functions, then\n\\[ \\max(vxqcrlma,hjnptqwe) = (vxqcrlma+hjnptqwe + |vxqcrlma-hjnptqwe|)/2.\\]\nTherefore, if $idwscrpt(lbgrtkhs)$ is the given function, we have\n\\begin{align*}\nidwscrpt(lbgrtkhs)\\ &= \\max\\{-3lbgrtkhs-3,0\\}-\\max\\{5lbgrtkhs,0\\}+3lbgrtkhs+2 \\\\\n      &= (-3lbgrtkhs-3+|3lbgrtkhs+3|)/2 \\\\\n      & \\qquad - (5lbgrtkhs + |5lbgrtkhs|)/2 + 3lbgrtkhs+2 \\\\\n      &= |(3lbgrtkhs+3)/2| - |5lbgrtkhs/2| -lbgrtkhs + \\frac{1}{2},\n\\end{align*}\nso we may set $oqpdzmla(lbgrtkhs)=(3lbgrtkhs+3)/2$, $kbvtryhs(lbgrtkhs) = 5lbgrtkhs/2$, and $zjfdmnel(lbgrtkhs)=-lbgrtkhs+\\frac{1}{2}$.}\n",
      "stderr": ""
    },
    "kernel_variant": {
      "question": "Find (if they exist) real–coefficient polynomials \\(f(x),\\,g(x),\\,h(x)\\) such that\n\\[\n|f(x)|-|g(x)|+h(x)=\n\\begin{cases}\n-5x-49 & \\text{if }x<-4,\\\\[4pt]\n6x-5 & \\text{if }-4\\le x\\le 2,\\\\[4pt]\n-3x+13 & \\text{if }x>2.\n\\end{cases}\n\\]",
      "solution": "Let\nF(x)=\\begin{cases}-5x-49 & (x<-4),\\\\\n6x-5    & (-4\\le x\\le 2),\\\\\n-3x+13  & (x>2).\\end{cases}\n\n----------------------------------------------------------------------\nStep 1 –  Writing F with max–terms\n\nObserve that the graph changes formula only at x=-4 and x=2.  Set\n\\[\nA(x)=-11x-44 \\qquad(=0\\text{ when }x=-4),\\qquad B(x)=9x-18 \\qquad(=0\\text{ when }x=2).\n\\]\nOn the three regions we have\n\\[\n\\begin{array}{c|ccc}\n & x<-4 & -4\\le x\\le 2 & x>2\\\\\\hline\nA(x) & >0 & \\le 0 & <0\\\\\nB(x) & <0 & \\le 0 & >0\n\\end{array}\n\\]\nHence\n\\[\nF(x)=\\max\\{A(x),0\\}-\\max\\{B(x),0\\}+6x-5.\n\\]\n----------------------------------------------------------------------\nStep 2 –  Eliminating the maxima\n\nFor any functions r,s we have \\(\\max\\{r,s\\}=\\tfrac12\\,(r+s+|r-s|)\\).  With s\\equiv0 this gives\n\\[\\max\\{u,0\\}=\\frac{u+|u|}{2}.\\]\nApplying it to the two max–terms,\n\\[\nF(x)=\\frac{A(x)+|A(x)|}{2}-\\frac{B(x)+|B(x)|}{2}+6x-5\n      =\\frac{|A(x)|}{2}-\\frac{|B(x)|}{2}+\\Bigl(\\frac{A(x)-B(x)}{2}+6x-5\\Bigr).\n\\]\n----------------------------------------------------------------------\nStep 3 –  Grouping as |f|-|g|+h\n\nDefine\n\\[\n\\boxed{\\,f(x)=\\dfrac{A(x)}{2}= -\\frac{11x+44}{2}\\,},\\qquad\n\\boxed{\\,g(x)=\\dfrac{B(x)}{2}= \\frac{9x-18}{2}\\,},\\qquad\n\\boxed{\\,h(x)=\\frac{A(x)-B(x)}{2}+6x-5\\,}.\n\\]\nSince\n\\[h(x)=\\frac{-11x-44-9x+18}{2}+6x-5=-4x-18,\\]\nall three functions are polynomials.  Finally,\n\\[\n|f(x)|-|g(x)|+h(x)=\\frac{|A(x)|}{2}-\\frac{|B(x)|}{2}+\\Bigl(\\frac{A(x)-B(x)}{2}+6x-5\\Bigr)=F(x),\n\\]\nso the requested polynomials are\n\\[\n\\boxed{\\,f(x)= -\\frac{11}{2}x-22,\\quad g(x)=\\frac{9}{2}x-9,\\quad h(x)=-4x-18\\,}.\n\\]\nThese indeed satisfy the given piecewise equation, completing the proof.",
      "_meta": {
        "core_steps": [
          "Rewrite the target piecewise-linear function as a combination of max{linear,linear} terms whose breakpoints coincide with those of the piecewise definition.",
          "Apply max(a,b) = (a + b + |a − b|)/2 to convert each max into an expression involving an absolute value.",
          "Re-group the resulting expression so it becomes |f(x)| − |g(x)| + h(x) with f, g, h polynomial."
        ],
        "mutable_slots": {
          "slot1": {
            "description": "Left breakpoint (first change of formula)",
            "original": -1
          },
          "slot2": {
            "description": "Right breakpoint (second change of formula)",
            "original": 0
          },
          "slot3": {
            "description": "Slope of the leftmost linear segment",
            "original": -3
          },
          "slot4": {
            "description": "Intercept of the leftmost linear segment",
            "original": -3
          },
          "slot5": {
            "description": "Slope of the middle linear segment",
            "original": 3
          },
          "slot6": {
            "description": "Intercept of the middle linear segment",
            "original": 2
          },
          "slot7": {
            "description": "Slope of the rightmost linear segment",
            "original": -2
          },
          "slot8": {
            "description": "Intercept of the rightmost linear segment",
            "original": 2
          },
          "slot9": {
            "description": "Coefficient of x in the subtracted max term (g-term) 5x",
            "original": 5
          },
          "slot10": {
            "description": "Slope & intercept used in f(x) = (3x + 3)/2",
            "original": {
              "slope": 3,
              "intercept": 3
            }
          }
        }
      }
    }
  },
  "checked": true,
  "problem_type": "calculation"
}