Complex numbers and the iterative command.

main
Joshua Potter 2025-01-02 20:08:59 -07:00
parent a7a8abfe4d
commit bb0b7f9fea
9 changed files with 392 additions and 11 deletions

View File

@ -241,7 +241,9 @@
"state-diagram.png", "state-diagram.png",
"state-diagram-ends1.png", "state-diagram-ends1.png",
"state-diagram-ends0.png", "state-diagram-ends0.png",
"dfs-edge-classification.png" "dfs-edge-classification.png",
"complex-plane-point.png",
"iterative-command.png"
], ],
"File Hashes": { "File Hashes": {
"algorithms/index.md": "3ac071354e55242919cc574eb43de6f8", "algorithms/index.md": "3ac071354e55242919cc574eb43de6f8",
@ -417,7 +419,7 @@
"_journal/2024-03/2024-03-15.md": "e54b2513beac5f46313b4c37622adf39", "_journal/2024-03/2024-03-15.md": "e54b2513beac5f46313b4c37622adf39",
"_journal/2024-03-17.md": "72e99c7630085aee2c7f340a06b5ada7", "_journal/2024-03-17.md": "72e99c7630085aee2c7f340a06b5ada7",
"_journal/2024-03/2024-03-16.md": "ab7629c24ebe70838072cf6acec47cb0", "_journal/2024-03/2024-03-16.md": "ab7629c24ebe70838072cf6acec47cb0",
"encoding/floating-point.md": "d19e3f992bf2e073d2049fb0973c89bd", "encoding/floating-point.md": "4deee7fd18a0efdf18fee993013ba4b0",
"_journal/2024-03-18.md": "8479f07f63136a4e16c9cd07dbf2f27f", "_journal/2024-03-18.md": "8479f07f63136a4e16c9cd07dbf2f27f",
"_journal/2024-03/2024-03-17.md": "23f9672f5c93a6de52099b1b86834e8b", "_journal/2024-03/2024-03-17.md": "23f9672f5c93a6de52099b1b86834e8b",
"set/directed-graph.md": "b4b8ad1be634a0a808af125fe8577a53", "set/directed-graph.md": "b4b8ad1be634a0a808af125fe8577a53",
@ -544,7 +546,7 @@
"_journal/2024-05-13.md": "71eb7924653eed5b6abd84d3a13b532b", "_journal/2024-05-13.md": "71eb7924653eed5b6abd84d3a13b532b",
"_journal/2024-05/2024-05-12.md": "ca9f3996272152ef89924bb328efd365", "_journal/2024-05/2024-05-12.md": "ca9f3996272152ef89924bb328efd365",
"git/remotes.md": "6fbbc95efa421c720e40500e5d133639", "git/remotes.md": "6fbbc95efa421c720e40500e5d133639",
"programming/pred-trans.md": "c02471c6c9728dd19f8df7bc180ef8b1", "programming/pred-trans.md": "5b271eebe32e33108d7a36ad98600148",
"set/axioms.md": "063955bf19c703e9ad23be2aee4f1ab7", "set/axioms.md": "063955bf19c703e9ad23be2aee4f1ab7",
"_journal/2024-05-14.md": "f6ece1d6c178d57875786f87345343c5", "_journal/2024-05-14.md": "f6ece1d6c178d57875786f87345343c5",
"_journal/2024-05/2024-05-13.md": "d549dd75fb42b4280d4914781edb0113", "_journal/2024-05/2024-05-13.md": "d549dd75fb42b4280d4914781edb0113",
@ -1047,7 +1049,7 @@
"encoding/xml/index.md": "01a66b1a102cccc682f8f1cab0f50bc6", "encoding/xml/index.md": "01a66b1a102cccc682f8f1cab0f50bc6",
"ontology/reification.md": "ef8275957dcc1a7e5501722d4652e41c", "ontology/reification.md": "ef8275957dcc1a7e5501722d4652e41c",
"ontology/rdf.md": "fd273c30bec6f46b68547f0d392620b1", "ontology/rdf.md": "fd273c30bec6f46b68547f0d392620b1",
"data-models/rdf.md": "98594898837f981dcbdd26df80e93a87", "data-models/rdf.md": "122bad0fa8e2b299e75e744bc5c246d6",
"serialization/xml.md": "84b632282ebcc2b6216923a02abdd4c2", "serialization/xml.md": "84b632282ebcc2b6216923a02abdd4c2",
"serialization/index.md": "5ed7e99e4efc4844839ea357d351f5d8", "serialization/index.md": "5ed7e99e4efc4844839ea357d351f5d8",
"data-models/index.md": "9e60f40798490f0743f291e55f492033", "data-models/index.md": "9e60f40798490f0743f291e55f492033",
@ -1065,7 +1067,7 @@
"_journal/2024-12/2024-12-23.md": "72b0964a8a5ed8ba0acf7fe10b5de279", "_journal/2024-12/2024-12-23.md": "72b0964a8a5ed8ba0acf7fe10b5de279",
"_journal/2024-12-25.md": "1717d37b074df58175ec0272adc278de", "_journal/2024-12-25.md": "1717d37b074df58175ec0272adc278de",
"_journal/2024-12/2024-12-24.md": "dcd3bd8b82ca4d47a9642a46d8bece0d", "_journal/2024-12/2024-12-24.md": "dcd3bd8b82ca4d47a9642a46d8bece0d",
"linkers/relocatable.md": "64c3c75dca8ec9676bd80a9a9feb7887", "linkers/relocatable.md": "31b5d8700a787e5aeee41f819864bcd9",
"data-models/federation.md": "1d92747304186bd2833a00a488fcac48", "data-models/federation.md": "1d92747304186bd2833a00a488fcac48",
"_journal/2024-12-26.md": "022aeaf68d46fd39b23aca9c577f3f41", "_journal/2024-12-26.md": "022aeaf68d46fd39b23aca9c577f3f41",
"_journal/2024-12/2024-12-25.md": "1717d37b074df58175ec0272adc278de", "_journal/2024-12/2024-12-25.md": "1717d37b074df58175ec0272adc278de",
@ -1416,7 +1418,10 @@
"_journal/2024/2024-12/2024-12-03.md": "54480a38f1e16e48529cbb99c5349c74", "_journal/2024/2024-12/2024-12-03.md": "54480a38f1e16e48529cbb99c5349c74",
"_journal/2024/2024-12/2024-12-02.md": "beb50f6f3656470f2cb28b759b652994", "_journal/2024/2024-12/2024-12-02.md": "beb50f6f3656470f2cb28b759b652994",
"_journal/2024/2024-12/2024-12-01.md": "84987be103489d6447eba85726aa2489", "_journal/2024/2024-12/2024-12-01.md": "84987be103489d6447eba85726aa2489",
"_journal/2025-01-01.md": "3cf29f753c27313c95a435a7845b4c13" "_journal/2025-01-01.md": "3cf29f753c27313c95a435a7845b4c13",
"_journal/2025-01-02.md": "d836d831495d0646e7bf8c564579f9f1",
"_journal/2025-01/2025-01-01.md": "3cf29f753c27313c95a435a7845b4c13",
"algebra/complex.md": "37befb93643418cd8905c49e2f53627b"
}, },
"fields_dict": { "fields_dict": {
"Basic": [ "Basic": [

View File

@ -0,0 +1,12 @@
---
title: "2025-01-02"
---
- [x] Anki Flashcards
- [x] KoL
- [x] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)
* Add a number of basic facts about [[complex|complex numbers]].
* Introductory notes on the [[pred-trans#Iterative|iterative command]].

246
notes/algebra/complex.md Normal file
View File

@ -0,0 +1,246 @@
---
title: Complex Numbers
TARGET DECK: Obsidian::STEM
FILE TAGS: algebra::complex
tags:
- algebra
- complex
---
## Overview
The set $\mathbb{C}$ of **complex numbers** is defined by $$\mathbb{C} = \{a + bi \mid a, b \in \mathbb{R}\},$$
where $i$ is the **imaginary number** defined as $i^2 = -1$.
%%ANKI
Basic
How is set the complex numbers denoted?
Back: As $\mathbb{C}$.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487309-->
END%%
%%ANKI
Basic
How is set $\mathbb{C}$ defined in set-builder notation?
Back: $\mathbb{C} = \{a + bi \mid a, b \in \mathbb{R}\}$
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487353-->
END%%
%%ANKI
Basic
Which of $\mathbb{R}$ or $\mathbb{C}$ is a subset of the other?
Back: $\mathbb{R} \subseteq \mathbb{C}$
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487367-->
END%%
%%ANKI
Basic
What is $i$ called?
Back: The imaginary number.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487383-->
END%%
%%ANKI
Basic
How is the imaginary number typically denoted?
Back: As $i$.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487411-->
END%%
%%ANKI
Basic
$i$ was invented to provide a solution to what equation?
Back: $x^2 = -1$
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487426-->
END%%
%%ANKI
Basic
What is the solution of $x^2 = -1$?
Back: $i$
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487437-->
END%%
%%ANKI
Cloze
Real number {$r$} is identified with complex number {$r + 0i$}.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487452-->
END%%
%%ANKI
Cloze
What real number is identified with $-\pi + 0i$?
Back: $-\pi$
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487459-->
END%%
%%ANKI
Cloze
What real number is identified with $\pi + 2i$?
Back: N/A.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487463-->
END%%
%%ANKI
Basic
What is the horizontal axis of the complex plane typically called?
Back: The real axis.
Reference: “Complex Plane,” in _Wikipedia_, December 14, 2024, [https://en.wikipedia.org/w/index.php?title=Complex_plane](https://en.wikipedia.org/w/index.php?title=Complex_plane&oldid=1263031649).
<!--ID: 1735870487466-->
END%%
%%ANKI
Basic
What is the vertical axis of the complex plane typically called?
Back: The imaginary axis.
Reference: “Complex Plane,” in _Wikipedia_, December 14, 2024, [https://en.wikipedia.org/w/index.php?title=Complex_plane](https://en.wikipedia.org/w/index.php?title=Complex_plane&oldid=1263031649).
<!--ID: 1735870487469-->
END%%
%%ANKI
Cloze
The complex plane is formed from the {$x$}-axis and {$yi$}-axis.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487472-->
END%%
%%ANKI
Basic
Which number is plotted on the complex plane below?
![[complex-plane-point.png]]
Back: $2 + i$
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487475-->
END%%
%%ANKI
Cloze
Real numbers are plotted on a {line} whereas complex numbers are plotted on a {plane}.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487478-->
END%%
## Operations
Addition and multiplication of complex numbers are done in the natural way. Given complex numbers $a + bi$ and $c + di$, we have that $$\begin{align*} (a + bi) + (c + di) & = (a + c) + (b + d)i \\ (a + bi) \cdot (c + di) & = (ac -bd) + (ad + bc)i \end{align*}$$
The **absolute value** of $a + bi$, denoted $\lvert a + bi \rvert$, is defined as $$\lvert a + bi \rvert = \sqrt{a^2 + b^2}.$$
%%ANKI
Basic
Let $a + bi$ and $c + di$ be complex numbers. What is their sum?
Back: $(a + c) + (b + d)i$
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487481-->
END%%
%%ANKI
Basic
Let $a + bi$ and $c + di$ be complex numbers. What is their product?
Back: $(ac - bd) + (ad + bc)i$
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487484-->
END%%
%%ANKI
Basic
Is addition of complex numbers commutative?
Back: Yes.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487487-->
END%%
%%ANKI
Basic
Is addition of complex numbers associative?
Back: Yes.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487491-->
END%%
%%ANKI
Basic
What does it mean for addition of complex numbers to be commutative?
Back: For $z_1, z_2 \in \mathbb{C}$, it follows that $z_1 + z_2 = z_2 + z_1$.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487494-->
END%%
%%ANKI
Basic
Is multiplication of complex numbers commutative?
Back: Yes.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487498-->
END%%
%%ANKI
Basic
Is multiplication of complex numbers associative?
Back: Yes.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487502-->
END%%
%%ANKI
Basic
What does it mean for multiplication of complex numbers to be associative?
Back: For $z_1, z_2, z_3 \in \mathbb{C}$, it follows that $z_1(z_2z_3) = (z_1z_2)z_3$.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870487506-->
END%%
%%ANKI
Basic
How is the absolute value of complex number $z \in \mathbb{C}$ denoted?
Back: As $\lvert z \rvert$.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870829668-->
END%%
%%ANKI
Basic
Let $z \in \mathbb{C}$. How is $\lvert z \rvert$ defined?
Back: Assuming $z = a + bi$, as $\lvert z \rvert = \sqrt{a^2 + b^2}$.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870829671-->
END%%
%%ANKI
Basic
Geometrically speaking, what does the absolute value of $z \in \mathbb{C}$ correspond to?
Back: $z$'s distance from the complex plane's origin.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870829675-->
END%%
%%ANKI
Basic
Let $a + bi$ be a complex number. How is $\sqrt{a^2 + b^2}$ more compactly written?
Back: As $\lvert a + bi \rvert$.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870829679-->
END%%
%%ANKI
Basic
What geometric theorem motivates the definition of complex numbers' absolute values?
Back: The Pythagorean theorem.
Reference: John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).
<!--ID: 1735870829684-->
END%%
## Bibliography
* “Complex Plane,” in _Wikipedia_, December 14, 2024, [https://en.wikipedia.org/w/index.php?title=Complex_plane](https://en.wikipedia.org/w/index.php?title=Complex_plane&oldid=1263031649).
* John B. Fraleigh, _A First Course in Abstract Algebra_, Seventh edition, Pearson new international edition (Harlow: Pearson, 2014).

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

@ -201,12 +201,12 @@ END%%
## Blank Nodes ## Blank Nodes
A **blank node** (bnode) is a node in an RDF graph representing a resource for which a [[uri|URI]] is not specified. That is, the represented resource is anonymous. Such a node can only be used as a subject or object in an RDF triple. A **blank node** (bnode) is a node in an RDF graph representing a resource for which a [[uri|IRI]] is not specified. That is, the represented resource is anonymous. Such a node can only be used as a subject or object in an RDF triple.
%%ANKI %%ANKI
Basic Basic
What is a blank node? What is a blank node?
Back: A node in an RDF graph representing a resource with an unspecified URI. Back: A node in an RDF graph representing a resource with an unspecified IRI.
Reference: Allemang, Dean, James A. Hendler, and Fabien L. Gandon. _Semantic Web for the Working Ontologist_. 3e ed. ACM Books 33. New York: Association for computing machinery, 2020. Reference: Allemang, Dean, James A. Hendler, and Fabien L. Gandon. _Semantic Web for the Working Ontologist_. 3e ed. ACM Books 33. New York: Association for computing machinery, 2020.
<!--ID: 1735162429073--> <!--ID: 1735162429073-->
END%% END%%
@ -214,7 +214,6 @@ END%%
%%ANKI %%ANKI
Cloze Cloze
A {bnode} is shorthand for a {blank node}. A {bnode} is shorthand for a {blank node}.
Back: A node in an RDF graph representing a resource with an unspecified URI.
Reference: Allemang, Dean, James A. Hendler, and Fabien L. Gandon. _Semantic Web for the Working Ontologist_. 3e ed. ACM Books 33. New York: Association for computing machinery, 2020. Reference: Allemang, Dean, James A. Hendler, and Fabien L. Gandon. _Semantic Web for the Working Ontologist_. 3e ed. ACM Books 33. New York: Association for computing machinery, 2020.
<!--ID: 1735162429077--> <!--ID: 1735162429077-->
END%% END%%

View File

@ -850,6 +850,15 @@ Tags: c17
<!--ID: 1710605798327--> <!--ID: 1710605798327-->
END%% END%%
%%ANKI
Basic
Let `float x = 1.0`. What does `x`'s exponent *value* equal?
Back: $0$
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17
<!--ID: 1735827481751-->
END%%
%%ANKI %%ANKI
Basic Basic
Let `double x = 1.0`. What is the bit representation of `x`'s exponent *field*? Let `double x = 1.0`. What is the bit representation of `x`'s exponent *field*?

View File

@ -225,21 +225,23 @@ Basic
What C variables are marked `COMMON` instead of put in `.bss`? What C variables are marked `COMMON` instead of put in `.bss`?
Back: Global uninitialized variables. Back: Global uninitialized variables.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17
<!--ID: 1735343812827--> <!--ID: 1735343812827-->
END%% END%%
%%ANKI %%ANKI
Basic Basic
What C variables are put in `.bss` instead of marked `COMMON`? What C variables are put in `.bss` instead of marked `COMMON`?
Back: Static variables or global variables initialized to zero. Back: Static variables and global variables initialized to zero.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17
<!--ID: 1735343812828--> <!--ID: 1735343812828-->
END%% END%%
%%ANKI %%ANKI
Basic Basic
Assuming `-fcommon`, what kind of C variables does the `.bss` section contain? Assuming `-fcommon`, what kind of C variables does the `.bss` section contain?
Back: Static variables or global and static variables initialized to zero. Back: Static variables and global variables initialized to zero.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17 Tags: c17
<!--ID: 1735343812829--> <!--ID: 1735343812829-->

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

@ -878,6 +878,14 @@ The general form of the **alternative command** is: $$\begin{align*} \textbf{if
Each $B_i \rightarrow S_i$ is called a **guarded command**. To execute the alternative command, find one true guard and execute the corresponding command. Notice this is nondeterministic. We denote the alternative command as $\text{IF}$ and define $\text{IF}$ in terms of $wp$ as: $$\begin{align*} wp(\text{IF}, R) = \;& (\forall i, 1 \leq i \leq n \Rightarrow domain(B_i)) \;\land \\ & (\exists i, 1 \leq i \leq n \land B_i) \;\land \\ & (\forall i, 1 \leq i \leq n \Rightarrow (B_i \Rightarrow wp(S_i, R))) \end{align*}$$ Each $B_i \rightarrow S_i$ is called a **guarded command**. To execute the alternative command, find one true guard and execute the corresponding command. Notice this is nondeterministic. We denote the alternative command as $\text{IF}$ and define $\text{IF}$ in terms of $wp$ as: $$\begin{align*} wp(\text{IF}, R) = \;& (\forall i, 1 \leq i \leq n \Rightarrow domain(B_i)) \;\land \\ & (\exists i, 1 \leq i \leq n \land B_i) \;\land \\ & (\forall i, 1 \leq i \leq n \Rightarrow (B_i \Rightarrow wp(S_i, R))) \end{align*}$$
%%ANKI
Basic
The conventional `if` statement corresponds to what command?
Back: The alternative command.
Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.
<!--ID: 1735873377633-->
END%%
%%ANKI %%ANKI
Basic Basic
How is the alternative command compactly denoted? How is the alternative command compactly denoted?
@ -960,6 +968,14 @@ Reference: Gries, David. *The Science of Programming*. Texts and Monographs in
<!--ID: 1722256906214--> <!--ID: 1722256906214-->
END%% END%%
%%ANKI
Basic
Suppose two guards of an alternative command is true. Which is chosen?
Back: Either is permitted.
Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.
<!--ID: 1735873377661-->
END%%
%%ANKI %%ANKI
Basic Basic
When *might* the following alternative command abort? $$\begin{align*} \textbf{if } & x > 0 \rightarrow z \coloneqq x \\ \textbf{ | } & x < 0 \rightarrow z \coloneqq -x \\ \textbf{fi } & \end{align*}$$ When *might* the following alternative command abort? $$\begin{align*} \textbf{if } & x > 0 \rightarrow z \coloneqq x \\ \textbf{ | } & x < 0 \rightarrow z \coloneqq -x \\ \textbf{fi } & \end{align*}$$
@ -1015,6 +1031,98 @@ Reference: Gries, David. *The Science of Programming*. Texts and Monographs in
<!--ID: 1722259243640--> <!--ID: 1722259243640-->
END%% END%%
### Iterative
The general form of the **iterative command** is: $$\begin{align*} \textbf{do } & B_1 \rightarrow S_1 \\ \textbf{ | } & B_2 \rightarrow S_2 \\ & \quad\cdots \\ \textbf{ | } & B_n \rightarrow S_n \\ \textbf{od } & \end{align*}$$
%%ANKI
Basic
The conventional `while` statement corresponds to what command?
Back: The iterative command.
Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.
<!--ID: 1735873377664-->
END%%
%%ANKI
Cloze
{1:$\text{IF}$} is to the {2:alternative} command whereas {2:$\text{DO}$} is to the {1:iterative} command.
Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.
<!--ID: 1735873377667-->
END%%
%%ANKI
Basic
How is the iterative command compactly denoted?
Back: As $\text{DO}$.
Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.
<!--ID: 1735873377671-->
END%%
%%ANKI
Basic
What kind of command is $\text{DO}$ a representation of?
Back: An iterative command.
Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.
<!--ID: 1735873377674-->
END%%
%%ANKI
Basic
What is the general form of the iterative command?
Back: $$\begin{align*} \textbf{do } & B_1 \rightarrow S_1 \\ \textbf{ | } & B_2 \rightarrow S_2 \\ & \quad\cdots \\ \textbf{ | } & B_n \rightarrow S_n \\ \textbf{od } & \end{align*}$$
Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.
<!--ID: 1735873377678-->
END%%
%%ANKI
Basic
How are iterative commands executed?
Back: By repeatedly choosing any true guard and executing the corresponding command.
Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.
<!--ID: 1735873377683-->
END%%
%%ANKI
Basic
What does it mean to "perform an iteration" of an iterative command?
Back: Choosing a true guard and executing its command.
Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.
<!--ID: 1735873377687-->
END%%
%%ANKI
Basic
In what way is the iterative command's execution different from traditional loop statements?
Back: It is nondeterministic.
Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.
<!--ID: 1735873377691-->
END%%
%%ANKI
Basic
Suppose two guards of an iterative command is true. Which is chosen?
Back: Either is permitted.
Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.
<!--ID: 1735873377695-->
END%%
%%ANKI
Basic
How is the following rewritten to have just one iterative guard? $$\begin{align*} \textbf{do } & B_1 \rightarrow S_1 \\ \textbf{ | } & B_2 \rightarrow S_2 \\ & \quad\cdots \\ \textbf{ | } & B_n \rightarrow S_n \\ \textbf{od } & \end{align*}$$
Back: Given $BB = B_1 \lor \cdots \lor B_n$, as $$\begin{align*} \textbf{do } & BB \rightarrow \textbf{if } B_1 \rightarrow S_1 \\ & \quad\quad\quad \textbf{ | } B_2 \rightarrow S_2 \\ & \quad\quad\quad \quad\cdots \\ & \quad\quad\quad \textbf{ | } B_n \rightarrow S_n \\ & \quad\quad\quad \textbf{fi } \\ \textbf{od } & \end{align*}$$
Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.
<!--ID: 1735873377699-->
END%%
%%ANKI
Basic
Which command is demonstrated in the following diagram?
![[iterative-command.png]]
Back: The iterative command.
Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.
<!--ID: 1735873599850-->
END%%
## Bibliography ## Bibliography
* Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981. * Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.