You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- Warning: This page requires javascript to render the math. -->
38
+
39
+
<!-- This is an example of a function. Functions are more restricted than programs - for example, we can't use any statements (If, For, WhileLp, etc.) or functions exclusive to the program environment<br>
40
+
A function has a benefit over programs in that they return their value just like any other function. In a program, they return '<pre>done</pre>', but a function will return the result.<br>
41
+
This means we don't need to use a PrintNatural to see the result or store the result in a fixed, unchanging variable defined in a program.<br><br> -->
42
+
<bodystyle="padding: 1%;">
43
+
<center>
44
+
<h1>Functions guide</h1>
45
+
</center>
46
+
47
+
<aclass="link" style="left:1%; top: 1%;" href="https://classpad.github.io">🔗 To classpad homepage</a><br>
48
+
<aclass="link" style="left:1%; top: 1%;" href="https://npc-strider.github.io/maths">🔗 To MATHS page</a><br>
49
+
<aclass="link" style="left:1%; top: 1%;" href="https://npc-strider.github.io">🔗 To personal homepage</a><br>
50
+
<br>
51
+
We define a new function with the <pre>Define</pre> command.<br>
52
+
<pre>
53
+
Define f(x,y,z,[...]) = [Function(x,y,z,[...])]
54
+
</pre>
55
+
The result of <pre>Function</pre> is returned directly to the result line.
You could use classpad-defined functions, such as <pre>compToRect()</pre> to convert from polar to rectangular form.<br>
62
+
Alternatively, you could use Euler's formula, \(z = r\cdot e^{i\theta}\), but this leaves an opportunity for error if you forget the \(i\). Additionally, this form isn't taught in WA and most questions use \(\cis\).<br><br>
Now whenever we use <pre>cis</pre>, we call this function.<br><br>
71
+
72
+
To make this function useful, we should add it as a shift key in the <pre>System</pre> tab. (you can add shift-keys for anything, even text which doesn't evaluate to a defined function.)
73
+
<divstyle="text-align: center;">
74
+
<imgsrc="./assets/cis_key.png">
75
+
</div>
76
+
77
+
<hr>
78
+
<divstyle="text-align: center;"><b>Example function: De Moivre root finder</b></div>
This is a tedious task, with a lot of steps (adding for each power), which results in opportunity to make mistakes. This is a good opportunity/case to automate.<br>
92
+
A function which does this tedious process automatically can help us verify if our working out is correct and will save time. (As always, we still need to show working for marks!)<br><br>
93
+
94
+
This function, <pre>zroot</pre>, returns the De Moivre roots of some number, raised to the power <pre>p</pre>, equal to the complex number <pre>z</pre><divclass="">
95
+
\[Z^p = z\]
96
+
Essentially, it returns the values of \(Z\), \(Z\in\mathbb{C} \).<br>
97
+
More specifically, it returns a matrix containing these solutions in polar form on the left column and in rectangular form in the right column.<br><br>
If we take a look at the code line-by-line, it's actually easy to understand. It appears big because we're limited in what we can store in variables, so there's a lot of duplicated code. (In this instance, we can't store lists in variables using the "with" notation, so we need to repeat some code).<br>
148
+
<astyle="font-size:x-small;">*Sorry - I can't use highlight.js to make the code below colorful. The above image was generated by Carbon so I can't split it into a table.</a>
<tr><td></td><td><pre>Define zsolve(p,z)=augment(</pre></td><td><preclass="comment">//Defines our custom command. augment() joins two arrays together (the polar and rectangular array columns)</pre></td></tr>
157
+
<tr><td></td><td><pre> listToMat(</pre></td><td><preclass="comment">//listToMat() converts a list (generated by seq()) to a matrix so it looks better.</pre></td></tr>
158
+
<tr><td></td><td><pre> M*augment(</pre></td><td><preclass="comment">//We multiply the list (below) by M, The magnitude of the zeroth solution. M is multiplied to all values in the augmented (joined) list. augment() concatenates two lists.</pre></td></tr>
159
+
<tr><td></td><td><pre> seq(Cis(θ+n),n,0,π,d),</pre></td><td><preclass="comment">//seq() is a function which generates a list based on a sequence. For example, seq(x^2,x,0,6,2) => {0,4,16,36}. Here we generate a list of polar coordinates with angles from 0 to π, with a constant θ added to n, a number which is generated from the seq() function. We increment each step by d, a constant. Also note the capital 'Cis' - this prevents it from being evaluated into rectangular form if cis() is defined. Cis() must be undefined to display in this form.</pre></td></tr>
160
+
<tr><td></td><td><pre> seq(Cis(θ+n),n,-d,-π,-d)</pre></td><td><preclass="comment">//Similar to the last line, except we increment by -d, starting at -d (to prevent a 'double up' of Cis(θ+0)) and counting to -π</pre></td></tr>
161
+
<tr><td></td><td><pre> ),</pre></td><td><preclass="comment">//Closing bracket for augment. We augment the sequence for positive angles and negative angles into one list.</pre></td></tr>
162
+
<tr><td></td><td><pre> ),</pre></td><td><preclass="comment">//Closing bracket for listToMat</pre></td></tr>
163
+
<tr><td></td><td><pre> listToMat(</pre></td><td><preclass="comment">//We repeat the process again. This time, we generate the rectangular form column.</pre></td></tr>
<tr><td></td><td><pre> seq(e^(i(θ+n)),n,0,π,d),</pre></td><td><preclass="comment">//Notice how we do not use Cis(), but Euler's formula to evaluate. We can use cis(θ+n) or cos(θ+n)+i*sin(θ+n), but Euler's formula is compact and always works (unlike cis() which might not be defined)</pre></td></tr>
<tr><td></td><td><pre>)|{</pre></td><td><preclass="comment">//This pipe or bar character is documented as the "with" operator. For example, (2x)|{x=5} evaluates to 10. We store constants within the curly braces to make things neater to represent.</pre></td></tr>
170
+
<tr><td></td><td><pre> θ=arg(z^(1/p)),</pre></td><td><preclass="comment">//This gets the phase of the zeroth solution. The zeroth solution is always the pth root of z.</pre></td></tr>
171
+
<tr><td></td><td><pre> M=(re(z)^2+im(z)^2)^(1/(2p)),</pre></td><td><preclass="comment">//This is the magnitude. Simple stuff, we multiply the half by 1/p to skip a step (because the root is z^(1/p) => M^(1/p))</pre></td></tr>
172
+
<tr><td></td><td><pre> d=2π/p</pre></td><td><preclass="comment">//This is our angle difference. Remember - you need to state this for one mark.</pre></td></tr>
173
+
<tr><td></td><td><pre>}</pre></td><td><preclass="comment">//Don't forget to close your brackets! tada!</pre></td></tr>
174
+
</tbody>
175
+
</table><br>
176
+
<center>
177
+
For complex applications, a function isn't suitable. We need to use a <b>program</b><br>
178
+
When I develop a guide for programs (If I get around to it), the link will be here!
179
+
</center>
180
+
181
+
<aclass="link" style="left:1%; top: 1%;" href="https://classpad.github.io">🔗 To classpad homepage</a><br>
182
+
<aclass="link" style="left:1%; top: 1%;" href="https://npc-strider.github.io/maths">🔗 To MATHS page</a><br>
183
+
<aclass="link" style="left:1%; top: 1%;" href="https://npc-strider.github.io">🔗 To personal homepage</a><br>
<!-- Warning: This page requires javascript to render the math. -->
38
+
<bodystyle="padding: 1%;">
39
+
<center>
40
+
<h1>Classpad resources</h1>
41
+
<h4>A compilation of classpad programs and functions used by me in Year 12!</h4>
42
+
</center>
43
+
44
+
<divclass="card">
45
+
<divclass="card-body">
46
+
<center><b>Why am I revealing this content?</b></center>
47
+
Using programs and eActivities can solve 'recurring' or 'expected' questions, which saves a large amount of time during a test that can be spent on harder/novel/unique questions.<br>
48
+
Additionally, classpad programs can be an extension to your notes. The classpad has a capacity of 5.5 MB for eActivities alone - in practice, this translates to infinitely many pages of notes. Unlike the two pages of hardcopy notes you bring into a test or exam, the 'notes' of the classpad are interactive.<br>
49
+
Personally, for me the classpad was a good way to put my programming skills to use.
<aclass="link" style="left:1%; top: 1%;" href="https://github.com/classpad/classpad-programs/raw/master/spec_method_programs-(eActivity).xcp"><b>DOWNLOAD</b>: Year 12 classpad programs (All compiled into one eActivity)</a><br>
63
+
* Last updated: 2021-01-15<br>
64
+
Connect your classpad to a computer and copy this eActivity file to the autoimport directory of the classpad.<br>
65
+
See section 15-2 of the classpad manual for more information on transferring files.<br>
66
+
* Report any bugs or suggest ideas to the classpad github repository:<br>
0 commit comments