reactive-md 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/CHANGELOG-ch.md +203 -194
  2. package/CHANGELOG.md +203 -194
  3. package/CONTRIBUTING-ch.md +67 -67
  4. package/CONTRIBUTING.md +69 -69
  5. package/README-ch.md +157 -157
  6. package/README-en.md +184 -184
  7. package/README.md +184 -184
  8. package/SECURITY-ch.md +81 -81
  9. package/SECURITY.md +81 -81
  10. package/THIRD_PARTY_NOTICES.md +313 -209
  11. package/bin/reactive-md.mjs +39 -39
  12. package/cli/args.mjs +181 -181
  13. package/cli/assets.mjs +390 -390
  14. package/cli/build.mjs +268 -268
  15. package/cli/document.mjs +130 -130
  16. package/cli/errors.mjs +61 -61
  17. package/cli/fs-utils.mjs +133 -133
  18. package/cli/glob.mjs +203 -203
  19. package/cli/help.mjs +138 -138
  20. package/cli/lint.mjs +177 -177
  21. package/cli/main.mjs +55 -55
  22. package/cli/migrate.mjs +368 -368
  23. package/cli/package.mjs +210 -210
  24. package/dist-library/{authoring-DSC0VsNK.js → authoring-BEVyth5X.js} +1 -1
  25. package/dist-library/compiler-Cm3ppMxG.js +46044 -0
  26. package/dist-library/{react-Dk94rcOp.js → react-Bh7_oxZp.js} +20110 -20113
  27. package/dist-library/reactive-md-authoring.js +2 -2
  28. package/dist-library/reactive-md-print.css +284 -284
  29. package/dist-library/reactive-md-react-unstyled.js +1 -1
  30. package/dist-library/reactive-md-react.js +1 -1
  31. package/dist-library/reactive-md.css +1 -1
  32. package/dist-library/reactive-md.js +3 -3
  33. package/dist-library/{runtime-D8KbnCd0.js → runtime-DlFYQ4s_.js} +1 -1
  34. package/dist-library/types/local/math-display.d.ts +22 -23
  35. package/dist-library/types/local/math-view.d.ts +6 -7
  36. package/dist-standalone/reactive-md-standalone.css +1 -1
  37. package/dist-standalone/reactive-md-standalone.js +318 -62
  38. package/docs/compatibility/compatibility-ch.md +121 -119
  39. package/docs/compatibility/compatibility-en.md +121 -119
  40. package/docs/compatibility/source-versioning-ch.md +159 -159
  41. package/docs/compatibility/source-versioning-en.md +159 -159
  42. package/docs/development/component-development-ch.md +210 -210
  43. package/docs/development/component-development-en.md +210 -210
  44. package/docs/development/component-protocol-ch.md +747 -747
  45. package/docs/development/component-protocol-en.md +747 -747
  46. package/docs/development/performance-ch.md +76 -76
  47. package/docs/development/performance-en.md +76 -76
  48. package/docs/development/releasing-ch.md +108 -108
  49. package/docs/development/releasing-en.md +108 -108
  50. package/docs/integration/author-tools-ch.md +62 -62
  51. package/docs/integration/author-tools-en.md +62 -62
  52. package/docs/integration/shareable-export-ch.md +209 -209
  53. package/docs/integration/shareable-export-en.md +211 -211
  54. package/docs/reference/computations-formatting-ch.md +87 -87
  55. package/docs/reference/computations-formatting-en.md +87 -87
  56. package/docs/reference/constraints-collections-ch.md +84 -84
  57. package/docs/reference/constraints-collections-en.md +84 -84
  58. package/docs/reference/diagnostics-counting-ch.md +104 -104
  59. package/docs/reference/diagnostics-counting-en.md +104 -104
  60. package/docs/reference/local-components-v2-ch.md +138 -138
  61. package/docs/reference/local-components-v2-en.md +104 -104
  62. package/docs/reference/local-interaction-syntax-ch.md +515 -511
  63. package/docs/reference/local-interaction-syntax-en.md +511 -507
  64. package/docs/reference/theme-protocol-ch.md +107 -107
  65. package/docs/reference/theme-protocol-en.md +107 -107
  66. package/docs/releases/release-0.4.0-ch.md +89 -89
  67. package/docs/releases/release-0.4.0-en.md +89 -89
  68. package/docs/releases/release-0.4.1-ch.md +23 -23
  69. package/docs/releases/release-0.4.1-en.md +23 -23
  70. package/docs/releases/release-0.6.1-ch.md +27 -0
  71. package/docs/releases/release-0.6.1-en.md +27 -0
  72. package/examples/conformance/README.md +53 -53
  73. package/examples/conformance/component-protocol-1.json +482 -482
  74. package/examples/conformance/component-protocol-1.schema.json +76 -76
  75. package/examples/conformance/local-draft-1.json +50 -50
  76. package/examples/conformance/local-draft-2.json +212 -212
  77. package/examples/integration/README.md +47 -47
  78. package/examples/integration/core/index.mjs +32 -32
  79. package/examples/integration/worker/index.html +19 -19
  80. package/examples/integration/worker/main.js +61 -61
  81. package/examples/integration/worker/package.json +13 -13
  82. package/examples/integration/worker/worker.js +3 -3
  83. package/examples/local/README.md +74 -74
  84. package/examples/local/charts.reactive.md +73 -73
  85. package/examples/local/recipes/invoice-zh.reactive.md +36 -36
  86. package/examples/local/recipes/invoice.reactive.md +36 -36
  87. package/examples/local/recipes/workshop-zh.reactive.md +33 -33
  88. package/examples/local/recipes/workshop.reactive.md +33 -33
  89. package/examples/local/showcase/README.md +25 -25
  90. package/examples/local/showcase/explore.reactive.md +102 -102
  91. package/examples/local/showcase/flow.reactive.md +86 -86
  92. package/examples/local/showcase/forms.reactive.md +126 -126
  93. package/examples/local/showcase/functions.reactive.md +119 -119
  94. package/examples/local/showcase/layout.reactive.md +100 -100
  95. package/examples/local/showcase/statistics.reactive.md +108 -108
  96. package/examples/local/showcase/tasks.reactive.md +89 -89
  97. package/examples/local/showcase/zh/explore.reactive.md +102 -102
  98. package/examples/local/showcase/zh/flow.reactive.md +86 -86
  99. package/examples/local/showcase/zh/forms.reactive.md +126 -126
  100. package/examples/local/showcase/zh/functions.reactive.md +119 -119
  101. package/examples/local/showcase/zh/layout.reactive.md +100 -100
  102. package/examples/local/showcase/zh/statistics.reactive.md +108 -108
  103. package/examples/local/showcase/zh/tasks.reactive.md +89 -89
  104. package/package.json +152 -152
  105. package/dist-library/compiler-CRD88BMt.js +0 -24964
@@ -1,126 +1,126 @@
1
- <computed name="organizer" value="{{ trim(name) == '' ? 'Your group' : trim(name) }}">
2
- <computed name="unitCost" value="{{ (format == 'onsite' ? 80 : 60) + (equipment ? 20 : 0) }}">
3
- <computed name="total" value="{{ seats * unitCost }}">
4
- <computed name="datesReady" value="{{ date != '' && deadline != '' && dateCompare(deadline, date) <= 0 }}">
5
- <computed name="registrationGap" value="{{ datesReady ? dateDiff(date, deadline) : null }}">
6
-
7
- # Build a workshop plan
8
-
9
- Change the name, headcount and format. Lower the budget or move the registration deadline past the workshop to see a hint; choose subjects to generate a preparation plan.
10
-
11
- <grid>
12
- <card>
13
- <panel title="Workshop details">
14
- <input bind="name" label="Organizer" initial="Alex" placeholder="Your name">
15
- <choices bind="format" label="Format" initial="onsite">
16
- <option value="onsite">In person</option>
17
- <option value="online">Online</option>
18
- </choices>
19
- <slider bind="seats" label="Participants" initial="4" min="1" max="20">
20
- <date bind="date" label="Workshop date" initial="2026-11-01">
21
- <date bind="deadline" label="Registration deadline" initial="2026-10-25">
22
- <number bind="budget" label="Spending limit" initial="500" min="0" max="5000" step="10">
23
- <validation when="{{ datesReady }}" message="Fill both dates and close registration on or before the workshop date." fields="deadline date">
24
- <validation when="{{ total <= budget }}" message="Estimate exceeds the limit by {{ formatCurrency(total - budget, 'USD', 2, 'en-US') }}; adjust participants, materials or the limit." fields="seats equipment budget">
25
- <textarea bind="notes" label="Special requests" placeholder="What would help your group?">
26
- <toggle bind="equipment" label="Include a materials kit (20 per person)">
27
- </panel>
28
- </card>
29
-
30
- <card title="Your workshop at a glance">
31
- **{{ organizer }}** · {{ date }}
32
-
33
- {{ format == 'onsite' ? 'In-person workshop' : 'Online workshop' }} · **{{ seats }}** participants
34
-
35
- Per person: **{{ formatCurrency(unitCost, 'USD', 2, 'en-US') }}**
36
-
37
- Estimated total: **{{ formatCurrency(total, 'USD', 2, 'en-US') }}**
38
-
39
- <badge tone="{{ total <= budget ? 'success' : 'warning' }}">Spending limit: {{ formatCurrency(budget, 'USD', 2, 'en-US') }}</badge>
40
-
41
- <if when="{{ datesReady }}">
42
- Registration closes **{{ deadline }}**, **{{ registrationGap }}** days before the workshop.
43
- </if>
44
-
45
- Requests: {{ trim(notes) == '' ? 'No special requests yet.' : trim(notes) }}
46
-
47
- <if when="{{ format == 'onsite' }}">
48
- <alert title="Prepare the room">Reserve a room with at least {{ seats }} seats and arrange a shared display.</alert>
49
- </if>
50
- <if when="{{ format == 'online' }}">
51
- <alert title="Prepare the call">Share the meeting link and check that everyone can open the workshop document.</alert>
52
- </if>
53
- </card>
54
- </grid>
55
-
56
- ## Try a complete change
57
-
58
- Choose Online, set 6 participants and add materials: the estimate becomes **{{ formatCurrency(480, 'USD', 2, 'en-US') }}**. Reset Workshop details to return to the original **{{ formatCurrency(320, 'USD', 2, 'en-US') }}**.
59
-
60
- ## Tailor the workshop to your group
61
-
62
- Choose the level, pace and subjects. These details shape the learning plan alongside the cost estimate above.
63
-
64
- <panel title="Learning preferences">
65
- <select bind="level" label="Experience level" initial="intro">
66
- <option value="intro">First workshop</option>
67
- <option value="advanced">Already familiar</option>
68
- </select>
69
-
70
- <radio-group bind="pace" label="Session pace" initial="guided">
71
- <option value="guided">Guided practice</option>
72
- <option value="independent">Independent exploration</option>
73
- </radio-group>
74
-
75
- <multi-select bind="subjects" label="Workshop subjects" max-selected="2" color="#167875">
76
- <option value="math">Mathematics</option>
77
- <option value="physics">Physics</option>
78
- <option value="chemistry">Chemistry</option>
79
- </multi-select>
80
-
81
- <checkbox bind="accessible" label="Include a written step-by-step guide">
82
-
83
- | Detail | Your choice |
84
- | --- | --- |
85
- | Level | {{ level == 'intro' ? 'Start with a worked example' : 'Compare several approaches' }} |
86
- | Pace | {{ pace == 'guided' ? 'Work through the steps together' : 'Leave time to explore independently' }} |
87
- | Subjects | {{ len(subjects) }} / 2 selected |
88
-
89
- <data-table label="Subject preparation" rows="{{ subjects }}" key="{{ item }}" max-rows="2">
90
- <column label="Subject" value="{{ item == 'math' ? 'Mathematics' : item == 'physics' ? 'Physics' : 'Chemistry' }}">
91
- <column label="Preparation" value="{{ item == 'chemistry' ? 'Prepare materials and instructions' : 'Prepare a worked example' }}">
92
- <column label="Guide" value="{{ accessible ? 'Written steps included' : 'Live explanation' }}">
93
- </data-table>
94
-
95
- <if when="{{ contains(subjects, 'chemistry') }}">
96
- <badge color="#167875">Include a chemistry example</badge>
97
- </if>
98
- <if when="{{ accessible }}">
99
- <alert title="Prepare the written guide">Include the parameter names and the expected result for each step.</alert>
100
- </if>
101
- </panel>
102
-
103
- ## How it is written
104
-
105
- <accordion>
106
- <disclosure label="Show the key source">
107
-
108
- ```markdown
109
- <const name="rate" value="{{ 80 }}">
110
- <computed name="total" value="{{ seats * rate }}">
111
- <slider bind="seats" label="Participants" initial="4" min="1" max="20">
112
- <number bind="budget" label="Spending limit" initial="500" min="0" max="5000">
113
- <validation when="{{ total <= budget }}" message="Adjust participants or the spending limit." fields="seats budget">
114
- <badge tone="{{ total <= budget ? 'success' : 'warning' }}">{{ formatCurrency(total, 'USD', 2, 'en-US') }}</badge>
115
-
116
- <multi-select bind="subjects" label="Subjects" max-selected="2">
117
- <option value="math">Mathematics</option>
118
- <option value="physics">Physics</option>
119
- </multi-select>
120
- <data-table label="Preparation" rows="{{ subjects }}" key="{{ item }}" max-rows="2">
121
- <column label="Subject" value="{{ item == 'math' ? 'Mathematics' : 'Physics' }}">
122
- </data-table>
123
- ```
124
-
125
- </disclosure>
126
- </accordion>
1
+ <computed name="organizer" value="{{ trim(name) == '' ? 'Your group' : trim(name) }}">
2
+ <computed name="unitCost" value="{{ (format == 'onsite' ? 80 : 60) + (equipment ? 20 : 0) }}">
3
+ <computed name="total" value="{{ seats * unitCost }}">
4
+ <computed name="datesReady" value="{{ date != '' && deadline != '' && dateCompare(deadline, date) <= 0 }}">
5
+ <computed name="registrationGap" value="{{ datesReady ? dateDiff(date, deadline) : null }}">
6
+
7
+ # Build a workshop plan
8
+
9
+ Change the name, headcount and format. Lower the budget or move the registration deadline past the workshop to see a hint; choose subjects to generate a preparation plan.
10
+
11
+ <grid>
12
+ <card>
13
+ <panel title="Workshop details">
14
+ <input bind="name" label="Organizer" initial="Alex" placeholder="Your name">
15
+ <choices bind="format" label="Format" initial="onsite">
16
+ <option value="onsite">In person</option>
17
+ <option value="online">Online</option>
18
+ </choices>
19
+ <slider bind="seats" label="Participants" initial="4" min="1" max="20">
20
+ <date bind="date" label="Workshop date" initial="2026-11-01">
21
+ <date bind="deadline" label="Registration deadline" initial="2026-10-25">
22
+ <number bind="budget" label="Spending limit" initial="500" min="0" max="5000" step="10">
23
+ <validation when="{{ datesReady }}" message="Fill both dates and close registration on or before the workshop date." fields="deadline date">
24
+ <validation when="{{ total <= budget }}" message="Estimate exceeds the limit by {{ formatCurrency(total - budget, 'USD', 2, 'en-US') }}; adjust participants, materials or the limit." fields="seats equipment budget">
25
+ <textarea bind="notes" label="Special requests" placeholder="What would help your group?">
26
+ <toggle bind="equipment" label="Include a materials kit (20 per person)">
27
+ </panel>
28
+ </card>
29
+
30
+ <card title="Your workshop at a glance">
31
+ **{{ organizer }}** · {{ date }}
32
+
33
+ {{ format == 'onsite' ? 'In-person workshop' : 'Online workshop' }} · **{{ seats }}** participants
34
+
35
+ Per person: **{{ formatCurrency(unitCost, 'USD', 2, 'en-US') }}**
36
+
37
+ Estimated total: **{{ formatCurrency(total, 'USD', 2, 'en-US') }}**
38
+
39
+ <badge tone="{{ total <= budget ? 'success' : 'warning' }}">Spending limit: {{ formatCurrency(budget, 'USD', 2, 'en-US') }}</badge>
40
+
41
+ <if when="{{ datesReady }}">
42
+ Registration closes **{{ deadline }}**, **{{ registrationGap }}** days before the workshop.
43
+ </if>
44
+
45
+ Requests: {{ trim(notes) == '' ? 'No special requests yet.' : trim(notes) }}
46
+
47
+ <if when="{{ format == 'onsite' }}">
48
+ <alert title="Prepare the room">Reserve a room with at least {{ seats }} seats and arrange a shared display.</alert>
49
+ </if>
50
+ <if when="{{ format == 'online' }}">
51
+ <alert title="Prepare the call">Share the meeting link and check that everyone can open the workshop document.</alert>
52
+ </if>
53
+ </card>
54
+ </grid>
55
+
56
+ ## Try a complete change
57
+
58
+ Choose Online, set 6 participants and add materials: the estimate becomes **{{ formatCurrency(480, 'USD', 2, 'en-US') }}**. Reset Workshop details to return to the original **{{ formatCurrency(320, 'USD', 2, 'en-US') }}**.
59
+
60
+ ## Tailor the workshop to your group
61
+
62
+ Choose the level, pace and subjects. These details shape the learning plan alongside the cost estimate above.
63
+
64
+ <panel title="Learning preferences">
65
+ <select bind="level" label="Experience level" initial="intro">
66
+ <option value="intro">First workshop</option>
67
+ <option value="advanced">Already familiar</option>
68
+ </select>
69
+
70
+ <radio-group bind="pace" label="Session pace" initial="guided">
71
+ <option value="guided">Guided practice</option>
72
+ <option value="independent">Independent exploration</option>
73
+ </radio-group>
74
+
75
+ <multi-select bind="subjects" label="Workshop subjects" max-selected="2" color="#167875">
76
+ <option value="math">Mathematics</option>
77
+ <option value="physics">Physics</option>
78
+ <option value="chemistry">Chemistry</option>
79
+ </multi-select>
80
+
81
+ <checkbox bind="accessible" label="Include a written step-by-step guide">
82
+
83
+ | Detail | Your choice |
84
+ | --- | --- |
85
+ | Level | {{ level == 'intro' ? 'Start with a worked example' : 'Compare several approaches' }} |
86
+ | Pace | {{ pace == 'guided' ? 'Work through the steps together' : 'Leave time to explore independently' }} |
87
+ | Subjects | {{ len(subjects) }} / 2 selected |
88
+
89
+ <data-table label="Subject preparation" rows="{{ subjects }}" key="{{ item }}" max-rows="2">
90
+ <column label="Subject" value="{{ item == 'math' ? 'Mathematics' : item == 'physics' ? 'Physics' : 'Chemistry' }}">
91
+ <column label="Preparation" value="{{ item == 'chemistry' ? 'Prepare materials and instructions' : 'Prepare a worked example' }}">
92
+ <column label="Guide" value="{{ accessible ? 'Written steps included' : 'Live explanation' }}">
93
+ </data-table>
94
+
95
+ <if when="{{ contains(subjects, 'chemistry') }}">
96
+ <badge color="#167875">Include a chemistry example</badge>
97
+ </if>
98
+ <if when="{{ accessible }}">
99
+ <alert title="Prepare the written guide">Include the parameter names and the expected result for each step.</alert>
100
+ </if>
101
+ </panel>
102
+
103
+ ## How it is written
104
+
105
+ <accordion>
106
+ <disclosure label="Show the key source">
107
+
108
+ ```markdown
109
+ <const name="rate" value="{{ 80 }}">
110
+ <computed name="total" value="{{ seats * rate }}">
111
+ <slider bind="seats" label="Participants" initial="4" min="1" max="20">
112
+ <number bind="budget" label="Spending limit" initial="500" min="0" max="5000">
113
+ <validation when="{{ total <= budget }}" message="Adjust participants or the spending limit." fields="seats budget">
114
+ <badge tone="{{ total <= budget ? 'success' : 'warning' }}">{{ formatCurrency(total, 'USD', 2, 'en-US') }}</badge>
115
+
116
+ <multi-select bind="subjects" label="Subjects" max-selected="2">
117
+ <option value="math">Mathematics</option>
118
+ <option value="physics">Physics</option>
119
+ </multi-select>
120
+ <data-table label="Preparation" rows="{{ subjects }}" key="{{ item }}" max-rows="2">
121
+ <column label="Subject" value="{{ item == 'math' ? 'Mathematics' : 'Physics' }}">
122
+ </data-table>
123
+ ```
124
+
125
+ </disclosure>
126
+ </accordion>
@@ -1,119 +1,119 @@
1
- <const name="monthsPerYear" value="{{ 12 }}">
2
- <computed name="monthlyRate" value="{{ r / (100 * monthsPerYear) }}">
3
- <computed name="growthFactor" value="{{ pow(1 + monthlyRate, monthsPerYear * t) }}">
4
- <computed name="endingBalance" value="{{ monthlyRate == 0 ? P + monthsPerYear * m * t : P * growthFactor + m * (growthFactor - 1) / monthlyRate }}">
5
- <computed name="deposits" value="{{ P + monthsPerYear * m * t }}">
6
- <computed name="distance" value="{{ sqrt(px * px + py * py) }}">
7
- <computed name="waveHeight" value="{{ a * sin(f * px) }}">
8
- <computed name="insideInterval" value="{{ px >= low && px <= high }}">
9
-
10
- # Functions you can shape
11
-
12
- Drag Amplitude to 0: the wave becomes a flat line. Restore it, then increase Frequency to fit more waves into the same interval.
13
-
14
- <grid>
15
- <card>
16
- <panel title="Shape the wave">
17
- <slider bind="a" label="Amplitude" initial="1" min="0" max="3" step="0.5">
18
- <slider bind="f" label="Frequency" initial="1" min="0.5" max="3" step="0.5">
19
- </panel>
20
-
21
- Amplitude **{{ a }}**, frequency **{{ f }}**.
22
-
23
- <if when="{{ a == 0 }}">
24
- <alert title="The wave is flat">Multiplying by zero makes every output zero, whatever the frequency.</alert>
25
- </if>
26
- </card>
27
- <card>
28
- <plot min="0" max="12.56" label="Adjustable sine wave" x-label="x" y-label="y">
29
- $$ y = a\sin(fx) $$
30
- </plot>
31
- </card>
32
- </grid>
33
-
34
- ## Explore the same parameters
35
-
36
- <tabs label="Function explorations">
37
- <tab label="Compare curves">
38
- Both curves share the amplitude and frequency above. Compare their peaks and zero crossings.
39
-
40
- <plot min="0" max="12.56" label="Sine and cosine">
41
- $$ y = a\sin(fx) $$
42
- $$ y = a\cos(fx) $$
43
- </plot>
44
- </tab>
45
- <tab label="Piecewise function">
46
- The negative side is linear; the positive side is quadratic. Amplitude scales both branches.
47
-
48
- <plot min="-3" max="3" label="Linear meets quadratic">
49
- $$
50
- y = \begin{cases}
51
- ax, & x < 0 \\
52
- ax^2, & x \ge 0
53
- \end{cases}
54
- $$
55
- </plot>
56
- </tab>
57
- <tab label="Savings application">
58
- Monthly deposits and monthly compounding turn a formula into a small planning tool. Set the annual rate to zero to compare deposits alone.
59
-
60
- <panel title="Savings parameters">
61
- <number bind="P" label="Starting amount" initial="10000" min="0" step="100">
62
- <number bind="m" label="Monthly deposit" initial="500" min="0" step="100">
63
- <slider bind="r" label="Annual rate (%)" initial="5" min="0" max="10" step="0.5">
64
- <slider bind="t" label="Years" initial="20" min="1" max="40">
65
- </panel>
66
-
67
- <plot min="0" max="{{ t }}" label="Savings growth" x-label="Years" y-label="Amount">
68
- $$
69
- y = \begin{cases}
70
- P + 12mx, & r = 0 \\
71
- P\left(1+\mathrm{monthlyRate}\right)^{12x} + m\frac{\left(1+\mathrm{monthlyRate}\right)^{12x}-1}{\mathrm{monthlyRate}}, & r \ne 0
72
- \end{cases}
73
- $$
74
- </plot>
75
-
76
- At year **{{ t }}**, the ending balance is **{{ formatCurrency(endingBalance, 'USD', 2, 'en-US') }}**: deposits of **{{ formatCurrency(deposits, 'USD', 2, 'en-US') }}** and interest of **{{ formatCurrency(endingBalance - deposits, 'USD', 2, 'en-US') }}**. The annual rate is **{{ formatPercent(r / 100, 1, 'en-US') }}**. The curve and ending balance share the monthly rate; at zero rate they count deposits directly.
77
- </tab>
78
- </tabs>
79
-
80
- ## Explore a point and an interval
81
-
82
- Choose an interval, then drag the point. Compare its horizontal position with the interval and read the wave height at that position.
83
-
84
- <panel title="Point and interval">
85
- <range-slider label="Observation interval" bind-start="low" bind-end="high" initial-start="-3" initial-end="3" min="-5" max="5" color="#7c3aed">
86
-
87
- Interval: **{{ low }}–{{ high }}**. Width: **{{ high - low }}**.
88
-
89
- <coordinate label="Point position" bind-x="px" bind-y="py" initial-x="1" initial-y="2" x-min="-5" x-max="5" y-min="-5" y-max="5" color="#2563eb">
90
-
91
- Point: **({{ px }}, {{ py }})**. Distance from the origin: **{{ formatNumber(distance, 2, 'en-US') }}**.
92
-
93
- {{ insideInterval ? 'The point lies inside the horizontal interval.' : 'The point lies outside the horizontal interval.' }} Wave height at this x: **{{ formatNumber(waveHeight, 2, 'en-US') }}**.
94
-
95
- The same height in scientific notation is **{{ formatScientific(waveHeight, 2, 'en-US') }}**, useful when comparing values near zero.
96
-
97
- <quiz type="number" label="How far is (3, 4) from the origin?" answer="5" tolerance="0.01" explanation="The square root of 3² + 4² is 5. Try placing the point at (3, 4).">
98
- </quiz>
99
- </panel>
100
-
101
- ## How it is written
102
-
103
- <accordion>
104
- <disclosure label="Show the key source">
105
-
106
- ```markdown
107
- <slider bind="a" label="Amplitude" initial="1" min="0" max="3" step="0.5">
108
- <slider bind="f" label="Frequency" initial="1" min="0.5" max="3" step="0.5">
109
- <coordinate label="Point position" bind-x="px" bind-y="py" initial-x="1" initial-y="2" x-min="-5" x-max="5" y-min="-5" y-max="5">
110
- <computed name="waveHeight" value="{{ a * sin(f * px) }}">
111
- Height: {{ formatNumber(waveHeight, 2) }} · {{ formatScientific(waveHeight, 2) }}
112
-
113
- <plot min="0" max="12.56" label="Sine wave">
114
- $$ y = a\sin(fx) $$
115
- </plot>
116
- ```
117
-
118
- </disclosure>
119
- </accordion>
1
+ <const name="monthsPerYear" value="{{ 12 }}">
2
+ <computed name="monthlyRate" value="{{ r / (100 * monthsPerYear) }}">
3
+ <computed name="growthFactor" value="{{ pow(1 + monthlyRate, monthsPerYear * t) }}">
4
+ <computed name="endingBalance" value="{{ monthlyRate == 0 ? P + monthsPerYear * m * t : P * growthFactor + m * (growthFactor - 1) / monthlyRate }}">
5
+ <computed name="deposits" value="{{ P + monthsPerYear * m * t }}">
6
+ <computed name="distance" value="{{ sqrt(px * px + py * py) }}">
7
+ <computed name="waveHeight" value="{{ a * sin(f * px) }}">
8
+ <computed name="insideInterval" value="{{ px >= low && px <= high }}">
9
+
10
+ # Functions you can shape
11
+
12
+ Drag Amplitude to 0: the wave becomes a flat line. Restore it, then increase Frequency to fit more waves into the same interval.
13
+
14
+ <grid>
15
+ <card>
16
+ <panel title="Shape the wave">
17
+ <slider bind="a" label="Amplitude" initial="1" min="0" max="3" step="0.5">
18
+ <slider bind="f" label="Frequency" initial="1" min="0.5" max="3" step="0.5">
19
+ </panel>
20
+
21
+ Amplitude **{{ a }}**, frequency **{{ f }}**.
22
+
23
+ <if when="{{ a == 0 }}">
24
+ <alert title="The wave is flat">Multiplying by zero makes every output zero, whatever the frequency.</alert>
25
+ </if>
26
+ </card>
27
+ <card>
28
+ <plot min="0" max="12.56" label="Adjustable sine wave" x-label="x" y-label="y">
29
+ $$ y = a\sin(fx) $$
30
+ </plot>
31
+ </card>
32
+ </grid>
33
+
34
+ ## Explore the same parameters
35
+
36
+ <tabs label="Function explorations">
37
+ <tab label="Compare curves">
38
+ Both curves share the amplitude and frequency above. Compare their peaks and zero crossings.
39
+
40
+ <plot min="0" max="12.56" label="Sine and cosine">
41
+ $$ y = a\sin(fx) $$
42
+ $$ y = a\cos(fx) $$
43
+ </plot>
44
+ </tab>
45
+ <tab label="Piecewise function">
46
+ The negative side is linear; the positive side is quadratic. Amplitude scales both branches.
47
+
48
+ <plot min="-3" max="3" label="Linear meets quadratic">
49
+ $$
50
+ y = \begin{cases}
51
+ ax, & x < 0 \\
52
+ ax^2, & x \ge 0
53
+ \end{cases}
54
+ $$
55
+ </plot>
56
+ </tab>
57
+ <tab label="Savings application">
58
+ Monthly deposits and monthly compounding turn a formula into a small planning tool. Set the annual rate to zero to compare deposits alone.
59
+
60
+ <panel title="Savings parameters">
61
+ <number bind="P" label="Starting amount" initial="10000" min="0" step="100">
62
+ <number bind="m" label="Monthly deposit" initial="500" min="0" step="100">
63
+ <slider bind="r" label="Annual rate (%)" initial="5" min="0" max="10" step="0.5">
64
+ <slider bind="t" label="Years" initial="20" min="1" max="40">
65
+ </panel>
66
+
67
+ <plot min="0" max="{{ t }}" label="Savings growth" x-label="Years" y-label="Amount">
68
+ $$
69
+ y = \begin{cases}
70
+ P + 12mx, & r = 0 \\
71
+ P\left(1+\mathrm{monthlyRate}\right)^{12x} + m\frac{\left(1+\mathrm{monthlyRate}\right)^{12x}-1}{\mathrm{monthlyRate}}, & r \ne 0
72
+ \end{cases}
73
+ $$
74
+ </plot>
75
+
76
+ At year **{{ t }}**, the ending balance is **{{ formatCurrency(endingBalance, 'USD', 2, 'en-US') }}**: deposits of **{{ formatCurrency(deposits, 'USD', 2, 'en-US') }}** and interest of **{{ formatCurrency(endingBalance - deposits, 'USD', 2, 'en-US') }}**. The annual rate is **{{ formatPercent(r / 100, 1, 'en-US') }}**. The curve and ending balance share the monthly rate; at zero rate they count deposits directly.
77
+ </tab>
78
+ </tabs>
79
+
80
+ ## Explore a point and an interval
81
+
82
+ Choose an interval, then drag the point. Compare its horizontal position with the interval and read the wave height at that position.
83
+
84
+ <panel title="Point and interval">
85
+ <range-slider label="Observation interval" bind-start="low" bind-end="high" initial-start="-3" initial-end="3" min="-5" max="5" color="#7c3aed">
86
+
87
+ Interval: **{{ low }}–{{ high }}**. Width: **{{ high - low }}**.
88
+
89
+ <coordinate label="Point position" bind-x="px" bind-y="py" initial-x="1" initial-y="2" x-min="-5" x-max="5" y-min="-5" y-max="5" color="#2563eb">
90
+
91
+ Point: **({{ px }}, {{ py }})**. Distance from the origin: **{{ formatNumber(distance, 2, 'en-US') }}**.
92
+
93
+ {{ insideInterval ? 'The point lies inside the horizontal interval.' : 'The point lies outside the horizontal interval.' }} Wave height at this x: **{{ formatNumber(waveHeight, 2, 'en-US') }}**.
94
+
95
+ The same height in scientific notation is **{{ formatScientific(waveHeight, 2, 'en-US') }}**, useful when comparing values near zero.
96
+
97
+ <quiz type="number" label="How far is (3, 4) from the origin?" answer="5" tolerance="0.01" explanation="The square root of 3² + 4² is 5. Try placing the point at (3, 4).">
98
+ </quiz>
99
+ </panel>
100
+
101
+ ## How it is written
102
+
103
+ <accordion>
104
+ <disclosure label="Show the key source">
105
+
106
+ ```markdown
107
+ <slider bind="a" label="Amplitude" initial="1" min="0" max="3" step="0.5">
108
+ <slider bind="f" label="Frequency" initial="1" min="0.5" max="3" step="0.5">
109
+ <coordinate label="Point position" bind-x="px" bind-y="py" initial-x="1" initial-y="2" x-min="-5" x-max="5" y-min="-5" y-max="5">
110
+ <computed name="waveHeight" value="{{ a * sin(f * px) }}">
111
+ Height: {{ formatNumber(waveHeight, 2) }} · {{ formatScientific(waveHeight, 2) }}
112
+
113
+ <plot min="0" max="12.56" label="Sine wave">
114
+ $$ y = a\sin(fx) $$
115
+ </plot>
116
+ ```
117
+
118
+ </disclosure>
119
+ </accordion>