{
  "format": "mathssim",
  "version": 1,
  "title": "20 - Worked Examples: Mathematical Foundations",
  "computeMode": "standard",
  "functions": [],
  "notation": {
    "E20x": "E_x",
    "E20y": "E_y",
    "E20mag": "\\left|\\mathbf{E}\\right|",
    "E20theta": "\\theta_E",
    "z20mag": "\\left|z\\right|",
    "z20deg": "\\angle z",
    "z20conj": "z^*",
    "z20prod": "\\left|z\\right|^2",
    "V20a": "\\tilde{V}_1",
    "V20b": "\\tilde{V}_2",
    "V20t": "\\tilde{V}",
    "A20": "\\mathbf{A}",
    "B20": "\\mathbf{B}",
    "dot20": "\\mathbf{A}\\cdot\\mathbf{B}",
    "ang20": "\\theta_{AB}",
    "Bpar20": "B_{\\parallel}",
    "E20v": "\\mathbf{E}",
    "H20v": "\\mathbf{H}",
    "S20v": "\\mathbf{S}",
    "xp20": "x_0",
    "yp20": "y_0",
    "dVx20": "\\frac{\\partial V}{\\partial x}",
    "dVy20": "\\frac{\\partial V}{\\partial y}",
    "Ex20p": "E_x",
    "Ey20p": "E_y",
    "line20": "I",
    "flux20": "\\Phi",
    "Q20cyl": "Q",
    "a20coax": "a",
    "b20coax": "b",
    "V020coax": "V_0",
    "rho20": "\\rho",
    "V20coax": "V(\\rho)",
    "Er20coax": "E_\\rho(\\rho)"
  },
  "regions": [
    {
      "id": "ch20-head-001",
      "type": "text",
      "x": 65,
      "y": 35,
      "w": 990,
      "content": "20 - Worked Examples: Mathematical Foundations",
      "heading": true
    },
    {
      "id": "ch20-note-002",
      "type": "text",
      "x": 65,
      "y": 140,
      "w": 990,
      "content": "Interactive M²S companion to EM Course Document 20.\nTen course worked examples from Documents 1-4, reproduced as editable M²S calculations and plots.\nEdit the input Math regions, then Calculate. M²S values are unitless, so SI units are stated explicitly in labels and notes.",
      "heading": false
    },
    {
      "id": "ch20-head-003",
      "type": "text",
      "x": 65,
      "y": 291,
      "w": 990,
      "content": "Worked Example 1 - Resolve a field vector",
      "heading": true
    },
    {
      "id": "ch20-math-004",
      "type": "math",
      "x": 65,
      "y": 396,
      "w": 475,
      "target": "E20x",
      "expr": "30"
    },
    {
      "id": "ch20-math-005",
      "type": "math",
      "x": 560,
      "y": 396,
      "w": 475,
      "target": "E20y",
      "expr": "40"
    },
    {
      "id": "ch20-math-006",
      "type": "math",
      "x": 65,
      "y": 561,
      "w": 990,
      "target": "E20mag",
      "expr": "sqrt(E20x^2+E20y^2)"
    },
    {
      "id": "ch20-math-007",
      "type": "math",
      "x": 65,
      "y": 726,
      "w": 990,
      "target": "E20theta",
      "expr": "atan2(E20y,E20x)*180/pi"
    },
    {
      "id": "ch20-table-008",
      "type": "table",
      "x": 65,
      "y": 891,
      "w": 990,
      "h": 280,
      "title": "Example 1 result",
      "headersText": "Value",
      "rowLabels": "|E| (V/m)\nAngle from +x (deg)",
      "expr": "cols([E20mag,E20theta])",
      "precision": "12"
    },
    {
      "id": "ch20-head-009",
      "type": "text",
      "x": 65,
      "y": 1261,
      "w": 990,
      "content": "Worked Example 2 - Convert a complex RF quantity",
      "heading": true
    },
    {
      "id": "ch20-math-010",
      "type": "math",
      "x": 65,
      "y": 1366,
      "w": 990,
      "target": "z20",
      "expr": "4+3*i"
    },
    {
      "id": "ch20-math-011",
      "type": "math",
      "x": 65,
      "y": 1531,
      "w": 990,
      "target": "z20mag",
      "expr": "abs(z20)"
    },
    {
      "id": "ch20-math-012",
      "type": "math",
      "x": 65,
      "y": 1696,
      "w": 990,
      "target": "z20deg",
      "expr": "arg(z20)*180/pi"
    },
    {
      "id": "ch20-math-013",
      "type": "math",
      "x": 65,
      "y": 1861,
      "w": 990,
      "target": "z20conj",
      "expr": "conj(z20)"
    },
    {
      "id": "ch20-math-014",
      "type": "math",
      "x": 65,
      "y": 2026,
      "w": 990,
      "target": "z20prod",
      "expr": "real(z20*z20conj)"
    },
    {
      "id": "ch20-table-015",
      "type": "table",
      "x": 65,
      "y": 2191,
      "w": 990,
      "h": 330,
      "title": "Example 2 result",
      "headersText": "Value",
      "rowLabels": "|z|\nPhase (deg)\nRe(conj z)\nIm(conj z)\nz·conj(z)",
      "expr": "cols([z20mag,z20deg,real(z20conj),imag(z20conj),z20prod])",
      "precision": "12"
    },
    {
      "id": "ch20-head-016",
      "type": "text",
      "x": 65,
      "y": 2611,
      "w": 990,
      "content": "Worked Example 3 - Add two phasors",
      "heading": true
    },
    {
      "id": "ch20-math-017",
      "type": "math",
      "x": 65,
      "y": 2716,
      "w": 990,
      "target": "V20a",
      "expr": "polar(10,20*pi/180)"
    },
    {
      "id": "ch20-math-018",
      "type": "math",
      "x": 65,
      "y": 2881,
      "w": 990,
      "target": "V20b",
      "expr": "polar(6,105*pi/180)"
    },
    {
      "id": "ch20-math-019",
      "type": "math",
      "x": 65,
      "y": 3046,
      "w": 990,
      "target": "V20t",
      "expr": "V20a+V20b"
    },
    {
      "id": "ch20-table-020",
      "type": "table",
      "x": 65,
      "y": 3211,
      "w": 990,
      "h": 280,
      "title": "Example 3 result",
      "headersText": "Value",
      "rowLabels": "Re(VT)\nIm(VT)\n|VT| (V)\nPhase (deg)",
      "expr": "cols([real(V20t),imag(V20t),abs(V20t),arg(V20t)*180/pi])",
      "precision": "12"
    },
    {
      "id": "ch20-head-021",
      "type": "text",
      "x": 65,
      "y": 3581,
      "w": 990,
      "content": "Worked Example 4 - Dot product and projection",
      "heading": true
    },
    {
      "id": "ch20-math-022",
      "type": "math",
      "x": 65,
      "y": 3686,
      "w": 990,
      "target": "A20",
      "expr": "[3,4,0]"
    },
    {
      "id": "ch20-math-023",
      "type": "math",
      "x": 65,
      "y": 3851,
      "w": 990,
      "target": "B20",
      "expr": "[5,2,0]"
    },
    {
      "id": "ch20-math-024",
      "type": "math",
      "x": 65,
      "y": 4016,
      "w": 990,
      "target": "dot20",
      "expr": "dot(A20,B20)"
    },
    {
      "id": "ch20-math-025",
      "type": "math",
      "x": 65,
      "y": 4181,
      "w": 990,
      "target": "ang20",
      "expr": "acos(dot20/(norm(A20)*norm(B20)))*180/pi"
    },
    {
      "id": "ch20-math-026",
      "type": "math",
      "x": 65,
      "y": 4346,
      "w": 990,
      "target": "Bpar20",
      "expr": "dot20/norm(A20)"
    },
    {
      "id": "ch20-table-027",
      "type": "table",
      "x": 65,
      "y": 4511,
      "w": 990,
      "h": 280,
      "title": "Example 4 result",
      "headersText": "Value",
      "rowLabels": "A·B\nAngle (deg)\nComponent of B along A",
      "expr": "cols([dot20,ang20,Bpar20])",
      "precision": "12"
    },
    {
      "id": "ch20-note-028",
      "type": "text",
      "x": 65,
      "y": 4881,
      "w": 990,
      "content": "Using the stated A and B components, M²S evaluates the angle as about 31.33°. The PDF prints approximately 31.5°; the dot product and projection values are unchanged.",
      "heading": false
    },
    {
      "id": "ch20-head-029",
      "type": "text",
      "x": 65,
      "y": 4996,
      "w": 990,
      "content": "Worked Example 5 - Cross product and power direction",
      "heading": true
    },
    {
      "id": "ch20-math-030",
      "type": "math",
      "x": 65,
      "y": 5101,
      "w": 990,
      "target": "E20v",
      "expr": "[100,0,0]"
    },
    {
      "id": "ch20-math-031",
      "type": "math",
      "x": 65,
      "y": 5266,
      "w": 990,
      "target": "H20v",
      "expr": "[0,0.265,0]"
    },
    {
      "id": "ch20-math-032",
      "type": "math",
      "x": 65,
      "y": 5431,
      "w": 990,
      "target": "S20v",
      "expr": "cross(E20v,H20v)"
    },
    {
      "id": "ch20-table-033",
      "type": "table",
      "x": 65,
      "y": 5596,
      "w": 990,
      "h": 280,
      "title": "Example 5 result",
      "headersText": "Value",
      "rowLabels": "Sx\nSy\nSz (W/m²)",
      "expr": "cols([at(S20v,0),at(S20v,1),at(S20v,2)])",
      "precision": "12"
    },
    {
      "id": "ch20-plot-034",
      "type": "plot",
      "kind": "quiver3d",
      "title": "Example 5: Poynting direction",
      "xexpr": "[-1,0,1]",
      "yexpr": "[-1,0,1]",
      "zexpr": "[-1,0,1]",
      "x": 65,
      "y": 5966,
      "w": 990,
      "h": 500,
      "xlabel": "x",
      "ylabel": "y",
      "y2label": "",
      "zlabel": "z",
      "vlines": "",
      "bins": 20,
      "palette": "blue",
      "xlog": false,
      "ylog": false,
      "y2log": false,
      "uexpr": "0",
      "vexpr": "0",
      "wexpr": "at(S20v,2)",
      "vectorStyle": "arrows",
      "vectorAutoScale": true,
      "vectorScale": 0.8,
      "vectorNormalize": true,
      "vectorHeadSize": 0.58,
      "vectorWidth": 2.0,
      "vectorOpacity": 0.9,
      "vectorDensity": 1,
      "vectorAnchor": "tail",
      "vectorColorMode": "single",
      "vectorColor": "#2175b5",
      "vectorPalette": "Viridis",
      "showColorbar": false,
      "animate": false,
      "animVar": "t",
      "animStart": "0",
      "animStop": "2*pi",
      "animFrames": 32,
      "animFps": 14,
      "animLoop": true
    },
    {
      "id": "ch20-head-035",
      "type": "text",
      "x": 65,
      "y": 6571,
      "w": 990,
      "content": "Worked Example 6 - Partial derivatives and electrostatic gradient",
      "heading": true
    },
    {
      "id": "ch20-math-036",
      "type": "math",
      "x": 65,
      "y": 6676,
      "w": 475,
      "target": "xp20",
      "expr": "1"
    },
    {
      "id": "ch20-math-037",
      "type": "math",
      "x": 560,
      "y": 6676,
      "w": 475,
      "target": "yp20",
      "expr": "2"
    },
    {
      "id": "ch20-math-038",
      "type": "math",
      "x": 65,
      "y": 6841,
      "w": 990,
      "target": "dVx20",
      "expr": "2*xp20"
    },
    {
      "id": "ch20-math-039",
      "type": "math",
      "x": 65,
      "y": 7006,
      "w": 990,
      "target": "dVy20",
      "expr": "yp20"
    },
    {
      "id": "ch20-math-040",
      "type": "math",
      "x": 65,
      "y": 7171,
      "w": 990,
      "target": "Ex20p",
      "expr": "-dVx20"
    },
    {
      "id": "ch20-math-041",
      "type": "math",
      "x": 65,
      "y": 7336,
      "w": 990,
      "target": "Ey20p",
      "expr": "-dVy20"
    },
    {
      "id": "ch20-table-042",
      "type": "table",
      "x": 65,
      "y": 7501,
      "w": 990,
      "h": 280,
      "title": "Example 6 at (1,2)",
      "headersText": "Value",
      "rowLabels": "∂V/∂x\n∂V/∂y\nEx\nEy",
      "expr": "cols([dVx20,dVy20,Ex20p,Ey20p])",
      "precision": "12"
    },
    {
      "id": "ch20-plot-043",
      "type": "plot",
      "kind": "contour",
      "title": "Example 6: V=x²+0.5y² contours",
      "xexpr": "linspace(-2,2,55)",
      "yexpr": "linspace(-2,2,55)",
      "zexpr": "x^2+0.5*y^2",
      "x": 65,
      "y": 7871,
      "w": 990,
      "h": 410,
      "xlabel": "x",
      "ylabel": "y",
      "y2label": "",
      "zlabel": "V",
      "vlines": "",
      "bins": 20,
      "palette": "blue",
      "xlog": false,
      "ylog": false,
      "y2log": false
    },
    {
      "id": "ch20-plot-044",
      "type": "plot",
      "kind": "quiver2d",
      "title": "Example 6: E=-grad(V)",
      "xexpr": "linspace(-2,2,11)",
      "yexpr": "linspace(-2,2,11)",
      "zexpr": "",
      "x": 65,
      "y": 8386,
      "w": 990,
      "h": 470,
      "xlabel": "x",
      "ylabel": "y",
      "y2label": "",
      "zlabel": "",
      "vlines": "",
      "bins": 20,
      "palette": "blue",
      "xlog": false,
      "ylog": false,
      "y2log": false,
      "uexpr": "-2*x",
      "vexpr": "-y",
      "wexpr": "",
      "vectorAutoScale": true,
      "vectorScale": 0.85,
      "vectorNormalize": true,
      "vectorHeadSize": 0.42,
      "vectorWidth": 2.0,
      "vectorOpacity": 0.92,
      "vectorDensity": 1,
      "vectorAnchor": "tail",
      "vectorColorMode": "magnitude",
      "vectorColor": "#2175b5",
      "vectorPalette": "Viridis",
      "showColorbar": true,
      "animate": false,
      "animVar": "t",
      "animStart": "0",
      "animStop": "2*pi",
      "animFrames": 36,
      "animFps": 16,
      "animLoop": true
    },
    {
      "id": "ch20-head-045",
      "type": "text",
      "x": 65,
      "y": 8961,
      "w": 990,
      "content": "Worked Example 7 - Line integral",
      "heading": true
    },
    {
      "id": "ch20-math-046",
      "type": "math",
      "x": 65,
      "y": 9066,
      "w": 990,
      "target": "line20",
      "expr": "integral(8*t+3,t,0,1)"
    },
    {
      "id": "ch20-table-047",
      "type": "table",
      "x": 65,
      "y": 9231,
      "w": 990,
      "h": 210,
      "title": "Example 7 result",
      "headersText": "Value",
      "rowLabels": "∫C E·dl (V)",
      "expr": "cols([line20])",
      "precision": "12"
    },
    {
      "id": "ch20-head-048",
      "type": "text",
      "x": 65,
      "y": 9531,
      "w": 990,
      "content": "Worked Example 8 - Electric flux through a tilted surface",
      "heading": true
    },
    {
      "id": "ch20-math-049",
      "type": "math",
      "x": 65,
      "y": 9636,
      "w": 990,
      "target": "flux20",
      "expr": "5e-6*0.20*cos(30*pi/180)"
    },
    {
      "id": "ch20-table-050",
      "type": "table",
      "x": 65,
      "y": 9801,
      "w": 990,
      "h": 280,
      "title": "Example 8 result",
      "headersText": "Value",
      "rowLabels": "Flux (C)\nFlux (µC)",
      "expr": "cols([flux20,flux20*1e6])",
      "precision": "12"
    },
    {
      "id": "ch20-head-051",
      "type": "text",
      "x": 65,
      "y": 10171,
      "w": 990,
      "content": "Worked Example 9 - Volume integration of charge density",
      "heading": true
    },
    {
      "id": "ch20-math-052",
      "type": "math",
      "x": 65,
      "y": 10276,
      "w": 990,
      "target": "Q20cyl",
      "expr": "4e-6*pi*0.020^2*0.100"
    },
    {
      "id": "ch20-table-053",
      "type": "table",
      "x": 65,
      "y": 10441,
      "w": 990,
      "h": 280,
      "title": "Example 9 result",
      "headersText": "Value",
      "rowLabels": "Total charge (C)\nTotal charge (nC)",
      "expr": "cols([Q20cyl,Q20cyl*1e9])",
      "precision": "12"
    },
    {
      "id": "ch20-head-054",
      "type": "text",
      "x": 65,
      "y": 10811,
      "w": 990,
      "content": "Worked Example 10 - Coaxial coordinates",
      "heading": true
    },
    {
      "id": "ch20-math-055",
      "type": "math",
      "x": 65,
      "y": 10916,
      "w": 475,
      "target": "a20coax",
      "expr": "1e-3"
    },
    {
      "id": "ch20-math-056",
      "type": "math",
      "x": 560,
      "y": 10916,
      "w": 475,
      "target": "b20coax",
      "expr": "4e-3"
    },
    {
      "id": "ch20-math-057",
      "type": "math",
      "x": 65,
      "y": 11081,
      "w": 990,
      "target": "V020coax",
      "expr": "10"
    },
    {
      "id": "ch20-math-058",
      "type": "math",
      "x": 65,
      "y": 11246,
      "w": 990,
      "target": "rho20",
      "expr": "linspace(a20coax,b20coax,301)"
    },
    {
      "id": "ch20-math-059",
      "type": "math",
      "x": 65,
      "y": 11411,
      "w": 990,
      "target": "V20coax",
      "expr": "V020coax*log(b20coax/rho20)/log(b20coax/a20coax)"
    },
    {
      "id": "ch20-math-060",
      "type": "math",
      "x": 65,
      "y": 11576,
      "w": 990,
      "target": "Er20coax",
      "expr": "V020coax/(rho20*log(b20coax/a20coax))"
    },
    {
      "id": "ch20-plot-061",
      "type": "plot",
      "kind": "line",
      "title": "Example 10: coax potential and radial E",
      "xexpr": "rho20*1e3",
      "yexpr": "Potential (V) := V20coax\nRadial E (V/m) [y2] := Er20coax",
      "zexpr": "",
      "x": 65,
      "y": 11741,
      "w": 990,
      "h": 450,
      "xlabel": "Radius ρ (mm)",
      "ylabel": "Potential (V)",
      "y2label": "Eρ (V/m)",
      "zlabel": "",
      "vlines": "",
      "bins": 20,
      "palette": "blue",
      "xlog": false,
      "ylog": false,
      "y2log": false
    },
    {
      "id": "ch20-out-062",
      "type": "output",
      "kind": "csv",
      "title": "Worked-example values",
      "filename": "ch20-worked-foundations.csv",
      "sources": "example1_E_mag := E20mag\nexample1_angle_deg := E20theta\nexample2_z_mag := z20mag\nexample3_Vsum := V20t\nexample4_dot := dot20\nexample5_S := S20v\nexample7_line_integral := line20\nexample8_flux_C := flux20\nexample9_charge_C := Q20cyl",
      "x": 65,
      "y": 12296,
      "w": 990,
      "csvLayout": "columns",
      "delimiter": "comma",
      "headers": true,
      "quote": "auto",
      "txtLayout": "readable",
      "txtSeparator": "tab",
      "precision": "12",
      "complexFormat": "abi"
    },
    {
      "id": "ch20-head-063",
      "type": "text",
      "x": 65,
      "y": 12501,
      "w": 990,
      "content": "Checkpoint / exploration",
      "heading": true
    },
    {
      "id": "ch20-note-064",
      "type": "text",
      "x": 65,
      "y": 12606,
      "w": 990,
      "content": "These are the course examples with editable inputs/calculations. Recalculate after changing one value and explain which mathematical operation changes: vector geometry, complex algebra, differentiation or integration.",
      "heading": false
    }
  ]
}
