Compare commits

..

1 Commits

Author SHA1 Message Date
fb37c5b4cd Migrate to VitePress 2022-05-27 23:00:55 -04:00
48 changed files with 1208 additions and 8742 deletions

153
.gitignore vendored
View File

@ -1,2 +1,151 @@
site/
docs/resources/
docs/resources
# do not commit lockfiles
package-lock.json
yarn.lock
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Serverless directories
.serverless/
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# dotenv environment variables file
.env
.env.test
# See http://help.github.com/ignore-files/ for more about ignoring files.
# ignore server configuration
env/development.js
docker-compose.local.yml
*.azcli
# DynamoDB Local files
.dynamodb/
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# compiled output
/dist
/tmp
/out-tsc
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.vscode-test
# TernJS port file
.tern-port
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
testem.log
/typings
# e2e
/e2e/*.js
/e2e/*.map
# vuepress build output
.vuepress/dist
# vitepress build output
.vitepress/dist
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# System Files
.DS_Store
/.DS_Store
*/.DS_Store
Thumbs.db

View File

@ -39,7 +39,7 @@ Pomme de terre!
Links to images must be either from Kognity or available for free non-commercial use. They should be sent to the site administrator's email to be loaded in as a static local asset. Images should be linked using HTML, have a maximum width of 700 pixels, contain a reference to the source organisation, and fit the overall theme of the site. The link to the image path is `/resources/images/image.file-extension`. If possible, PNGs are preferred. Images should be relevantly named in lowercase with hyphens separating words.
`<img src="/resources/images/velocity-time-graph.png" width=700>(Source: Kognity)</img>`
`<img src="/resources/images/velocity-time-graph.png" width=700>(Source: Kognity)</img>
## Special Markdown

View File

@ -1,351 +1,412 @@
### GNU Free Documentation License
### GNU GENERAL PUBLIC LICENSE
Version 1.3, 3 November 2008
Version 3, 29 June 2007
Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation,
Inc. <https://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc.
<https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
#### 0. PREAMBLE
### Preamble
The purpose of this License is to make a manual, textbook, or other
functional and useful document "free" in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
This License is a kind of "copyleft", which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom
to share and change all versions of a program--to make sure it remains
free software for all its users. We, the Free Software Foundation, use
the GNU General Public License for most of our software; it applies
also to any other work released this way by its authors. You can apply
it to your programs, too.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals; it
can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
#### 1. APPLICABILITY AND DEFINITIONS
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you
have certain responsibilities if you distribute copies of the
software, or if you modify it: responsibilities to respect the freedom
of others.
This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License. Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein. The "Document", below, refers
to any such manual or work. Any member of the public is a licensee,
and is addressed as "you". You accept the license if you copy, modify
or distribute the work in a way requiring permission under copyright
law.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
A "Modified Version" of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
A "Secondary Section" is a named appendix or a front-matter section of
the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject. (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
The "Invariant Sections" are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License. If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant. The Document may contain zero
Invariant Sections. If the Document does not identify any Invariant
Sections then there are none.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the
manufacturer can do so. This is fundamentally incompatible with the
aim of protecting users' freedom to change the software. The
systematic pattern of such abuse occurs in the area of products for
individuals to use, which is precisely where it is most unacceptable.
Therefore, we have designed this version of the GPL to prohibit the
practice for those products. If such problems arise substantially in
other domains, we stand ready to extend this provision to those
domains in future versions of the GPL, as needed to protect the
freedom of users.
The "Cover Texts" are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License. A Front-Cover Text may be
at most 5 words, and a Back-Cover Text may be at most 25 words.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish
to avoid the special danger that patents applied to a free program
could make it effectively proprietary. To prevent this, the GPL
assures that patents cannot be used to render the program non-free.
A "Transparent" copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text. A copy that is not "Transparent" is called "Opaque".
The precise terms and conditions for copying, distribution and
modification follow.
Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, LaTeX input format, SGML
or XML using a publicly available DTD, and standard-conforming simple
HTML, PostScript or PDF designed for human modification. Examples of
transparent image formats include PNG, XCF and JPG. Opaque formats
include proprietary formats that can be read and edited only by
proprietary word processors, SGML or XML for which the DTD and/or
processing tools are not generally available, and the
machine-generated HTML, PostScript or PDF produced by some word
processors for output purposes only.
### TERMS AND CONDITIONS
The "Title Page" means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, "Title Page" means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
#### 0. Definitions.
The "publisher" means any person or entity that distributes copies of
the Document to the public.
"This License" refers to version 3 of the GNU General Public License.
A section "Entitled XYZ" means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
specific section name mentioned below, such as "Acknowledgements",
"Dedications", "Endorsements", or "History".) To "Preserve the Title"
of such a section when you modify the Document means that it remains a
section "Entitled XYZ" according to this definition.
"Copyright" also means copyright-like laws that apply to other kinds
of works, such as semiconductor masks.
The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document. These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
#### 2. VERBATIM COPYING
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of
an exact copy. The resulting work is called a "modified version" of
the earlier work or a work "based on" the earlier work.
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no
other conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
A "covered work" means either the unmodified Program or a work based
on the Program.
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
#### 3. COPYING IN QUANTITY
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user
through a computer network, with no transfer of a copy, is not
conveying.
If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify you
as the publisher of these copies. The front cover must present the
full title with all words of the title equally prominent and visible.
You may add other material on the covers in addition. Copying with
changes limited to the covers, as long as they preserve the title of
the Document and satisfy these conditions, can be treated as verbatim
copying in other respects.
An interactive user interface displays "Appropriate Legal Notices" to
the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
#### 1. Source Code.
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
The "source code" for a work means the preferred form of the work for
making modifications to it. "Object code" means any non-source form of
a work.
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to
give them a chance to provide you with an updated version of the
Document.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
#### 4. MODIFICATIONS
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
- A. Use in the Title Page (and on the covers, if any) a title
distinct from that of the Document, and from those of previous
versions (which should, if there were any, be listed in the
History section of the Document). You may use the same title as a
previous version if the original publisher of that version
gives permission.
- B. List on the Title Page, as authors, one or more persons or
entities responsible for authorship of the modifications in the
Modified Version, together with at least five of the principal
authors of the Document (all of its principal authors, if it has
fewer than five), unless they release you from this requirement.
- C. State on the Title page the name of the publisher of the
Modified Version, as the publisher.
- D. Preserve all the copyright notices of the Document.
- E. Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
- F. Include, immediately after the copyright notices, a license
notice giving the public permission to use the Modified Version
under the terms of this License, in the form shown in the
Addendum below.
- G. Preserve in that license notice the full lists of Invariant
Sections and required Cover Texts given in the Document's
license notice.
- H. Include an unaltered copy of this License.
- I. Preserve the section Entitled "History", Preserve its Title,
and add to it an item stating at least the title, year, new
authors, and publisher of the Modified Version as given on the
Title Page. If there is no section Entitled "History" in the
Document, create one stating the title, year, authors, and
publisher of the Document as given on its Title Page, then add an
item describing the Modified Version as stated in the
previous sentence.
- J. Preserve the network location, if any, given in the Document
for public access to a Transparent copy of the Document, and
likewise the network locations given in the Document for previous
versions it was based on. These may be placed in the "History"
section. You may omit a network location for a work that was
published at least four years before the Document itself, or if
the original publisher of the version it refers to
gives permission.
- K. For any section Entitled "Acknowledgements" or "Dedications",
Preserve the Title of the section, and preserve in the section all
the substance and tone of each of the contributor acknowledgements
and/or dedications given therein.
- L. Preserve all the Invariant Sections of the Document, unaltered
in their text and in their titles. Section numbers or the
equivalent are not considered part of the section titles.
- M. Delete any section Entitled "Endorsements". Such a section may
not be included in the Modified Version.
- N. Do not retitle any existing section to be Entitled
"Endorsements" or to conflict in title with any Invariant Section.
- O. Preserve any Warranty Disclaimers.
The Corresponding Source need not include anything that users can
regenerate automatically from other parts of the Corresponding Source.
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
The Corresponding Source for a work in source code form is that same
work.
You may add a section Entitled "Endorsements", provided it contains
nothing but endorsements of your Modified Version by various
parties—for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
#### 2. Basic Permissions.
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
You may make, run and propagate covered works that you do not convey,
without conditions so long as your license otherwise remains in force.
You may convey covered works to others for the sole purpose of having
them make modifications exclusively for you, or provide you with
facilities for running those works, provided that you comply with the
terms of this License in conveying all material for which you do not
control copyright. Those thus making or running the covered works for
you must do so exclusively on your behalf, under your direction and
control, on terms that prohibit them from making any copies of your
copyrighted material outside their relationship with you.
#### 5. COMBINING DOCUMENTS
Conveying under any other circumstances is permitted solely under the
conditions stated below. Sublicensing is not allowed; section 10 makes
it unnecessary.
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
In the combination, you must combine any sections Entitled "History"
in the various original documents, forming one section Entitled
"History"; likewise combine any sections Entitled "Acknowledgements",
and any sections Entitled "Dedications". You must delete all sections
Entitled "Endorsements".
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such
circumvention is effected by exercising rights under this License with
respect to the covered work, and you disclaim any intention to limit
operation or modification of the work as a means of enforcing, against
the work's users, your or third parties' legal rights to forbid
circumvention of technological measures.
#### 6. COLLECTIONS OF DOCUMENTS
#### 4. Conveying Verbatim Copies.
You may make a collection consisting of the Document and other
documents released under this License, and replace the individual
copies of this License in the various documents with a single copy
that is included in the collection, provided that you follow the rules
of this License for verbatim copying of each of the documents in all
other respects.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may extract a single document from such a collection, and
distribute it individually under this License, provided you insert a
copy of this License into the extracted document, and follow this
License in all other respects regarding verbatim copying of that
document.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
#### 7. AGGREGATION WITH INDEPENDENT WORKS
#### 5. Conveying Modified Source Versions.
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an "aggregate" if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these
conditions:
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
- a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
- b) The work must carry prominent notices stating that it is
released under this License and any conditions added under
section 7. This requirement modifies the requirement in section 4
to "keep intact all notices".
- c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
- d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
#### 8. TRANSLATION
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
#### 6. Conveying Non-Source Forms.
If a section in the Document is Entitled "Acknowledgements",
"Dedications", or "History", the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
You may convey a covered work in object code form under the terms of
sections 4 and 5, provided that you also convey the machine-readable
Corresponding Source under the terms of this License, in one of these
ways:
#### 9. TERMINATION
- a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
- b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the Corresponding
Source from a network server at no charge.
- c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
- d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
- e) Convey the object code using peer-to-peer transmission,
provided you inform other peers where the object code and
Corresponding Source of the work are being offered to the general
public at no charge under subsection 6d.
You may not copy, modify, sublicense, or distribute the Document
except as expressly provided under this License. Any attempt otherwise
to copy, modify, sublicense, or distribute it is void, and will
automatically terminate your rights under this License.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal,
family, or household purposes, or (2) anything designed or sold for
incorporation into a dwelling. In determining whether a product is a
consumer product, doubtful cases shall be resolved in favor of
coverage. For a particular product received by a particular user,
"normally used" refers to a typical or common use of that class of
product, regardless of the status of the particular user or of the way
in which the particular user actually uses, or expects or is expected
to use, the product. A product is a consumer product regardless of
whether the product has substantial commercial, industrial or
non-consumer uses, unless such uses represent the only significant
mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to
install and execute modified versions of a covered work in that User
Product from a modified version of its Corresponding Source. The
information must suffice to ensure that the continued functioning of
the modified object code is in no case prevented or interfered with
solely because modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or
updates for a work that has been modified or installed by the
recipient, or for the User Product in which it has been modified or
installed. Access to a network may be denied when the modification
itself materially and adversely affects the operation of the network
or violates the rules and protocols for communication across the
network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
#### 7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders
of that material) supplement the terms of this License with terms:
- a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
- b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
- c) Prohibiting misrepresentation of the origin of that material,
or requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
- d) Limiting the use for publicity purposes of names of licensors
or authors of the material; or
- e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
- f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions
of it) with contractual assumptions of liability to the recipient,
for any liability that these contractual assumptions directly
impose on those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions; the
above requirements apply either way.
#### 8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your license
from a particular copyright holder is reinstated (a) provisionally,
@ -364,82 +425,193 @@ your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, receipt of a copy of some or all of the same material does
not give you any rights to use it.
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
#### 10. FUTURE REVISIONS OF THIS LICENSE
#### 9. Acceptance Not Required for Having Copies.
The Free Software Foundation may publish new, revised versions of the
GNU Free Documentation License from time to time. Such new versions
You are not required to accept this License in order to receive or run
a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
#### 10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
#### 11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned
or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within the
scope of its coverage, prohibits the exercise of, or is conditioned on
the non-exercise of one or more of the rights that are specifically
granted under this License. You may not convey a covered work if you
are a party to an arrangement with a third party that is in the
business of distributing software, under which you make payment to the
third party based on the extent of your activity of conveying the
work, and under which the third party grants, to any of the parties
who would receive the covered work from you, a discriminatory patent
license (a) in connection with copies of the covered work conveyed by
you (or copies made from those copies), or (b) primarily for and in
connection with specific products or compilations that contain the
covered work, unless you entered into that arrangement, or that patent
license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
#### 12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under
this License and any other pertinent obligations, then as a
consequence you may not convey it at all. For example, if you agree to
terms that obligate you to collect a royalty for further conveying
from those to whom you convey the Program, the only way you could
satisfy both those terms and this License would be to refrain entirely
from conveying the Program.
#### 13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
#### 14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions
of the GNU General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in
detail to address new problems or concerns. See
<https://www.gnu.org/licenses/>.
detail to address new problems or concerns.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
Each version is given a distinguishing version number. If the Program
specifies that a certain numbered version of the GNU General Public
License "or any later version" applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation. If the Document specifies
that a proxy can decide which future versions of this License can be
used, that proxy's public statement of acceptance of a version
permanently authorizes you to choose that version for the Document.
following the terms and conditions either of that numbered version or
of any later version published by the Free Software Foundation. If the
Program does not specify a version number of the GNU General Public
License, you may choose any version ever published by the Free
Software Foundation.
#### 11. RELICENSING
If the Program specifies that a proxy can decide which future versions
of the GNU General Public License can be used, that proxy's public
statement of acceptance of a version permanently authorizes you to
choose that version for the Program.
"Massive Multiauthor Collaboration Site" (or "MMC Site") means any
World Wide Web server that publishes copyrightable works and also
provides prominent facilities for anybody to edit those works. A
public wiki that anybody can edit is an example of such a server. A
"Massive Multiauthor Collaboration" (or "MMC") contained in the site
means any set of copyrightable works thus published on the MMC site.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
license published by Creative Commons Corporation, a not-for-profit
corporation with a principal place of business in San Francisco,
California, as well as future copyleft versions of that license
published by that same organization.
#### 15. Disclaimer of Warranty.
"Incorporate" means to publish or republish a Document, in whole or in
part, as part of another Document.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
CORRECTION.
An MMC is "eligible for relicensing" if it is licensed under this
License, and if all works that were first published under this License
somewhere other than this MMC, and subsequently incorporated in whole
or in part into the MMC, (1) had no cover texts or invariant sections,
and (2) were thus incorporated prior to November 1, 2008.
#### 16. Limitation of Liability.
The operator of an MMC Site may republish an MMC contained in the site
under CC-BY-SA on the same site at any time before August 1, 2009,
provided the MMC is eligible for relicensing.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
### ADDENDUM: How to use this License for your documents
#### 17. Interpretation of Sections 15 and 16.
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
Copyright (C) YEAR YOUR NAME.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
If you have Invariant Sections, Front-Cover Texts and Back-Cover
Texts, replace the "with … Texts." line with this:
with the Invariant Sections being LIST THEIR TITLES, with the
Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License, to
permit their use in free software.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

View File

@ -1,8 +1,8 @@
# Eifueo
A "competitor" of sorts to magicalsoup/highschool available at https://eifueo.eggworld.tk.
A "competitor" of sorts to magicalsoup/highschool.
Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines and formatting information.
Please see [CONTRIBUTING.md](/eggy/eifueo/src/branch/master/CONTRIBUTING.md) for guidelines and formatting information.
## Dependencies
@ -18,9 +18,3 @@ MkDocs is used to build the site.
```
mkdocs build
```
For live reload in a development environment:
```
mkdocs serve
```

31
docs/.vitepress/config.ts Normal file
View File

@ -0,0 +1,31 @@
import { defineConfig } from "vitepress";
export default defineConfig({
title: "Eifueo",
description: "Rewritten notes!",
lang: "en-US",
lastUpdated: true,
themeConfig: {
nav: [{ text: "HL Chemistry 2", link: "/sch4uz.html" }],
sidebar: getSidebar(),
repo: "https://git.eggworld.tk/eggy/eifueo",
docsDir: "docs",
},
markdown: {
config: (md) => {
md.use(require("markdown-it-mathjax3"), {
loader: { load: ["[tex]/mhchem"] },
tex: { packages: { "[+]": ["mhchem"] } },
});
},
},
});
function getSidebar() {
return [
{
text: "Grade 12 IB",
children: [{ text: "HL Chemistry 3", link: "/g12/snc4mz" }],
},
];
}

View File

@ -0,0 +1,15 @@
<script setup>
import DefaultTheme from "vitepress/theme";
const { Layout } = DefaultTheme;
</script>
<template>
<Layout></Layout>
</template>
<style>
main > .container {
/* love that */
max-width: 54rem !important;
}
</style>

View File

@ -0,0 +1,7 @@
import DefaultTheme from "vitepress/theme";
import Layout from "./Layout.vue";
export default {
...DefaultTheme,
Layout,
};

View File

@ -1,246 +0,0 @@
# ECE 105: Classical Mechanics
## Motion
Please see [SL Physics 1#2.1 - Motion](/g11/sph3u7/#21-motion) for more information.
## Kinematics
Please see [SL Physics 1#Kinematic equations](/g11/sph3u7/#kinematic-equations) for more information.
## Projectile motion
Please see [SL Physics 1#Projectile motion](/g11/sph3u7/#projectile-motion) for more information.
## Uniform circular motion
Please see [SL Physics 1#6.1 - Circular motion](/g11/sph3u7/#61-circular-motion) for more information.
## Forces
Please see [SL Physics 1#2.2 - Forces](/g11/sph3u7/#22-forces) for more information.
## Work
Please see [SL Physics 1#2.3 - Work, energy, and power](/g11/sph3u7/#23-work-energy-and-power) for more information.
## Momentum and impulse
Please see [SL Physics 1#2.4 - Momentum and impulse](/g11/sph3u7/#24-momentum-and-impulse) for more information.
The change of momentum with respect to time is equal to the average force **so long as mass is constant**.
$$\frac{dp}{dt} = \frac{mdv}{dt} + \frac{vdm}{dt}$$
Impulse is actually the change of momentum over time.
$$\vec J = \int^{p_f}_{p_i}d\vec p$$
## Centre of mass
The centre of mass $x$ of a system is equal to the average of the centre of masses of its components relative to a defined origin.
$$x_{cm} = \frac{m_1x_1 + m_2x_2 + ... + m_nx_n}{m_1 + m_2 + ... + m_n}$$
To determine the centre of mass of a system with a hole, the hole should be treated as negative mass. If the geometry of the system is **symmetrical**, the centre of mass is also symmetrical in the x and y dimensions.
For each mass, its surface density $\sigma$ is equal to:
$$
\sigma = \frac{m}{A} \\
m = \sigma A
$$
Holes have negative mass, i.e., $m = -\sigma A$.
For a **one-dimensional** hole, the linear mass density uses a similar formula:
$$
\lambda =\frac{m}{L} \\
\lambda = \frac{dm}{dx}
$$
This means that a hole in a rod can use a different formula:
$$x_{cm} = \frac{1}{M}\int^M_0 x\cdot dm$$
For a solid object, the centre of mass can be expressed as a Riemann sum and thus an integral:
$$r_{cm} = \frac{1}{M}\int_0^M r\cdot dm$$
In an **isolated system**, it is guaranteed that the centre of mass of the whole system never changes so long as only rigid bodies are involved.
## Rotational motion
### Moment of inertia
The moment of inertia of an object represents its ability to resist rotation, effectively the rotational equivalent of mass. It is equal to the sum of each point and distance from the axis of rotation.
$$I=\sum(mr)^2$$
For more complex objects where the distance often changes:
$$I=\int^M_0 R^2 dm$$
#### Common moment shapes
- Solid cylinder or disc symmetrical to axis: $I = \frac{1}{2}MR^2$
- Hoop about symmetrical axis: $I=MR^2$
- Solid sphere: $\frac{2}{5}MR^2$
- Thin spherical shell: $I=\frac{2}{3}MR^2$
- Solid cylinder about the central diameter: $I=\frac{1}{4}MR^2 + \frac{1}{12}ML^2$
- Hoop about diameter: $I=\frac{1}{2}MR^2$
- Rod about center: $I=\frac{1}{12}ML^2$
- Rod about end: $I=\frac{1}{3}ML^2$
- Thin rectangular plate about perpendicular axis through center: $I=\frac{1}{3}ML^2$
### Rotational-translational equivalence
Most translational variables have a rotational equivalent.
Although the below should be represented as cross products, this course only deals with rotation perpendicular to the axis, so the following are always true.
Angular acceleration is related to acceleration:
$$\alpha = \frac{a}{r}$$
Angular velocity is related to velocity:
$$\omega = \frac{v}{r}$$
The direction of the tangential values can be determined via the right hand rule. Where $r$ is the vector from the **origin to the mass**:
$$
\vec v = r\times\omega \\
\vec a = r\times\alpha
$$
And all kinematic equations have their rotational equivalents.
- $\theta = \frac{1}{2}(\omega_f + \omega_i)t$
- $\omega_f = \omega_i + \alpha t$
- $\theta = \omega_i t + \frac{1}{2}\alpha t^2$
- $\omega_f^2 + \omega_i^2 + 2\alpha\theta$
Most translational equations also have rotational equivalents.
$$E_\text{k rot} = \frac{1}{2}I\omega^2$$
## Torque
Torque is the rotational equivalent of force.
$$\vec\tau=I\vec\alpha$$
$$\vec\tau=\vec r\times\vec F$$
$$|\vec\tau=|r||F|\sin\theta$$
In the general case, especially when the force is variable, the work done is equal to the integral of force over displacement.
$$W=\int^{x_f}_{x_i}F_xdx$$
Work is also related to torque:
$$W=\tau\Delta\theta$$
$$W=F\Delta S$$
The total net work from torque from external forces is equivalent to:
$$W=\Delta E_k = \int^{\theta_f}_{\theta_i}\tau d\theta$$
### Angular momentum
This is the same as linear momentum.
$$\vec L = \vec r\times\vec p$$
$$\vec L = I\vec\omega$$
$$\vec L =\vec\tau t$$
## Rolling motion
!!! definition
- **Slipping** is sliding faster than spinning.
- **Skidding** is spinning faster than sliding.
Pure rolling motion is **only true if** the tangential velocity of the centre of mass is equal to its rotational velocity.
$$v_{cm}=R\omega$$
In pure rolling motion, the point at the top is moving at two times the velocity while the point at the bottom has no tangential velocity.
<img src="https://upload.wikimedia.org/wikipedia/commons/8/8d/Velocitats_Roda.svg" width=500>(Source: Wikimedia Commons)</img>
For any point in the mass:
$$
v_{net} = v_{trans} + v_{rot} \\
v_{net} = v_{cm} + \vec R \times\vec\omega \\
E_{k roll} = E_{k trans} + E_{k rot}
$$
Alternatively, the rolling can be considered as a rotation about the pivot point between the disk and the ground, allowing rolling motion to be represented as rotational motion around the pivot point. The **parallel axis theorem** can be used to return it back to the original point.
$$\sum\tau_b=I_b\alpha$$
At least one external torque and one external force is required to initiate pure rolling motion because the two components are separate.
If an object is purely rolling and then it moves to:
- a flat, frictionless surface, it continues purely rolling
- an inclined, frictionless surface, external torque is needed to maintain pure rolling motion
- an inclined surface with friction, it continues purely rolling
Where $c$ is the coefficient to the moment of inertia ($I=cMR^2$), while rolling down an incline:
$$
v_{cm} = \sqrt{\frac{2}{1+c}gh} \\
a_{cm} = \frac{g\sin\theta}{1+c}
$$
## Statics
An object at **static equilibrium** has no rotational or translational velocity with zero net force and torque.
An object at **dynamic equilibrium** has a constant rotational and translational velocity with zero net force and torque.
$$
\sum\vec F = 0 \\
\sum\vec\tau = 0
$$
Whether an object *stays* at static equilibrium depends on the
- It is at **unstable equilibrium** if the object moves away and does not return to equilibrium
- It is at **stable equilibrium** if the object returns to its original position and equilibrium
- It is **neutral** if the object does not move
## Simple harmonic motion
!!! definition
- The **amplitude** $A$ of a wave is always greater than zero and is equal to the height of the wave above the axis.
- The **angular frequency** $\omega$ is the angular velocity, which is dependent only on the restorative force.
- The **phase constant** $\phi$ is the offset from equilibrium at $t=0$.
Please see [SL Physics 1#Simple harmonic motion](/g11/sph3u7/#simple-harmonic-motion) for more information.
The position of any periodic motion can be represented as a sine or cosine function (adjust phase as needed).
$$x(t)=A\cos(\omega t+\phi)$$
This means that the velocity function has a phase shift of $\frac{\pi}{2}$ and the acceleration function has a phase shift of $\pi$ along with other changes.
SHM is linked to uniform circular motion:
- $\phi$ is the angle from the standard axis
- $A$ is the radius
The restorative force can be modelled by substituting in $a(t)$ into $F=ma$
$$F=-m\omega^2x(t)$$
Because restoring force is proportional to the negative position for **smaller displacements**, $F=-Cx(t)$.
Torque is also linear: $\tau=-k\theta$
!!! warning
For small angles, $\sin\theta = \theta$.
$$\omega=\sqrt{\frac{C}{m}}$$

View File

@ -1,654 +0,0 @@
# ECE 150: C++
## Non-decimal numbers
Binary numbers are prefixed with `0b`.
!!! example
The following two snippets are equivalent:
```cpp
int a{0b110001};
```
```cpp
int a{25};
```
To convert from **binary to decimal**, each digit should be treated as a power of two much like in the base 10 system.
!!! example
$$0
\text{0b1011}=1\times2^3 + 0\times2^2+1\times2^1+1\times2^0=11
$$
Binary addition is the same as decimal addition except $1+1=10$ and $1+1+1=11$.
To convert from **decimal to binary**, the number should be repeatedly divided by 2 and the binary number taken from the remainders from bottom to top.
!!! example
$$
\begin{align*}
13 &= 2\times6 + 1 \\
6 &= 2\times3 + 0 \\
3 &= 2\times1 + 1 \\
1 &= 2\times0 + 1
\\
&\therefore 13 = \text{0b1101}
\end{align*}
$$
To convert from **binary to hexadecimal**, each group of four digits beginning from the right should be converted to their hexadecimal representation.
To convert from **hexadecimal to binary**, each hexadecimal digit should be expanded into its four-digit binary representation.
To convert from **decimal to hexadecimal**, the number should be repeatedly divided by 16 and the hex number taken from the remainders from bottom to top.
!!! example
$$
\begin{align*}
37 &= 16\times2 + 5 \\
2 &= 16\times0 + 2
\\
&\therefore 37 = \text{0x25}
\end{align*}
$$
## Numbers
### Integers
!!! definition
- A **carry** occurs if an overflow or underflow happens in an unsigned number.
The $k$th bit of a number is as known as its **coefficient** because it can be expressed in the form $n\times 2^k$ in binary or $n\times 16^k$ in hexadecimal.
| Type | Bits | Can store |
| --- | --- | --- |
| `short` | 16 | $\pm2^{15}-1$ |
| `int` | 32 | $\pm2^{31}-1$ |
| `long` | 64 | $\pm2^{63}-1$ |
| `char` | 8 | N/A |
| `unsigned short` | 16 | $2^{16}-1$ |
| `unsigned int` | 32 | $2^{32}-1$ |
| `unsigned long` | 64 | $2^{64}-1$ |
| `unsigned char` | 8 | N/A |
The `sizeof()` operator evaluates the size the type takes in memory at compile time.
Signed numbers use the first bit to represent positive or negative numbers. A negative number is equal to the **two's complement** of its positive form. This allows subtraction to be done by taking the two's complement of the subtracter.
!!! definition
The two's complement form of a number flips all bits **but the rightmost digit equal to one**.
### Floating point numbers
| Type | Bits | Digits of precision |
| --- | --- | --- |
| `float` | 32 | ~7 |
| `double` | 64 | ~16 |
Floating point numbers let a computer work with numbers of arbitrary precision. However, the limited digits of precision mean that a small number added to a large number can result in the number not changing. This results in odd scenarios such as:
$$
x+(y+z)\neq(x+y)+z
$$
## References
The ampersand (&) represents a reference variable and an argument passed into a parameter with an ampersand must be a valid lvalue.
Effectively, it is a pointer, letting you do weird shit such as:
```cpp
void inc(int &n) {
n++;
}
```
where the variable passed into `inc` will actually increase in the caller function.
This can also be used in variable declarations to not create a second local variable:
```cpp
#include <climits>
double const &pi{M_PI}; // pi links back to M_PI
```
## Arrays
```cpp
// typename identifier[n]{};
int array[5]{};
int partial[3]{2};
int filled[3]{1, 2, 3};
```
Arrays are contiguous in memory and default to 0 when initialised. If field initialised with values, the array will fill the first values as those values and set the rest to 0.
Because arrays do not check bounds, `array[n+10]` or `array[-5]` will go to the memory address directed without complaint and ruin your day.
| Pros | Cons |
| --- | --- |
| Random access is $O(1)$ | $O(n)$ push front |
| | Fixed size and unused allocated memory |
| | Concatenation is slow |
### Local arrays
Local arrays cannot be assigned to nor returned from a function. If an array is marked `const`, its entries cannot be modified.
Arrays can be passed to functions by reference (via pointer to the first entry).
## Memory
!!! definition
- **Volatile** memory is erased after the memory is powered off.
- **Byte-addressable** memory is memory that has an address for each byte, such that to change a single bit the whole byte must be rewritten.
Main memory (random access memory, RAM) is volatile and any location in the memory has the same access speed.
An **address bus** with $n$ lines allows the CPU to update $n/8$ bytes at once (one address bit per line). The number of total memory addresses is limited by the number of lanes in the address bus.
When a program is run, the operating system (OS) allocates a block of memory for it such that the largest address is at the bottom of the memory block for the program.
- Instructions (the **code segment**) are stored at the **top** of the block
- Constants (the **data segment**, including string literals) are stored **after** the instructions
- Local variables (the **call stack**) are stored beginning from the **bottom** of the block
Dynamically allocated variables and static variables are stored between the call stack and the data segment.
### Call stack
The call stack represents memory and variables are allocated space from bottom to top.
At the moment a function is run, its parameters are allocated space at the bottom, followed by all local variables that **may or may not** be defined.
The return value of the function overwrites whatever is at the bottom of the function-allocated block such that the caller can simply reach up to get return data.
!!! warning
Arrays are allocated **top-down** such that indexing is made easy.
## C-style strings
C-style strings are char arrays that end with a **null terminator** (`\0`). By default, char arrays are initialised with this character.
If there is not a null terminator, attempting to access a string continues to go down the call stack until a zero byte is found.
## Dynamic allocation
Compared to static memory allocation, which is done by the compiler, dynamic memory is managed by the developer, and is stored between the call stack and data segment in the **heap**.
The `new` operator attempts to allocate its type operand, optionally initialising the variable and returning its memory address.
```cpp
char *c{new char{'i'}};
```
If the operating system cannot allocate that much memory, `std::bad_alloc` is raised, but passing in `nothrow` can return a `nullptr` instead if allocation fails.
```cpp
char *c{new(nothrow) char{`i`}};
if (c == nullptr) {
}
```
The `delete` operator tells the OS that the memory address passed is no longer needed. Generally, it is a good idea to set the deleted pointer afterward to a null pointer.
```cpp
delete c;
c = nullptr;
```
If deleting arrays, `delete[]` should be used instead.
!!! warning
Statically allocated memory **cannot be deallocated** manually as it is done so by the compiler, so differentiating the two is generally a good idea.
### Vectors at home
Dynamic allocation can be used to mimick an `std::vector` by creating a new array whenever an element would be full and doubling its size, copying all elements over.
!!! example
Sample implementation:
```cpp
std::size_t capacity{10};
double *data{new double[capacity]};
std::size_t els{0};
while (true) {
double x{};
std::cin >> x;
++els;
if (els == capacity) {
std::size_t old_capacity{capacity};
double *old_data{data};
capacity *= 2;
data = new double[capacity];
for (int i{}; i < old_capacity; ++i) {
data[i] = old_data[i];
}
delete[] old_data;
old_data = nullptr;
}
}
```
### Wild pointers
A wild pointer is any uninitialised pointer. Its behaviour is undefined. Accessing unallocated memory results in a **segmentation fault**, causing the OS to terminate the program.
!!! warning
Occasionally, the OS does not prevent program access to deallocated memory for some time, which may allow the program to reuse garbage pointers, allowing the pointer to work. This causes inconsistent crashing.
To avoid wild pointers, pointers should always be initialised and set to `nullptr` if not needed even if they would go out of scope.
### Dangling pointers
A dangling pointer is one that has been deallocated, which has the same issues as a wild pointer, especially if two pointers have the same address.
!!! example
`p_2` is dangling.
```cpp
int* p_1{};
int* p_2{p_1};
delete p_1;
```
To avoid dangling pointers, pointers should be immediately set to `nullptr` after deleting them. Deleting a `nullptr` is **guaranteed to be safe**.
### Memory leaks
A memory leak occurs when a pointer is not freed, such as via an early return or setting a pointer to another pointer. This causes memory usage to grow until the program is terminated.
!!! example
The `new int[20]` has leaked and is no longer accessible to the program but remains allocated memory.
```cpp
int* p{new int[20]};
p = new int[10];
```
## Pointers
!!! definition
- A **pointer** is a variable that stores a memory address.
The asterisk `*` indicates that the variable is a pointer address and can be **dereferenced**. `&` can convert an identifier to a pointer.
```cpp
int array[10];
int *p_array{array};
int num{2};
int *p_num{&num};
```
!!! warning
Only **addresses** should be passed when assigning pointer variables — this means that primitive types must be converted first to a reference with `&`.
The default size of a pointer (the address size) can be found by taking the `sizeof` of any pointer.
```cpp
sizeof(int*);`
```
The memory at the location of the pointer can be accessed by setting the pointer as the lvalue:
```cpp
*var = 100;
```
The `const` modifier only makes constant the value immediately after `const`, meaning that the expression after it cannot be used as an lvalue.
!!! example
```cpp
int* const p_x{&x};
p_x = &y; // not allowed
*p_x = y; // allowed
```
```cpp
int const *p_x{&x};
p_x = &y; // allowed
*p_x = y; // not allowed
```
```cpp
int const * const p_x{&x};
p_x = &y; // not allowed
*p_x = y; // not allowed
```
Pointers to `const` values must also be `const`.
!!! example
BAD:
```cpp
const int x = 2;
int *p_x{&x};
```
GOOD:
```cpp
const int x = 2;
int const *p_x{&x};
```
## Sorting algorithms
### Selection sort
Selection sort takes the largest item in the array each time and adds it to the end.
```rust
fn selection_sort(array: &mut [i32]) {
for i in (0..array.len()).rev() {
let mut max_index = 0;
for j in 0..i + 1 {
if array[j] > array[max_index] {
max_index = j;
}
}
let _ = &array.swap(i, max_index);
}
}
```
### Insertion sort
Insertion sort assumes the first element of the array is sorted and expands that partition by moving each element afterward to the correct spot.
```rust
fn insertion_sort(array: &mut [i32]) {
for i in 1..array.len() {
let mut temp = array[0];
for j in 0..i {
if array[j] < array[i] {
temp = array[i];
for k in (j..i).rev() {
array[k + 1] = array[k]
}
array[j] = temp;
break;
}
}
}
}
```
## Recursion
### Merge sort
Merge sort is a recursive sorting algorithm with the following pseudocode:
- If the array length is one or less, do not modify the array
- Otherwise, split the array into two halves and call merge sort on both halves
- Merge the split arrays together in sorted order (adding each in sequence such that it is sorted)
```cpp
void merge_sort( double array[], std::size_t capacity ) {
if ( capacity <= 1 ) {
return;
} else {
std::size_t capacity_1{ capacity/2 };
std::size_t capacity_2{ capacity - capacity_1 };
merge_sort( array, capacity_1 );
merge_sort( array + capacity_1, capacity_2 );
merge( array, capacity_1, capacity_2 );
}
}
void merge( double array[], std::size_t cap_1,
std::size_t cap_2 ) {
double tmp_array[cap_1 + cap_2];
std::size_t k1{0};
std::size_t k2{cap_1};
std::size_t kt{0};
// As long as not everything in each half is not
// copied over, copy the next smallest entry into the
// temporary array.
while ( (k1 < cap_1) && (k2 < cap_1 + cap_2 ) ) {
if ( array[k1] <= array[k2] ) {
tmp_array[kt] = array[k1];
++k1;
} else {
tmp_array[kt] = array[k2];
++k2;
}
++kt;
}
// Copy all entries left from the left half (if any)
// to the temporary array.
while ( k1 < cap_1 ) {
tmp_array[kt] = array[k1];
++k1;
++kt;
}
// Copy all entries left from the right half (if any)
// to the temporary array.
while ( k2 < cap_1 + cap_2 ) {
tmp_array[kt] = array[k2];
++k2;
++kt;
}
// Copy all the entries back to the original array.
for ( std::size_t k{0}; k < (cap_1 + cap_2); ++k ) {
array[k] = tmp_array[k];
}
}
```
## Classes
By convention, class member variables are suffixed with an underscore.
Classes inherently have two default constructors — one if passed another version of itself and one if the user does not define one, using the list of `public` variables.
!!! example
the following initialisers both do the same thing — they both copy `earth` into a new variable (not by reference).
```cpp
Body earth{};
Body tmp{earth};
Body tmp2 = earth;
```
### Namespaces
Namespaces allow definitions to be scoped, such as `std`.
```cpp
namespace eggy {
std::string name{"eggy"};
std::string get_name() {
return eggy::name;
}
}
```
Namespaces can also be nested within namespaces.
!!! warning
`std::cout` does weird shenanigans that passes itself to every function afterward, such as `std::endl`.
This means that `std::cout << std::endl;` is equivalent to `std::endl(std::cout);`.
### Operator overloading
Operators can be overloaded for various classes.
!!! example
Overloading for displaying to `cout`:
```cpp
std::ostream operator<<(std::ostream &out, ClassName const &p) {
out << "text here";
return out;
}
### Constructors
Constructors can be defined with default values after a colon and before the function body:
```cpp
Rational::Rational():
numer_{0},
denom_{0} {
}
```
Subsequent members can even use the values of previous ones.
Constructors can also contain parameters with default values, but default values must also be present in the class declaration.
### Member functions
A `const` after a member function forbids the modification of any member variables within that function.
```cpp
int get_val() const {
}
```
## Exceptions
`#define NDEBUG` turns off assertions.
`static_cast<double>(var)` performs the typical implicit conversion explicitly during compile time.
Exceptions are expensive error handlers that **do not protect** from program termination (e.g., attempt to access invalid memory).
The following are all exception classes in `std`:
- `domain_error`
- `runtime_error`
- `range_error`
- `overflow_error`
- `underflow_error`
- `logic_error`
- `length_error`
- `out_of_range`
`...` is a catch-all exception.
!!! example
```cpp
try {
throw std::domain_error{"cannot compute stupidity"};
} catch (std::domain_error &e) {
std::cerr << e->what();
} catch (...) {
}
```
## Copies and moves
The copy constructor by default copies **the value** of every public and private field, including pointers, both from field initialisation or assignment.
```cpp
MyClass n{};
MyClass m{n}; // copy
MyClass p = n; // copy
```
The move constructor copies every field from the other object and resets the original object to no longer point to that data, typically called only via `std::move`.
```cpp
MyClass a{};
MyClass b{std::move(a)};
```
It is an excellent idea to blank out the two constructors to do nothing so that unexpected behaviour does not occur.
```cpp
class MyClass {
public:
MyClass(MyClass const &rhs) = delete;
MyClass(MyClass &&rhs) = delete;
MyClass &operator=(MyClass const &rhs) = delete;
MyClass &operator=(MyClass &&rhs) = delete;
}
```
If a move occurs and the compiler determines that the original object is no longer needed, its destructor is automatically called immediately after the constructor / assignment finishes.
During construction, default initialisation picks the one with the fewest parameters if ambiguous. Parameters passed by value are **copied** by reference via the copy constructor.
Much like statically allocated arrays, dynamically allocated arrays also automatically dereference when accessed by index.
## Linked lists
Dynamic memory allocation for many objects instead of one like arrays is slow.
## Inheritance
All member functions and the destructor must be `virtual` functions if they can be inherited.
```cpp
class Base {
public:
Base();
virtual ~Base();
virtual Base get_base() const;
virtual void set_base();
virtual void do_base() const;
```
A class that inherits another should contain `public <Base>` after the name of the class. Overriden functions must have `override` if they should have the same type signature. Otherwise, they reference the base function.
```cpp
class ExtendedBase: public Base {
public:
ExtendedBase();
Base get_base() const override;
void set_base() override;
virtual void do_base() override;
}
```
Functions can be overriden completely ignoring the function signature by excluding the `override` keyword.
The base class's functions implicitly refer to the current class, so they can be directly called:
```cpp
void set_base() override {
Base::set_base();
}
```
### protected
The `protected` access keyword only allows the original class as well as classes that extend the original one to access it.
### Extending exceptions
Exceptions should have two constructors: one for a char array pointer and another a string for the exception message, as well as any additional parameters as desired. The base exception constructor (not `std::exception` because that can't be instantiated`) should be called to do all of the base constructor things.
In addition, a `what()` function with the following signature should always be defined that cannot throw an exception, returning a C-style array.
```cpp
char const *error::what() const noexcept;
```

File diff suppressed because it is too large Load Diff

View File

@ -1,754 +0,0 @@
# MATH 117: Calculus 1
## Functions
A **function** is a rule where each input has exactly one output, which can be determined by the **vertical line test**.
!!! definition
- The **domain** is the set of allowable independent values.
- The **range** is the set of allowable dependent values.
Functions can be **composed** to apply the result of one function to another.
$$
(f\circ g)(x) = f(g(x))
$$
!!! warning
Composition is not commutative: $f\circ g \neq g\circ f$.
## Inverse functions
The inverse of a function swaps the domain and range of the original function: $f^{-1}(x)$ is the inverse of $f(x)$.. It can be determined by solving for the other variable:
$$
\begin{align*}
y&=mx+b \\
y-b&=mx \\
x&=\frac{y-b}{m}
\end{align*}
$$
Because the domain and range are simply swapped, the inverse function is just the original function reflected across the line $y=x$.
<img src="https://upload.wikimedia.org/wikipedia/commons/1/11/Inverse_Function_Graph.png" width=300>(Source: Wikimedia Commons, public domain)</img>
If the inverse of a function is applied to the original function, the original value is returned.
$$f^{-1}(f(x)) = x$$
A function is **invertible** only if it is "**one-to-one**": each output must have exactly one input. This can be tested via a horizontal line test of the original function.
If a function is not invertible, restricting the domain may allow a **partial inverse** to be defined.
!!! example
<img src="https://upload.wikimedia.org/wikipedia/commons/7/70/Inverse_square_graph.svg">(Source: Wikimedia Commons, public domain)</img>
By restricting the domain to $[0,\inf]$, the **multivalued inverse function** $y=\pm\sqrt{x}$ is reduced to just the partial inverse $y=\sqrt{x}$.
## Symmetry
An **even function** satisfies the property that $f(x)=f(-x)$, indicating that it is unchanged by a reflection across the y-axis.
An **odd function** satisfies the property that $-f(x)=f(-x)$, indicating that it is unchanged by a 180° rotation about the origin.
The following properties are always true for even and odd functions:
- even × even = even
- odd × odd = even
- even × odd = odd
Functions that are symmetric (that is, both $f(x)$ and $f(-x)$ exist) can be split into an even and odd component. Where $g(x)$ is the even component and $h(x)$ is the odd component:
$$
\begin{align*}
f(x) &= g(x) + h(x) \\
g(x) &= \frac{1}{2}(f(x) + f(-x)) \\
h(x) &= \frac{1}{2}(f(x) - f(-x))
\end{align*}
$$
!!! note
The hyperbolic sine and cosine are the even and odd components of $f(x)=e^x$.
$$
\cosh x = \frac{1}{2}(e^x + e^{-x}) \\
\sinh x = \frac{1}{2}(e^x - e^{-x})
$$
## Piecewise functions
A piecewise function is one that changes formulae at certain intervals. To solve piecewise functions, each of one's intervals should be considered.
### Absolute value function
$$
\begin{align*}
|x| = \begin{cases}
x &\text{ if } x\geq 0 \\
-x &\text{ if } x < 0
\end{cases}
\end{align*}
$$
### Signum function
The signum function returns the sign of its argument.
$$
\begin{align*}
\text{sgn}(x)=\begin{cases}
-1 &\text{ if } x < 0 \\
0 &\text{ if } x = 0 \\
1 &\text{ if } x > 0
\end{cases}
\end{align*}
$$
### Ramp function
The ramp function makes a ramp through the origin that suddenly flatlines at 0. Where $c$ is a constant:
$$
\begin{align*}
r(t)=\begin{cases}
0 &\text{ if } x \leq 0 \\
ct &\text{ if } x > 0
\end{cases}
\end{align*}
$$
<img src="https://upload.wikimedia.org/wikipedia/commons/c/c9/Ramp_function.svg" width=700>(Source: Wikimedia Commons, public domain)</img>
### Floor and ceiling functions
The floor function rounds down.
$$\lfloor x\rfloor$$
The ceiling function rounds up.
$$\lceil x \rceil$$
### Fractional part function
In a nutshell, the fractional part function:
- returns the part **after the decimal point** if the number is positive
- returns 1 - **the part after the decimal point** if the number is negative
$$\text{FRACPT}(x) = x-\lfloor x\rfloor$$
Because this function is periodic, it can be used to limit angles to the $[0, 2\pi)$ range with:
$$f(\theta) = 2\pi\cdot\text{FRACPT}\biggr(\frac{\theta}{2\pi}\biggr)$$
### Heaviside function
The Heaviside function effectively returns a boolean whether the number is greater than 0.
$$
\begin{align*}
H(x) = \begin{cases}
0 &\text{ if } t < 0 \\
1 &\text{ if } t \geq 0
\end{cases}
\end{align*}
$$
This can be used to construct other piecewise functions by enabling them with $H(x-a)$ as a factor, where $a$ is the interval.
In a nutshell:
- $1-H(t-a)$ lets you "turn a function off" at at $t=a$
- $H(t-a)$ lets you "turn a function on at $t=a$
- $H(t-a) - H(t-b)$ leaves a function on in the interval $(a, b)$
!!! example
TODO: example for converting piecewise to heaviside via collecting heavisides
and vice versa
## Periodicity
The function $f(t)$ is periodic only if there is a repeating pattern, i.e. such that for every $x$, there is an $f(x) = f(x + nT)$, where $T$ is the period and $n$ is any integer.
### Circular motion
Please see [SL Physics 1#6.1 - Circular motion](/g11/sph3u7/#61-circular-motion) and its subcategory "Angular thingies" for more information.
## Partial function decomposition (PFD)
In order to PFD:
1. Factor the denominator into *irreducibly* quadratic or linear terms.
2. For each factor, create a term. Where capital letters below are constants:
- A linear factor $Bx+C$ has a term $\frac{A}{Bx+C}$.
- An *irreducibly* quadratic factor $Dx^2+Ex+G$ has a term $\frac{Hx+J}{Dx^2+Ex+G}$.
- Duplicate factors have terms with denominators with that factor to the power of 1 up to the number of times the factor is present in the original.
4. Set the two equal to each other such that the denominators can be factored out.
5. Create systems of equations to solve for each constant.
!!! example
To decompose $\frac{x}{(x+1)(x^2+x+1)}$:
$$
\begin{align*}
\frac{x}{(x+1)(x^2+x+1)} &= \frac{A}{x+1} + \frac{Bx+C}{x^2+x+1} \\
&= \frac{A(x^2+x+1) + (Bx+C)(x+1)}{(x+1)(x^2+x+1)} \\
x &= A(x^2+x+1) + (Bx+C)(x+1) \\
0x^2 + x + 0 &= (Ax^2 + Bx^2) + (Ax + Bx + Cx) + (A + C) \\
\\
&\begin{cases}
0 = A + B \\
1 = A + B + C \\
0 = A + C
\end{cases}
\\
A &= -1 \\
B &= 1 \\
C &= 1 \\
\\
∴ \frac{x}{(x+1)(x^2+x+1)} &= -\frac{1}{x+1} + \frac{x + 1}{x^2 + x + 1}
\end{align*}
$$
## Trigonometry
1 radian represents the angle when the length of the arc of a circle is equal to the radius. Where $s$ is the arc length:
$$\theta=\frac{s}{r}$$
The following table indicates the special angles that should be memorised:
| Angle (rad) | 0 | $\frac{\pi}{6}$ | $\frac{\pi}{4}$ | $\frac{\pi}{3}$ | $\frac{\pi}{2}$ | $\pi$ |
| --- | --- | --- | --- | --- | --- | --- |
| cos | 1 | $\frac{\sqrt{3}}{2}$ | $\frac{\sqrt{2}}{2}$ | $\frac{1}{2}$ | 0 | -1 |
| sin | 0 | $\frac{1}{2}$ | $\frac{\sqrt{2}}{2}$ | $\frac{\sqrt{3}}{2}$ | 1 | 0 |
| tan | 0 | $\frac{\sqrt{3}}{3}$ | 1 | $\sqrt{3}$ | not allowed | 0 |
### Identities
The Pythagorean identity is the one behind right angle triangles:
$$\cos^2\theta+\sin^2\theta = 1$$
Cosine and sine can be converted between by an angle shift:
$$
\cos\biggr(\theta-\frac{\pi}{2}\biggr) = \sin\theta \\
\sin\biggr(\theta-\frac{\pi}{2}\biggr) = \cos\theta
$$
The **angle sum identities** allow expanding out angles:
$$
\cos(a+b)=\cos a\cos b - \sin a\sin b \\
\sin(a+b)=\sin a\cos b + \cos a\sin b
$$
Subtracting angles is equal to the conjugates of the angle sum identities.
The **double angle identities** simplify the angle sum identity for a specific case.
$$
\sin2\theta = 2\sin\theta\cos\theta \\
$$
The **half angle formulas** are just random shit.
$$
1+\tan^2\theta = \sec^2\theta \\
\cos^2\theta = \frac{1}{2}(1+\cos2\theta) \\
\sin^2\theta = \frac{1}{2}(1-\cos2\theta)
$$
### Inverse trig functions
Because extending the domain does not pass the horizontal line test, for engineering purposes, inverse sine is only the inverse of sine so long as the angle is within $[-\frac{\pi}{2}, \frac{\pi}{2}]$. Otherwise, it is equal to that version mod 2 pi.
$$y=\sin^{-1}x \iff x=\sin y, y\in [-\frac{\pi}{2}, \frac{\pi}{2}]$$
This means that $x\in[-1, 1]$.
$$
\sin(\sin^{-1}x) = x \\
\sin^{-1}(\sin x) = x \text{ only if } x\in[-\frac{\pi}{2}, \frac{\pi}{2}]
$$
Similarly, inverse **cosine** only returns values within $[0,\pi]$.
Similarly, inverse **tangent** only returns values within $(-\frac{\pi}{2}, \frac{\pi}{2})$. However, $\tan^{-1}$ is defined for all $x\in\mathbb R$.
Although most of the reciprocal function rules can be derived, secant is only valid in the odd range $[-\pi, -\frac{\pi}{2})\cup [0, \frac{\pi}{2})$, and returns values $(-\infty, -1]\cup [1, \infty)$.
### Electrical signals
Waves are commonly presented in the following format, where $A$ is a **positive** amplitude:
$$g(t)=A\sin(\omega t + \alpha)$$
In general, if given a sum of a sine and cosine:
$$a\sin\omega t + b\cos\omega t = \sqrt{a^2 + b^2}\sin(\omega t + \alpha)$$
The sign of $\alpha$ should be determined via its quadrant via the signs of $a$ (sine) and $b$ (cosine) via the CAST rule.
!!! example
Given $y=5\cos 2t - 3\sin 2t$:
$$
\begin{align*}
A\sin (2t+\alpha) &= A\sin 2t\cos\alpha + A\cos 2t\sin\alpha \\
&= (A\cos\alpha)\sin 2t + (A\sin\alpha)\cos 2t \\
\\
\begin{cases}
A\sin\alpha = 5 \\
A\cos\alpha = -3
\end{cases}
\\
\\
A^2\sin^2\alpha + A^2\cos^2\alpha &= 5^2 + (-3)^2 \\
A^2 &= 34 \\
A &= \sqrt{34} \\
\\
\alpha &= \tan^{-1}\frac{5}{3} \\
&\text{since sine is positive and cosine is negative, the angle is in Q3} \\
∴ \alpha &= \tan^{-1}\frac{5}{3} + \pi
\end{align*}
$$
## Limits
### Limits of sequences
!!! definition
- A **sequence** is an infinitely long list of numbers with the **domain** of all natural numbers (may also include 0).
- A sequence that does not converge is a **diverging** sequence.
A sequence is typically denoted via braces.
$$\{a_n\}\text{ or } \{a_n\}^\infty_{n=0}$$
Sometimes sequences have formulae.
$$\left\{\frac{5^n}{3^n}\right\}^\infty_{n=0}$$
The **limit** of a sequence is the number $L$ that the sequence **converges** to as $n$ increases, which can be expressed in either of the two ways below:
$$
a_n \to L \text{ as } n\to\infty \\
\lim_{n\to\infty}a_n=L
$$
: > Specifically, a sequence $\{a_n\}$ converges to limit $L$ if, for any positive number $\epsilon$, there exists an integer $N$ such that $n>N \Rightarrow |a_n - L | < \epsilon$.
Effectively, if there is always a term number that would lead to the distance between the sequence at that term and the limit to be less than any arbitrarily small $\epsilon$, the sequence has the claimed limit.
!!! example
A limit can be proved to exist with the above definition. To prove $\left\{\frac{1}{\sqrt{n}}\right\}\to0$ as $n\to\infty$:
$$
\begin{align*}
\text{Proof:} \\
n > N &\Rightarrow \left|\frac{1}{\sqrt{n}} - 0\right| < \epsilon \\
&\Rightarrow \frac{1}{\epsilon^2} < n
\end{align*} \\
\ce{Let \epsilon\ be any positive number{.} If n > \frac{1}{\epsilon^2}, then \frac{1}{\sqrt{n}}-> 0 as n -> \infty{.}}
$$
Please see [SL Math - Analysis and Approaches 1#Limits](/g11/mhf4u7/#limits) for more information.
The **squeeze theorem** states that if a sequence lies between two other converging sequences with the same limit, it also converges to this limit. That is, if $a_n\to L$ and $c_n\to L$ as $n\to\infty$, and $a_n\leq b_n\leq c_n$ is **always true**, $b_n\to L$.
!!! example
$\left\{\frac{\sin n}{n}\right\}$: since $-1\leq\sin n\leq 1$, $\frac{-1}{n}\leq\frac{\sin n}{n}\leq \frac{1}{n}$. Since both other functions converge at 0, and sin(n) is always between the two, sin(n) thus also converges at 0 as n approaches infinity.
If function $f$ is continuous and $\lim_{n\to\infty}a_n$ exists:
$$\lim_{n\to\infty}f(a_n)=f\left(\lim_{n\to\infty}a_n\right)$$
On a side note:
$$\lim_{n\to\infty}\tan^{-1} n = \frac{\pi}{2}$$
### Limits of functions
The definition is largely the same as for the limit of a sequence:
: > A function $f(x)\to L$ as $x\to a$ if, for any positive $\epsilon$, there exists a number $\delta$ such that $0<|x-a|<\delta\Rightarrow|f(x)-L|<\epsilon$.
Again, for the limit to be true, there must be a value $x$ that makes the distance between the function and the limit less than any arbitrarily small $\epsilon$.
The extra $0 <$ is because the behaviour for when $x=a$, which may or may not be defined, is irrelevant.
!!! example
To prove $3x-2\to 4$ as $x\to 2$:
$$
\ce{for any \epsilon\ > 0, there is a \delta\ > 0\ such that:}
$$
$$
\begin{align*}
|x-2| < \delta &\Rightarrow|(3x-2) - 4| &< \epsilon \\
&\Leftarrow |(3x-2) -4| &< \epsilon \\
&\Leftarrow |3x-6| &< \epsilon \\
&\Leftarrow |x-2| &< \frac{\epsilon}{3} \\
\delta &= \frac{\epsilon}{3}
\end{align*}
$$
$$
\ce{Let \epsilon\ be any positive number{.} If }|x-2|<\frac{\epsilon}{3}, \\
\text{then }|(3x-2)-4|<\epsilon\text{. Therefore }3x-2\to 4\text{ as }x\to 2.
$$
!!! warning
When solving for limits, negatives have to be considered if the limit approaches a negative number:
$$\lim_{x\to -\infty}\frac{x}{\sqrt{4x^2-3}} = \frac{1}{-\frac{1}{\sqrt{x}^2}\sqrt{4x^2-3}}$$
As the angle in **radians** of an arc approaches 0, it is nearly equal to the sine (vertical component).
$$
\lim_{\theta\to 0}\frac{\sin\theta}{\theta} = 1
$$
This function is commonly used in engineering and is known as the sinc function.
$$
\text{sinc}(x) = \begin{cases}
\frac{\sin x}{x}&\text{ if }x\neq 0 \\
0&\text{ if }x=0
\end{cases}
$$
## Continuity
Please see [SL Math - Analysis and Approaches 1#Limits and continuity](/g11/mhf4u7/#limits-and-continuity) for more information.
Most common functions can be assumed to be continuous (e.g., $\sin x,\cos x, x, \sqrt{x}, \frac{1}{x}, e^x, \ln x$, etc.).
: > $f(x)$ is continuous in an interval if for any $x$ and $y$ in the interval and any positive number $\epsilon$, there exists a number $\delta$ such that $|x-y|<\delta\Rightarrow |f(x)-f(y)| < \epsilon$.
Effectively, if $f(x)$ can be made infinitely close to $f(y)$ by making $x$ closer to $y$, the function is continuous.
If two functions are continuous:
- $(f\circ g)(x)$ is continuous
- $(f\pm g)(x)$ is continuous
- $(fg)(x)$ is continuous
- $\frac{1}{f(x)}$ is continuous anywhere $f(x)\neq 0$
### Intermediate value theorem
The IVT states that if a function is continuous and there is a point between two other points, its term must also be between those two other points.
: > If $f(x)$ is continuous, if $f(a)\leq C\leq f(b)$, there must be a number $c\in[a,b]$ where $f(c)=C$.
The theorem is used to validate using binary search to find roots (guess and check).
### Extreme value theorem
The EVT states that any function continuous within a **closed** interval has at least one maximum and minimum.
: > If $f(x)$ is continuous in the **closed interval** $[a, b]$, there exist numbers $c$ and $d$ in $[a,b]$ such that $f(c)\leq f(x)\leq f(d)$.
## Derivatives
Please see [SL Math - Analysis and Approaches 1#Rate of change](/g11/mhf4u7/#rate-of-change) and [SL Math - Analysis and Approaches#Derivatives](/g11/mhf4u7/#derivatives) for more information.
The derivative of a function $f(x)$ at $a$ is determined by the following limit:
$$\lim_{x\to a}\frac{f(x)-f(a)}{x-a}$$
If the limit does not exist, the function is **not differentiable at $a$**.
Alternative notations for $f'(x)$ include $\dot f(x)$ and $Df$ (which is equal to $\frac{d}{dx}f(x)$).
Please see [SL Math - Analysis and Approaches 1#Finding derivatives using first principles](/g11/mhf4u7/#finding-derivatives-using-first-principles) and [SL Math - Analysis and Approaches 1#Derivative rules](/g11/mhf4u7/#derivative-rules) for more information.
Some examples of derivatives of inverse functions:
- $\frac{d}{dx}f^{-1}(x) = \frac{1}{\frac{dx}{dy}}$
- $\frac{d}{dx}\sin^{-1} x = \frac{1}{\sqrt{1-x^2}}$
- $\frac{d}{dx}\cos^{-1} x = -\frac{1}{\sqrt{1-x^2}}$
- $\frac{d}{dx}\tan^{-1} x = \frac{1}{1+x^2}$
- $\frac{d}{dx}\log_a x = \frac{1}{(\ln a) x}$
- $\frac{d}{dx}a^x = (\ln a)a^x$
### Implicit differentiation
Please see [SL Math - Analysis and Approaches 1#Implicit differentiation](/g11/mhf4u7/#implicit-differentiation) for more information.
### Mean value theorem
The MVT states that the average slope between two points will be reached at least once between them if the function is differentiable.
: > If $f(x)$ is continuous in $[a, b]$ and differentiable in $(a, b)$, respectively, there must be a $c\in(a,b)$ such that $f'(c)=\frac{f(b)-f(a)}{b-a}$.
### L'Hôpital's rule
As long as $\frac{f(x)}{g(x)} = \frac{0}{0}\text{ or } \frac{\infty}{\infty}$:
$$\lim_{x\to a}\frac{f(x)}{g(x)} = \lim_{x\to a}\frac{f'(x)}{g'(x)}$$
: > If $f(x)$ and $g(x)$ are differentiable (except maybe at $a$), and $\lim_{x\to a}f(x) = 0$ and $\lim_{x\to a}g(x) = 0$, the relation is true.
### Related rates
Please see [SL Math - Analysis and Approaches 1#Related rates](/g11/mhf4u7/#related-rates) for more information.
## Differentials
$\Delta x$ and $\Delta y$ represent tiny increments of $x$ and $y$. $dx$ and $dy$ are used when those tiny ammounts approach 0.
Specifically, by rearranging the definition of the deriative, $df$ is a short form for the **differential** of $f$:
$$f'(x)dx=dy=df$$
By abusing differentials, the tangent line of a point in a function can be approximated.
$$\Delta f\approx f'(x)\Delta x$$
!!! example
If $f(x) = \sqrt{x},x_0=81$, $\sqrt{78}$ can be estimated by:
$$
\begin{align*}
\Delta x&=dx=78-81=-3 \\
\frac{df}{dx} &= f'(x) \\
df &= f'(x)dx \\
&= \frac{1}{2\sqrt{81}}(-3) = -\frac{1}{6} \\
f(78) &= \sqrt{81}-\frac{1}{6} \\
&= \frac{53}{54}
\end{align*}
$$
### Curve sketching
Please see [SL Math - Analysis and Approaches 1#5.2 - Increasing and decreasing functions](/g11/mhf4u7/#52-increasing-and-decreasing-functions) for more information.
## Integrals
Please see [SL Math - Analysis and Approaches 2#Integration](/g11/mhf4u7/#52-increasing-and-decreasing-functions) for more information.
### More integration rules
- $\int a^xdx = \frac{a^x}{\ln a} + C$
- $\int\sec^2xdx=\tan x+C$
- $\int\text{cosh } xdx = \text{sinh } x + C$
- $\int\text{sinh } xdx = \text{cosh } x + C$
- $\int\frac{1}{\sqrt{1-x^2}}dx = \sin^{-1}x+C$
- $\int\csc^2xdx = -\cot x+C$
- $\int\sec x\tan x dx = \sec x + C$
- $\int\csc x\cot xdx = -\csc x + C$
- $\int\frac{1}{1+x^2}dx=\tan^{-1}x+C$
- $\int\sec xdx = \ln|\sec x + \tan x| + C$
- $\int\csc x dx = -\ln|\csc x + \cot x| + C$
### Integration by parts
IBP lets you replace an integration problem with a different, potentially easier one.
$$
\int u\ dv = uv-\int v\ du
$$
or, in function notation:
$$
\int u(x)v'(x)dx = u(x)v(x)-\int v(x)u'(x)dx
$$
Effectively, a product of two factors should be made simpler such that one is differentiable and the other is integratable. While there are integrals on both sides, the constant $C$ can be cancelled out for simplicity.
Heuristics to be used:
- $dv$ must be differentiable
- $u$ should be simpler when differentiated
- IBP might need to be used repeatedly
- IBP and u-substitution might be needed together
!!! example
To solve $\int xe^xdx$:
Let $u=x$, $dv=e^xdx$:
$\therefore du=dx, v=e^x + C$
via IBP:
$$
\begin{align*}
\int udv &= xe^x - \int e^xdx \\
&= xe^x-e^x + K
\end{align*}
$$
Please see [SL Math - Analysis and Approaches 2#Area between two curves](/g11/mcv4u7/#area-between-two-curves) for more information.
- A **Type 1** region is bounded by functions of $x$ — it's open-ended in the x-axis.
- A **Type 2** region is bounded by functions of $y$, which can be solved by integrating $y$.
- A **Type 3** region can be viewed as either Type 1 or 2.
Substituting $u=\cos\theta$, $du=-\sin\theta d\theta$ is common.
### Mean values
The **mean value** of a continuous function $f(x)$ in $[a, b]$ is equal to:
$$\text{m.v.} (f) = \frac{1}{b-a}\int_a^b f(x)dx$$
The **root mean square** is equal to the square root of the mean value for each point:
$$\text{r.m.s.} (f) = \sqrt{\frac{1}{b-a}\int_a^b f(x)^2dx}$$
### Trigonometric substitution
If $a\in\mathbb R$, functions of the form $\sqrt{x^2\pm a^2}$ or $\sqrt{a^2-x^2}$ can be rearranged in the form of a trig function.
- In $\sqrt{x^2 + a^2} \rightarrow x=a\tan\theta$
- In $\sqrt{x^2-a^2} \rightarrow x=a\sec\theta$
- In $\sqrt{a^2-x^2} \rightarrow x=a\sin\theta$
…which can be used to derive other trig identities to be integrated.
### Rational integrals
All integrals of rational functions are expressible as more rational functions, ln, and arctan.
Partial fraction decomposition is useful here.
$$\int \frac{1}{x^2+a^2}dx=\frac{1}{a}tan^{-1}\left(\frac{x}{a}\right)+C$$
## Summary of all integration rules
- $\int x^n\ dx = \frac{1}{n+1}x^{n+1} + C,n\neq -1$
- $\int \frac{1}{x}dx = \ln|x| + C$
- $\int e^x\ dx = e^x + C$
- $\int a^x\ dx = \frac{1}{\ln a} a^x + C$
- $\int\cos x\ dx = \sin x + C$
- $\int\sin x\ dx = -\cos x + C$
- $\int\sec^2 x\ dx = \tan x + C$
- $\int\csc^2 x\ dx = -\cot x + C$
- $\int\sec x\tan x\ dx = \sec x + C$
- $\int\csc x\cot x\ dx = -\csc x + C$
- $\int\text{cosh}\ x\ dx = \text{sinh}\ x + C$
- $\int\text{sinh}\ x\ dx = \text{cosh}\ x + C$
- $\int\text{sech}^2\ x\ dx = \text{tanh}\ x + C$
- $\int\text{sech}\ x\text{tanh}\ x\ dx = \text{sech}\ x + C$
- $\int\frac{1}{1+x^2}dx=\tan^{-1}x+C$
- $\int\frac{1}{a^2+x^2}dx=\frac{1}{a}\tan^{-1}\left(\frac{x}{a}\right)+C$
- $\int\frac{1}{\sqrt{1-x^2}}dx=\sin^{-1}x+C$
- $\int\frac{1}{x\sqrt{x^2-1}}dx=\sec^{-1}x+C$
- $\int\sec x\ dx = \ln|\sec x+\tan x|+C$
- $\int\csc x\ dx = -\ln|\csc x + \cot x|+C$
## Applications of integration
The length of a curve over a given interval is equal to:
$$L=\int^b_a\sqrt{1+\left(\frac{dy}{dx}\right)^2\ dx}$$
For curves bounded by functions of $y$:
$$L(y)=\int^b_a\sqrt{1+\left(\frac{dx}{dy}\right)^2\ dy}$$
### Solids of revolution
Please see [SL Math - Analysis and Approaches 2#Volumes of solids of revolution](/g11/mcv4u7/#volumes-of-solids-of-revolution) for more information.
The **parallel axis theorem can be used** to shift the axis of the solid to $y=k$:
$$V=\pi\int^b_a [f(x)^2 + 2kf(x)]\ dx$$
Around the vertical axis about the origin with a function that is bounded by $y$:
$$V=\int^b_a2\pixf(x)\ dx$$
Around the vertical axis about the origin with functions bounded by $x$:
$$V=\int^b_a2\pi(x-k)[f(x)-g(x)]\ dx$$
The **frustrum** is the sesction bounded by two parallel plates.
The surface area of the solids are as follows:
$$SA=\int^b_a2\pi f(x)\sqrt{1+f'(x)^2}\ dx$$
Around the vertical axis about the origin:
$$SA=\int^b_a2\pi x\sqrt{1+f'(x)^2}\ dx$$
### Improper integrals
An improper integral is a definite integral where only one bound is defined:
!!! example
$\int_2^\infty$ or $\int_a^b$, where only $a$ is defined.
These can be expanded into limits:
$$\int_a^\infty f(x)\ dx = \lim_{t\to\infty}\int_a^t f(x)\ dx$$
The integral converges to a value if the limit exists.
$$\int_{-\infty}^a f(x)\ dx = \lim_{t\to-\infty}\int^a_tf(x)\ dx$$
Discontinuities can be simply dodged. If there is a discontinuity:
- at $b$: $\int_a^{b^-}f(x)\ dx$
- at $a$: $\int_{a^+}^b f(x)\ dx$
- at $a<c<b$: $\int_a^cf(x)\ dx + \int_c^bf(x)\ dx$
Limits to both infinities must be broken up because they may not approach them at the same rate.
$$\int^\infty_{-\infty}x\ dx = \int^0_{-\infty} x\ dx + \int^\infty_0 x\ dx$$
## Polar form
Please see [MATH 115: Linear Algebra#Polar form](/ce1/math115/#polar-form) for more information.
Instead of $r$ and $\theta$, engineers use $\rho$ and $\phi$.
For $\rho \geq 0$, these basic conversions go between the two forms:
- $x=\rho\cos\phi$
- $y=\rho\sin\phi$
- $\phi=\sqrt{x^2+y^2}$
- $\phi=\tan^{-1}\left(\frac{y}{x}\right) + 2k\pi,k\in\mathbb Z$
Polar form allows for simpler representations such as $x^2+y^2=4 \iff \rho=2$
Functions are described in the form $\rho=f(\phi)$, such as $\rho=\sin\phi+2$.
### Area under curves
From the axis to the curve:
$$A=\int^\beta_\alpha\frac{1}{2}[f(\phi)]^2\ d\phi$$
Between two curves:
$$A=\int^\beta_\alpha\frac{1}{2}[f(\phi)^2-g(\phi)^2]\ d\phi$$
Arc length:
$$L=\int^\beta_\alpha\sqrt{f'(\phi)^2 + f(\phi)^2}\ d\phi = \int^\beta_\alpha\sqrt{\left(\frac{d\rho}{d\phi}\right)^2+\rho^2}\ d\phi$$
## Complex numbers
Please see [MATH 115: Linear Algebra#Complex Numbers](/ce1/math115/#complex-numbers) for more information.
### Impedance
Where $\~i$ is a complex number representing the current of a circuit:
$$\~i(t)=I\cdot Im(e^{j\omega t})$$
This can be related to Ohm's law, because $v(t)=IR\sin(\omega t)$ such that $\~v=IRe^{j\omega t}$:
$$\~v=R\~i$$
In fact, t
$$
\~v=Z\~i,\text{ where } Z=\begin{cases}
\begin{align*}
&R &\text{ for resistors} \\
&\frac{1}{j\omega C} &\text{ for capacitors} \\
&j\omega L &\text{ for inductors}
\end{align*}
\end{cases}
$$
Impedance has similar properties to resistance.
- In series: $Z = Z_1 + Z_2 + Z_3 ...$
- In parallel: $\frac{1}{Z} = \frac{1}{Z_1} + \frac{1}{Z_2} + \frac{1}{Z_3} ...$

View File

@ -1,701 +0,0 @@
# ECE 106: Electricity and Magnetism
## MATH 117 review
!!! definition
A definite integral is composed of:
- the **upper limit**, $b$,
- the **lower limit**, $a$,
- the **integrand**, $f(x)$, and
- the **differential element**, $dx$.
$$\int^b_a f(x)\ dx$$
The original function **cannot be recovered** from the result of a definite integral unless it is known that $f(x)$ is a constant.
## N-dimensional integrals
Much like how $dx$ represents an infinitely small line, $dx\cdot dy$ represents an infinitely small rectangle. This means that the surface area of an object can be expressed as:
$$dS=dx\cdot dy$$
Therefore, the area of a function can be expressed as:
$$S=\int^x_0\int^y_0 dy\ dx$$
where $y$ is usually equal to $f(x)$, changing on each iteration.
!!! example
The area of a circle can be expressed as $y=\pm\sqrt{r^2-x^2}$. This can be reduced to $y=2\sqrt{r^2-x^2}$ because of the symmetry of the equation.
$$
\begin{align*}
A&=\int^r_0\int^{\sqrt{r^2-x^2}}_0 dy\ dx \\
&=\int^r_0\sqrt{r^2-x^2}\ dx
\end{align*}
$$
!!! warning
Similar to parentheses, the correct integral squiggly must be paired with the correct differential element.
These rules also apply for a system in three dimensions:
| Vector | Length | Area | Volume |
| --- | --- | --- | --- |
| $x$ | $dx$ | $dx\cdot dy$ | $dx\cdot dy\cdot dz$ |
| $y$ | $dy$ | $dy\cdot dz$ | |
| $z$ | $dz$ | $dx\cdot dz$ | |
Although differential elements can be blindly used inside and outside an object (e.g., area), the rules break down as the **boundary** of an object is approached (e.g., perimeter). Applying these rules to determine an object's perimeter will result in the incorrect deduction that $\pi=4$.
Therefore, further approximations can be made using the Pythagorean theorem to represent the perimeter.
$$dl=\sqrt{(dx^2) + (dy)^2}$$
### Polar coordinates
Please see [MATH 115: Linear Algebra#Polar form](/1a/math115/#polar-form) for more information.
In polar form, the difference in each "rectangle" side length is slightly different.
| Vector | Length difference |
| --- | --- |
| $\hat r$ | $dr$ |
| $\hat\phi$ | $rd\phi$ |
Therefore, the change in surface area can be approximated to be a rectangle and is equal to:
$$dS=(dr)(rd\phi)$$
!!! example
The area of a circle can be expressed as $A=\int^{2\pi}_0\int^R_0 r\ dr\ d\phi$.
$$
\begin{align*}
A&=\int^{2\pi}_0\frac{1}{2}R^2\ d\phi \\
&=\pi R^2
\end{align*}
$$
If $r$ does not depend on $d\phi$, part of the integral can be pre-evaluated:
$$
\begin{align*}
dS&=\int^{2\pi}_{\phi=0} r\ dr\ d\phi \\
dS^\text{ring}&=2\pi r\ dr
\end{align*}
$$
So long as the variables are independent of each other, their order does not matter. Otherwise, the dependent variable must be calculated first.
!!! tip
There is a shortcut for integrals of cosine and sine squared, **so long as $a=0$ and $b$ is a multiple of $\frac\pi 2$**:
$$
\int^b_a\cos^2\phi=\frac{b-a}{2} \\
\int^b_a\sin^2\phi=\frac{b-a}{2}
$$
The side length of a curve is as follows:
$$dl=\sqrt{(dr^2+(rd\phi)^2}$$
!!! example
The side length of the curve $r=e^\phi$ (Archimedes' spiral) from $0$ to $2\pi$:
\begin{align*}
dl &=d\phi\sqrt{\left(\frac{dr}{d\phi}\right)^2 + r^2} \\
\tag{$\frac{dr}{d\phi}=e^\phi$}&=d\phi\sqrt{e^{2\phi}+r^2} \\
&=????????
\end{align*}
Polar **volume** is the same as Cartesian volume:
$$dV=A\ dr$$
!!! example
For a cylinder of radius $R$ and height $h$:
$$
\begin{align*}
dV&=\pi R^2\ dr \\
V&=\int^h_0 \pi R^2\ dr \\
&=\pi R^2 h
\end{align*}
$$
### Moment of inertia
The **mass distribution** of an object varies depending on its surface density $\rho_s$. In objects with uniformly distributed mass, the surface density is equal to the total mass over the total area.
$$dm=\rho_s\ dS$$
The formula for the **moment of inertia** of an object is as follows, where $r_\perp$ is the distance from the axis of rotation:
$$dI=(r_\perp)^2dm$$
If the axis of rotation is perpendicular to the plane of the object, $r_\perp=r$. If the axis is parallel, $r_\perp$ is the shortest distance to the axis. Setting an axis along the axis of rotation is easier.
!!! example
In a uniformly distributed disk rotating about the origin like a CD with mass $M$ and radius $R$:
$$
\begin{align*}
\rho_s &= \frac{M}{\pi R^2} \\
dm &= \rho_s\ r\ dr\ d\phi \\
dI &=r^2\ dm \\
&= r^2\rho_s r\ dr\ d\phi \\
&= \rho_s r^3dr\ d\phi \\
I &=\rho_s\int^{2\pi}_{\phi=0}\int^R_{r=0} r^3dr\ d\phi \\
&= \rho_s\int^{2\pi}_{\phi=0}\frac{1}{4}R^4d\phi \\
&= \rho_s\frac{1}{2}\pi R^4 \\
&= \frac 1 2 MR^2
\end{align*}
$$
## Electrostatics
!!! definition
- The **polarity** of a particle is whether it is positive or negative.
The law of **conservation of charge** states that electrons and charges cannot be created nor destroyed, such that the **net charge in a closed system stays the same**.
The law of **charge quantisation** states that charge is discrete — electrons have the lowest possible quantity.
Please see [SL Physics 1#Charge](/sph3u7/#charge) for more information.
**Coulomb's law** states that for point charges $Q_1, Q_2$ with distance from the first to the second $\vec R_{12}$:
$$\vec F_{12}=k\frac{Q_1Q_2}{||R_{12}||^2}\hat{R_{12}}$$
!!! warning
Because Coulomb's law is an experimental law, it does not quite cover all of the nuances of electrostatics. Notably:
- $Q_1$ and $Q_2$ must be point charges, making distributed charges inefficient to calculate, and
- the formula breaks down once charges begin to move (e.g., if a charge moves a lightyear away from another, Coulomb's law says the force changes instantly. In reality, it takes a year before the other charge observes a difference.)
### Dipoles
An **electric dipole** is composed of two equal but opposite charges $Q$ separated by a distance $d$. The dipole moment is the product of the two, $Qd$.
The charge experienced by a positive test charge along the dipole line can be reduced to as the ratio between the two charges decreases to the point that they are basically zero:
$$\vec F_q=\hat x\frac{2kQdq}{||\vec x||^3}$$
## Maxwell's theorems
Compared to Coulomb's law, $Q_1$ creates an electric field around itself — each point in space is assigned a vector that depends on the distance away from the charge. $Q_2$ *interacts* with the field. According to Maxwell, as a charge moves, it emits a wave that carries information to other charges.
The **electric field strength** $\vec E$ is the force per unit *positive* charge at a specific point $p$:
$$\vec E_p=\lim_{q\to 0}\frac{\vec{F}}{q}$$
Please see [SL Physics 1#Electric potential](/sph3u7/#electric-potential) for more information.
### Electric field calculations
If charge is distributed over a three-dimensional object, integration similar to moment of inertia can be used. Where $dQ$ is an infinitely small point charge at point $P$, $d\vec E$ is the electric field at that point, and $r$ is the vector representing the distance from any arbitrary point:
$$d\vec E = \frac{kdQ}{r^2}\hat r$$
!!! warning
As the arbitrary point moves, both the direction and the magnitude of the distance from the desired point $P$ change (both $\hat r$ and $r$).
Generally, if a decomposing the vector into Cartesian forms $d\vec E_x$, $d\vec E_y$, and $d\vec E_z$ is helpful even if it is easily calculated in polar form because of the significantly easier ability to detect symmetry in the shape. Symmetry about the axis allows deductions such as $\int d\vec E_y=0$, which makes calculations easier.
In a **one-dimensional** charge distribution (a line), the charge density is used in a similar way as moment of inertia's surface density:
$$dQ=\rho_\ell d\ell$$
**Two-dimensional** charge distributions are more or less the same, but polar or Cartesian forms of the surface area work depending on the shape.
$$dQ=\rho_s dS$$
!!! example
A rod of uniform charge density and length $L$ has a charge density of $p_\ell=\frac{Q}{L}$.
1. Determine the formula for the charge density $\rho$
2. Choose an origin and coordinate system (along the axes of the object when possible)
3. Choose an arbitrary point $A$ on the charge
4. Create a right-angle triangle with $A$, the desired point, and usually the origin
5. Attempt to find symmetry
6. Solve
## Gauss's law
!!! definition
- A **closed surface** is any closed three-dimensional object.
- **Electric flux** represents the number of electric field lines going through a surface.
At an arbitrary surface, the **normal** to the plane is its vector form:
$$\vec{dS}=\vec n\cdot dS$$
The **electric flux density** $\vec D$ is an alternate representation of electric field strength. In a vacuum:
$$\vec D = \epsilon_0\vec E$$
**Electric flux** is the electric flux density multiplied by the surface area at every point of an object.
$$\phi_e=\epsilon_0\int_s\vec E\bullet\vec{dS}$$
The flux from charges outside a closed surface will **always be zero at the surface**. A point charge in the centre of a closed space has a flux equal to its charge. Regardless of the charge distribution or shape, the **total flux** through a closed surface is equal to the **total charge within** the closed surface.
$$\oint \vec D\bullet\vec{dS}=Q_\text{enclosed}$$
This implies $\phi_e>0$ is a net positive charge enclosed.
!!! warning
Gauss's law only applies when $\vec E$ is from all charges in the system
### Charge distributed over a line/cylinder
!!! warning "Limitations"
To apply this strategy, the following conditions must hold:
- $Q$ must not vary with the length of the cylinder or $\phi$
- The charge must be distributed over either a cylindrical surface or the volume of the cylinder.
- In the real world, $r$ must be significantly smaller than $L$ as an approximation.
- The strategy is more accurate for points closer to the centre of the wire.
Please see [Maxwell's integral equations#Gauss's law](https://en.wikiversity.org/wiki/MyOpenMath/Solutions/Maxwell%27s_integral_equations) for more information.
**Outside** the radius $R$ of the cylinder of the Gaussian surface, the enclosed charge is, where $L$ is the length of the cylinder:
$$Q_{enc}=\pi R^2\rho_0L$
such that the field at any radius $r>R$ is equal to:
$$\vec E(r)=\frac{\rho_0\pi R^2}{2\pi\epsilon_0r}\hat r$$
**Inside** the radius $R$ of the cylinder, the enclosed charge depends on $r$. For a uniform charge density:
$$Q_{enc}=\pi r^2\rho_0L$$
such that the field at any radius $r< R$ is equal to:
$$\vec E(r)=\frac{\rho_0}{2\epsilon_0}r\hat r$$
The direction of $\vec E$ should always be equal to that of $\vec r$. Generally, where $lim$ is $r$ if $r$ is *inside* the cylinder or $R$ otherwise, $\rho_v$ is the function for charge density based on radius, and $r_1$ is hell if I know:
$$\epsilon_0 E2\pi rL=\int^{lim}_0\rho_v(r_1)2\pi r_1L\ dr_1$$
### Charge distributed over a plane
!!! warning
To apply this strategy, the following conditions must hold:
- $Q$ must not vary with the lengths of the plane
- The charge must be distributed over a plane or slab
- In the real world, the thickness $z$ must be significantly smaller than the lengths as an approximation
Where $\rho_v$ is an **even** surface density function and $lim$ is from $0$ to $z$ if the desired field is outside of the charge, or $0$ to field height $h$ if it is inside the charge:
$$\epsilon_0 E=\int_{lim}\rho_v\ dh_1$$
Any two points have equal electric fields regardless of distance due to the construction of a uniform electric field.
Where $\rho_v$ is not an even surface density function, $d$ is the thickness of the slab, and $E$ is the electric field **outside** the slab:
$$2\epsilon_0E = \int^d_0\rho_v(A)dh_1$$
Where $E$ is the electric field **inside** the slab at some height $z$:
$$E=\frac{\rho_0}{4\epsilon_0}(2z^2-d^2),0\leq z\leq d$$
If $E$ is negative, it must point opposite the original direction ($\hat z$).
Generally:
1. Determine $\vec E$ outside the slab.
2. Set one outside surface and one inside surface as a pillbox and apply rules.
## Electrostatic potential
At a point $P$, the electrostatic potential $V_p$ or voltage is the work done per unit positive test charge from infinity to bring it to point $P$ by an external agent.
$$
V_p=\lim_{q\to 0^+}\frac{W_i}{q} \\
W_I=\int^p_\infty\vec F_I\bullet \vec{dl}=\Delta U=QV_p
$$
Because the desired force acts opposite to the force from the electric field, as long as $\vec E$ is known at each point:
$$
V_p=-\int^p_\infty\vec E\bullet\vec{dl} \\
V_p=-\int^p_\infty E\ dr
$$
The work done only depends on initial and final positions — it is conservative, thus implying Kirchoff's voltage law.
Where $\vec dl$ is the path of the test charge from infinity to the point, and $\vec dr$ is the direct path from the origin through the point to the charge, because $dr=-dl$:
$$\vec E\bullet\vec{dl}=Edr$$
Therefore, the potential due to a point charge is equal to (the latter is true only if distance from charge is always constant, regardless of distribution):
$$V_p=-\int^p_\infty\frac{kQ}{r^2}dr=\frac{kQ}{r}$$
**Positive** charges naturally move to **lower** potentials ($V$ decreases) while negative charges do the opposite. Potential energy always decreases.
In order to calculate the voltage for charge distributions:
- If $\vec E$ is easy to find via Gauss law:
$$V_p=-\int^p_\infty\vec E\bullet\vec{dl}$$
- If the charge is asymmetric:
$$V_p=\int_\text{charge dist}\frac{kdQ}{r}$$
The electric field always points in the direction of **lower** potential, and is equal to the **negative gradient** of potential.
$$\vec E=-\nabla V$$
If $\vec E$ is constant:
$$\vec E=\frac{Q_{enc\ net}}{\epsilon_0\oint dS}$$
The **superposition** principle allows potential due to different charges to be calculated separately and summed together to achieve the same result.
## Conductors
An **ideal conductor** has electrons loosely bound to atoms such that an electric field causes them to freely move by $F=Q_e E$. However, this assumes that there are infinite electrons in the conductor, and that the electrons will move with **zero resistance** to the surface of the conductor but **not leave it**.
A conductor placed in an external electric field will cause electrons to hop from atom to atom to reach the surface, charging one surface negatively and the other positively. The **induced electric field** from this imbalance opposes the external field force, slowing down electron movement until equilibrium is reached.
$$\text{equilibrium}\iff \vec E_{ext}+\vec E_{ind}=\vec 0$$
At equilibrium, **every point in the conductor is equipotential**. Gauss's law implies that there is no volume charge inside a conductor.
At its surface, $\vec E$ tangent to the surface must be zero. Normal to the surface:
$$|\vec E_N|=\frac{|\rho_0|}{\epsilon_0}$$
- $\rho_0$ is negative if field lines **enter** the conductor.
- $\rho_0$ is positive if field lines exit the conductor.
### Conductor cavities
A cavity surface must have **zero surface charge**. This creates a Faraday cage — outside fields cannot affect the cavity, but fields from the cavity can affect the outside world.
If there is a fixed/non-moving charge $Q$ in the cavity:
- $\vec E=0$ inside the conductor, so the boundary surface charge must be $-Q$.
- Electrons are taken from the surface, so the surface charge outside the conductor must be $Q$, propagating the effect of the charge to the outside world.
### Ground
A **ground** is a reservoir or sink of charges that never changes, regardless of the quantity added or removed from it. At the connection point, $V=0$ is always guaranteed.
Grounding a conductor means that it takes charges from the ground to balance an internal charge, neutralising it.
A charge released into a conductor (e.g., battery into wire) will always go to the outside surface, regardless of the point of insertion. Two charged objects connected by a thin conductor will redistribute their charge such that:
- their potentials are equal
- conservation of charge is followed.
This implies that a larger object has more charge, but a smaller object has a denser charge and thus stronger electric field.
$$Q_1=\frac {R_1} {R_2}Q_2$$
!!! example
For two spheres, as $\rho=\frac{Q_1}{4\pi R^2}$:
$$\rho_1=\frac {R_2} {R_1}\rho_2$$
A non-uniform object, such as a cube, will have larger charge density / stronger electric field at sharper points in its shape. Symmetrical surfaces always have uniform charge density.
!!! warning
An off-centre charge in a cavity will require a non-uniform induced charge to cancel out the internal field, but the external surface charge will be uniform (or non-uniform if the surface is odd).
### Nutshell
**Inside** a conductor:
- $\vec E=0$
- $\Delta V=0$
- $\rho_v=0$
Inside a cavity, if there exists an external field:
- $\vec E=0$
- $\rho_s=-Q$
- $\rho_{s\ outer}=Q$
The inner surface charge distribution matches that of the inner charge, but the outer surface charge distribution is dependent only on the shape of the conductor.
On conductor surfaces, the only $\vec E$ is **normal** to the surface and dependents on the shape of the surface.
$$|\vec E_N|=\frac{|\rho_s|}{\epsilon_0}$$
Grounding a conductor neutralises any free charges.
In slabs, as $A>>d$, assume $Q$ is uniformly distributed.
To solve systems:
- Assigning charge **density** is easier with sheets
- Assigning **charges** is easier with cylinders/spheres
## Dielectrics
!!! definition
- An **insulator** has electrons tightly bound to atoms.
### Polarisation
Polarisation is the act of inducing a dipole to a lesser extent than conductors. The induced field cannot reduce $\vec E$ inside the insulator to zero, but it will reduce its effects. The **polarisation vector** $\vec P$ is an average of the effects of all induced fields on a certain point inside a volume.
$$\vec P=\lim_{\Delta V\to 0}\frac{\sum^{N\Delta v}\vec p_i}{\Delta v}$$
where:
- $\Delta v\approx dv$ is the volume of the insulator
- $p_i$ is the dipole moment at a point
- $N$ is the total number of atoms in the volume
Polarisation is proportional to electric field and the **electric susceptibility** $X_e$ of a material to external fields.
$$\boxed{\vec P=\epsilon_0X_e\vec E}$$
The **relative permittivity** $\epsilon_r$ of a material is the ratio of decreasing $\vec E$ inside a medium relative to free space.
$$\epsilon_r=1+X_e$$
The new **flux density** formula includes polarised charges, so now $Q_{enc}$ includes **only free charges** (i.e., not polarised charges).
$$\boxed{\vec D=\epsilon_0\vec E+\vec P=\epsilon_0\epsilon_r\vec E}$$
$$\boxed{\oint\vec D\bullet\vec{dS}=Q_{enc,free}}$$
In uniform charge distributions, the surface charge density is related to its polarisation. Where $\hat n$ is the unit normal of the surface:
$$\rho_s=\vec P\bullet\hat n$$
### Boundary conditions
Regardless of permittivity, the $\vec E$ **tangential to the boundary** between two materials must be equal.
## Capacitors
!!! definition
- A **capacitor** is a device that uses the capacitance of materials to store energy in electric fields. It is usually composed of two conductors separated by a dielectric.
**Capacitance** is a measurement of the charge that can be stored per unit difference in potential.
$$\boxed{Q=C\Delta V}$$
To determine $C$:
1. Place a positive and a negative charge on conductors
2. Determine charge distribution
3. Determine $\vec E$ between the conductors
4. Find a path from the negative to the positive conductor and determine voltage
??? example
For two plates separated by distance $d$, with charges of $+Q$ and $-Q$, and a dielectric in between with permittivity $\epsilon_0\epsilon_r$:
- Clearly $\rho_0=\frac Q A$ as sheets must have uniform distribution. $-\rho_0$ is on the negative plate.
- From Gauss' law, creating a Gaussian surface outside the capacitor to between the plates gives $DA=\rho_0A$.
- $D=\epsilon_0\epsilon_rE$ gives $E=\frac{\rho_0}{\epsilon_0\epsilon_r}$
- Sheets have uniform fields, thus $\Delta V=Ed$
- Finally, $C=\epsilon_0\epsilon_r\frac A d$
!!! warning
If three dielectrics with different permittivities are allowed to touch each other, they will create **fringe fields** at their intersection that destroy the boundary condition.
### Capacitors and energy
The stored energy inside capacitors is the same as any other energy.
$$\boxed{U_e=\frac 1 2CV^2}$$
Much like VIR, it's usually easier to work with the form of the equation that has squared constants.
$$U_e=\frac 1 2 \frac {Q^2}{C}=\frac 1 2 QV$$
Adding dielectrics increases capacitance but decrease stored energy.
## Magnetism
All magnetic field lines are closed, i.e., they all return to the same magnetic object, much like a dipole. All lines must be perpendicular to the surface:
$$\oint\vec B\bullet\vec{dS}=0$$
Per **Biot-Savart's law**, magnets are complicated.
$$\boxed{d\vec B_p=\frac{\mu_0}{4\pi}I\frac{\vec {dl}\times\hat r}{|r|^2}}$$
where:
- $\mu_0$ is the magnetic permeability of free space
- $\hat r$ is the unit vector pointing from an arbitrary point of a wire to the desired point
- $I$ is current
- $dl$ follows the direction of current
The final direction can be determined in advance with the **right-hand rule**. Therefore, magnitude can be reduced to:
$$|dl\times\hat r|=|dl||\hat r|\sin\theta=|dl|\sin\theta$$
### Calculations
1. Define coordinate system
2. Go to some arbitrary point $A$ on a coordinate axis such that $r=AP$
3. Determine magnitude of the cross product
4. Determine final magnetic field direction (should be constant)
5. Rewrite equation in terms of one variable (usually $\theta$)
6. Integrate
### Selenoids
It's easiest to place the origin at the target point.
A selenoid with $N$ turns around a coil of length $L$ has density $n$, and has parallel electric fields inside.
$$n=\frac N L$$
The effective current of a selenoid for magnetic purposes is the sum of all currents.
$$\boxed{I_{eff}=ndzI}$$
where:
- $dz$ is the axis in the direction of current
- $I$ is current
This can be substituted directly into Biot-Savart's law, although definite integration should be done **in the direction of the axis** (from the desired point to the farthest point of the selenoid).
### Velocity and current
Biot-Savart's law can be applied to moving charges:
$$I\cdot \vec{dl}=\frac{dq\cdot dl}{dt}=dq\cdot \vec v$$
### Ampere's law
!!! definition
- **Drift velocity** is the average speed of electrons through a material.
The **current density** $\vec J$ is the amount of charge per unit time that flows through a unit area of a cross section.
$$\boxed{\vec J=nq\vec u=\rho_v\vec u}$$
where:
- $\vec u$ is drift velocity
- $n$ is the charge per unit volume
- $q$ is the total charge
Ohmic resistors have current density proportional to electric field by a material's **conductivity** $\sigma$.
$$\vec J=\sigma\vec E$$
Resistivity is related to conductivity: $\rho=\frac 1\sigma$
Integrating over a cross section returns current:
$$\boxed{I=\oint\vec J\bullet\vec{dS}}$$
**Ampere's law** asserts that magnetic flux due to all currents is equal to current enclosed inside a closed boundary/loop.
$$
\boxed{\begin{align*}
\oint\vec B\bullet\vec{dl}&=\mu_0I_{enc} \\
&=\mu_0\oint\vec J\bullet\vec{dS}
\end{align*}}
$$
where:
- $dl$ is the line along the loop/boundary in an arbitrary direction
- $I_{enc}$ is the sum of all enclosed currents
$dl$ (along the loop) and $dS$ are related in direction with each other per the **right hand rule**.
!!! warning
Ampere's law is only true in when dealing with DC.
For each enclosed $I$, if its direction is:
- the same as $\vec dS$, it is positive in the sum term
- opposite $\vec dS$, it is negative in the sum term
1. Use $dl$ to find $dS$ or vice versa
2. Determine $I_{enc}$
3. Solve
The angle of a cut to a surface does not affect any equations and can be treated identically. Any imaginary closed loop such that $\vec B$ **is constant over the loop and parallel to the loop** is usable with Ampere's law as $B$ can be reduced to a constant scalar.
The geometries that work include:
- Infinite cylinders with $J$ that may vary with $r$ but not $\phi$
- Infinite sheets/slabs where $J$ may vary with $z$ but not $x,y$
- Infinite selenoids
- Toroids (a selenoid bent into a donut shape)
1. Create a cross-section perpendicular to the current and determine if symmetry of the loop can meet conditions for geometry
2. Choose $dl$ in the direction of $B$ (counterclockwise)
3. Determine $dS$ (out of the page) and apply Ampere's law
$$\hat\phi=\hat z\times\hat r_1$$
!!! warning
A spinning cylinder rotates faster along its outer ring, forcing an integral setup.
### Faraday's law
Faraday's law states relates magnetic flux similarly to electric flux. Where $s$ is the open surface bounded by the conductor:
$$\phi_m=\int_s\vec B\bullet\vec{dS}$$
A flux that changes with time results in an **induced voltage** across the terminals of the conductor. Per Faraday's law of electromagnetic induction, magnetic energy is convertible to electric energy.
$$V_{ind}=-\frac{d}{dt}\phi_m$$
As the electric field is always perpendicular to a magnetic field, this indicates that it will curl around a straight magnetic field.
Relating $dl$ and $dS$ with the right-hand rule accounts for **Lenz's law**, which creates a $\vec E$ to create a $\vec B$ to oppose the change in $\phi_m$ that created the current.
$$\boxed{\oint\vec E\bullet\vec{d\ell}=\frac{d}{dt}\int\vec B\bullet\vec{dS}}$$
If there is a conducting loop in a time-varying magnetic field, a $V_{ind}$ is formed such that the current is in the direction of the induced field:
$$V_{ind}=\oint\vec E\bullet\vec{d\ell}=-\frac{d}{dt}\int\vec B\bullet\vec{dS}$$
Time-varying magnetic fields are formed if the field or charge is moving or if bounds change.
## Inductance
Kirchoff's voltage law is a simplification of Faraday's law, valid when there is no fluctuating magnetic field within the closed loop, so it's used with low frequency waves with less time variation.
The **inductance** is the flux travelling through a medium over its current.
$$L=\frac{\phi_m}{i}$$
If there are $N$ loops in a selenoid, where $\Lambda=N\phi_m$ is the total flux/**flux linkage**, $i$ is the current in one loop, and $I$ is the current of all loops:
$$L=\frac{\phi_m}{i}=\frac{\Lambda}{I_{eff}}$$
The **energy density** per unit volume is $u_m$.
$$u_m=\frac 1 2 \frac {B^2}{\mu_0}$$
The **total work** $U_m$ done to charge current from $0$ to $I$ is related to energy density.
$$U_m=\sqrt u_m=\frac 1 2 LI^2$$
$$\boxed{\frac 1 2 LI^2=\frac 1 2\int_{volume}U_mdV}$$
### Self-inductance
A magnetic flux that passes through the current that created it will induce voltage if $I$ changes.
**Mutual inductance** is wireless charging as changing current in one coil produces a changing magnetic flux in another, creating a voltage $\epsilon_{1\to 2}$.
$$V_{ind}=\epsilon_{1\to 2}=N_2\frac{d\phi_{1\to 2}}{dt}=-\frac{d}{dt}\int \vec B_1\bullet\vec{dS}_2$$
The mutual inductance is the rate of change of magnetic flux proportional to the rate of change of current. It is equal regardless of direction.
$$\boxed{M_{1\to 2}=\frac{N_2\phi_{1\to 2}}{I_1}}$$

View File

@ -1,958 +0,0 @@
# ECE 108: Discrete Math 1
An **axiom** is a defined core assumption of the mathematical system held to be true without proof.
!!! example
True is not false.
A **theorem** is a true statement derived from axioms via logic or other theorems.
!!! example
True or false is true.
A **proposition/statement** must be able to have the property that it is exclusively true or false.
!!! example
The square root of 2 is a rational number.
An **open sentence** becomes a proposition if a value is assigned to the variable.
!!! example
$x^2-x\geq 0$
## Truth tables
A truth table lists all possible **truth values** of a proposition, containing independent **statement variables**.
!!! example
| p | q | p and q |
| --- | --- | --- |
| T | T | T |
| T | F | F |
| F | T | F |
| F | F | F |
## Logical operators
!!! definition
- A **compound statement** is composed of **component statements** joined by logical operators AND and OR.
The **negation** operator is equivalent to logical **NOT**.
$$\neg p$$
The **conjunction** operaetor is equivalent to logical **AND**.
$$p\wedge q$$
The **disjunction** operator is equivalent to logical **OR**.
$$p\vee q$$
### Proposation relations
!!! definition
A **tautology** is a statement that is always true, regardless of its statement variables.
The **implication** sign requires that if $p$ is true, $q$ is true, such that *$p$ implies $q$*. The first symbol is the **hypothesis** and the second symbol is the **conclusion**.
$$p\implies q$$
| $p$ | $q$ | $p\implies q$ |
| --- | --- | --- |
| T | T | T |
| T | F | F |
| F | T | T |
| F | F | F |
The **inference** sign represents the inverse of the implication sign, such that $p$ **is implied by** $q$. It is equivalent to $q\implies p$.
$$p\impliedby q$$
The **if and only if** sign requires that the two propositions imply each other — i.e., that the state of $p$ is the same as the state of $q$. It is equivalent to $(p\implies q)\wedge (p\impliedby q)$.
$$p\iff q$$
The **logical equivalence** sign represents if the truth values for both statements are **the same for all possible variables**, such that the two are **equivalent statements**.
$$p\equiv q$$
$p\equiv q$ can also be defined as true when $p\iff q$ is a tautology.
!!! warning
$p\equiv q$ is *not a proposition* itself but instead *describes* propositions. $p\iff q$ is the propositional equivalent.
## Common theorems
The **double negation rule** states that if $p$ is a proposition:
$$\neg(\neg p)\equiv p$$
!!! tip "Proof"
Note that:
| $p$ | $\neg p$ | $\neg(\neg p)$ |
| --- | --- | --- |
| T | F | T |
| F | T | F |
Because the truth values of $p$ and $\neg(\neg p)$ for all possible truth values are equal, by definition, it follows that $p\equiv\neg(\neg p)$.
!!! warning
Proofs must include the definition of what is being proven, and any relevant evidence must be used to describe why.
The two **De Morgan's Laws** allow distributing the negation operator in a dis/conjunction if the junction is inverted.
$$
\neg(p\vee q)\equiv(\neg p)\wedge(\neg q) \\
\neg(p\wedge q)\equiv(\neg p)\vee(\neg q)
$$
An implication can be expressed as a disjunction. As long as it is stated, it can used as its definition.
$$p\implies \equiv (\neg p)\vee q$$
Two **converse** propositions imply each other:
$$p\implies q\text{ is the converse of }q\implies p$$
A **contrapositive** is the negatated converse, and is **logically equivalent to the original implication**. This allows proof by contrapositive.
$$\neg p\implies\neg q\text{ is the contrapositive of }q\implies p$$
### Operator laws
Both **AND** and **OR** are commutative.
$$
p\wedge q\equiv q\wedge p \\
p\vee q\equiv q\vee p
$$
Both **AND** and **OR** are associative.
$$
(p\wedge q)\wedge r\equiv p\wedge(q\wedge r) \\
(p\vee q)\vee r\equiv p\vee(q\vee r)
$$
Both **AND** and **OR** are distributive with one another.
$$
p\wedge(q\vee r)\equiv(p\wedge q)\vee(p\wedge r) \\
p\vee(q\wedge r)\equiv(p\vee q)\wedge(p\vee r)
$$
!!! tip "Proof"
$$
\begin{align*}
(\neg p\vee\neg r)\wedge s\wedge\neg t&\equiv\neg(p\wedge r\vee s\implies t) \\
\tag*{definition of implication} &\equiv \neg (p\wedge r\vee[\neg s\vee t]) \\
\tag*{DML} &\equiv\neg(p\wedge r)\wedge\neg[(\neg s)\vee t)] \\
\tag*{DML} &\equiv(\neg p\vee\neg r)\wedge\neg[(\neg t)\vee t] \\
\tag*{DML} &\equiv(\neg p\vee\neg r)\wedge\neg(\neg s)\wedge\neg t \\
\tag*{double negation} &\equiv(\neg p\vee\neg r)\wedge s\wedge\neg t
\end{align*}
$$
### Quantifiers
A **quantified statement** includes a **quantifier**, **variable**, **domain**, and **open sentence**.
$$
\underbrace{\text{for all}}_\text{quantifier}\ \underbrace{\text{real numbers}\overbrace{x}^\text{variable}\geq 5}_\text{domain}, \underbrace{x^2-x\geq 0}_\text{open sentence}
$$
The **universal quantifier** $\forall$ indicates "for all".
$$\forall x\in S,P(x)$$
!!! example
All real numbers greater than or equal to 5, defined as $x$, satisfy the condition $x^2-x\geq 0$.
$$\forall x\in\mathbb R\geq 5,x^2-x\geq 0$$
The **existential quantifier** $\exists$ indicates "there exists at least one".
$$\exists x\in S, P(x)$$
!!! example
There exists at least one real number greater than or equal to 5, defined as $x$, satisfies the condition $x^2-x\geq 0$.
$$\exists x\in\mathbb R\geq 5,x^2-x\geq 0$$
Quantifiers can also be negated and nested. The opposite of "for each ... that satisfies $P(x)$" is "there exists ... that does **not** satisfy $P(x)$".
$$\neg(\forall x\in S,P(x))\equiv\exists x\in S,\neg P(x)$$
Nested quantifiers are **evaluated in sequence**. If the quantifiers are the same, they can be grouped together per the commutative and/or associative laws.
$$\forall x\in\mathbb R,\forall y\in\mathbb R\equiv \forall x,y\in\mathbb R$$
!!! warning
This means that the order of the quantifiers is relevant if the quantifiers are different:
$\forall x\in\mathbb R,\exists y\in\mathbb R,x-y=1$ is **true** as setting $y$ to $x-1$ always fulfills the condition.
$\exists y\in\mathbb R,\forall x\in\mathbb R, x-y=1$ is **false** as when $x$ is selected first, it is impossible for every value of $y$ to satisfy the open sentence.
## Proof techniques
There are a variety of methods to prove or disprove statements.
- **Deduction**: a chain of logical inferences from a starting assumption to a conclusion
- **Case analysis**: exhausting all possible cases (e.g., truth table)
- **Contradiction**: assuming the conclusion is false, which follows that a core assumption is false, therefore the conclusion must be true
- **Contrapositive**: is equivalent to the original statement
- **Counterexample**: disproves things
- **Induction**: Prove for a small case, then prove that that applies for all cases
Implications can be proven in two simple steps:
1. It is assumed that the hypothesis is true (the implication is always true when it is false)
2. Proving that it follows that the conclusion is true
!!! example "Proving implications"
Prove that if $n+7$ is even, $n+2$ is odd.
$\text{Proof:}$
$\text{Assume }n+7\text{ is an even number. It follows that for some }k\in\mathbb Z$
$$
\begin{align*}
n+7&=2k \\
\text{s.t.} n+2&=2k-5 \\
&=2(k-3)+1
\end{align*}
$$
$\text{which is of the form }2z+1,z\in\mathbb Z,\text{ thus } n+2\text{ is odd.}$
!!! example "Proof by contradiction"
Prove that there is no greatest integer.
$\text{Proof:}$
$\text{ Let }n\in\mathbb Z\text{ be given and assume }\overbrace{\text{for the sake of contradiction}^\text{FTSOC}}\text{ that }n\text{ is the largest integer. Note that }n+1\in\mathbb Z\text{ and }n+1>n.\text{ This contradicts the initial assumption that }n\text{ is the largest integer, therefore there is no largest integer.}$
### Formal theorems
An **even number** is a multiple of two.
$$\boxed{n\ \text{is even}\iff\exists k\in\mathbb Z,n=2k}$$
An **odd number** is a multiple of two plus one.
$$\boxed{n\text{ is odd}\iff\exists k\in\mathbb Z,n=2k+1}$$
A number is **divisible** by another $m|n$ if it can be part of its product.
$$\boxed{n\text{ is divisible by } m\iff\exists k\in\mathbb Z,n=mk}$$
A number is a **perfect square** if it is the square of an integer.
$$n\text{ is a perfect square}\iff \exists k\in\mathbb Z,n=k^2$$
### Induction
!!! definition
- A proof **without loss of generality** (WLOG) indicates that the roles of variables do not matter — so long as the symbols CTRL-H'd, the proof remains exactly the same. For example, "WLOG, let $x,y\in\mathbb Z$ st. $x<y$."
Induction is a proof technique that can be used if the open sentence $P(n)$ depends on the parameter $n\in\mathbb N$. Because induction works in discrete steps, it generally cannot be applied domains of all real numbers.
To do so, the following must be proven:
- $P(1)$ must be true (the base case)
- $P(k+1)$ must be true for all $P(k)$, assuming $P(k)$ is true (the inductive case)
!!! warning
The statement **cannot** be assumed to be true, so one side must be derived into the other side.
!!! tip "Proof"
This should more or less be exactly followed. For the statement $\forall n\in\mathbb Z,n!>2^n$:
> We use mathematical induction on $n$, where $P(n)$ is the statement $n!>2^n$.
>
> **Base case**: Our base case is $P(4)$. Note that $4!=24>16=2^4$, so the base case holds.
>
> **Inductive step**: Let $k\geq 4$ for an arbitrary natural number and assume that $k!>2^k$. Multiplying by $k+1$ gives
>
> $$(k+1)k^2>(k+1)2^k$$
>
> By definition $(K=1)k!=(k+1)!$. Since $k\geq 4$, $k+1>2$ and thus $(k+1)2^k>2\cdot 2^k=2^{k+1}$. Putting this together gives
>
> $$(k+1)!>2^{k+1}$$
>
> Thus $P(k+1)$ is true and by the Principle of Mathematical Induction (POMI), $P(n)$ is true for all $n\geq 4$.
Induction can be applied to the whole set of integers by proving the following:
- $P(0)$
- if $i\geq 0, P(i)\implies P(i+1)$
- if $i\leq 0, P(i)\implies P(i-1)$
Alternatively, some steps can be skipped in **strong induction** by proving that if for $k\in\mathbb N$, $P(i)$ holds for all $i\leq k$, so $P(k+1)$ holds. In other words, by assuming that the statement is true for all values before $k$. If strong induction is true, regular induction must also be true, but not vice versa.
## Sets
!!! definition
- A **set** is an unordered collection of distinct objects.
- An **element/member** of a set is an object in that set.
- A **multiset** is an unordered collection of objects.
Sets are expressed with curly brackets:
$$\{s_1, s_2,\dots\}$$
Numbers are defined as sets of recursively empty sets:
$$
\begin{align*}
0&:=\empty \\
1&:=\{\empty\} \\
2&:=\{\empty,\{\empty\}\}
\end{align*}
$$
### Special sets
- $\mathbb N$ is the set of **natural numbers** $\{1, 2, 3,\dots\}$
- $\mathbb W$ is the set of **whole numbers** $\{0, 1, 2,\dots\}$
- $\mathbb Z$ is the set of **integers** $\{\dots, -1, 0, 1, \dots\}$
- $\mathbb Z^+_0$ is the set of **positive integers, including zero** — these modifiers can be applied to the set of negative integers and real numbers as well
- $2\mathbb Z$ is the set of **even integers**
- $2\mathbb Z + 1$ is the set of **odd integers**
- $\mathbb Q$ is the set of **rational numbers**
- $\mathbb R$ is the set of **real numbers**
- $\empty$ or $\{\}$ is the **empty set** with no elements
### Set builder notation
!!! definition
- The **domain of discourse** is the context of the current problem, which may limit the universal set (e.g., if only integers are discussed, the domain is integers only)
$x$ is an element if $x$ is in $\mathcal U$ and $P(x)$ is true.
$$\{x\in\mathcal U|P(x)\}$$
!!! example
All even numbers: $A=\{n\in\mathbb Z,\exists k\in\mathbb Z,n=2k\}$
$f(x)$ is an element if $x$ is in $\mathcal U$, and $P(x)$ is true:
$$\{f(x)|\underbrace{x\in\mathcal U, P(x)}_\text{swappable, omittable}\}$$
!!! example
- All even numbers: $A=\{2k|k\in\mathbb Z\}$
- All rational numbers: $\mathbb Q=\{\frac a b | a,b\in\mathbb Z,b\neq 0\}$
The **complement** of a set is the set containing every element **not** in the set.
$$\overline S$$
The **universal set** is the set containing everything, and is the complement of the empty set.
$$\mathcal U=\overline\empty$$
Two sets are **disjoint** if they do not have any elements in common.
$$S\cup T=\empty$$
### Set operations
A **subset** is inside another that is a **superset**.
$$
S\subseteq T \\
S\subseteq T\iff \forall x\in\mathcal U,(x\in S\implies x\in T)
$$
A **strict or proper subset** is a subset that is not equal to its **strict or proper superset**.
$$S\subset T$$
Two sets are equal if they are subsets of each other.
$$S=T\equiv (S\subseteq T)\wedge (T\subseteq S)$$
The **union** of two sets is the set that contains any element in either set.
$$S\cup T=\{x\in\mathcal U|(x\in S)\vee(x\in T)\}$$
The **intersection** of two sets is the set that only contains elements in both sets.
$$S\cap T=\{x\in\mathcal U|(x\in S)\wedge(x\in T)\}$$
The **difference** of two sets is the set that contains elements in the first but not the second. The remainder is dropped.
$$S-T=S\backslash T$$
The **complementary** set is every element not in that set.
$$
\overline S=\{x:x\not\in S\} \\
\overline S=\mathcal U-S
$$
The intersection and union operators have the same properties as **AND** and **OR** and so are equally commutative / associative.
**De Morgan's laws** still hold with sets.
### Intervals
An interval can be represented as a bounded set.
$$[a,b)=\{x\in\mathcal U|a\leq x\wedge x<b\}$$
$\empty$ is any impossible interval.
### Ordered pairs
!!! definition
- A **binary relation** on two sets $A, B$ is a subset of their Cartesian product.
- An ***n*-ary relation** between $n$ sets is a subset of their *n*-Cartesian product.
Also known as **tuples**, ordered pairs are represented by angle brackets.
$$\left<a,b\right> = \left<c,d\right>\iff (a=c)\wedge(b=d)$$
The **Cartesian product** of two sets is the set of all ordered pair combinations within the two sets.
$$A\times B=\{\left<a,b\right> | (a\in A)\wedge (b\in B)\}$$
It is effectively the cross product, so is not commutative, although distributing unions, intersections, and differences works as expected.
The **n-Cartesian product** of $n$ sets expands the Cartesian product.
$$A\times B\times\dots\times Z=\{\left<a, b,\dots z\right>|a\in A, b\in B,\dots,z\in Z\}$$
### Powersets
!!! definition
- An **index set** $I$ is the set containing all relevant indices.
A **partition** of a set $S$ is a set of **disjoint** sets that create the original set when unioned.
$$S=\bigcup_{i\in I}A_i$$
!!! example
$\{\{1\},\{2,3\},\{4,\dots\}\}$ is a partition of $\mathbb N$.
A **powerset** of a set $A$ is the set of all possible subsets of that set.
$$\mathcal P(A)=\{X|X\subseteq A\}$$
The empty set is the subset of every set so is part of each powerset. The number of elements in a subset is equal to the the number of elements in the original set as a power of two.
$$\dim(\mathcal P(A))=2^{\dim(A)}$$
!!! example
- $\mathcal P(\empty)=\empty$
- $\mathcal P(\{1,2\})=\{\empty, \{1\}, \{2\}, \{1, 2\}\}$
By definition, any subset is an element in the powerset.
$$A\subseteq B\equiv A\in\mathcal P(B)$$
- $\empty\in\mathcal P(A)$
- $A\in\mathcal P(A)$
- $A\subseteq B\implies (\mathcal P(A)\subseteq \mathcal P(B))$
- $A\in C\implies (C-A\subseteq C)$
!!! example
To prove $A\subseteq B\implies \mathcalP(A)\subseteq \mathcal P(B)$:
**Proof:** Let $A\subseteq B$ and $X\in\mathcal P(A)$. By definition, since $X\in\mathcal P(A), X\subseteq A$. Since $A\subseteq B$, it follows that $X\subseteq B$. Thus by the definition of the powerset, $X\in\mathcal P(B)$.
## Functions
!!! definition
- A **surjective** function has an equal codomain and range.
A **function** a relation between two sets $f:X\to Y$ such that each $x\in X$ **maps to** a unique $f(x)\in Y$.
$$
\begin{align*}
f:\ &X\to Y \\
&x\longmapsto f(x)
\end{align*}
$$
!!! example
Sample function with multiple cases and indices:
$$
\begin{align*}
f:\ &X\to Y \\
&x_i\longmapsto \begin{cases}
y_1 & i\in\{1,2\} \\
y_3 & i\in\{3,4,5\}
\end{cases}
\end{align*}
$$
The **domain** $\text{dom}(f)$ is the input set.
$$X=\text{dom}(f)$$
The **codomain** $\text{cod}(f)$ is the output set.
$$Y=\text{cod}(f)$$
The **range** $\text{rang}(f)$ is the subset of $Y$ that is actually mapped to by the domain.
$$
\begin{align*}
\text{rang}(f)&=\{y\in Y|\exists x\in X,y=f(x)\} \\
&=\{f(x)|x\in X\}
\end{align*}
$$
The **pre-image** is the subset of the domain that maps to a specific subset $B$ of the codomain.
$$\text{preimage}(f)=\{x\in X|\exists y\in B,y=f(x)\}$$
The **image** is the subset of the codomain that is mapped by a specific subset $A$ of the domain.
$$\text{image}(f)=\{f(x)|\exists x\in A\}$$
!!! example
For the function $f: \mathbb R^+_0\to \mathbb R$ defined by $x\longmapsto x^2$:
- the domain is $\mathbb R^+_0$
- the codomain is $\mathbb R$
- the range is $\mathbb R^+_0$
- the preimage for $\{1\}$ is $\{1,-1\}$
- the image for $0$ is $\{0\}$
Two functions $f=g$ are equal if and only if:
- their domains are equal
- their codomains are equal
- $f(x)=g(x)$ for all $x\in \text{dom}(f)$
### Function types
An **injective function**, **injection**, or **one-to-one function** is a function that maps only one $y$-value to each $x$.
$$\forall x_1,x_2\in\text{dom}(f), \text{ if } f(x_1)=f(x_2),x_1=x_2$$
A **surjective function**, **surjection**, or **onto** is a function that has its codomain equal to its range. A surjection $g:Y\to X$ exists if and only if an injection $f:X\to Y$ exists.
$$
\forall y\in\text{cod}(f),\exists x\in\text{dom}(f), f(x)=y \\
\text{rang}(f)=\text{cod}(f)
$$
A **bijective function** is both injective and surjective.
An **inverse relation** swaps the domain, codomain, and ordered pairs.
$$
\begin{align*{
R^{-1}:Y&\to X \\
R(x)&\mapsto x
$$
A function is **invective** or **invertible** if and only if it is bijective. All inversions are also bijective.
$$f^{-1^{-1}}=f$$
A **composition** maps the codomain of one to the domain of another function only if the first is a subset ($Y_1\subseteq Y_2$).
$$
\begin{align*}
f&:X\to Y_1,x\mapsto f(x) \\
g&:Y_2\to Z,y\mapsto g(y) \\
gf&: X\to Z,x\mapsto g(f(x))
\end{align*}
$$
Compositions are commutative but not associative.
- $h(gf)=(hg)f$
- $hgf\neq hfg$
- $f, g$ are injective $\implies$ $gf$ is injective
- $f, g$ are surjective $\implies$ $gf$ is surjective
- $gf$ is injective $\implies$ $f$ is injective
- $gf$ is surjective $\implies$ $g$ is surjective
The **identity function** is the function that returns its argument. Generally, a function composed with its inverse is the identity function.
$$
\begin{align*}
I:X&\to X \\
x&\mapsto x
\end{align*}
$$
If $f: X\to Y$ is bijective:
- the identity on $Y$ is $f(f^{-1}(y))$
- the identity on $X$ is $f^{-1}(f(x))$
If $f: X\to Y$ and $g: Y\to Z$ are bijective:
- $gf$ exists and is invertible
- $f^{-1}g^{-1}=(gf)^{-1}$ and exists
## Cardinality
!!! definition
- A **countably infinite** set is such that there exists a **bijective** function that maps the set to the set of natural numbers.
- A **countable** set is a finite set or a countably infinite set.
- An **uncountable** or **uncountably infinite** set is not countable.
The **cardinality** of a set is the number of elements in that set.
$$|S|$$
If two sets have a finite number of elements, their Cartesian product will have the same number of elements as the product of their elements.
$$|A|,|B|\in\mathbb N\implies|A\times B|=|A||B|$$
If two sets $X$ and $Y$ have finite cardinality and $f:X\to Y$:
- An injective function must have $|X|\leq |Y|$.
- A surjective function must have $|X|\geq |Y|$.
- A bijective function occurs if and only if $|X|=|Y|$.
A set is **finite** if it is empty or it is mappable to a subset of the natural numbers. By definition, the set of natural numbers is infinite.
$$\exists n\in\mathbb N,\exists f\text{ is bijective}, f:S\to \mathbb N_n,|s|=n$$
### Uncountable sets
The cardinality of countable sets is relative to the cardinality of the set of **natural numbers**.
$$|\mathbb N|=\aleph_0$$
By Contor's theorem, the powerset of the natural numbers must have a larger cardinality than the set of natural numbers.
$$|X|=\aleph_0\implies|\mathcal P(X)|=2^{\aleph_0}>\aleph_0$$
The following can be taken for granted:
- $|\mathbb R|>|\mathbb N|$
- $|\mathcal P(\mathbb N)|>|\mathbb N|$
- $|\mathcal P(\mathbb N)|=|\mathbb R|$
## Relations
A **binary relation** $R$ from sets $A$ to $B$ must be a subset of the two. A relation from $A$ to $A$ can be written as $R\subseteq A^2$.
$$R\subseteq A\times B$$.
!!! example
- $\forall x,y\in A,B,x<y$ is a subset. $<$ is a binary relation.
For $R\subseteq X\times Y$:
- $\text{dom}(R)=\{x\in X|\exists y\in Y,xRy\}$
- $\text{cod}(R)=Y$
- $\text{rang}(R)=\{y\in Y|\exists x\in X,xRy\}$
- The **image** of $X_1\subseteq X$ under $R$: $R(X_1)=\{y\in Y|\exists x\in X_1xRy\}$
- The **pre-image** is: $R^{-1}(Y_1)=\{x\in X|\exists y\in Y_1,xRy\}$
Relations are trivially proven to be relations through subset analysis.
!!! example
For the relation $L$\subseteq R^2=\{\left<x,y\right>\in\mathbb R^2|x<y\}$:
Clearly it is a subset of $R^2$, so it is a relation.
- The domain is $\mathbb R$.
- The range is $\mathbb R$.
- $L(\{1,4\})=\{y>4|y\in\mathbb R\}$ (1 OR 4)
- $L^{-1}(\{-1,2\})=\{x\in\mathbb R|x<2\}$ (-1 OR 2)
The **empty relation** $\empty$ is a relation on all sets.
The **identity relation** on all sets returns itself.
$$E=\{\left<a,a\right>|a\in A\}$$
The **universal relation** relates each element in the first set to every element to the second set.
$$U=A^2$$
The **restriction** of relation $R$ to set $B$ limits a previous relation on a superset $A$ such that $B\subseteq A$.
$$R\big|_B=R\cap B^2$$
Graphs are often used to represent relations. A node from $4\to3$ can be represented as $\left<3,4\right>$, much like an adjacency list.
### Reflexivity
A **reflexive** relation $R\subseteq X^2$ is such that every element in $X$ is related to itself by the relation.
$$\forall x\in X,\left<x,x\right>\in R$$
An **irreflexive** relation is such that each element is *not* related to itself.
$$\forall x\in X,\left<x,x\right>\not\in R$$
Reflexivity is determined graphically by checking if the main diagonal of a truth table is true.
!!! example
For the reflexive relation $R$, $A=\{1,2\},R=\{\left<1,1\right>,\left<2,2\right>\}$:
|$A\times A$ | 1 | 2 |
| --- | --- | --- |
| 1 | T | F |
| 2 | F | T |
!!! warning
$\empty$ is often vacuously true for most conditions.
If $R$ is a **non-empty** relation on a **non-empty** set $X$, $R$ cannot be both reflexive and irreflexive.
### Symmetry
A **symmetric** relation $R\subseteq X^2$ is such that every relation goes both ways.
$$\forall x,y\in X^2,\left<x,y\right>\in R\iff\left<y,x\right>\in R$$
An **asymmetric** relation is such that **no** relation goes both ways.
$$\forall x,y\in X^2,\left<x,y\right>\in R\implies\left<y,x\right>\not\in R$$
An **antisymmetric** relation is such that **no** relation goes both ways, *except* if compared to itself, and that the relation relates identical items.
$$\forall x,y\in X^2,\left<x,y\right>\in R\wedge\left<y,x\right>\in R\implies x=y$$
Where $x,y,z$ are elements in $X$, and $p,q,r$ are arbitrary proposition results (true/false):
- Symmetric relations must be symmetrical across the main diagonal of a truth table.
| $X^2$ | $x$ | $y$ | $z$ |
| --- | --- | --- | --- |
| $x$ | ? | $p$ | $q$ |
| $y$ | $\neg p$ | ? | $r$ |
| $z$ | $\neg q$ | $\neg r$ | ? |
- Asymmetric relations must be oppositely symmetrical across the main diagonal. The main diagonal also must be false.
- Antisymmetric relations must be false only if there is a true.
### Transitivity
A **transitive** relation links related terms. For example, $a<b$ and $b<c$ implies $a<c$.
$$\forall x,y,z\in X,\left<x,y\right>\in R\wedge\left<y,z\right>\in R\implies\left<x,z\right>\in R$$
## Orders
!!! definition
- A **partial order** is reflextive, antisymmetric, and transitive.
A **partially ordered set (poset)** is a set $S$ partially ordered with relation $R$.
$$\left<S,R\right>\text{ on } P=R_{S,P}$$
!!! example
$R_{\mathbb Z,\geq}$ is a poset. $\left<\mathcal P(A),\subseteq\right>$ on $A$ is also a poset.
A **strict poset** is irreflexive, asymmetric, and transitive.
A **total order** is a strict poset such that the relation is defined between every possible pair on the set.
$$\forall x,y\in S,xPy\wedge yPx\in\left<S,P\right>$$
### Equivalence relations
An **equivalence class** is a criterion that determines whether two objects are equivalent. The original set must be the union of all equivalence classes.
!!! example
The following are all in the equivalence class $=_1$: $\{1,\frac 2 2,\frac 3 3,\frac 4 4,...\right}$
## Combinatorics
!!! definition
- **and** usually requires you to multiply sets together.
- **or** usually requires you to add then subtract unions.
The number of ways to choose exactly one element from finite sets is the product of their dimensions.
$$|A_1||A_2|...|A_n|$$
!!! example
The number of unique combinations (including order) from four dice is $|6|^4$.
### Ordered with replacement
These problems count order as separate permutations and replace an item after it is taken for the future. If there are $n$ outcomes, and $m$ events that take one of those outcomes:
$$P=n^m$$
To pick $m$ items out of $n$ elements:
$$P(n,m)=\frac{n!}{(n-m!)}$$
If there are duplicates that would otherwise result in an identical string, divide the result by $m!$, where $m$ is the number of repetitions for each duplicate $n_1,n_2,...$.
$${n\choose n_1!n_2!n_k!}=\frac{n!}{n_1!n_2!...n_k!}$$
!!! example
The number of permutations of "ECE119" has two characters that have duplicates. Therefore, the number of possibilities is:
$$\frac{6!}{2!2!}$$
### Unordered with replacement
To rearrange $n$ unique items, the number of possibilities is:
$$n!$$
To choose $n$ items $m$ times, regardless of order, the number of possibilities is:
$${n\choose m}=\frac{n!}{(n-m)!m!}={n\choose(n-m),m}$$
Clearly ${n\choose m}=0$ if $m>n$ or $m<0$.
To choose $k$ out of $n$ items one time, multichoose can be used:
$$\left({n\choose k}\right)={n+k-1\choose k}={n-1+k\choose n-1,k}$$
### Binomial coefficients
A **slack variable** is used to change inequalities into equalities.
!!! example
If solving $x+y\leq 7$, setting $z=7-(x+y)$ to make everything the same domain ($\mathbb Z^+_0$) to use choose.
**Pascal's identity** defines the choose operator recursively.
$${n\choose m}={n-1\choose m-1}+{n-1\choose m}$$
The **binomial theorem** expands a binomial.
$$\forall a,b\in\mathbb R,(a+b)^n=\sum^n_{i=0}{n\choose i}a^{n-i}b^i$$
The sum of choosing integers is its power to 2. Therefore, a finite set with dimension $n$ must have exactly $2^n$ possible subsets.
$$\forall n\in\mathbb Z^+_0,\sum^n_{k=0}{n\choose k}=2^n$$
### Inclusion-exclusion
The inclusion-exclusion principle removes duplicate counting.
$$|A\cup B|=|A|+|B|-|A\cap B|$$
This can be extended to 3+ sets, proven by a bijection to $\mathbb N_{|A| + |B|+|A\cap B|}$:
$$|A\cup B\cup C|=|A| + |B| + |C| - (|A\cap B| + |A\cap C| + |B\cap C|)-|A\cap B\cap C|$$
If $B$ is a subset of $A$, the dimension of $B$ is related to that of $A$.
$$B\subseteq A\implies|B|=|A|-|\overline B|$$
## Probability
!!! definition
- An **experiment** is an event that has a number of outcomes.
- **Elementary events** are the outcomes of an experiment compose the set of all events.
- An **event** $E$ is a subset of the sample space $S$, which is the **certain event**.
- The **null event** is the empty set.
- Sets of events are **mutually exclusive** if they are disjoint.
- Elementary events are **equiprobable** if they are equally probable.
- A **uniform probability distribution** on $S$ is such that all elementary events are equiprobable.
A **probability distribution function (PDF)** $Pr$ converts the elements of the powerset of all outcomes to a real number — its probability.
$$Pr:\mathcal P(S)\to\mathbb R,0\leq P(A)\leq 1$$
A PDF must have, if $S$ is the sample space:
- $\forall A\subseteq S,Pr\{A\}\geq 0$
- $Pr\{S\}=1$
- The union of all mutually exclusive sets is the sample space
A **discrete probability distribution** is such that the sample space is a countable set.
For all $A\subseteq S$, the probability of event $A$ is the sum of the probabilities of all elementary events in $A$.
- $Pr\{A\}=\sum_{e\in A}Pr\{\{e\}\}$
- $Pr\{\empty\}=0$
- $Pr\{A'\}=1-Pr\{A\}$
Adding events together can never decrease their probability, and the sum of all probabilities must equal $1$ such that $\text{rang}(Pr)\subseteq[0,1]$.
$$A\subseteq B\subseteq S\implies Pr\{A\}\leq Pr\{B\}$$
The **inclusion-exclusion principle** also applies.
$$Pr\{A\cup B\}=Pr\{A\}+Pr\{B\}-Pr\{A\cup B\}$$
### Named PDFs
!!! definition
- An **emperical PDF** is collected from empirical data.
A **Bernouilli trial** is an event with exactly two options, pass $P$ with probability $p$, or fail $F$ with probability $q=1-p$. For the event $X$:
$$
Pr\{X\}=\begin{cases}
p &\text{if }X=\{P\} \\
1-p&\text{if }X=\{F\}
\end{cases}
$$
For exactly two options for $x$ (1 or 0):
$$Pr\{X=x\}=p^x(1-p)^{1-x}$$
Please see [SL Math - Analysis and Approaches 2#Binomial distribution](/g11/mcv4u7/#binomial-distribution) for more information.
A **random variable** is a function that assigns a real number to every item in the sample space. A **discrete random variable** is used if the sample space is discrete. The probability of all events that lead to a possible discrete random variable $x\in\mathbb R$, where $X$ is the function to transform those variables:
$$Pr\{X^{-1}(\{x\})\}$$
Thus the **binomial distribution** for $r$ successes of $n$ total tries, if they are independent, is:
$$Pr\{X=r\}{n\choose r}p^rq^{n-r}$$
### Independence
Please see [SL Math - Analysis and Approaches 2#Conditional probability](/g11/mcv4u7/#conditional-probability) for more information.
Two events are independent if they can be treated separately.
$$\text{independent}\iff Pr\{A\cap B\}=Pr\{A\}Pr\{B\}$$
Or, via the inclusion-exclusion theorem:
$$\text{independent}\iff Pr\{A\cup B\}=Pr\{A\}+Pr\{B\}-Pr\{A\}Pr\{B\}$$
**Bayes' theorem** provides a general formula for conditional probability:
$$Pr\{A|B\}=\frac{Pr\{B|A\}}{Pr\{B\}}$$
Formally, this can be solved without $Pr\{B\}$:
$$Pr\{A|B\}=\frac{Pr\{A\}Pr\{B|A\}}{Pr\{A\}Pr\{B|A\}+Pr\{\overline A\}Pr\{B|\overline A\}}$$
### Expected value
The **expected value**, **mean**, or **expectation of $X$** is:
$$E[X]=\sum_{x\in\mathbb R}x\cdot Pr\{X=x\}=\sum_{s\in S}X(s)\cdot Pr\{\{s\}\}$$
This operation is **linear**, but multiplies using AND:
$$
E[X+Y]=E[X}+E[Y] \\
E[XY]=\sum_{x\in X,y\in Y}xy\cdotPr\{X=x\wedge y\=y\}
$$
Thus if $X$ and $Y$ are independent:
$$E[XY]=E[X]E[Y]$$
An **indicator random variable** only has two possible outcomes: zero or one. Thus an indicator random variable $X$ has an expected value equal to its probability:
$$E[X]=Pr\{X=1\}$$
The **covariance** of $X$ and $Y$ represents the direction of difference of $X$ and $Y$ from their means.
$$Cov[X,Y]=E[XY]-E[X]E[Y]$$

View File

@ -1,591 +0,0 @@
# ECE 124: Digital Circuits
## Base / radix conversion
Please see [ECE 150: C++#Non-decimal numbers](/1a/ece150/#non-decimal numbers) for more information.
## Binary logic
A **binary logic variable** is a variable that has exactly two states:
- 0, or false (switch open)
- 1, or true (switch closed)
**Binary logic functions** are any function that satisfies the following type signature:
```python
BoolFunc = Callable[[bool | BoolFunc, ...], bool]
```
In other words:
- it must accept a number of booleans and/or other logic functions, and
- it must return exactly one boolean.
These can be expressed via truth table inputs/outputs, algebraically, or via a logical circuit schematic.
### Logical operators
Operator precedence is () > NOT > AND > OR.
The **AND** operator returns true if and only if **all** arguments are true.
$$A\cdot B \text{ or }AB$$
<img src="https://upload.wikimedia.org/wikipedia/commons/b/b9/AND_ANSI_Labelled.svg" width=200>(Source: Wikimedia Commons)
The **OR** operator returns true if and only if **at least one** argument is true.
$$A+B$$
<img src="https://upload.wikimedia.org/wikipedia/commons/1/16/OR_ANSI_Labelled.svg" width=200>(Source: Wikimedia Commons)</img>
The **NOT** operator returns the opposite of its singular input.
$$\overline A \text{ or } A'$$
<img src="https://upload.wikimedia.org/wikipedia/commons/6/60/NOT_ANSI_Labelled.svg" width=200>(Source: Wikimedia Commons)</img>
The **NAND** operator is equivalent to **NOT AND**.
$$\overline{A\cdot B}$$
<img src="https://upload.wikimedia.org/wikipedia/commons/e/e6/NAND_ANSI_Labelled.svg" width=200>(Source: Wikimedia Commons)</img>
The **NOR** operator is equivalent to **NOT OR**.
$$\overline{A+B}$$
<img src="https://upload.wikimedia.org/wikipedia/commons/c/c6/NOR_ANSI_Labelled.svg" width=200>(Source: Wikimedia Commons)</img>
The **XOR** operator returns true if and only if the inputs are not equal to each other.
$$A\oplus B$$
<img src="https://upload.wikimedia.org/wikipedia/commons/1/17/XOR_ANSI_Labelled.svg" width=200>(Source: Wikimedia Commons)</img>
The **XNOR** operator is equivalent to **NOT XOR**.
$$\overline{A\oplus B}$$
<img src="https://upload.wikimedia.org/wikipedia/commons/b/b8/XNOR_ANSI_Labelled.svg" width=200>(Source: Wikimedia Commons)</img>
### Buffer gates
The **buffer** gate returns the input without any changes, and is usually used for adding delays into circuits.
<img src="https://upload.wikimedia.org/wikipedia/commons/7/75/Digital_buffer.svg" width=200>(Source: Wikimedia Commons</img>
A **tri-state buffer** gate controls whether the input affects the circuit at all. When the controlling input is off, the input is disconnected from the rest of the system, leaving the output of the buffer as a third state **Z** (high impedance).
One example of a tri-state buffer is a switch.
<img src="https://upload.wikimedia.org/wikipedia/commons/c/c0/Tristate_buffer.svg" width=400>(Source: Wikimedia Commons)</img>
!!! example
Tri-state buffers are often used to implement **select inputs** or **multiplexers** — setting the mux switch in one direction or another only allows signals from one input to pass through.
<img src="https://upload.wikimedia.org/wikipedia/commons/1/16/Multiplexer2.svg" width=400>(Source: Wikimedia Commons)</img>
### NAND/NOR completeness
NAND and NOR are **universal gates** — some combination of them can form any other logic gate. Constructions of other gates using only these gates are called **NAND-NAND realisations** or **NOR-NOR realisations**.
This is useful in SOP as if two ANDs feed into an OR, all can be turned into NANDs to achieve the same result.
!!! example
NOT can be expressed purely with NAND as $A$ NAND $A$:
<img src="https://upload.wikimedia.org/wikipedia/commons/3/3f/NOT_from_NAND.svg" width=150>(Source: Wikimedia Commons)</img>
### Postulates
In binary algebra, if $x,y,z\in\mathbb B$ such that $\mathbb B=\{0, 1\}$:
The **identity element** for **AND** $1$ is such that any $x\cdot 1 = x$.
The **identity element** for **OR** $0$ is such that any $x + 0 = x$.
In this space, it can be deduced that $x+x'=1$ and $x\cdot x'=0$.
**De Morgan's laws** are much easier to express in boolean algebra, and denote distributing a negation by flipping the operator:
$$
(x\cdot y)'=x'+y' \\
(x+y)=x'\cdot y'
$$
Please see [ECE 108: Discrete Math 1#Operator laws](/1b/ece108/#operator-laws) for more information.
AND and OR are commutative.
- $x\cdot y=y\cdot x$
- $x+y=y+x$
AND and OR are associative.
- $x\cdot(y\cdot z)=(x\cdot y)\cdot z)$
- ...
AND and OR are distributive with each other.
- $x\cdot (y+z)=x\cdot y+z\cdot z$
A term that depends on another term ORed together can be "absorbed".
- $x+x\cdot y=x$
- $x\cdot(x+y)=x$
If a term being true also results in other ORed terms being true, it is redundant and can be eliminated via consensus.
- $x\cdot y+y\cdot z+x'\cdot z=x\cdot y+x'\cdot z$
- if y and z are true, at least one of the other two terms must be true
- $(x+y)\cdot (y+z)\cdot(x'+z)=(x+y)\cdot (x'+z)$
The **synthesis** of an algebraic formula represents its implementation via logic gates. In this course, its total cost is the sum of all inputs to all gates and the number of gates, *excluding* initial inputs of "true" or an initial negation.
In order to deduce an algebraic expression from a truth table, **OR** all of the rows in which the function returns true and simplify.
??? example
Prove that $(x+y)\cdot(x+y')=x$:
\begin{align*}
\tag{distributive property}(x+y)\cdot(x+y')&=xx+xy'+yx+yy' \\
\tag{$yy'$ = 0, $xx=x$}&=x + xy' + yx \\
\tag{distributive, commutative properties}&= x(1+y'+y) \\
\tag{1 + ... = 1}&= x(1) \\
&=x
\end{align*}
Prove that $xy+yz+x'z=xy+x'z$:
\begin{align*}
\tag{$x+x'=1$}xy+yz+x'z&=xy+yz(x+x')+x'z \\
\tag{distributive property}&=xy+xyz+x'yz+x'z \\
\tag{distributive property}&=x(y+yz) + x'(yz+z) \\
\tag{distributive property}&=xy(1+z) + x'z(y+1) \\
\tag{$1+k=1$}&=xy(1) + x'z(1) \\
\tag{$1\cdot k=k$}&= xy+x'z
\end{align*}
### Minterms and maxterms
The **minterm** $m$ is a **product** term where all variables in the function appear once. There are $2^n$ minterms for each function, where $n$ is the number of input variables.
To determine the relevant function, the subscript can be converted to binary and each function variable set such that:
- if the digit is $1$, the complement is used, and
- if the digit is $0$, the original is used.
$$m_j=x_1+x_2+\dots x_n$$
!!! example
For a function that accepts three variables:
- there are eight minterms, from $m_0$ to $m_7$.
- the sixth minterm $m_6=xyz'$ because $6=0b110$.
For a sample function defined by the following minterms:
$$
\begin{align*}
f(x_1,x_2,x_3)&=\sum m(1,2,5) \\
&=m_1+m_2+m_5 \\
&=x_1x_2x_3' + x_1x_2'x_3 + x_1'x_2x_3'
\end{align*}
$$
The **maxterm** $M$ is a **sum** term where all variables in the function appear once. It is more or less the same as a minterm, except the condition for each variable is **reversed** (i.e., $0$ indicates the complement).
$$M_j=x_1+x_2+\dots +x_n$$
!!! example
For a sample function defined by the following maxterms:
\begin{align*}
f(x_1,x_2,x_3,x_4)&=\prod M(1,2,8,12) \\
&=M_1M_2M_8M_{12} \\
\end{align*}
??? example
Prove that $\sum m(1,2,3,4,5,6,7)=x_1+x_2+x_3$: **(some shortcuts taken for visual clarity)**
\begin{align*}
\sum m(1,2,3,4,5,6,7) &=001+011+111+010+110+100+000 \\
\tag{SIMD distribution}&=001+010+100 \\
&=x_1+x_2+x_3
\end{align*}
A **canonical sum of products (SOP)** is a function expressed as a sum of minterms.
$$f(x_1,x_2,\dots)=\sum m(a,b, \dots)$$
A **canonical product of sums (POS)** is a function expressed as a product of maxterms.
$$f(x_1,x_2,\dots)=\prod M(a,b,\dots)$$
## Transistors
Binary is represented in hardware via switches called **transistors**. Above a certain voltage threshold, its output is $1$, whlie it is $0$ if below a threshold instead.
A transistor has three inputs/outputs:
- A ground
- An input **source**, which has voltage that determines whether the circuit is connected to the ground
- An output **drain**, which will either be grounded or have a voltage depending on whether the switch is closed.
<img src="https://upload.wikimedia.org/wikipedia/commons/6/61/IGFET_N-Ch_Enh_Labelled_simplified.svg" width=200>(Source: Wikimedia Commons)</img>
A **negative logic** transistor uses a NOT bubble to represent that it is closed while the voltage is **below** a threshold.
<img src="https://upload.wikimedia.org/wikipedia/commons/c/c4/IGFET_P-Ch_Enh_Labelled_simplified.svg" width=200>(Source: Wikimedia Commons)</img>
## Hardware
!!! definition
- A **programmable logic gate** does shit
- A **programmable logic array** does more shit
- **Programmable array logic** is the shit being done
### FPGAs
A **field-programmable gate array** (FPGA) is hardware that does not come with factory-fabricated AND and OR gates, requiring the user to set them up themselves. It contains:
- input/output pads
- routing channels (to connect with physical wires and switches)
- logic blocks (that are user-programmed to behave like gates)
- lookup tables (LUTs) inside the logic gates, which are a small amount of memory
## Gray code
The Gray code is a binary number system that has any two adjacent numbers differing by **exactly one bit**. It is used to optimise the number of gates in a function.
The 1-bit Gray code is $0, 1$. To convert an $n$-bit Gray code to an $n+1$-bit Gray code:
- Mirror the code: $0,1,1,0$
- Add $0$ to the original and $1$ to the new ones: $00, 01, 11, 10$
Sorting truth table inputs in the order of the Gray code makes optimisation easier to do.
A **"don't care"** is represented by a $d$ in truth tables. It is used for optimisation if the state of that output doesn't matter, and can be treated as a one or a zero as desired.
It can be more efficient to optimise two different functions differently such that they are more optimised when combined.
### K-maps
Karnaugh maps are an alternate representation of truth tables arranged by the Gray code.
- Coordinates are the input values to the function
- The output square of the coordinates is the output value of the function
- Headers are sorted by Gray code (multiple variables can be combined by increasing the number of bits in the Gray code)
Each 1 square is effectively a minterm, and finding the least number of rectangles that only cover "1"s allows for the simplest algebraic form of the truth table to be deduced. If needed, rectangles can wrap around on any side. The same rules apply to optimise for maxterms (product of sums), or $f'$, by optimising for zeros.
<img src="https://upload.wikimedia.org/wikipedia/commons/b/b7/K-map_6%2C8%2C9%2C10%2C11%2C12%2C13%2C14.svg" width=500>(Source: Wikimedia Commons)</img>
A K-map for five variables can be expressed in two maps for four variables — one with the fifth variable set to zero, and the other set to 1.
### Multiplexers
An $n$-input mux has $\lceil\log_2 n\rceil$ **select inputs** all in the same mux.
!!! example
A 4-1 multiplexer. $f=s_0's_1A+s_0's_1B+s_0s_1'C+s_0s_1D$
<img src="https://upload.wikimedia.org/wikipedia/commons/7/75/Multiplexer_4-to-1.svg" width=300>(Source: Wikimedia Commons)</img>
**Shannon's expansion theorem** states that any function can be turned into a function that purely uses multiplexers:
$$
\begin{align*}
f(w_1,\dots, w_n) &=w_1f_{w_1} + w_1'f_{w_1'} \\
&= w_1f(1, \dots, w_n) = w_1'f(0, \dots, w_n)
\end{align*}
$$
A **demultiplexer** has one input, $n$ select inputs, and up to $2^n$ outputs that carry the input signal depending on the select input.
<img src="https://upload.wikimedia.org/wikipedia/commons/4/48/Demultiplexer.png" width=400>(Source: Wikimedia Commons)</img>
A **binary encoder** takes $2^n$ inputs and $n$ outputs, with the binary representation of the $n$ outputs indicating the inputs enabled by binary index.
## Sequential circuits
!!! definition
- A **combinatorial circuit** is dependent on present signals.
- A **sequential circuit** is dependent on past and present signals, using storage elements to track state.
**Synchronous** sequential circuits only change signals at discrete times, such as with clock signals. Asynchronous circuits change whenever.
### Clocks
!!! definition
- The **period** $t$ is the duration of one clock cycle.
- The **frequency** $f$ is the reciprocal of the period.
- The **rising edge** is the instant a clock changes from $0$ to $1$.
- The **falling edge** is the instant a clock changes from $1$ to $0$.
### Storage elements
A **basic latch** changes based on its input signal level such that it is level-sensitive.
A **gated latch** is a basic latch as well as a control input that locks the current state. The latch is only togglable when the control input is on.
A **flip-flop** contains two gated latches and a control input. The state is only adjustable during the edges of the control signal, so it can only change up to once per cycle.
### Asynchronous latches
An **RS-NOR** basic latch has a *set* input that must be *reset* before being set again, with one output representing each state. Setting both to one resets both outputs to zero.
<img src="https://upload.wikimedia.org/wikipedia/commons/c/c6/R-S_mk2.gif" width=300>(Source: Wikimedia Commons)</img>
| $R$ | $S$ | $Q$ | $Q'$ |
| --- | --- | --- | --- |
| 0 | 0 | no change | no change |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 0 | 0 |
An **RS-NAND** basic latch operates the same way, and looks practically the same, except shifting to $(1, 1)$ resets both to zero instead, and $(0, 0)$ causes no change.
### Synchronous latches
A **NAND gated latch** only allows changes when the clock control input *clk* is on.
<img src="https://upload.wikimedia.org/wikipedia/commons/e/e1/SR_%28Clocked%29_Flip-flop_Diagram.svg" width=400>(Source: Wikimedia Commons)</img>
A **gated D latch** effectively stores $R$ and $S$ by assuming that they are the complement for each other, setting $R$ as $D$ and $S$ as $D'$ or vice versa. This **level-sensitive** latch is commonly used to store past state as there is no change when *clk* is zero.
<img src="https://upload.wikimedia.org/wikipedia/commons/c/cb/D-type_Transparent_Latch_%28NOR%29.svg" width=400>(Source: Wikimedia Commons)</img>
### Flip-flops
**Edge-triggered flip-flops** only change state on the edge of a clock. A negative-edge D flip flop below changes only at the **falling edge** of the clock and is greated with two gated D latches in series. A positive-edge D flip flop can be created by inverting both enable inputs.
<img src="https://upload.wikimedia.org/wikipedia/commons/5/52/Negative-edge_triggered_master_slave_D_flip-flop.svg" width=500>(Source: Wikimedia Commons)</img>
The asynchronous operations **clear** and **preset** can be added to force the state of the flip-flop to 0 or 1, respectively. To make them synchronous, the input $D$ can be replaced with $D\text{ and clear}'$. These operations are **active low**.
<img src="https://upload.wikimedia.org/wikipedia/commons/8/8c/D-Type_Flip-flop.svg" width=200>(Source: Wikimedia Commons</img>
A **T flip-flop** holds state if $T=0$ or **toggles** state if $T=1$.
<img src="https://upload.wikimedia.org/wikipedia/commons/a/a9/T-Type_Flip-flop.svg" width=200>(Source: Wikimedia Commons</img>
!!! example
<img src="https://upload.wikimedia.org/wikipedia/commons/3/3b/Dual-edge-triggered-flip-flop-XOR.png" width=500>(Source: Wikimedia Commons)</img>
A **JK flip-flop** acts as a **D flip-flop** if $J\neq K$ and as a **T flip-flop** if $J=K$.
<img src="https://upload.wikimedia.org/wikipedia/commons/3/37/JK_Flip-flop_%28Simple%29_Symbol.svg" width=200>(Source: Wikimedia Commons)</img>
### Timing analysis
Because flip-flop outputs only change on an active clock edge, there are **propagation delays** before the state changes completely.
- The **setup time** $t_{su}$ is the waiting time the input must be held stable **before** the active clock edge
- The **hold time** $t_h$ is the time the input must be held stable **after** the active clock edge
- The **clock-to-output time** $t_{cq}$ is the time required for the output to stabilise after the active clock edge
A **timing violation** occurs if these timing parameters are not met, which limits clock cycle frequency.
### Registers
!!! definition
- An **n-bit register** stores *n* bits.
A flip-flop is a one-bit register.
A **shift register** is a chain of redstone repeaters, consisting of a chain of flip-flops with each output connected to the next input.
<img src="https://upload.wikimedia.org/wikipedia/commons/4/45/4-Bit_SIPO_Shift_Register.svg" width=300>(Source: Wikimedia Commons)</img>
An **up-counter** increments its binary value on input. A **down-counter** decrements its value. It is **synchronous** if all bits update simultaneously.
### Counters
A **Johnson counter** overflows by connecting the complement of the final output to the first input.
A **ring counter** has exactly one output bit equal to one, looping when it reaches the end. It is equivalent to a loop of redstone repeaters, if redstone repeaters required input to switch to the next repeater.
## Synchronous sequential circuits
A **synchronous sequential circuit** or **state machine** is created with a combinational circuit and a flip-flop.
A **state diagram** is a directed graph with nodes and arcs. Each node represents a state while arcs represent changes in input/output to other states. A circuit with $n$ inputs has $2^n$ arcs.
!!! example
A state diagram for a turnstile.
<img src="https://upload.wikimedia.org/wikipedia/commons/9/9e/Turnstile_state_machine_colored.svg" width=300>(Source: Wikimedia Commons)</img>
A **state table** is a simplified state diagram.
!!! example
Where $A,B,C$ are states, and $w$ is the input, a Moore machine can be represented as:
| state | next state | | output |
| --- | --- | --- | --- |
| | $w=0$ | $w=1$ | |
| A | A | B | 0 |
| B | A | C | 0 |
| C | A | C | 1 |
To design a state circuit:
1. Create a state diagram, select starting state
2. Minimise the number of states
3. Decide the number of state variables
4. Choose flip-flop types and derive next state logic expressions to control flip-flops
5. Derive logic expressions
6. Implement the logic expressions
### Moore machine
A Moore machine changes state **only** on the positive edge of the clock. Its output is true only if the previous two inputs were true.
State variables are usually tracked with flip-flops. These can be done with flip-flops treated as binary indexes for each state or with **one hot state** such that one state is tracked with one flip-flop.
### Mealy machine
A Mealy machine changes state **asynchronously**. Its output is true only if the current and past inputs are true.
| state | $w=0$ | $w=1$ | output |
| --- | --- | --- | --- |
| A | A | B | 0 |
| B | A | B | 1 |
### Minimising state
An **equivalent state** is such that each input has the same output and an equivalent next state. Reducing the number of redundant equivalent states minimises the number of states needed.
1. Group states by outputs
2. For each state, if not all states transition to the same group, subgroup them such that they do
3. Repeat as necessary
## Asynchronous sequential circuits
ASCs hae no clocks, relying on feedback from outputs for their memory effect.
!!! warning
ASCs break down if any of these assumptions fail.
- Only one input is allowed to change at a time
- Inputs change only after the circuit stabilises
- There is no propagation delay, although it may be compensated for with a delay element for the output / feedback
### Analysis
1. Determine logic expressions for next state and output in terms of current state and input
2. Create transition and flow tables
3. Circle stable states (will lead to itself)
4. Replace bits with letters
5. Assign bit variables to avoid changing more than one input at a time (as it is undefined)
To create a circuit:
1. Create a state diagram
2. Flow table
3. Minimise state
4. Excitation table
5. Circuit
### Reducing state
1. Partition per [#Minimising state](#minimising-state)
- *don't cares* are no longer equivalent unless both states have them in the same columns
2. States are compatible if and only if, regardless of input:
- their output is the same
- their next state is the same, is stable, or are unspecified
3. Merger diagram, identifying conflicts/compatible pairs
4. Connect diagram, merging a subset (not all) of compatible states
- states can only be in at most one subset
5. Repeat
### Avoiding races
!!! definition
- **Non-critical races** result in the same stable end state.
- **Critical races** cause *problems*.
- A **hazard** is unwanted switching due to unequal propagation delays.
To avoid races: an $n$-dimensional cube with one vertex per state, ensuring that changes only move along one edge. If more states are needed to avoid this, they are automagically *unstable*.
Alternatively, if $n\leq 4$, a state $A$ can be split into equivalent states $A1, A2$.
1. Create a cube with $2n$ vertices
2. Pairs must be adjacent
3. Determine next states by following cube lines only
Alternatively, each state can be assigned exactly one `1` bit, and transitions from one to another have `1`s at the states they transition between.
### Hazards
**Static-1/0 hazards** occur when output should stay constant, but suddenly flickers to the other. These can be fixed by covering minterms adjacent but not connected with another gate as an extra check.
**Dynamic hazards** occur when outputs flip multiple times before stabilising. These can be avoided by switching everything to 2-term POS or SOP and fixing static hazards.
## Multilevel synthesis
!!! definition
- A **literal** is an input character.
- An **implicant** is a collection of inputs that results in a true output.
- A **prime implicant** is such that no literals can be removed while remaining an implicant.
- A **cover** is a set of implicants that cover every possible way $f=1$.
- An **essential prime implicant** is such that there is no other prime implicant that fulfill a necessary condition to make $f$ true.
TO reduce fan-in, multi-input ANDs and ORs can be broken up to multiple versions of their nested form via **factoring**.
$$abcde\to(abc)(de)$$
**Functional decomposition** takes common terms and only calculates them first before feeding that input into the rest of the circuit.
### Tabular method
Cost is minimised when all essential prime implicants are present and the fewest number of prime implicants for the remaining terms.
1. List minterms, group by the number of ones in binary (don't cares can be treated as minterms)
2. Write the implicant for each
3. For each group, if an implicant differs by one bit from an implicant in the group above, merge them (replacing the distinctive term with $x$) and check that minterm / implicant off
4. Repeat, ensuring that $x$ only merges with $x$ in the same columns
Implicants not checked off are prime implicants.
1. List all primes and the minterms they cover as a table, excluding don't cares
- Minterms with only one prime have that as an essential prime
2. Primes that cover the same minterms as another but also more are objectively better (**row dominance**)
3. Make educated guesses to minimise prime implicants
Alternatively, instead of removing **dominated rows**, **dominatING columns** can be removed instead.
### Petrick method
Once reduced to tablular form:
1. For each column, sum all the possible ways a minterm can be covered, then product those sums
2. Expand and simplify, then choose the products with the least number of literals
3. Each product is a solution if you replace the product with a sum of the multiplied literals instead
## VHDL
VHDL is a hardware schematic language.
<img src="https://static.javatpoint.com/tutorial/digital-electronics/images/multiplexer3.png" width=600 />
For example, the basic 2-to-1 multiplexer expressed above can be programmed as:
```vhdl
entity two_one_mux is
port (a0, s, a1 : in bit;
f : out bit);
end two_one_mux
architecture LogicFunc of two_one_mux is
begin
y <= (a0 AND s) OR (NOT s AND a1);
end LogicFunc;
```
In this case, the inputs are `a0, s, a1` that lead to an output `y`. All input/output is of type `bit` (a boolean).
The **architecture** defines how inputs translate to outputs via functions. These all run **concurrently**.

View File

@ -1,511 +0,0 @@
# ECE 140: Linear Circuits
## Voltage, current, and resistance
Please see [SL Physics 1#Electric potential](/g11/sph3u7#electric-potential) for more information on voltage.
Please see [SL Physics 1#5.2 - Heating effect of electric currents](/g11/sph3u7/#52-heating-effect-of-electric-currents) for more information on current.
Please see [SL Physics 1#Resistance](/g11/sph3u7/#resistance) for more information on resistance.
**Electric charge** $Q$ quantises the charge of electrons and positive ions, and is expressed in coulombs (**C**).
Objects with charge generate electric fields, thus granting potential energy that is released upon proximity to another charge.
!!! warning
Voltage and current are capitalised in **direct current only** ($V$, $I$). In general use, their lowercase forms should be used instead ($v, $i$).
**Voltage** is related to the change in energy ($dw$) over the change in charge ($dq$), or alternatively through Ohm's law:
$$i=\frac{dw}{dq}=\frac{i}{R}$$
**Current** represents the rate of flow of charge in amps (**A**). Conventional current moves opposite electron flow because old scientists couldn't figure it out properly.
$$i=\frac{dq}{dt}\approx \frac{\Delta q}{\Delta t}$$
### Power
Power represents the rate of doing work, in unit watts ($\pu W$, \pu{J/s})
$$P=\frac{dw}{dt}$$
It is also directly related to voltage and current:
$$P=vi$$
Much like relative velocity, power is directional and relative, with a positive sign indicating the direction of conventional current.
$$P_{CB}=-P_{BC}$$
In a closed system, conservation of energy applies:
$$\sum P_\text{in}=\sum P_\text{out}$$
The **ground** is the "absolute zero" voltage with a maximum potential difference. It is also known as the "reference voltage".
### Independent energy sources
!!! definition
- A **ground** is the reference point that all **potential differences are relative to**.
A **generic voltage source** provides a known potential difference between its two terminals that is defined by the source. The resultant current can be calculated.
<img src="https://upload.wikimedia.org/wikipedia/commons/f/ff/Voltage_Source.svg" width=100>(Source: Wikimedia Commons)</img>
A **generic current source** provides a known amperage between its two terminals that is defined by the source. The resultant voltage can be calculated.
<img src="https://upload.wikimedia.org/wikipedia/commons/b/b2/Current_Source.svg" width=100>(Source: Wikimedia Commons)</img>
!!! tip
A current in the **positive direction** indicates that the source is releasing power (is a source). Otherwise, it is consuming power (is a load).
### Dependent energy sources
A **dependent <&ZeroWidthSpace;T: voltage | current> source** has a **T** dependent on the voltage or current elsewhere in the circuit. $k$ is a function that is likely but not guaranteed to be linear.
$$
v=kv_0\ |\ ki_0 \\
i=kv_0\ |\ ki_0
$$
<img src="https://upload.wikimedia.org/wikipedia/commons/5/55/Voltage_Source_%28Controlled%29.svg" width=100>(Source: Wikimedia Commons)</img>
<img src="https://upload.wikimedia.org/wikipedia/commons/f/fe/Current_Source_%28Controlled%29.svg" width=100>(Source: Wikimedia Commons)</img>
### Applications
A **cathode ray tube** produces an electron beam of variable intensity depending on the input signal. Electrons are deflected by the screen to produce imagery.
<img src="/resources/images/crt.png" />
### Resistance
A **resistor** *always absorbs power*, so must be oriented such that current goes into the positive sign.
According to Ohm's law, the voltage, current, and resistance are related:
$$v=iR$$
The **conductance** of a resistor is the inverse of its resistance, and is expressed in siemens ($\pu{S}$)
$$G=\frac 1 R = \frac I V$$
Therefore, power can be expressed by manipulating the equations:
$$
\begin{align*}
P &= IR^2 \\
&= V^2G \\
&= \frac{V^2}{R}
\end{align*}
$$
## Kirchhoff's laws
!!! definition
- A **node** is any point in the circuit to which 3+ elements are *directly* connected (i.e., all junctions).
- A **supernode** is any connected group in the circuit to which 3+ elements are *directly* connected.
- A **loop** is any closed path of elements.
Kirchhoff's **current law** states that the sum of all current entering a node must be zero, where positive indicates current entrance.
$$\sum i_\text{entering node}=0$$
Kirchoff's **voltage law** states that the sum of all voltage in a **closed loop** must be zero.
$$\sum v_\text{loop}=0$$
### Nodal analysis
Nodal analysis uses the voltages at the **nodes** instead of elements to calculate things in a three-step process:
1. Determine a reference node with $v=0$ and stick a ground out of that node.
2. Use KCL and Ohm's law on non-reference nodes to get their currents in terms of the reference node.
3. Solve the system of equations with the formula below.
On either side of a resistor, the current flowing that entire segment can be determined via the following formula:
$$i=\frac{v_\text{higher}-v_\text{lower}}{R}$$
### Mesh analysis
!!! definition
- A **mesh** is a loop with no inner loops.
- A **supermesh** is a combination of multiple meshes that share a common current source.
Mesh / loop analysis is used to determine unknown currents, using KVL instead of KCL to create a system of equations.
1. Assign mesh currents to each loop.
2. Use KVL and Ohm's law to get voltages in terms of mesh currents.
3. Solve the system of equations.
It may be easier to delete the branch of the current source in supermeshes, treating the region as one mesh with multiple mesh currents.
## Linearity
Circuits are linear if and only if their voltages, resistances, and currents can be expressed in terms of linear transformations of one another. They contain only linear loads, linear dependent sources, and independent souces.
$$\text{output}\propto\text{input}+C$$
!!! example
Halving voltage must halve current (or at least halve it relative to a base current / voltage).
### Superposition
In linear circuits, the superposition principle states that the voltage/current through an element is equal to the sum of the voltages/currents from each independent source alone.
$$
v=\sum v_x \\
i=\sum i_x
$$
To do so, each unused independent source should be replaced with a short circuit (voltage) or an open circuit (current).
### Source transformation
In linear circuits, a voltage source in series with a resistor can be replaced by a current source in parallel to that resistor (or vice versa), so long as Ohm's law is followed for the replacement:
$$v_1=i_2R$$
The arrow of the current source must point in the positive direction of the voltage source. This can also be used with dependent sources.
### Thevenin's theorem
Any part of a circuit including an independent source can be replaced with exactly one voltage source and a resistor in series. Two circuits are **Thevenin equivalent** if their $\lambda$ are equal in $V=\lambda I$.
If there are no dependent sources, all independent sources should be removed to determine the resistance across points $AB$:
$$R_{Th}=R_{AB}$$
Otherwise, $V_{AB}$ and $I_{AB}$ should be found by repeating these steps:
1. Cut off the load (open if finding voltage, short if finding current)
- If dependent sources depend on elements inside the load branch, zero them
2. Use analysis to determine the desired quantity
Across the load:
$$
I_L=\frac{V_{Th}}{R_{Th}+R_L} \\
V_L=R_LI_L = \frac{R_L}{R_{Th}+R_L}V_{Th}
$$
!!! warning
A negative resistance $R_{L}$ indicates that the load supplies power.
### Maximum power transfer
To maximise the power transferred from the circuit to the load, $R_L$ should be equal to $R_{Th}$.
$$P_L=v_Li_L$$
## Operational amplifiers
The entire op-amp follows KCL. The output current is the sum of all input currents (the two inputs and V+, V-).
Where $\Delta V$ is the difference between the two inputs, and $A$ is the gain of the opamp:
$$\boxed{V_{out}=A\Delta V}$$
Output voltage is limited by the maximum/minimum of the power supply $V_cc$.
If the output is fed directly into the inverting input (as a **voltage follower**), the gain is ignored and results in $V_{out}=\Delta V$.
An **ideal opamp** has no input current and equal voltages entering the opamp.
$$
\boxed{i_1=i_2=0} \\
\boxed{v_1=v_2}
$$
**Inverting amplifiers** feed their input back and return negative voltage.
$$V_{out}=-\frac{R_f}{R_i}V_{in}$$
<img src="https://upload.wikimedia.org/wikipedia/commons/4/41/Op-Amp_Inverting_Amplifier.svg" width=700>(Source: Wikimedia Commons)</img>
**Non-inverting amplifiers** moves the voltage source to the non-inverting terminal.
$$v_o=\left(1+\frac{R_f}{R_i}v_i\right)$$
<img src="https://upload.wikimedia.org/wikipedia/commons/6/66/Operational_amplifier_noninverting.svg" width=700>(Source: Wikimedia Commons)</img>
**Voltage followers** have either $R_f=0$ or $R_i=\infty$, so:
$$v_o=v_i$$
<img src="https://upload.wikimedia.org/wikipedia/commons/f/f7/Op-Amp_Unity-Gain_Buffer.svg" width=700>(Source: Wikimedia Commons)</img>
A **summing amplifier** splits an inverting amplifier's input into multiple voltage sources in series with resistances, all parallelised into the opamp:
$$v_o=-R_f\left(\frac{V_1}{R_1}+\frac{V_2}{R_2}+\frac{V_3}{R_3}\right)$$
<img src="https://upload.wikimedia.org/wikipedia/commons/3/3e/Op-Amp_Summing_Amplifier.svg" width=700>(Source: Wikimedia Commons)</img>
A **difference amplifier** is funky. To ensure that output is zero when inputs are equal, $\frac{R_1}{R_2}=\frac{R_3}{R_4}$.
$$v_o=\frac{R_2}{R_1}(v_2-v_1)$$
<img src="https://upload.wikimedia.org/wikipedia/commons/a/a2/Op-Amp_Differential_Amplifier.svg" width=700>(Source: Wikimedia Commons)</img>
## Capacitors
Capacitors are open circuits in DC that store energy in electric fields. Capacitance is measured in **farads** ($\pu{1 F = 1 C/V}$).
Where $A$ is the cross-section area of the wire, $\epsilon$ is the permittivity of the dielectric, and $d$ is the distance between plates:
$$C=\frac{\epsilon A}{d}$$
Capacitors charge only when power is positive ($VI>0$).
For linear capacitors:
$$i=C\frac{dv}{dt}$$
$$v(t)=\frac{1}{C}\int^t_{t_0}i(t)dt+v(t_0)$$
The energy in a capacitor can be interconverted.
$$U=\frac 1 2 CV^2$$
Capacitor rules are the opposite of resistor rules.
- In parallel: $C_{eq} = C_1 + C_2 + ...$
- In series: $\frac{1}{C_{eq}} = \frac{1}{C_1} + \frac{1}{C_2} + ...$
## Inductors
Inductors store energy in their magnetic field. Inductance is measured in **henrys** ($\pu{1 H = 1 V\cdot S/A}$). An ideal inductor has zero resistance and capacitance
Where $L$ is the inductance (opposition of charge flow):
$$V=L\frac{di}{dt}$$
Inductor rules are the same as resistor rules.
### Selenoids
Selenoids have an inductance based on their cross sectional area $A$, number of coils $N$, length $\ell$, and core permeability $\mu$:
$$L=\frac{N^2\mu A}{\ell}$$
Where $i(t_0)$ is the total current for $-\infty<t<t_0$
$$i=\frac 1 L\int^t_{t_0}v(t)dt + i(t_0)$$
Much like capacitors, inductors have energy now based on current.
$$U=\frac 1 2 Li^2$$
## First-order circuits
!!! definition
- An **RC** circuit contains a resistor and a capacitor.
- An **RL** circuit contains a resistor and an inductor.
- **First-order circuits** contain derivatives.
- A **source-free circuit** assumes that energy already exists in the capacitor/inductor and no external energy enters the system.
- The **circuit response** is the behaviour of the circuit after excitation.
- The **natural response** is the behaviour of the circuit without external excitation.
The **time constant** $\tau$ is the time requirement for the circuit to decay to $\frac 1 e$ of its initial value. For RC circuits:
$$\tau=RC$$
$$v(t)=v_0e^{-t/\tau}$$
RL circuits have very similar formulae:
$$\tau=\frac L R$$
$$i(t)=i_0e^{-t/\tau}$$
### Singularity functions
The **unit step function** is a stair that is undefined at zero.
$$
u(t)=\begin{cases}
0 & \text{if }t<0 \\
1 & \text{if }t>0
$$
The **unit impulse/delta function** is the derivative of the unit step function.
$$
\delta(t)=\frac{d}{dt}u(t)=\begin{cases}
0 & \text{if }t<0 \\
\text{undefined} & \text{if }t=0 \\
0 & \text{if }t>0
$$
The sudden spike at $t=0$ means that $\int^{0+}_{0-}\delta(t)dt=1$.
This function is related to signal strength. For the function $a\delta(t+y)$, changing $y$ shifts the phase while shifting $a$ shifts amplitude.
To obtain $f(t)$ at the impulse:
$$\int^b_a\delta(t-t_0)dt=f(t_0$$
The **unit ramp function** is the integral of the unit step function.
\begin{align*}
r(t)&=\int^1_{-\infty}u(\lambda)d\lambda=tu(t) \\
&=\begin{cases}
0 & \text{if }t\leq 0 \\
t & \text{if }t\geq 0
\end{cases}
\end{align*}
## Circuit responses
The total response to a circuit $V$ can be expressed as various combinations of:
- the natural response, $v_n=v_0e^{-t/\tau}$
- the forced response (induced) $v_f=v_s(1-e^{-t\tau})$
- the temporary response, $(v_0-v_s)e^{-1/t}$
- the permanent/steady-state response, $v_s$
$$
v(t)=\begin{cases}
v_0 & \text{if }t<0 \\
v_s+(v_0-v_s)e^{-t/\tau} &\text{if }t>0
\end{cases}
$$
In general, for current and voltage ($x$), where $x_\infty$ is the final value and $x_0$ is the initial value:
$$\boxed{x(t)=x(\infty)+[x(0)-x(\infty)]^{-t/\tau}}$$
A delayed response by $t_0$ shifts $t$ to $t-t_0$ and $x(0)$ to $x(t_0)$.
## Alternating current
Where $V_m$ is the amplitude of the voltage and $\omega$ is its angular frequency:
$$v(t)=V_m\sin(\omega t)$$
For a sinusoid's period $T$, a circuit is period if and only if, for all $n\in\mathbb Z$:
$$v(t)=v(t+nT)$$
### Phasors
The **phasor** is the complex number vector version of the sinusoid in the time domain.
$$v(t)=\text{Re}(\bold Ve^{j\omega t})$$
Please see [MATH 115: Linear Algebra#Geometry](/1a/math115/#geometry) for more information.
$$\bold V=V_m^{j\phi}$$
To transform time domains to frequency domains:
| Sinusoidal | Phasor |
| --- | --- |
| $V_m\cos(\omega t+\phi)$ | $V_m\angle\phi$ |
| $V_m\sin(\omega t+\phi)$ | $V_m\angle\phi-90^\circ$ |
The **derivative** of a phasor is itself multiplied by $j\omega$.
$$\frac{d}{dt}\bold V=j\omega\bold V$$
Adding sinusoids of the **same frequency** ($\omega$) is equivalent to adding their phasors.
If $\bold V$ and $\bold I$ are phasors:
- Inductors: $\bold V=j\omega L\bold I$ ($\bold I$ lags $\bold V$ by 90°)
- Capacitors: $\bold V=\frac{I}{j\omega C}$ ($\bold V$ lags $\bold I$ by 90°)
The **scalar** quantity of **impedance** represents the opposition to electron flow, measured in ohms.
$$Z=\frac{1}{j\omega C}=j\omega L$$
It is effectively generalised resistance. Where $X$ is a positive value representing **reactance** such that $+jX$ implies inductance while $-jX$ implies capacitance:
$$Z=\frac{\bold V}{\bold I}=R\pm jX$$
**Admittance** is the inverse of impedance with units Siemens/mhos with factors **conductance** and **susceptance**:
$$Y=G+jB$$
Arranging equations yields
$$
G=\frac{R}{R^2+X^2} \\
B=-\frac{X}{R^2+X^2}
$$
### Steady state analysis
**Kirchoff's laws** only hold for phasor forms.
1. Convert to phasor forms
2. Solve phasor forms
3. Convert back to time domain
Superposition must be summed at the end only, although individual components can first be solved.
1. Convert to phasor forms
2. Solve each individual current/voltage that make KCL/KVL
3. Convert to time domain
4. Apply KCL/KVL
When applying source transformations, different equivalent circuits for **each frequency** must be calculated individually — reducing it to one equivalent circuit is not possible.
### Power
The average power is the integral average of instantaneous power:
$$P=\frac 1 T \int^T_0 p(t)dt$$
!!! tip
The average of a sinusoid over its period is zero.
Alternatively, power can be calculated with magnitudes:
$$P=\frac 1 2\text{Re}[VI^*]=\frac 1 2 V_mI_m\cos(\theta_v-\theta_i)$$
The same rules for maximum power transfer apply with resistance, but with $Z_L$ as the **complex conjugate** of $Z_{Th}$. The maximum power has a shortcut formula:
$$P_{max}=\frac{|V_{Th}^2}{8R_{Th}}$$
The **effective value** of a sinusoid is its DC equivalent. It is the root mean square.
$$X_{rms}=\sqrt{\frac 1 T\int^T_0x^2dt}$$
The **apparent power** $S$ is the seemingly true power.
$$S=V_{rms}I_{rms}$$
The **power factor (pf)** is the required factor to take the apparent power into real power.
$$pf=\frac P S = \cos(\theta_v-\theta_i)$$
The **power factor angle** $\theta_v-\theta_i$ is the angle of local impedance between voltage and current.
$$Z=\frac{V_{rms}}{I_{rms}}\phase{\theta_v-\theta_i}=\frac{V_m}{I_m}\phase{\theta_v-\theta_i}$$
- A **leading** power factor has current lead voltage (capacitive)
- A **lagging** power factor has voltage lead current (inductive)
- A **unity** power factor has no phase shift
Complex power $\bold S$ stores more phase information where $\bold{V_{rms}}=V_{rms}\phase{\theta_v}$.
$$\bold S=\frac 1 2\bold{VI}^*=\bold{V_{rms}I^*_{rms}}$$
These have units volt-amperes (VA).
$$\bold S=V_{rms}I_{rms}\phase{\theta_v-\theta_i}=V_{rms}I_{rms}\cos(\theta_v-\theta_i)+jV_{rms}I_{rms}\sin(\theta_v-\theta_i)$$
The two components of complex power are actual power $P=I^2_{rms}R$ and reactive power $Q=I^2_{rms}X$, the latter with units VAR (volt-ampere reactive).
$$\bold S=P+jQ$$
Complex power still follows most DC laws:
$$\bold S=I^2_{rms}\bold Z=\frac{V^2_{rms}}{\bold Z^*}=\bold{V_{rms}I^*_{rms}}$$
All powers (instantaneous, real, reactive, and complex) are conserved, except for apparent power.

View File

@ -1,3 +0,0 @@
# ECE 192: Engineering Economics
History is better!

View File

@ -1,851 +0,0 @@
# MATH 119: Calculus 2
## Multivariable functions
!!! definition
- A **multivariable function** accepts more than one independent variable, e.g., $f(x, y)$.
The signature of multivariable functions is indicated in the form *[identifier]*: *[input type]**[return type]*. Where $n$ is the number of inputs:
$$f: \mathbb R^n \to \mathbb R$$
!!! example
The following function is in the form $f: \mathbb R^2\to\mathbb R$ and maps two variables into one called $z$ via function $f$.
$$(x,y)\longmapsto z=f(x,y)$$
### Sketching multivariable functions
!!! definition
- In a **scalar field**, each point in space is assigned a number. For example, topography or altitude maps are scalar fields.
- A **level curve** is a slice of a three-dimensional graph by setting to a general variable $f(x, y)=k$. It is effectively a series of contour plots set in a three-dimensional plane.
- A **contour plot** is a graph obtained by substituting a constant for $k$ in a level curve.
Please see [level set](https://en.wikipedia.org/wiki/Level_set) and [contour line](https://en.wikipedia.org/wiki/Contour_line) for example images.
In order to create a sketch for a multivariable function, this site does not have enough pictures so you should watch a YouTube video.
!!! example
For the function $z=x^2+y^2$:
For each $x, y, z$:
- Set $k$ equal to the variable and substitute it into the equation
- Sketch a two-dimensional graph with constant values of $k$ (e.g., $k=-2, -1, 0, 1, 2$) using the other two variables as axes
Combine the three **contour plots** in a three-dimensional plane to form the full sketch.
A **hyperbola** is formed when the difference between two points is constant. Where $r$ is the x-intercept:
$$x^2-y^2=r^2$$
<img src="/resources/images/hyperbola.svg" width=600 />
If $r^2$ is negative, the hyperbola is is bounded by functions of $x$, instead.
## Limits of two-variable functions
A function is continuous at $(x, y)$ if and only if all possible lines through $(x, y)$ have the same limit. Or, where $L$ is a constant:
$$\text{continuous}\iff \lim_{(x, y)\to(x_0, y_0)}f(x, y) = L$$
In practice, this means that if any two paths result in different limits, the limit is undefined. Substituting $x|y=0$ or $y=mx$ or $x=my$ are common solutions.
!!! example
For the function $\lim_{(x, y)\to (0,0)}\frac{x^2}{x^2+y^2}$:
Along $y=0$:
$$\lim_{(x,0)\to(0, 0)} ... = 1$$
Along $x=0$:
$$\lim_{(0, y)\to(0, 0)} ... = 0$$
Therefore the limit does not exist.
## Partial derivatives
Partial derivatives have multiple different symbols that all mean the same thing:
$$\frac{\partial f}{\partial x}=\partial_x f=f_x$$
For two-input-variable equations, setting one of the input variables to a constant will return the derivative of the slice at that constant.
By definition, the **partial** derivative of $f$ with respect to $x$ (in the x-direction) at point $(a, B)$ is:
$$\frac{\partial f}{\partial x}(a, B)=\lim_{h\to 0}\frac{f(a+h, B)-f(a, B)}{h}$$
Effectively:
- if finding $f_x$, $y$ should be treated as constant.
- if finding $f_y$, $x$ should be treated as constant.
!!! example
With the function $f(x,y)=x^2\sqrt{y}+\cos\pi y$:
\begin{align*}
f_x(1,1)&=\lim_{h\to 0}\frac{f(1+h,1)-f(1,1)} h \\
\tag*{$f(1,1)=1+\cos\pi=0$}&=\lim_{h\to 0}\frac{(1+h)^2-1} h \\
&=\lim_{h\to 0}\frac{h^2+2h} h \\
&= 2 \\
\end{align*}
### Higher order derivatives
!!! definition
- **wrt.** is short for "with respect to".
$$\frac{\partial^2f}{\partial x^2}=\partial_{xx}f=f_{xx}$$
Derivatives of different variables can be combined:
$$f_{xy}=\frac{\partial}{\partial y}\frac{\partial f}{\partial x}=\frac{\partial^2 f}{\partial xy}$$
The order of the variables matter: $f_{xy}$ is the derivative of f wrt. x *and then* wrt. y.
**Clairaut's theorem** states that if $f_x, f_y$, and $f_{xy}$ all exist near $(a, b)$ and $f_{yx}$ is continuous **at** $(a,b)$, $f_{yx}(a,b)=f_{x,y}(a,b)$ and exists.
!!! warning
In multivariable calculus, **differentiability does not imply continuity**.
### Linear approximations
A **tangent plane** represents all possible partial derivatives at a point of a function.
For two-dimensional functions, the differential could be used to extrapolate points ahead or behind a point on a curve.
$$
\Delta f=f'(a)\Delta d \\
\boxed{y=f(a)+f'(a)(x-a)}
$$
The equations of the two unit direction vectors in $x$ and $y$ can be used to find the normal of the tangent plane:
$$
\vec n=\vec d_1\times\vec d_2 \\
\begin{bmatrix}-f_x(a,b) \\ -f_y(a,b) \\ 1\end{bmatrix} = \begin{bmatrix}1\\0\\f_x(a,b)\end{bmatrix}
\begin{bmatrix}0\\1\\f_y(a,b)\end{bmatrix}
$$
Therefore, the general expression of a plane is equivalent to:
$$
z=C+A(x-a)+B(x-b) \\
\boxed{z=f(a,b)+f_x(a,b)(x-a)+f_y(a,b)(y-b)}
$$
??? tip "Proof"
The general formula for a plane is $c_1(x-a)+c_2(y-b)+c_3(z-c)=0$.
If $y$ is constant such that $y=b$:
$$z=C+A(x-a)$$
which must represent in the x-direction as an equation in the form $y=b+mx$. It follows that $A=f_x(a,b)$. A similar concept exists for $f_y(a,b)$.
If both $x=a$ and $y=b$ are constant:
$$z=C$$
where $C$ must be the $z$-point.
Usually, functions can be approximated via the **tangent at $x=a$.**
$$f(x)\simeq L(x)$$
!!! warning
Approximations are less accurate the stronger the curve and the farther the point is away from $f(a,b)$. A greater $|f''(a)|$ indicates a stronger curve.
!!! example
Given the function $f(x,y)=\ln(\sqrt[3]{x}+\sqrt[4]{y}-1)$, $f(1.03, 0.98)$ can be linearly approximated.
$$
L(x=1.03, y=0.98)=f(1,1)=f_x(1,1)(x-1)+f_y(1,1)(y-1) \\
f(1.03,0.98)\simeq L(1.03,0.98)=0.005
$$
### Differentials
Linear approximations can be used with the help of differentials. Please see [MATH 117#Differentials](/1a/math117/#differentials) for more information.
$\Delta f$ can be assumed to be equivalent to $df$.
$$\Delta f=f_x(a,b)\Delta x+f_y(a,b)\Delta y$$
Alternatively, it can be expanded in Leibniz notation in the form of a **total differential**:
$$df=\frac{\partial f}{\partial x}dx+\frac{\partial f}{\partial y}dy$$
??? tip "Proof"
The general formula for a plane in three dimensions can be expressed as a tangent plane if the differential is small enough:
$$f(x,y)=f(a,b)+f_x(a,b)(x-a)+f_y(a,b)(x-b)$$
As $\Delta f=f(x,y)-f(a,b)$, $\Delta x=x-a$, and $\Delta y=y-b$, it can be assumed that $\Delta x=dx,\Delta y=dy, \Delta f\simeq df$.
$$\boxed{\Delta f\simeq df=f_x(a,b)dx+f_y(a,b)dy}$$
### Related rates
Please see [SL Math - Analysis and Approaches 1](/g11/mhf4u7/#related-rates) for more information.
!!! example
For the gas law $pV=nRT$, if $T$ increases by 1% and $V$ increases by 3%:
\begin{align*}
pV&=nRT \\
\ln p&=\ln nR + \ln T - \ln V \\
\tag{multiply both sides by $d$}\frac{d}{dp}\ln p(dp)&=0 + \frac{d}{dT}\ln T(dt)-\frac{d}{dV}\ln V(dV) \\
\frac{dp}{p} &=\frac{dT}{T}-\frac{dV}{V} \\
&=0.01-0.03 \\
&=-2\%
\end{align*}
### Parametric curves
Because of the existence of the parameter $t$, these expressions have some advantages over scalar equations:
- the direction of $x$ and $y$ can be determined as $t$ increases, and
- the rate of change of $x$ and $y$ relative to $t$ as well as each other is clearer
$$
\begin{align*}
f(x,y,z)&=\begin{bmatrix}x(t) \\ y(t) \\ z(t)\end{bmatrix} \\
&=(x(t), y(t), z(t))
\end{align*}
$$
The **derivative** of a parametric function is equal to the vector sum of the derivative of its components:
$$\frac{df}{dt}=\sqrt{\left(\frac{dx}{dt}\right)^2+\left(\frac{dy}{dt}\right)^2+\left(\frac{dz}{dt}\right)^2}$$
Sometimes, the **chain rule for multivariable functions** creates a new branch in a tree for each independent variable.
For two-variable functions, if $z=f(x,y)$:
$$\frac{dz}{dt}=\frac{\partial z}{\partial x}\frac{dx}{dt}+\frac{\partial z}{\partial y}\frac{dy}{dt}$$
Sample tree diagram:
<img src="/resources/images/two-var-tree.jpg" width=300>(Source: LibreTexts)</img>
!!! example
This can be extended for multiple functions — for the function $z=f(x,y)$, where $x=g(u,v)$ and $y=h(u,v)$:
<img src="/resources/images/many-var-tree.jpg" width=300>(Source: LibreTexts)</img>
Determining the partial derivatives with respect to $u$ or $v$ can be done by only following the branches that end with those terms.
$$
\frac{\partial z}{\partial u} = \frac{\partial z}{\partial x}\frac{\partial x}{\partial u} + \frac{\partial z}{\partial y}\frac{\partial y}{\partial u} \\
$$
!!! warning
If the function only depends on one variable, $\frac{d}{dx}$ is used. Multivariable functions must use $\frac{\partial}{\partial x}$ to treat the other variables as constant.
### Gradient vectors
The **gradient vector** is the vector of the partial derivatives of a function with respect to its independent variables. For $f(x,y)$:
$$\nabla f=\left(\frac{\partial f}{\partial x},\frac{\partial f}{\partial y}\right)$$
This allows for the the following replacements to appear more like single-variable calculus. Where $\vec r=(x,y)$ is a desired point, $\vec a=(a,b)$ is the initial point, and all vector multiplications are dot products:
Linear approximations are simplified to:
$$f(\vec r)=f(\vec a)+\nabla f(\vec a)\bullet(\vec r-\vec a)$$
The chain rule is also simplified to:
$$\frac{dz}{dt}=\nabla f(\vec r(t))\bullet\vec r'(t)$$
A **directional derivative** is any of the infinite derivatives at a certain point with the length of a unit vector. Specifically, in the unit vector direction $\vec u$ at point $\vec a=(a,b)$:
$$D_{\vec u}f(a_b)=\lim_{h\to 0}\frac{f(\vec a+h\vec u)\bullet f(\vec a)}{h}$$
This reduces down by taking only $h$ as variable to:
$$D_{\vec u}f(a,b)=\nabla f(a,b)\bullet\vec u$$
Cartesian and polar coordinates can be easily converted between:
- $x=r\sin\theta\cos\phi$
- $y=r\sin\theta\sin\phi$
- $z=r\cos\theta$
## Optimisation
**Local maxima / minima** exist at points where all points in a disk-like area around it do not pass that point. Practically, they must have $\nabla f=0$.
**Critical points** are any point at which $\nabla f=0|undef$. A critical point that is not a local extrema is a **saddle point**.
Local maxima tend to be **concave down** while local minima are **concave up**. This can be determined via the second derivative test. For the critical point $P_0$ of $f(x,y)$:
1. Calculate $D(x,y)= f_{xx}f_{yy}-(f_{xy})^2$
2. If it greater than zero, the point is an extremum
a. If $f_{xx}(P_0)<0$, the point is a maximum otherwise it is a minimum
3. If it is less than zero, it is a saddle point — otherwise the test is inconclusive and you must use your eyeballs
### Optimisation with constraints
If there is a limitation in optimising for $f(x,y)$ in the form $g(x,y)=K$, new critical points can be found by setting them equal to each other, where $\lambda$ is the **Lagrange multiplier** that determines the rate of increase of $f$ with respect to $g$:
$$\nabla f = \lambda\nabla g, g(x,y)=K$$
The largest/smallest values of $f(x,y)$ from the critical points return the maxima/minima. If possible, $\nabla g=\vec 0, g(x,y)=K$ should also be tested **afterward**.
!!! example
If $A(x,y)=xy$, $g(x,y)=K: x+2y=400$, and $A(x,y)$ should be maximised:
\begin{align*}
\nabla f &= \left<y, x\right> \\
\nabla g &= \left<1, 2\right> \\
\left<y, x\right> &= \lambda \left<1, 2\right> \\
&\begin{cases}
y &= \lambda \\
x &= 2\lambda \\
x + 2y &= 400 \\
\end{cases}
\\
\\
\therefore y&=100,x=200,A=20\ 000
\end{align*}
??? example
If $f(x,y)=y^2-x^2$ and the constraint $\frac{x^2}{4} + y^2=1$ must be satisfied:
\begin{align*}
\nabla f &=\left<-2x, 2y\right> \\
\nabla g &=\left<\frac{1}{2} x,2y\right> \\
\tag{$\left<0,0\right>$ does not satisfy constraints} \left<-2x,2y\right>&=\lambda\left<-\frac 1 2 x,2y\right> \\
&\begin{cases}
-2x &= \frac 1 2\lambda x \\
2y &= \lambda2y \\
\frac{x^2}{4} + y^2&= 1
\end{cases} \\
\\
2y(1-\lambda)&=0\implies y=0,\lambda=1 \\
&\begin{cases}
y=0&\implies x=\pm 2\implies\left<\pm2, 0\right> \\
\lambda=1&\implies \left<0,\pm 1\right>
\end{cases}
\\
\tag{by substitution} \max&=(2,0), (-2, 0) \\
\min&=(0, -1), (0, 1)
\end{align*}
??? example
If $f(x, y)=x^2+xy+y^2$ and the constraint $x^2+y^2=4$ must be satisfied:
\begin{align*}
\tag{domain: bounded at $-2\leq x\leq 2$}y=\pm\sqrt{4-x^2} \\
f(x,\pm\sqrt{4-x^2}) &= x^2+(\pm\sqrt{4-x^2})x + 4-x^2 \\
\frac{df}{dx} &=\pm(\sqrt{4-x^2}-\frac{1}{2}\frac{1}{\sqrt{4-x^2}}2x(x)) \\
\tag{$f'(x)=0$} 0 &=4-x^2-x^2 \\
x &=\pm\sqrt{2} \\
\\
2+y^2 &= 4 \\
y &=\pm\sqrt{2} \\
\therefore f(x,y) &= 2, 6
\end{align*}
Alternatively, trigonometric substitution may be used to solve the system parametrically.
\begin{align*}
x^2+y^2&=4\implies &x=2\cos t \\
& &y=2\sin t \\
\therefore f(x,y) &= 4+2\sin(2t),0\leq t\leq 2\pi \\
\tag{include endpoints $0,2\pi$}t &= \frac\pi 4,\frac{3\pi}{4},\frac{5\pi}{4} \\
\end{align*}
!!! warning
Terms cannot be directly cancelled out in case they are zero.
This applies equally to higher dimensions and constraints by adding a new term for each constraint. Given $f(x,y,z)$ with constraints $g(x,y,z)=K$ and $h(x,y,z)=M$:
$$\nabla f=\lambda_1\nabla g + \lambda_2\nabla h$$
### Absolute extrema
- If end points exist, those should be added
- If no endpoints exist and the limits go to $\pm\infty$, there are no absolute extrema
## Double integration
In a nutshell, double integration is done by taking infinitely small lines then finding the area under those lines to form a volume.
For a surface formed by vectors $[a,b]$ and $[c,d]$:
$$[a,b]\times[c,d]=R=\{(x,y)|a\leq x\leq b,c\leq y\leq d\}$$
If the function is continuous and bounds do not depend on variables, the order of integration doesn't matter.
$$\boxed{\int^d_c\int^b_af(x,y)dxdy}$$
!!! example
For $f(x,y)=x^2y$ and $R=[0,3]\times[1,2]$:
\begin{align*}
V&=\int^2_1\int^3_0x^2ydxdy \\
&=\int^2_1\left[\frac 1 3 3^3y\right]dy \\
&=\frac{9}{2}y^2\biggr|^2_1 \\
&=\frac 9 2 (4)-\frac 9 2 \\
&=\frac{27}{2}
\end{align*}
If the function is the product of two functions of separate variables, i.e., if $f(x,y)=g(x)\cdot h(y)$:
$$\int^b_a\int^d_cg(x)h(y)dxdy=\left(\int^b_ah(y)dy\right)\left(\int^d_cg(x)dx\right)$$
### Volume betweeen two functions
The result of the bound variable should be integrated first. For functions of $y$:
$$\int^b_a\left(\int^{g(x)}_{h(x)}f(x,y)dy\right)dx$$
Functions can also be replaced to be bounded by the other if necessary.
!!! example
For $f(x,y)$ bounded by $y=x$ and $y=\sqrt x$:
$$\int^1_0\int^{\sqrt x}_xf(x,y)dydx = \int^1_0\left(\int^y_{y^2}f(x,y)dx\right)dy$$
??? example
For $f(x,y)=xy$ bounded by $x=2$, $y=0$, and $y=2x$:
\begin{align*}
\int^2_0\int^{2x}_0xy\ dydx&=\int^2_0x\left(\frac 1 2(2x)^2\right)dx \\
&=\int^2_02x^3dx \\
&=\frac 1 4 x^4(2)\biggr|^2_0 \\
&= 8
\end{align*}
### Double polar integrals
The differential elements can be directly replaced:
$$dA=dxdy=\rho d\rho d\phi$$
In general, the radius should be the inner integral, and functions converted from Cartesian to polar forms.
$$\int^{\phi_2}_{\phi_1}\int^{\rho_2}_{\rho_1}f(\rho\cos\phi,\rho\sin\phi)\rho d\rho d\phi$$
### Change of variables
The **Jacobian** is the proportion of change in the differentials between different coordinate systems.
$$
\frac{\partial(x,y)}{\partial(u, v)}=\det\begin{bmatrix}
\partial x / \partial u & \partial x / \partial v \\
\partial y / \partial u & \partial y / \partial v
\end{bmatrix}
$$
The Jacobian can be treated as a fraction — it may be easier to determine the reciprocal of the Jacobian and then reciprocal it again.
When converting between two systems, the absolute value of the Jacobian should be incorporated.
$$dA=\left|\frac{\partial(x,y)}{\partial(u,v)}\right|du\ dv$$
!!! example
The Jacobian of the polar coordinate system relative to the Cartesian coordinate system is $\rho$. Therefore, $dA=\rho\ d\rho\ d\phi$.
If $x=x(u,v)$, $y=y(u,v)$, and $\partial(x,y)/\partial(u,v)\neq 0$ in the domain of $u$ and $v$ $D_{uv}$:
$$\iint_{D_{xy}}f(x,y)dA = \iint_{D_{uv}}f(x(u,v),y(u,v))\left|\frac{\partial(x,y)}{\partial(u,v)}\right|du\ dv$$
1. Pick a good transformation that simplifies the domain and/or the function.
2. Compute the Jacobian
3. Determine bounds (domain)
4. Integrate with the formula
If the Jacobian contains $x$ and/or $y$ terms:
- they can be substituted into the integral directly, praying that the terms all cancel out
- or $x$ and $y$ can be written in terms of $u$ and $v$ and then all substituted
!!! example
For the volume within $x^2y^2\sqrt{1-x^3-y^3}$ bounded by $x=0,y=0,x^3+y^3=1$:
By graphical inspection, the bounds can be determined to be $x=0,y=0, y^3=x^3-1,x=1$.
Let $u=x^3,du=3x^2dx$. Let $v=y^3,dv=3y^2dy$. The bounds change to $0\leq u\leq 1,0\leq v\leq 1-u$.
\begin{align*}
\int^1_0\int^{1-u}_0\frac 1 9\sqrt{1-u-v}\ dudv &= \int^1_0\frac{2}{27}(1-v-u)^{3/2}\biggr|^{1-u}_0du \\
&= \int^1_0\frac{2}{27}(1-u)^{3/2}du \\
&= \frac{4}{135}(1-u)^{5/2}\biggr|^1_0 \\
&= \frac{4}{135}
\end{align*}
### Applications of multiple integrals
The area enclosed within bounds $R$ is the volume with a height of 1.
$$A_R=\iint_R 1\ dA$$
!!! example
For the area between $y=(x-1)^2$ and $y=5-(x-2)^2$:
POI: $x^2-3x=0,\therefore x=0, 3$
\begin{align*}
\int^3_0\int^{5-(x-2)^2}_{(x-1)^2}dydx &=\int^3_0(5-(x-2)^2-(x-1)^2)dx \\
&=\int^3_0(-2x^2+6x)dx \\
&=-\frac 2 3x^3+3x^2\biggr|^3_0 \\
&=9
\end{align*}
!!! example
For the area of $\left(\frac x a\right)^2+\left(\frac y b\right)^2=1$ in the region $a,b>0$:
**For ellipses of this form, a direct substitution to $a\rho\cos\phi$ and $b\rho\cos\phi$ is fastest.**
Let $u=\frac x a$ and $v=\frac y b$.
$$
\frac{\partial(x,y)}{\partial(u,v)}=\det\begin{bmatrix}
a & 0 \\
0 & b
\end{bmatrix}=ab
$$
Thus $A=\iint_Rab\ du\ dv$.
Let $u=\rho\cos\phi,v=\rho\sin\phi$. Radius is 1 by inspection.
\begin{align*}
A&=\int^{2\pi}_0\int^1_0ab\rho\ d\rho\ d\phi \\
&=\int^{2\pi}\frac 1 2 ab\ d\phi \\
&=\frac 1 2 ab\phi\biggr|^{2\pi}_0 \\
&=\pi ab
\end{align*}
The average value of the function $f(x,y)$ over a region $R$, where $A_R$ is the area of the region:
$$\overline{f}_R=\frac{1}{A_R}\iint_Rf(x,y) dA$$
!!! example
The average value of $x^2+y^2$ over $x=0,x=1, y=x$:
\begin{align*}
\text{avg}&=\frac 1 A\int^1_0\int^x_0(x^2+y^2)dydx \\
&=2\int^1_0(x^2y+\frac 1 3y^3)\biggr|^x_0dx \\
&=2\int^1_0\frac 4 3 x^3dx \\
&=\frac 2 3 x^4 \biggr|^1_0 \\
&=\frac 2 3
\end{align*}
The total "amount" of within a region, if $f(x,y)$ describes the density at point $(x,y)$:
$$\iint_R f(x,y)dA$$
!!! example
The total of $x^2+y^2$ with density $\sigma=\sqrt{1-x^2-y^2}$:
Let $x^2=\rho\cos\phi,y^2=\rho\sin\phi$. Thus $\sigma=\sqrt{1-\rho^2}$.
\begin{align*}
M&=\int^{2\pi}_0\int^1_0\sqrt{1-\rho^2}\rho\ d\rho\ d\phi \\
&=\int^{2\pi}_0d\phi\int^1_0\sqrt{1-\rho^2}\ d\rho\ d\phi \\
\end{align*}
Let $u=1-\rho^2$. Thus $du=-2\rho\ d\rho$.
\begin{align*}
m&=2\pi\int^1_0-\frac 1 2\sqrt u du \\
&=\frac 2 3u^{3/2}du\biggr|^1_0 \\
&=\frac 2 3\pi
\end{align*}
## Triple integration
Much like double integrals:
The **volume** within bounds $E$ is the integral of 1:
$$V=\iiint_E1dV$$
The **average value** within a volume is:
$$\overline f_E=\frac 1 V\iiint_Ef(x,y,z)dV$$
!!! example
For the volume within $x+y+z=1$ and $2x+2y+z=2,x,y,z\geq 0$:
The points intersect the axes and each other to create the bounds $0\leq x\leq 1,0\leq y\leq 1-x,1-x-y\leq z\leq 2-2x-2y$.
$$\int^1_0\int^{1-x}_0\int^{2-2x-2y}_{1-x-y}1dz\ dy\ dx =\frac 1 6$$
The average value is:
$$6\iiint_Ez\ dV=\frac 3 4$$
The **total quantity** if $f$ represents density is:
$$T=\iiint_Ef(x,y,z)dV$$
### Cylindrical coordinates
Cylindrical coordinates are effectively polar coordinates with a height.
$$
x=\rho\cos\phi \\
y=\rho\sin\phi \\
z=z
$$
$$
\rho=\sqrt{x^2+y^2} \\
\tan\phi=\frac y x
$$
The Jacobian is still $\rho$.
!!! example
For the volume under $z=9-x^2-y^2$, outside $x^2+y^2=1$, and above the $xy$ plane:
- $0\leq z\leq 9-x^2-y^2\implies 0\leq z\leq 9-\rho^2$
- $1\leq \rho\leq 3$
- $0\leq \phi\leq 2\pi$
$$
\int^3_1\int^{2\pi}_0\int^{9-\rho^2}_0\rho\ dz\ d\rho\ d\phi =32\pi
$$
### Spherical coordinates
Where $r$ is the direct distance from the point to the origin, $\phi$ is the angle to the x-axis in the xy-plane ($[0,2\pi]$), and $\theta$ is the angle to the z-axis, top to bottom ($[0,\pi]$):
$$
z=r\cos\theta \\
x=r\sin\theta\cos\phi \\
y=r\sin\theta\sin\phi
$$
The Jacobian is $r^2\sin\theta$.
!!! example
The mass inside the sphere $x^2+y^2+z^2=9$ with density $z=\sqrt{\frac{x^2+y^2}{3}}$:
It is clear that $\tan\theta=\sqrt 3\implies\theta=\frac\pi 3,r=3$. Thus:
$$\int^3_0\int^{\pi/3}_0,\int^{2\pi}_0 \frac{\rho}{\sqrt{3}}\rho\ d\phi\ d\theta\ d\rho=\frac{243\pi}{5}$$
## Approximation and interpolation
Each of these finds roots, so a rooted equation is needed.
!!! example
To find an $x$ where $x=\sqrt 5$, the root of $x^2-5=0$ should be found.
### Bisection
1. Select two points that are guaranteed to enclose the point
2. Select an arbitrary $x$ and check if it is greater than or less than zero
3. Slice the remaining section in half in the correct direction
### Newton's method
The below formula can be repeated after plugging in an arbitrary value.
$$x_1=x_0-\frac{f(x_0)}{f'(x_0}$$
!!! warning
If Newton's method converges to the wrong root, bisection is necessary to brute force the result.
### Polynomial interpolation
Where $\Delta^k y_0$ are the $k$th differences between the $y$ points:
$$f(x)=y_0+x\Delta y_0+x(x-1)\frac{\Delta^2y_0}{2!}+x(x-1)(x-2)\frac{\Delta^3 y_0}{3!} ...$$
### Taylor polynomials
The $n$th order Taylor polynomial centred at $x_0$ is:
$$\boxed{P_{n,x_0}(x)=\sum^n_{k=0}\frac{f^{(k)}(x_0)(x-x_0)^k}{k!}}$$
**Maclaurin's theorem** states that if some function $P^{(k)}(x_0)=f^{(k)}(x_0)$ for all $k=0,...n$:
$$P(x)=P_{n,x_0}(x)$$
!!! example
If $P(x)=1+x^3+\frac{x^6}{2}$ and $f(x)=e^{x^5}}$, ... TODO
The desired function $P(x)$ being the $n$th degree Maclaurin polynomial implies that $P(kx^m)$ is the $(mn)$th degree polynomial for $f(kx^m)$.
Therefore, if you have the Maclaurin polynomial $P(x)$ where $P$ is the $n$th order Taylor polynomial:
- $P'(x)=P_{n-1,x_0}(x)$ for $f'(x)$
- $\int P(x)dx=P_{n+1,x_0}(x)$ for $\int f(x)dx$
The integration constant $C$ can be found by substituting $x_0$ as $x$ and solving.
For $m\in\mathbb Z\geq 0$, where $P(x)$ is the Maclaurin polynomial for $f(x)$ of order $n$, $x^mP(x)$ is the $(m+n)$th order polynomial for $x^mf(x)$.
### Taylor inequalities
The **triangle inequality** for integrals applies itself many times over the infinite sum.
$$\left|\int^b_af(x)dx\right|\leq\int^b_a|f(x)|dx$$
The **Taylor remainder** is the error between a Taylor polynomial and its actual value. Where $k$ is an arbitrary value chosen as the **upper bound** of the difference of the first derivative between $x_0$ and $x$: $k\geq |f^{(n+1)}(z)|$
$$|R_n(x)|\leq\frac{k|x-x_0|^{n+1}}{(n+1)!}$$
An approximation correct to $n$ decimal places requires that $|R_n(x)|<10^{-n}$.
!!! warning
$k$ should be as small as possible. When rounding, round down for the lower bound, and round up for the upper bound.
### Integral approximation
The upper and lower bounds of a Taylor polynomial are clearly $P(x)\pm R(x)$. Integrating them separately reveals creates bounds for the integral.
$$\int P(x)dx-\int R(x)dx\leq\int P(x)\leq\int P(x)dx +\int R(x)dx$$
## Infinite series
The $n$th partial sum of a sequence is used to determine divergence.
$$S_n=\sum^n_{k=0}a_k=a_0 + a_1 ... a_n$$
A sum converges to $S$ if the sum eventually ends up there. Otherwise, if the limit is infinity or does not exist, it diverges.
$$\lim_{x\to\infty}S_n=S\implies\sum^\infty_{n=0}a_n=S$$
### Divergence test
By the divergence test, if the limit of each term never reaches zero, the sum diverges.
$$\lim_{x\to\infty}a_n\neq 0\implies\sum^\infty_{n=0}a_n\text{ diverges}$$
### Geometric series
The $n$th partial sum of a geometric series $ar^n$ is equal to:
$$S_n=\frac{a(1-r)^{n+1}}{1-r}$$
To simply test for convergence:
- If $|r|<1$, $S_n\to\frac{a}{1-r}$.
- Otherwise, it diverges by the test for divergence.
### Integral test
If $f(x)$ is **continuous**, **decreasing**, and **positive** on some $[a,\infty)$:
$$\int^\infty_af(x)dx\text{ converges}\iff\sum^\infty_{k=a}f(k)\text{ converges$$
### p-series test
For all $p\in\mathbb R$, a series of the form
$$\sum^\infty_{n=1}\frac{1}{n^p}$$
converges if and only if $p>1$.
### Comparison test
For two series $\sum a_n$ and $\sum b_n$ where **all terms are positive**, if $a_n\leq b_n$ for all $n$, either both converge or both diverge.
The **limit comparison test** has the same requirements, but if $L=\lim_{n\to\infty}\frac{a_n}{b_n}$ such that $0<L<\infty$, either both converge or both diverge.
### Ratio tests
The **ratio test** is applicable if the $L$ exists or is infinity:
$$L+\lim_{n\to\infty}\left|\frac{a_{n+1}}{a_n}\right|$$
- $L<1$ implies the function converges absolutely
- $L>1$ implies the function diverges
- $L=1$ is inconclusive
It is useful if a constant is raised to the power of $n$ or if a factorial is present.
The **root test** has the same analysis but with a different limit:
$$L=\lim_{n\to\infty}\sqrt[n]{|a_n|}$$
It is useful for functions of the form $f(x)^{g(x)}$.
### Alternating series
If the absolute value of all terms $b_k$ continuously decreases and $\lim_{k\to b_k}=0$, the alternating function $\sum^\infty_{k=0}(-1)^kb_k$ converges.
The **alternating series estimation theorem** places an upper bound on the error of a partial sum. If the series passes the alternate series test, $S_n$ is the $n$th partial sum, $S$ is the sum of the series, and $b_k$ is the $k$th term:
$$|S-S_n|\leq b_{n+1}$$
### Conditional convergence
$\sum a_n$ converges **absolutely** only if $\sum |a_n|$ converges.
An absolutely converging series also has its regular form converge.
A series converges **conditionally** if it converges but not absolutely. This indicates that it is possible for all $b\in\mathbb R$ to rearrange $\sum a_n$ to cause it to converge to $b$.
### Power series
A power series **centred at $x_0$** is an infinitely long polynomial.
$$\sum^\infty_{n=0}c_n(x-x_0)^n$$
If there are multiple identified domains of convergence, the endpoints must be tested separately to get the **interval of convergence**. The **radius of convergence** is the amplitude of the interval, regardless of inclusion/exclusion.
$$r=\frac{\text{max}-\text{min}}{2}$$
For a power series of radius $R$, regardless if it is differentiated, integrated, multiplied (by non-zero), the radius remains $R$.
!!! warning
The interval may change.
Adding functions with different radii results in a radius roughly near the smaller interval of convergence.
The **binomial series** is the infinite expansion of $(1+x)^m$ with radius 1.
$$(1+x)^m=\sum^\infty_{n=0}\frac{m(m-1)(m-2)...(m-n+1)}{n!}x^n$$
## Big O notation
A function $f$ is of order $g$ as $x\to x_0$ if $|f(x)|\leq c|g(x)|$ for all $x$ near $x_0$. This is written as big O:
$$f(x)=O(g(x))\text{ as }x\to x_0$$
The inner function only dictates how it grows, discarding any constant terms.
!!! example
As $x\to 0$, $x^3=O(x^2)$ as well as $O(x)$ and $O(1)$. Thus $kx^3=O(x^2)$ for all $k\in\mathbb R$.
However, $x^3=O(x^4)$ only as $x\to\infty$ by the definition.
!!! example
As $|\sin x|\leq |x|$, $\sin x=O(x)$ as $x\to 0$.
If $f=O(x^m)$ and $g=O(x^n)$ as $x\to 0$:
- $fg=O(x^{m+n})$
- $f+g=O(x^q)$, where `q=min(m,n)`
- $kO(x^n)=O(x^n)$
- $O(x^n)^m=O(x^{nm})$
- $O(x^m)\div x^n=O(x^{m-n})$
With Taylor series, big O is the remainder.
$$R_n(x)=O((x-x_0)^{n+1})$$
The limit of big O is the behaviour of $g(x)$.
!!! example
\begin{align*}
\lim_{x\to 0}\frac{x^2e^x+2\cos x-2}{x^3}&=\lim_{x\to 0}\frac{x^3+O(x^4)}{x^3} \\
&= 1+O(x) \\
&= 1
\end{align*}

View File

@ -1,3 +0,0 @@
# ECE 109: Materials Chemistry
😜

View File

@ -1,294 +0,0 @@
# ECE 204: Numerical Methods
## Linear regression
Given a regression $y=mx+b$ and a data set $(x_{i..n}, y_{i..n})$, the **residual** is the difference between the actual and regressed data:
$$E_i=y_i-b-mx_i$$
### Method of least squares
This method minimises the sum of the square of residuals.
$$\boxed{S_r=\sum^n_{i=1}E_i^2}$$
$m$ and $b$ can be found by taking the partial derivative and solving for them:
$$\frac{\partial S_r}{\partial m}=0, \frac{\partial S_r}{\partial b}=0$$
This returns, where $\overline y$ is the mean of the actual $y$-values:
$$
\boxed{m=\frac{n\sum^n_{i=1}x_iy_i-\sum^n_{i=1}x_i\sum^n_{i=1}y_i}{n\sum^n_{i=1}x_i^2-\left(\sum^n_{i=1}x_i\right)^2}} \\
b=\overline y-m\overline x
$$
The total sum of square around the mean is based off of the actual data:
$$\boxed{S_t=\sum(y_i-\overline y)^2}$$
Error is measured with the **coefficient of determination** $r^2$ — the closer the value is to 1, the lower the error.
$$
r^2=\frac{S_t-S_r}{S_t}
$$
If the intercept is the **origin**, $m$ reduces down to a simpler form:
$$m=\frac{\sum^n_{i=1}x_iy_i}{\sum^n_{i=1}x_i^2}$$
## Non-linear regression
### Exponential regression
Solving for the same partial derivatives returns the same values, although bisection may be required for the exponent coefficient ($e^{bx}$) Instead, linearising may make things easier (by taking the natural logarithm of both sides. Afterward, solving as if it were in the form $y=mx+b$ returns correct
!!! example
$y=ax^b\implies\ln y = \ln a + b\ln x$
### Polynomial regression
The residiual is the offset at the end of a polynomial.
$$y=a+bx+cx^2+E$$
Taking the relevant partial derivatives returns a system of equations which can be solved in a matrix.
## Interpolation
Interpolation ensures that every point is crossed.
### Direct method
To interpolate $n+1$ data points, you need a polynomial of a degree **up to $n$**, and points that enclose the desired value. Substituting the $x$ and $y$ values forms a system of equations for a polynomial of a degree equal to the number of points chosen - 1.
### Newton's divided difference method
This method guesses the slope to interpolate. Where $x_0$ is an existing point:
$$\boxed{f(x)=b_0+b_1(x-x_0)}$$
The constant is an existing y-value and the slope is an average.
$$
\begin{align*}
b_0&=f(x_0) \\
b_1&=\frac{f(x_1)-f(x_0)}{x_1-x_0}
\end{align*}
$$
This extends to a quadratic, where the second slope is the average of the first two slopes:
$$\boxed{f(x)=b_0+b_1(x-x_0)+b_2(x-x_0)(x-x_1)}$$
$$
b_2=\frac{\frac{f(x_2)-f(x_1)}{x_2-x_1}-\frac{f(x_1)-f(x_0)}{x_1-x_0}}{x_2-x_0}
$$
## Derivatives
Derivatives are estimated based on first principles:
$$f'(x)=\frac{f(x+h)-f(x)}{h}$$
### Derivatives of continuous functions
At a desired $x$ for $f'(x)$:
1. Choose an arbitrary $h$
2. Calculate derivative via first principles
3. Shrink $h$ and recalculate derivative
4. If the answer is drastically different, repeat step 3
### Derivatives of discrete functions
Guesses are made based on the average slope between two points.
$$f'(x_i)=\frac{f(x_{i+1})-f(x_i)}{x_{i+1}-x_i}$$
### Divided differences
- Using the next term, or a $\Delta x > 0$ indicates a **forward divided difference (FDD)**.
- Using the previous term, or a $\Delta x < 0$ indicates a **backward divided difference (BDD)**.
The **central divided difference** averages both if $h$ or $\Delta x$ of the forward and backward DDs are equal.
$$f'(x)=CDD=\frac{f(x+h)-f(x-h)}{2h}$$
### Higher order derivatives
Taking the Taylor expansion of the function or discrete set and then expanding it as necessary can return any order of derivative. This also applies for $x-h$ if positive and negative are alternated.
$$f(x+h)=f(x)+f'(x)h+\frac{f''(x)}{2!}h^2+\frac{f'''(x)}{3!}h^3$$
!!! example
To find second order derivatives:
\begin{align*}
f''(x)&=\frac{2f(x+h)-2f(x)-2f'(x)h}{h^2} \\
&=\frac{2f(x+h)-2f(x)-(f(x+h)-f(x-h))}{h^2} \\
&=\frac{f(x+h)-2f(x)+f(x-h)}{h^2}
\end{align*}
!!! example
$f''(3)$ if $f(x)=2e^{1.5x}$ and $h=0.1$:
\begin{align*}
f''(3)&=\frac{f(3.1)-2\times2f(3)+f(2.9)}{0.1^2} \\
&=405.08
\end{align*}
For discrete data:
- If the desired point does not exist, differentiating the surrounding points to create a polynomial interpolation of the derivative may be close enough.
!!! example
| t | 0 | 10 | 15 | 20 | 22.5 | 30 |
| --- | --- | --- | --- | --- | --- | --- |
| v(t) | 0 | 227.04 | 362.78 | 517.35 | 602.47 | 901.67 |
$v'(16)$ with FDD:
Using points $t=15,t=20$:
\begin{align*}
v'(x)&=\frac{f(x+h)-f(x)}{h} \\
&=\frac{f(15+5)-f(15)}{5} \\
&=\frac{517.35-362.78}{5} \\
&=30.914
\end{align*}
$v'(16)$ with Newton's first-order interpolation:
\begin{align*}
v(t)&=v(15)+\frac{v(20)-v(15)}{20-15}(t-15) \\
&=362.78+30.914(t-15) \\
&=-100.93+30.914t \\
v'(t)&=\frac{v(t+h)-v(t)}{2h} \\
&=\frac{v(16.1)-v(15.9)}{0.2} \\
&=30.914
\end{align*}
- If the spacing is not equal (to make DD impossible), again creating an interpolation may be close enough.
- If data is noisy, regressing and then solving reduces random error.
## Integrals
If you can represent a function as an $n$-th order polynomial, you can approximate the integral with the integral of that polynomial.
### Trapezoidal rule
The **trapezoidal rule** looks at the first order polynomial and
From $a$ to $b$, if there are $n$ trapezoidal segments, where $h=\frac{b-a}{n}$ is the width of each segment:
$$\int^b_af(x)dx=\frac{b-a}{2n}[f(a)+2(\sum^{n-1}_{i=1}f(a+ih))+f(b)]$$
The error for the $i$th trapezoidal segment is $|E_i|=\left|\frac{h^3}{12}\right|f''(x)$. This can be approximated with a maximum value of $f''$:
$$\boxed{|E_T|\leq(b-a)\frac{h^2}{12}M}$$
### Simpson's 1/3 rule
This uses the second-order polynomial with **two segments**. Three points are usually used: $a,\frac{a+b}{2},b$. Thus for two segments:
$$\int^b_af(x)dx\approx\frac h 3\left[f(a)+4f\left(\frac{a+b}{2}\right)+f(b)\right]$$
For an arbitrary number of segments, as long as there are an **even number** of **equal** segments:
$$\int^b_af(x)dx=\frac{b-a}{3n}\left[f(x_0)+4\sum^{n-1}_{\substack{i=1 \\ \text{i is odd}}}f(x_i)+2\sum^{n-2}_{\substack{i=2 \\ \text{i is even}}}f(x_i)+f(x_n)\right]$$
The error is:
$$|E_T|=(b-a)\frac{h^4}{180}M$$
## Ordinary differential equations
### Initial value problems
These problems only have results for one value of $x$.
**Euler's method** converts the function to the form $f(x,y)$, where $y'=f(x,y)$.
!!! example
$y'+2y=1.3e^{-x},y(0)=5\implies f(x,y)=1.3e^{-x}-2y,y(0)=5$
Where $h$ is the width of each estimation (lower is better):
$$y_{n+1}=y_n+hf(x_n,y_n)$$
!!! example
If $f(x,y)=2xy,h=0.1$, $y_{n+1}=y_n+h2x_ny_n$
$$
y(1.1)=y(1)+0.1×2×1×\underbrace{y(1)}_{1 via IVP}=1.2 \\
y(1.2)=y(1.1)+0.1×2×1.1×\underbrace{y(1.1)}_{1.2}=1.464
$$
**Heun's method** uses Euler's formula as a predictor. Where $y^*$ is the Euler solution:
$$y_{n+1}=y_n+h\frac{f(x_n,y_n)+f(x_{n+1},y^*_{n+1}}{2}$$
!!! example
For $f(x,y)=2xy,h=0.1, y(1)=1$:
Euler's formula returns $y^*_{n+1}=y_n+2hx_ny_n\implies y^*(1.1)=1.2$.
Applying Heun's correction:
\begin{align*}
y(1.1)&=y(1)=0.1\frac{2×1×y(1)+2×1.1×y^*(1.1)}{2} \\
&=1+0.1\frac{2×1×1+2×1.1×1.2}{2} \\
&=1.232
\end{align*}
The **Runge-Kutta fourth-order method** is the most accurate of the three methods:
$$y_n+1=y_n+\frac 1 6(k_1+2k_2+2k_3+k_4)$$
- $k_1=hf(x_n,y_n)$
- $k_2=hf(x_n+\tfrac 1 2h,y_n+\tfrac 1 2k_1)$
- $k_3=hf(x_n+\tfrac 1 2 h, y_n+\tfrac 1 2 k_2)$
- $k_4=hf(x_n+h,y_n+k_3)$
### Higher order ODEs
Higher order ODEs can be solved by reducing them to first order ODEs by creating a system of equations. For a second order ODE: Let $y'=u$.
$$
y'=u \\
u'=f(x,y,u)
$$
For each ODE, the any method can be used:
$$
y_{n+1}=y_n+hu_n \\
u_{n+1}=u_n+hf(x_n,y_n,u_n)
$$
!!! example
For $y''+xy'+y=0,y(0)=1,y'(0)=2,h=0.1$:
\begin{align*}
y'&= u \\
u'&=-xu-y \\
y_1&=y_0+0.1u_0 \\
&=1+0.1×2 \\
&=1.2 \\
\\
u_1&=u_0+0.1×f(x_0,y_0,u_0) \\
&=u_0+0.1(-x_0u_0-y_0] \\
&=2+0.1(-0×2-1) \\
&=1.9
\end{align*}
### Boundary value problems
The **finite difference method** divides the interval between the boundary into $n$ sub-intervals, replacing derivatives with their first principles representations. Solving each $n-1$ equation returns a proper system of equations.
!!! example
For $y''+2y'+y=x^2, y(0)=0.2,y(1)=0.8,n=4\implies h=0.25$:
$x_0=0,x_1=0.25,x_2=0.5,x_3=0.75,x_4=1$
Replace with first principles:
$$\frac{y_{i+1}-2y_i+y_{i-1}{h^2}+2\frac{y_{i+1}-y_i}{h}+y_i=x_i^2$$

View File

@ -1,552 +0,0 @@
# ECE 205: Advanced Calculus 1
## Laplace transform
The Laplace transform is a wonderful operation to convert a function of $t$ into a function of $s$. Where $s$ is an unknown variable independent of $t$:
$$
\mathcal L\{f(t)\}=F(s)=\int^\infty_0e^{-st}f(t)dt, s > 0
$$
??? example
To solve for $\mathcal L\{\sin(at)\}$:
\begin{align*}
\mathcal L\{f(t)\}&=\int^\infty_0e^{-st}\sin(at)dt \\
\\
\text{IBP: let $u=\sin(at)$, $dv=e^{-st}dt$:} \\
&=\lim_{B\to\infty} \underbrace{\biggr[
\cancel{-\frac 1 se^{-st}\sin(at)}}_\text{0 when $s=0$ or $s=\infty$}+\frac a s\int e^{-st}\cos(at)dt
\biggr]^B_0 \\
&=\frac a s\lim_{B\to\infty}\left[\int e^{-st}\cos(at)dt \right]^B_0 \\
\text{IBP: let $u=\cos(at)$, $dv=e^{-st}dt$:} \\
&=\frac a s \lim_{B\to\infty}\left[
-\frac 1 s e^{-st}\cos(at)-\frac a s\underbrace{\int e^{-st}\sin(at)dt}_{\mathcal L\{\sin(at)\}}
\right]^B_0 \\
&=\frac{a}{s^2}-\frac{a^2}{s^2}\mathcal L\{\sin(at)\} \\
\mathcal L\{\sin(at)\}\left(1+\frac{a^2}{s^2}\right)&=\frac{a}{s^2} \\
\mathcal L\{\sin(at)\}&=\frac{a}{a^2+s^2}, s > 0
\end{align*}
A **piecewise continuous** function on $[a,b]$ is continuous on $[a,b]$ except for a possible finite number of finite jump discontinuities.
- This means that any jump discontinuities must have a finite limit on both sides.
- A piecewise continuous function on $[0,\infty)$ must be piecewise continuous $\forall B>0, [0,B]$.
The **exponential order** of a function is $a$ if there exist constants $K, M$ such that:
$$|f(t)|\leq Ke^{at}\text{ when } t\geq M$$
!!! example
- $f(t)=7e^t\sin t$ has an exponential order of 1.
- $f(t)=e^{t^2}$ does not have an exponential order.
### Linearity
A **piecewise continuous** function $f$ on $[0,\infty)$ of an exponential order $a$ has a defined Laplace transform for $s>a$.
Laplace transforms are **linear**. If there exist LTs for $f_1, f_2$ for $s>a_1, a_2$, respectively, for $s=\text{max}(a_1, a_2)$:
$$\mathcal L\{c_1f_1 + c_2f_2\} = c_1\mathcal L\{f_1\} + c_2\mathcal L\{f_2\}$$
??? example
We find the Laplace transform for the following.
$$
f(t)=\begin{cases}
1 & 0\leq t < 1 \\
e^{-t} & t\geq 1
\end{cases}
$$
Clearly $f(t)$ is piecewise ocontinuous on $[0,\infty)$ and has an exponential order of -1 when $t\geq 1$ and 0 when $0\leq t<1$. Thus $\mathcal L\{f(t)\}$ is defined for $s>0$.
\begin{align*}
\mathcal L\{f(t)\}&=\int^1_0 e^{-st}dt + \int^\infty_1e^{-st}e^{-t}dt \\
\tag{$s\neq 0$}&=\left[-\frac 1 s e^{-st}\right]^1_0 + \int^\infty_1e^{t(-s-1)}dt \\
&=-\frac 1 se^{-s}+\frac 1 s + \lim_{B\to\infty}\left[ \frac{1}{-s-1}e^{t(-s-1)} \right]^B_1 \\
\tag{$s\neq 0,s>-1$}&=\frac{-e^{-s}+1}{s} -\frac{e^{-s-1}}{-s-1}
\end{align*}
We solve for the special case $s=0$:
\begin{align*}
\mathcal L\{f(t)\}&=\int^1_0 e^{0}dt + \int^\infty_1e^{-st}e^{-t}dt \\
&=1 -\frac{e^{-s-1}}{-s-1} \\
\end{align*}
$$
\mathcal L\{f(t)\}=
\begin{cases}
\frac{-e^{-s}+1}{s}-\frac{e^{-s-1}}{-s-1} & s\neq 0, s>-1 \\
1-\frac{e^{-s-1}}{-s-1} &s=0
\end{cases}
$$
If there exists a transform for $s>a$, the original function multiplied by $e^{-bt}$ exists for $s>a+b$.
$$\mathcal L\{f(t)\}=F(s), s>a\implies \mathcal L\{e^{-bt}f(t)\}=F(s),s>a+b$$
### Inverse transform
The inverse is found by manipulating the equation until you can look it up in the [Laplace Table](#resources).
The inverse transform is also **linear**.
### Inverse of rational polynomials
If the transformed function can be expressed as a partial fraction decomposition, it is often easier to use linearity to reference the table.
$$\mathcal L^{-1}\left\{\frac{P(s)}{Q(s)}\right\}$$
- $Q, P$ are polynomials
- $\text{deg}(P) > \text{deg}(Q)$
- $Q$ is factored
??? example
\begin{align*}
\mathcal L^{-1}\left\{\frac{s^2+9s+2}{(s-1)(s^2+2s-3)}\right\} &=\mathcal L^{-1}\left\{\frac{A}{s-1}+\frac{B}{s+3} + \frac{Cs+D}{(s-1)^2}\right\} \\
&\implies A=2,B=3,C=-1 \\
&=2\mathcal L^{-1}\left\{\frac{1}{s-1}\right\} + 3\mathcal L^{-1}\left\{\frac{1}{(s-1)^2}\right\}-\mathcal L^{-1}\left\{\frac{1}{s+3}\right\} \\
&=2e^t+3te^t-e^{-3t}
\end{align*}
### Inverse of differentiable equations
If a function $f$ is continuous on $[0,\infty)$ and its derivative $f'$ is piecewise continuous on $[0,\infty)$, for $s>a$:
$$
\mathcal L\{ f'\}=s\mathcal L\{f\}-f(0) \\
\mathcal L\{ f''\} = s^2\mathcal L\{f\}-s\cdot f(0)-f'(0)
$$
### Solving IVPs
Applying the Laplace transform to both sides of an IVP is valid to remove any traces of horrifying integration.
!!! example
\begin{align*}
y''-y'-2y=0, y(0)=1, y'(0)=0 \\
\mathcal L\{y''-y'-2y\}&=\mathcal L\{0\} \\
s^2\mathcal L\{y\}-s\cdot y(0)-y'(0) - s\mathcal L\{y\} +y(0) - 2\mathcal L\{y\}&=0 \\
\mathcal L\{y\}(s^2-s-2)-s+1&=0 \\
\mathcal L\{y\}&=\frac{s-1}{(s-2)(s+1)} \\
&= \\
\mathcal L^{-1}\{\mathcal L\{y\}\}&=\mathcal L^{-1}\left\{
\frac 1 3\cdot\frac{1}{s-2} + \frac 2 3\cdot\frac{1}{s+1}
\right\} \\
y&=\frac 1 3\mathcal L^{-1}\left\{\frac{1}{s-2}\right\} + \frac 2 3\mathcal L^{-1}\left\{\frac{1}{s+1}\right\} \\
\tag{from Laplace table}&=\frac 1 3 e^{2t} + \frac 2 3 e^{-t}
\end{align*}
### Heaviside / unit step
The Heaviside and unit step functions are identical:
$$
H(t-c)=u(t-c)=u_c(t)=\begin{cases}
0 & t < c \\
1 & t \geq c
\end{cases}
$$
Piecewise continuous functions can be manipulated into a single equation via the Heaviside function.
For a Heaviside transform $\mathcal L\{u_c(t)g(t)\}$, if $g$ is defined on $[0,\infty)$, $c\geq 0$, and $\mathcal L\{g(t+c)\}$ exists for some $s>s_0$:
$$
\mathcal L\{u_c(t)g(t)\}=e^{-sc}\mathcal L\{g(t+c)\},s>s_0
$$
Likewise, under the same conditions, shifting it twice restores it back to the original.
$$
\mathcal L\{u_c(t)f(t-c)\}=e^{-sc}\mathcal L\{f\}
$$
### Convolution
Convolution is a weird thingy that does weird things.
$$(f*g)(t)=\int^t_0f(\tau)g(t-\tau)d\tau$$
It is commutative ($f*g=g*f$) and is useful in transforms:
$$\mathcal L\{f*g\}=\mathcal L\{f\}\mathcal L\{g\}$$
!!! example
To solve $4y''+y=g(t),y(0)=3, y'(0)=-7$:
\begin{align*}
4\mathcal L\{y''\}+\mathcal L\{y\}&=\mathcal L\{g(t)\} \\
4(s^2\mathcal L\{y\}-s\cdot y(0) - y'(0))+\mathcal L\{y\} &=\mathcal L\{g(t)\} \\
\mathcal L\{y\}(4s^2+1)-12s+28&=\mathcal L\{g(t)\} \\
\mathcal L\{y\}&=\frac{\mathcal L\{g(t)\}}{4s^2+1} + \frac{12s}{4s^2+1} - \frac{28}{4s^2+1} \\
y&=\mathcal L^{-1}\left\{\frac{1}{4s^2+1}\mathcal L\{g(t)\}\right\} + \mathcal L^{-1}\left\{3\frac{s}{s^2+\frac 1 4}\right\}-\mathcal L^{-1}\left\{7\frac{1}{s^2+\frac 1 4}\right\} \\
&= \mathcal L^{-1}\left\{\frac 1 2\mathcal L\left\{\sin\left(\tfrac 1 2 t\right)\right\}\mathcal L\{g(t)\} \right\}+3\cos\left(\tfrac 1 2 t\right)-14\sin\left(\tfrac 1 2t\right) \\
&=\frac 1 2\left(\sin\left(\tfrac 1 2 t\right)*g(t)\right)+3\cos\left(\tfrac 1 2 t\right)-14\sin\left(\tfrac 1 2t\right) \\
&=\frac 1 2\int^t_0\sin(\tfrac 1 2\tau)g(t-\tau)d\tau + 3\cos(\tfrac 1 2 t)-14\sin(\tfrac 1 2 t)
\end{align*}
### Impulse
The **impulse for duration $\epsilon$** is defined by the **dirac delta function**:
$$
\delta_\epsilon(t)=\begin{cases}
\frac 1\epsilon & \text{if }0\leq t\leq\epsilon \\
0 & \text{else}
\end{cases}
$$
As $\epsilon\to 0, \delta_\epsilon(t)\to\infty$. Thus:
$$
\delta(t-a)=\begin{cases}
\infty & \text{if }t=a \\
0 & \text{else}
\end{cases} \\
\boxed{\int^\infty_0\delta(t-a)dt=1}
$$
If a function is continuous, multiplying it by the impulse function is equivalent to turning it on at that particular point. For $a\geq 0$:
$$\boxed{\int^\infty_0\delta(t-a)dt=g(a)}$$
Thus we also have:
$$\mathcal L\{\delta (t-a)\}=e^{-as}\implies\mathcal L^{-1}\{1\}=\delta(t)$$
## Heat flow
The temperature of a tube from $x=0$ to $x=L$ can be represented by the following DE:
$$\text{temp}=u(x,t)=\boxed{u_t=a^2u_{xx}},0<x<L,y>0$$
Two boundary conditions are requred to solve the problem for all $t>0$ — that at $t=0$ and at $x=0,x=L$.
- $u(x,0)=f(x),0\leq x\leq L$
- e.g., $u(0,t)=u(L,t)=0,t>0$
Thus the general solution is:
$$
\boxed{u(x,t)=\sum^\infty_{n=1}a_ne^{-\left(\frac{n\pi a}{L}\right)^2t}\sin(\frac{n\pi x}{L})} \\
f(x)=\sum^\infty_{n=1}a_n\sin(\frac{n\pi x}{L})
$$
### Periodicity
The **period** of a function is an increment that always returns the same value: $f(x+T)=f(x)$, and its **fundamental period** of a function is the smallest possible period.
!!! example
The fundamental period of $\sin x$ is $2\pi$, but any $2\pi K,k\in\mathbb N$ is a period.
The fundamental periods of $\sin \omega x$ and $\cos\omega x$ are both $\frac{2\pi}{\omega}$.
If functions $f$ and $g$ have a period $T$, then both $af+bg$ and $fg$ also must have period $T$.
#### Manipulating polarity
- even: $\int^L_{-L}f(x)dx=2\int^L_0f(x)dx$
- odd: $\int^L_{-L}f(x)dx=0$
- even × even = even
- odd × odd = even
- even × odd = odd
## Orthogonality
$$\int^L_{-L}\cos(\frac{m\pi x}{L})\sin(\frac{n\pi x}{L})dx=0$$
$$
\int^L_{-L}\cos(\frac{m\pi x}{L})(\frac{n\pi x}{L})dx=\begin{cases}
2L & \text{if }m=n=0 \\
L & \text{if }m=n\neq 0 \\
0 & \text{if }m\neq n
\end{cases}
$$
$$
\int^L_{-L}\sin(\frac{m\pi x}{L}\sin(\frac{n\pi x}{L})dx=\begin{cases}
L & \text{if }m=n \\
0 & \text{if }m\neq n
\end{cases}
$$
Functions are **orthogonal** on an interval when the integral of their product is zero, and a set of functions is **mutually orthogonal** if all functions in the set are orthogonal to each other.
If a Fourier series converges to $f(x)$:
$$f(x)=\frac{a_0}{2} + \sum^\infty_{n=1}\left(a_n\cos(\frac{n\pi x}{L})+b_n\sin(\frac{n\pi x}{L})\right)$$
The **Euler-Fourier** formulae must apply:
$$
\boxed{a_n=\frac 1 L\int^L_{-L}f(x)\cos(\frac{n\pi x}{L})dx} \\
\\
\boxed{b_n=\frac 1 L\int^L_{-L}f(x)\sin(\frac{n\pi x}{L})dx}
$$
!!! example
The Fourier series for the square wave function: $f(x)=\begin{cases}-1 & -\pi < x < 0 \\ 1 & 0 < x < \pi\end{cases}$
The period is clearly $2\pi\implies L=\pi$. $f(x)$ is also odd, by inspection.
\begin{align*}
a_n&=\frac 1\pi\int^\pi_{-\pi}\underbrace{f(x)\cos(\frac{n\pi x}{\pi})}_\text{odd × even = odd}dx=0=a_0 \\
b_n&=\frac 1 \pi\int^\pi_{-\pi}f(x)\sin(\frac{n\pi x}{\pi})dx \\
\tag{even}&=\frac 2\pi\int^\pi_0f(x)\sin(nx)dx \\
\tag{$f(x)>1$ when $x>0$}&=\frac 2\pi\int^\pi_0\sin(nx)dx \\
&=\frac 2\pi\left[\frac{-\cos nx}{n}\right]^\pi_0 \\
&=\begin{cases}
\frac{4}{\pi n} & \text{if $n$ is odd} \\
0 & \text{else}
\end{cases}
\therefore f(x)&=\sum^\infty_{n=1}\frac 2\pi\left(\frac{1-(-1)^n}{n}\sin(nx)\right) \\
\tag{only odd $n$s are non-zero}&=\frac4\pi\sum^\infty_{n=1}\frac{1}{2n-1}\sin[(2n-1)x]
\end{align*}
Thus the Fourier series is $$.
### Separation of variables
To solve IBVPs, where $X(x)$ and $T(t)$ are exclusively functions of their respective variables:
$$u(x,t)=X(x)T(t)$$
Substituting it into the IBVP results in a **separation constant** $-\lambda$.
$$\boxed{\frac{T'(t)}{a^2T(t)}=\frac{X''(x)}{X(x)}=-\lambda}$$
Possible values for the separation constant are known as **eigenvalues**, and their corresponding **eigenfunctions** contain the unknown constant $a_n$:
$$
\lambda_n=\left(\frac{n\pi}{L}\right)^2 \\
X_n(x)=a_n\sin(\frac{n\pi x}{L})
$$
### Wave equation
A string stretched between two secured points at $x=0$ and $x=L$ can be represented by the following IBVP:
$$
u_{tt}=a^2u_{xx},0<x<L,t>0 \\
u(0,t)=u(L,t)=0,t>0 \\
u(x,0)=f(x), 0\leq x\leq L \\
u_t(x,0)=g(x), 0\leq x\leq L
$$
The following conditions must be met:
$$
u(x,t)=\sum^\infty_{n=1}\sin(\frac{n\pi x}{L})\left(\alpha_n\cos(\frac{n\pi a}{L}t)+\beta_n\sin(\frac{n\pi a}{L}t)\right) \\
\boxed{f(x)=\sum^\infty_{n=1}\alpha_n\sin(\frac{n\pi x}{L}),0\leq x\leq L} \\
\boxed{g(x)=\sum^\infty_{n=1}\frac{n\pi a}{L}\beta_n\sin(\frac{n\pi x}{L}), 0\leq x\leq L}
$$
### Fourier symmetry
To find a Fourier series for functions defined only on $[0, L]$ instead of $[-L, L]$, a **periodic extension** can be used.
A **half-range sine expansion (HRS)** is used for odd functions:
$$
f_o(x)=\begin{cases}
f(x) & x\in(0, L) \\
-f(-x) & x\in(-L, 0)
\end{cases}
$$
A **half-range cosine expansion (HRC)** is used for even functions:
$$
f_e(x)=\begin{cases}
f(x) & x\in(0, L) \\
f(-x) & x\in(-L, 0)
\end{cases}
$$
Thus if a Fourier series on $(0,L)$ exists, it can be expressed as either a **Fourier sine series** (via HRS) or a **Fourier cosine series** (via HRC).
!!! example
For $f(x)=\begin{cases}\frac\pi 2 & [0,\frac\pi 2] \\ x-\frac\pi 2 & (\frac\pi2,\pi]\end{cases}$:
\begin{align*}
a_n&=\frac 2 L\int^L_0f(x)\cos(\frac{n\pi x}{L})dx \\
&=\frac 2\pi \int^{\pi/2}_0\frac\pi 2\cos(\frac{n\pi x}{\pi})dx + \frac 2 \pi\int^\pi_{\pi/2}(x-\frac\pi2)\cos(\frac{n\pi x}{\pi})dx \\
&=\frac{2}{n^2\pi}[(-1)^n-\cos(\frac{n\pi}{2})+\frac{n\pi}{2}\sin(\frac{n\pi}{2}) \\
\\
a_0&=\frac2\pi\int^\pi_0f(x)\cos(0)dx \\
&=\frac{3\pi}{4} \\
\\
\therefore f(x)&=\frac{3\pi}{8}+\sum^\infty_{n=1}\frac{2}{n^2\pi^2}[(-1)^n-\cos(\frac{n\pi}{2})+\frac{n\pi}{2}\sin(\frac{n\pi}{2})]\cos(nx),x\in[0,\pi]
\end{align*}
!!! example
For:
$$
u_t=2u_{xx},0<x<\pi,t:0 \\
u(0,t)=u(\pi,t)=0,t>0 \\
u(x,0)=\begin{cases}
\frac\pi 2 & [0,\frac\pi 2] \\
x-\frac\pi 2 & (\frac\pi 2,\pi]
\end{cases}
$$
We have $L=\pi,a=\sqrt 2$.
\begin{align*}
u(x,t)&=\sum^\infty_{n=1}\alpha_ne^{\left(\frac{n\pi\sqrt 2}{\pi}\right)^2t}\sin(\frac{n\pi x}{\pi})
&=\sum^\infty_{n=1}\alpha_ne^{-2n^2t}\sin(nx) \\
\alpha_n&=\frac 2 L\int^L_0f(x)\sin(\frac{n\pi x}{L})dx \\
&=\frac2\pi\int^{\pi/2}_0\frac\pi 2\sin(nx)dx+\frac2\pi\int^\pi_{\pi/2}(x-\frac\pi2\sin(nx)dx \\
&=\frac 1 n[1+(-1)^{n+1}-\cos(\frac{n\pi}{2})-\frac{2}{n\pi}\sin(\frac{n\pi}{2}]
\end{align*}
### Convergence of Fourier series
!!! definition
- $f(x^+)=\lim_{h\to0^+}f(x+h)$
- $f(x^-=\lim_{h\to0^-}f(x+h)$
If $f$ and $f'$ are piecewise continuous on $[-L, L]$ for $x\in(-L,L)$, where $a_n$ and $b_n$ are from the Euler-Fourier formulae:
$$\frac{a_0}{2}+\sum^\infty_{n=1}a_n\cos(\frac{n\pi x}{L})+b_n\sin(\frac{n\pi x}{L})=\boxed{\frac 1 2[f(x^+)+f(x^-)]}$$
At $x=\pm L$, the series converges to $\frac 1 2[f(-L^+)+f(L^-)]$. This implies:
- A continuous $f$ converges to $f(x)$
- A discontinuous $f$ has the Fourier series converge to the average of the left and right limits
- Extending $f$ to infinity using periodicity allows it to hold for all $x$
!!! example
The square wave function $f(x)=\begin{cases}-1 & -\pi<x<0 \\ 1 & 0<x<\pi\end{cases},f(x+2\pi)=f(x)$:
$f$ and $f'$ are piecewise continuous, but the function is discontinuous at $k\pi,k\in\mathbb Z$. Thus at $x=\pm\pi$, the series converges to $\frac 1 2(-1+1)=0$. At $x=0$, the series converges to $\frac 1 2(1+(-1))=0$.
If $f$ is 2L-periodic and continuous on $-\infty,\infty$, and $f'$ is piecewise continuous on $[-L,L]$, the Fourier series converges **uniformly** to $f$ on $[-L,L]$ and thus any interval.
More formally, for every $\epsilon>0$, there exists an integer $N_0$ depending on $\epsilon$ such that $|f(x)-[\frac{a_0}{2}+\sum^N_{n=1}a_n\cos(\frac{n\pi x}{L})+b_n\sin(\frac{n\pi x}{L})]|<\epsilon$ for all $N\geq N_0$ and all $x\in(-\infty,\infty)$.
More intuitively, for a high enough summation of the Fourier series, the value must lie in an **$\epsilon$-corridor** of $f(x)$ such that $f(x)$ is always between $f(x)\pm\epsilon$.
!!! example
- The Fourier series for the triangle wave function **is** uniformly convergent.
- The Fourier series for the square wave function **is not** uniformly convergent, which means that Gibbs overshoots would not fit in an arbitrarily small $\epsilon$-corridor.
The **Weierstrass M-test** states that if $|a_n(x)|\leq M_n$ for all $x\in[a,b]$ and if $\sum^\infty_{n=1}M_n$ converges, then $\sum^\infty_{n=1}a_n(x)$ converges uniformly to $f(x)$ on $[a,b]$.
!!! example
$\sum^\infty_{n=1}\frac{1}{n^2}\cos(nx)$ converges uniformly on any finite closed interval $[a,b]$.
$|\frac{\cos(nx)}{n^2}|\leq\frac{1}{n^2}$ for all $x$, and $\sum^\infty_{n=1}\frac{1}{n^2}$ also converges. Thus the result follows from the M-test.
### Differentiating Fourier series
You can termwise differentiate the Fourier series of $f(x)$ only if:
- $f(x)$ is continuous on $(-\infty,\infty)$ and 2L-periodic
- $f'(x),f''(x)$ are both piecewise continuous on $[-L,L]$
You can termwise integrate the Fourier series of $f(x)$ only if $f(x)$ is piecewise continuous on $[-L,L]$.
Then, for any $x\in[-L,L]$:
$$\int^x_{-L}f(t)dt=\int^x_{-L}\frac{a_0}{2}dt+\sum^\infty_{n=1}\int^x_{-L}(a_n\cos(\frac{n\pi t}{L})+b_n\sin(\frac{n\pi t}{L}))dt$$
### Complex Fourier series
By employing Euler's theorem, sine and cosine can be transformed into exponential forms.
$$
\cos(\frac{n\pi x}{L})=\frac{e^{i\frac{n\pi x}{L}} + e^{-i\frac{n\pi x}{L}}}{2} \\
\sin(\frac{n\pi x}{L})=\frac{-ie^{i\frac{n\pi x}{L}} + ie^{-i\frac{n\pi x}{L}}}{2}
$$
Thus the **complex Fourier series** is given by:
$$
f(x)=\sum^\infty_{n=-\infty}c_ne^{i\frac{n\pi x}{L}} \\
c_n=\frac{1}{2L}\int^L_{-L}f(x)e^{-i\frac{n\pi x}{L}}dx = \frac 1 2(a_n-ib_n)
$$
To convert it to a real Fouier series:
- $a_0=2c_0$
- $a_n=c_n+\overline{c_n}$
- $b_n=i(c_n-\overline{c_n})$
!!! example
The complex Fourier series for the sawtooth wave function: $f(x)=x,-1<x<1,f(x+2)=f(x)$. Thus we have a period of 2 and $L=1$.
\begin{align*}
c_0&=\frac 1 2\int^1_{-1}\underbrace{xe^{0}}_\text{odd}dx \\
&=0 \\
\\
c_n&=\frac 1 2\int^1_{-1}xe^{-in\pi x}dx \\
\tag{IBP}&=\frac 1 2\left[\frac{xe^{-in\pi x}}{-in\pi}-\int\frac{1}{-in\pi}e^{-in\pi x}dx\right]^1_{-1} \\
&=\frac 1 2\left[\frac{xe^{-n\pi x}}{-in\pi}+\frac{1}{n^2\pi^2}e^{-in\pi x}\right]^1_{-1} \\
&=\frac{(-1)^ni}{n\pi} \\
\\
\therefore f(x)&=\sum^\infty_{\substack{n=-\infty \\ n\neq0}}\frac{(-1)^ni}{n\pi}e^{in\pi x}
\end{align*}
The Fourier coefficients $c_n$ map to the amplitude spectrum $|c_n|$. **Parseval's theorem** maps the frequency domain ($\{c_n\}$) to and from the time domain ($f(t)$):
If a 2L-periodic function $f(t)$ has a complex Fourier series $f(t)=\sum^\infty_{n=-\infty}c_ne^{\frac{in\pi x}{L}}$:
$$\frac{1}{2L}\int^L_{-L}\underbrace{[f(t)]^2}_\text{time domain}dt=\sum^\infty_{n=-\infty}\underbrace{|c_n|^2}_\text{time domain}$$
!!! example
For the Sawtooth function, $f(t)=t, -1 < t < 1, f(t+2)=f(t)$:
\begin{align*}
f(x)&=\sum^\infty_{\substack{n=-\infty \\ n\neq 0}}\frac{ni}{n\pi}e^{in\pi t}+0 \\
\frac 1 2\int^1_{-1}t^2dt&=\sum^\infty_{\substack{n=-\infty \\ n\neq 0}}\left|\frac{(-1)^ni}{n\pi}\right|^2+|0|^2 \\
\tag{$\left|\frac{(-1)^ni}{n\pi}\right|=\frac{1}{n\pi}$}\frac 1 3 &=\sum^\infty_{\substack{n=-\infty \\ n\neq 0}}\left(\frac{1}{n\pi}\right)^2 \\
&=\sum^{-1}_{n=-\infty}\left(\frac{1}{n\pi}\right)^2+\sum^\infty_{n=1}\left(\frac{1}{n\pi}\right)^2 \\
\tag{$\frac 1 n^2$ sign doesn't matter}&=2\sum^\infty_{n=1}\frac{1}{n^2\pi^2} \\
\frac 1 3 &=\frac{2}{\pi^2}\sum^\infty_{n=1}\frac{1}{n^2} \\
\frac{\pi^2}{6}&=\sum^\infty_{n=1}\frac{1}{n^2}
\end{align*}
### Fourier transform
To convert a function to a Fourier series:
$$\mathcal F\{f(x)\}=\hat f(\omega)=\int^\infty_{-\infty}f(x)e^{-i\omega x}dx$$
To convert a Fourier series back to the original function, the following conditions must hold:
- there must not be any infinite discontinuities: $\int^\infty_{-\infty}|f(x)|dx<\infty$
- in any finite interval, there must be a finite number of extrema and discontinuities
Then, the **Fourier integral** / **inverse Fourier transform** converges to $f(x)$ wherever continuous and $\frac 1 2[f(x^+)+f(x^-)]$ at discontinuities.
$$\mathcal F^{-1}\{\hat f(\omega)\}=f(x)=\frac{1}{2\pi}\int^\infty_{-\infty}\hat f(\omega)e^{i\omega x}d\omega$$
!!! example
For $f(x)=\begin{cases} 1 & -1<x<1 \\ 0 & \text{else}\end{cases}$:
\begin{align*}
\mathcal F\{f(x)\}&=\int^\infty_{-\infty}f(x)e^{-i\omega x}dx \\
&=\int^1_{-1}e^{-i\omega x}dx \\
&=\frac{i\omega}(e^{i\omega}-e^{-i\omega}) \\
&=\frac{2\sin\omega}{\omega}
\end{align*}
Parseval's theorem can be generalised to non-periodic situations via Fourier transforms.
$$\int^\infty_{-\infty}[f(t)]^2dt=\frac{1}{2\pi}\int^\infty_{-\infty}|\hat f(\omega)|^2d\omega$$
#### Properties of the Fourier transform
- FT/IFT are linear: $\mathcal F\{af+bg\}=a\mathcal F\{f\}+b\mathcal F\{g\}$
- FT is scalable: $\mathcal F\{f(ax)\}=\frac 1 a\hat f\left(\frac{\omega}{a}\right)$
- FT can shift frequencies: $\mathcal F\{e^{iax}f(x)\}=\hat f(\omega-a)$
- FT can shift time: $\mathcal F\{f(x-a)\}=e^{ia\omega}\hat f(\omega)$
- If the IFT is applicable: $\mathcal F\{f^{(n)}(x)\}=(i\omega)^n\hat f(\omega)$
- The FT is symmetrical: $\mathcal F\{\hat f(x)\}=2\pi f(-\omega)$
## Resources
- [Laplace Table](/resources/ece/laplace.pdf)

View File

@ -1,211 +0,0 @@
# ECE 222: Digital Computers
## Exceptions
In ARM, anything that interrupts the normal control flow of a program is an exception.
- An **interrupt** from an **interrupt request (IRQ)** occurs when a peripheral wants to interrupt the current flow
- A **fault** indicates a CPU error (e.g., division by zero) and returns to the faulty instruction
- A **trap** runs the interrupt handler and returns to the next instruction
Exceptions are handled by running an exception handler then returning to the original line.
### Vector table
A vector table is an array of handler addresses. Each index contains a number (a "vector") and a priority.
### Exception handling
First, in hardware: If the exception priority is higher than the current operating priority, the exception is immediately handled.
- the current context is pushed to the stack
- the operating mode is set to privileged
- the operating priority is set to the exception priority
- the program counter is set to the address of the exception (`vector_table[exception_num]`)
Next, the handler runs, and it should:
- preserve the any R4-R11 it modifies
- clear the interrupt request (IRQ)
- restore R4-R11
- return with `BX LR`
Finally, in hardware:
- the previous context is restored
- the previous operating priority and mode are restored
!!! warning
Interrupts can interrupt other interrupts, if their priority is sufficiently high!
!!! example
How to interrupt-driven I/O:
**Write the ISR:** Assuming that the IRQ bit is cleared if `R0` is read:
```asm
ISR PUSH {R4-R11} ; save previous state onto stack
LDR R3, [R0] ; clear the IRQ by reading from it
POP {R4-R11} ; restore state
BX LR ; return to original address
```
**Store the interrupt handler in the vector table:** Assuming that the vector number is `22` and the vector table starts 16 addresses after the 0x00:
```asm
MOV32 R0, #ISR ; handler address
MOV R1, #38 * 4 ; offset: (16 + 22) * 4 bytes per address
STR R1, [R0] ; save address to table
```
**Enable interrupt requests:**
```asm
MOV32 R0, #ADDRESS_INTERRUPT_ENABLE
MOV R1, #1
STR R1, [R0] ; enable interrupts
```
## Processor design
Comparing the **complex instruction set computer** architecture to the **reduced instruction set computer** architecture:
| Task | CISC | RISC |
| ---- | ---- | ---- |
| ALU operands can come from? | registers, memory | registers (load/store) |
| Addressing mode | complex | simple |
| Binary size | small | large (~30% larger) |
| Instruction size | variable | fixed |
| Pipelining | difficult | simple |
### Operation encoding
The **R-format** is used for operations of the form `ADD Rd, Rn, Rm`:
$$\underbrace{\text{op-code}}_\text{11 b}\ \ \overbrace{\text{Rm}}^\text{5 b}\ \ \underbrace{\text{shift amount}}_\text{6 b}\ \ \overbrace{\text{Rn}}^\text{5 b}\ \ \underbrace{\text{Rd}}_\text{5 b}$$
The **D-format** is used for operations of the form `LDR Rt, [Rn, #offset]`:
$$\underbrace{\text{op-code}}_\text{11 b}\ \ \overbrace{\text{offset}}^\text{9 b}\ \ 00\ \ \overbrace{\text{Rn}}^\text{5 b}\ \ \underbrace{\text{Rt}}_\text{5 b}$$
The **CB-format** is used for operations of the form `CBZ Rt, LABEL`:
$$\underbrace{\text{op-code}}_\text{8 b}\ \ \overbrace{\text{offset}}^\text{19 b}\ \ \underbrace{\text{Rt}}_\text{5 b}$$
### Instruction data path
To execute an instruction, the following steps are observed:
1. Instruction fetch (IF)
- fetch the instruction from instruction memory
- increment the instruction address (`PC += 4`), latchedd into PC register at the end of the CPU cycle
2. Instruction decode (ID)
- decode fields like the op-code, offset
- read recoded registers
3. Execute (EX)
- ALU calculates ADD, SUB, etc, as well as addresses for LDR/STR, sets zero status for CBZ
- branch adder calculates any branch target addresses
4. Memory (ME)
- if memory needs to be reached, either `Write` or `Read` must be asserted to prepare for it
- write to memory
5. Writeback (WB)
- write results to registers from memory, the ALU, or another register
### Performance
Each step in the instruction data path has a varying time, so the clock period must be at least as long as the slowest step.
Performance is usually compared by comparing the execution times of standard benchmarks, such that:
$$\text{time}=n_{instructions}\times\underbrace{\frac{\text{cycles}}{\text{instruction}}}_\text{CPI}\times\frac{\text{seconds}}{\text{cycle}}$$
## Pipelining
Pipelining changes the granularity of a clock cycle to be per step, instead of per-instruction. This allows multiple instructions to be processed concurrently.
<img src="https://upload.wikimedia.org/wikipedia/commons/c/cb/Pipeline%2C_4_stage.svg" width=500>(Source: Wikimedia Commons)</img>
### Data forwarding
If data needs to be used from a prior operation, a pipeline stall would normally be required to remove the hazard and wait for the desired result (a **read-after-write** data hazard). However, a processor can mitigate this hazard by allowing the stalled instrution to read from the prior instruction's result instead.
### Load hazards
If a value is produced in memory access (e.g., loads) that is required in the next instruction's EX. a stall is for the dependent instruction. This can be detected in the ID stage by testing if the current instruction sets the memory read flag and the next instruction accesses the destination register.
A processor **stalls** by disabling the PC and IF/ID write to prevent fetching the next instruction. Additionally, it sets the control in ID/EX to 0 to insert a no-op in the pipeline.
## Memory
### Static RAM (SRAM)
- retains data as long as power is supplied
- compared to DRAM, it is faster but more expensive, so it is used for cache
- To **read**: set word line = 1, turning on transistors, then read the **bit line**'s voltage
- To **write**: set word line = 1, turning on transistors, then drive the **bit line**'s voltage
<img src="https://2.bp.blogspot.com/-dCCrTGB-c6U/T1zaY5TG1oI/AAAAAAAAAu8/MutoYbjglvs/s640/SRAM.gif" width=500 />
### Dynamic RAM (DRAM)
- DRAM capacitors lose their charge over time so must be periodically **refreshed**
- Roughly 5x slower than SRAM, but cheaper, so it is used for main memory
- To **read**: precharge the bit line to $V_{DD}/2$, then set word line = 1, then sense and amplify the voltage change on the bit line. This also writes back the value.
- To **write**: along the bit line, drive $V_DD$ to charge the capacitor (write a $1$) or $GND$ to discharge (write a $0$).
<img src="https://www.electronics-notes.com/images/ram-dynamic-dram-basic-cell-01.svg" width=500 />
### Large DRAM chips
Each bit cell is placed into a symmetric 2D matrix to avoid linear searching. Assuming each addressing pin can address one byte (8 bits), including one bit to select row or column:
$$\text{\# addr bits} = \log_2(2\times\text{\# bytes})$$
The matrix would store a total of eight times the number of bytes / words, so each edge is the square root of that. To read an address, the memory controller gives the row on the address pins and asserts **row address strobe (RAS)**. After the row is read, the controller gives the column and asserts **column address strobe (CAS)**.
$$
\text{\# bits} = 2\times\text{\# bytes}\times\frac{\pu{8 bits}}{\pu{1 word}} \\
\text{matrix length}=\sqrt{\text{\# bits}}
$$
!!! example
A 16 Mib machine stores 2 MiB, or $1024^2$ bytes. Thus the bits are arranged in a $\sqrt{2\times1024^2\times8}=2^{12}$ by $2^{12}$ matrix, where each row holds $2^9$ 8-bit words.
### DRAM timing
**Asynchronous** DRAM:
1. Provide row number, assert RAS
2. Wait
3. Provide column number, assert CAS
4. Wait
5. Transfer data
**Fast page mode** DRAM:
1. Provide row number
2. Specify multiple column numbers
3. Transfer multiple data
**Synchronous** DRAM (SDRAM) synchronises commands and data transfers to the bus clock. A row is buffered, then data is transferred in bursts of 2<sup>n</sup> words.
**Double data rate** SDRAM transfers data on the rising and falling edges of the bus clock.
### DRAM performance
!!! definition
- **Latency** is measured by the time from the start of the request to the start of data transfer.
- **Bandwidth** is measured by the volume of data transferred per unit time
**DDR SDRAM** transfers 64 bits per channel at once. A **rank** of memory chips provides the data, and each rank chip is mounted on a **dual inline memory module (DIMM)**. To increase capacity without increasing latency, each rank is subdivided into **banks**.
As a JEDEC standard, chips are named by DDR generation and bandwidth:
$$
\text{PC}\#-bandwidth
$$
!!! example
A **PC3-12800** chip is DDR3 with a bus transfer rate of 12800 MB/s. Or, at 8 B/transfer, a bus clock rate of 1600 MT/s. At 2 transfers/cycle (DDR), it must thus run at 800 MHz.

View File

@ -1,223 +0,0 @@
# ECE 240: Electronic Circuits
## Diodes
A **diode** is a two-terminal device that only allows current to flow in the direction of the arrow.
<img src="https://upload.wikimedia.org/wikipedia/commons/b/b4/Diode_symbol.svg" width=300>(Source: Wikimedia Commons)</img>
The current across a diode is, where $I_s$ is a forced saturation current, $V$ is the voltage drop across it, and $V_T$ is the **thermal voltage** such that $V_T=\frac{kT}{q}$, where $T$ is the temperature, $k$ is the Boltzmann constant, and $q$ is the charge of an electron:
$$I=I_s\left(e^{V/V_T}-1\right)$$
!!! tip
- $V_T\approx\pu{25 mV}$ at 20°C
- $V_T\approx\pu{20 mV}$ at 25°C
A diode is open when current is flowing reverse the desired direction, resulting in zero current, until the voltage drop becomes so great that it reaches the **breakdown voltage** $V_B$. Otherwise, the above current formula is followed.
<img src="https://upload.wikimedia.org/wikipedia/commons/2/2a/Diode_current_wiki.png" width=500>(Source: Wikimedia Commons)</img>
Diodes are commonly used in **rectifier circuits** — circuits that convert AC to DC.
By preventing negative voltage, a relatively constant positive DC voltage is obtained. The slight dip between each hill is known as **ripple** $\Delta V$.
<img src="https://upload.wikimedia.org/wikipedia/en/8/8b/Reservoircapidealised.gif" width=500>(Source: Wikimedia Commons)</img>
In a simple series RC circuit, across a diode, Where $R_LC>>\frac 1 \omega$, and $f=\frac{\omega}{2\pi}$:
$$\Delta V\approx \frac{I_\text{load}}{2fC}\approx\frac{V_0}{2fR_LC}$$
### Zener diodes
A Zener diode is a calibrated diode with a known breakdown voltage, $V_B$. If the voltage across the diode would be greater than $V_B$, it is **capped at $V_B$.**
<img src="https://upload.wikimedia.org/wikipedia/commons/9/92/Zener_diode_symbol-2.svg" width=200>(Source: Wikimedia Commons)</img>
## Voltage/current biasing
Solving for current for each element in a series returns a negative linear line and other non-linear lines.
- the linear line is the **load line**, which represents the possible solutions to the circuit when it is loaded
- Depending on the base current $I_s$, the diode or transistor will be **biased** toward one of the curves, and the voltage and current will settle on one of the intersections, or **bias points**.
<img src="https://upload.wikimedia.org/wikipedia/commons/2/27/BJT_CE_load_line.svg" width=600>(Source: Wikimedia Commons)</img>
- To bias current, as $R\to\infty$ (or, in practical terms, $R>>diode$), the slope of the load line $\to 0$, which results in a constant current.
- To bias voltage, as $R\to 0$, the slope of the load line $\to\infty$, which results in a constant voltage.
!!! example
<img src="https://miro.medium.com/v2/resize:fit:432/1*mijJgpHdt7DDmrPsb7tOcg.png" width=200 />
The current across the resistor and the diode is the same:
\begin{align*}
i_D&=\frac{V_s}{R} \\
i_D&\approx I_se^{V_D/V_T}
\end{align*}
If a diode is put in series with AC and DC voltage sources $V_d(t)$ and $V_D$:
\begin{align*}
i_D(t)&=I_se^{(V_D+V_d(t))/V_T} \\
&=\underbrace{I_se^{V_D/V_T}}_\text{bias current}\ \underbrace{e^{V_d(t)/V_T}}_\text{$\approx 1+\frac{V_d}{V_T}$} \\
&=I_D\left(1+\frac{V_d}{V_T}\right) \\
&=\underbrace{I_D}_\text{large signal = bias = DC}+\underbrace{I_D\frac{V_d(t)}{V_T}}_\text{small signal = AC}
\end{align*}
Diodes may act as resistors, depending on the bias current. They may exhibit a **differential resistance**:
$$r_d=\left(\frac{\partial i_D}{\partial v_D}\right)^{-1} = \frac{V_T}{I_D}$$
!!! example
Thus from the previous sequence:
$$i_D(t)=I_D+\frac{1}{r_d}V_d(t)$$
### Signal analysis
1. Analyse DC signals
- assume blocking capacitors are open circuits
- turn off AC sources
2. Analyse AC signals
- assume blocking capacitors are shorts
- turn off DC sources
- replace diode with effective resistor (the differential resistor)
!!! tip
Most $R$s in the circuit can be assumed to be significantly greater than $r_d$, so $r_d$ can be removed in series or $R$ can be removed in parallel.
!!! warning
Oftentimes, turning off a DC source to nowhere is actually a short to ground.
## MOSFETs
A MOSFET is a transistor. Current flows from the drain to the source, and only if voltage is applied to the gate.
<img src="https://upload.wikimedia.org/wikipedia/commons/6/69/Mosfet_saturation.svg" width=500>(Source: Wikimedia Commons)</img>
<img src="https://upload.wikimedia.org/wikipedia/commons/9/91/Transistor_Simple_Circuit_Diagram_with_NPN_Labels.svg" width=300>(Source: Wikimedia Commons)</img>
In strictly DC, current passes the gate if the gate voltage is greater than the threshold voltage $V_G>V_t$. The difference between the two is known as the **overdrive voltage** $V_{ov}$:
$$V_{ov}=V_G-V_t$$
At a small $V_{DS}$, or in AC, the slope of $I_D$ to $V_{DS}$ is proportional to $V_G$. The **channel transconductance** $g_{DS}$ represents this slope, which is constant based on the **transconductance parameter** of the device.
$$\frac{I_D}{V_{DS}}=g_{DS}=k_nV_{ov}$$
Before the saturation region, the current grows exponentially:
$$\boxed{I_s=k_n(V_{ov}-\tfrac 1 2V_{DS})V_{DS}}$$
Afterward, it remains constant, based on the overdrive voltage:
$$\boxed{I_s=\frac 1 2k_nV_{ov}^2}$$
### Common-source amplifiers
<img src="https://upload.wikimedia.org/wikipedia/commons/4/4f/N-channel_JFET_common_source.svg" width=200>(Source: Wikimedia Commons)</img>
Where $V_{out}=V_{DS}$:
<img src="https://media.cheggcdn.com/media/b65/b65d59bd-ac35-4d28-b811-0ad1b5cf5bb6/phpCBbhn6" width=700 />
$|V_{ds}|>|V_{gs}|$ indicates AC voltage gain.
The gain can be modelled with Ohm's law:
$$V_{DS}=V_{DD}-I_DR_D=V_{DD}-\frac 1 2k_n(V_{GS}-V_t)R_D$$
At a certain gate voltage:
\begin{align*}
A_V&=\frac{\partial V_{DS}}{\partial V_{GS}} \\
&=-g_{DS}R_D
\end{align*}
### Small signal analysis
The current from the drain to the source is equal to:
$$i_D=g_mV_{gs}$$
For small signals, a transistor is equivalent to, where $r_0=\frac{1}{\lambda I_D}=\frac{V_A}{I_D}$:
<img src="https://i.stack.imgur.com/EZK7K.png" width=600 />
It can be assumed that the differential resistance is always significantly smaller than any other external resistance: $r_o << R_d$.
To solve for the output resistance of the amplifier, turn off all sources and take the Thevenin resistance $R_{DS}$.
### Common-drain amplifiers / source followers
The input resistance of common amplifiers is infinity.
<img src="https://upload.wikimedia.org/wikipedia/commons/3/30/N-channel_JFET_source_follower.svg" width=200>(Source: Wikimedia Commons)</img>
As $V_{gs}$ is not necessarily zero, dependent sources must be left in when solving for output resistance, and so a small test source at the point of interest is required.
### Common-gate amplifiers
These can be represented by either the T-model or pi-model. The gate of the transistor is grounded.
$$
A_{VO}=g_mR_d \\
G_V=\frac{V_o}{V_{sig}}=g_mR_d\left(\frac{1}{1+g_mR_{sig}}\right)
$$
<img src="https://upload.wikimedia.org/wikipedia/commons/9/99/Common_Gate.svg" width=200 />
<img src="https://upload.wikimedia.org/wikipedia/commons/a/a9/Common_gate_output_resistance.PNG" width=400 />
### Differential pairs
These are used at the input of opamps.
In **differential mode,** assuming $Q_1=Q_2$:
$V_{in}^+=-V_{in}^-=\frac{V_d}{2}$, so the current going down from both gates is equal $i_{gs1}=-i_{gs2}$. This means that node before $R_E$ is effectively ground, so the circuit can be split into two common source circuits.
$$G_D=\frac{V_o^--V_o^+}{V_d}=\frac{R_{C1}g_m}{1}=-\frac{-R_{C1}}{r_m}$$
<img src="https://upload.wikimedia.org/wikipedia/commons/3/3a/Differential_amplifier_long-tailed_pair.svg" width=300 />
In **common mode**:
$V_{in}^+=V_{in}^-$
$$G_{CM}=-\frac{R_D}{r_m+R_S+2R_C}$$
The **common-mode rejection ratio** is:
$$\frac{G_D}{G_{CM}}=1+\frac{2R_C}{r_m+R_s}$$
## MOSFET biasing
To bias a MOSFET:
- the transistor must be on: $V_{GS}>V_t$
- the transistor must be saturated $V_{DS} > (V_{GS}-V_t)$
$$V_{GS}=V_G-R_EI_D$$
This is a negative feedback loop that forces a constant $I_D$.
<img src="https://i.stack.imgur.com/Yxslx.png" width=300 />
With two DC supplies ($-V_{EE}, V_{DD}$), having an $R_G$ results in:
$$I_D=\frac{-V_{EE}}{R_S}-\frac{V_{GS}}{R_S}$$
## PMOS transistors
These have current flowing from the source to the drain. It is effectively equal to an NMOS at all points but with its polarity reversed.
\begin{align*}
\tag{triode}I_D&=k_p\left(|V_{ov}|-\frac 1 2V_{SD}\right)V_{SD} \\
\tag{saturation}I_D&=\frac 1 2 k_p(V_{SG}-|V_{tp}|)^2
\end{align*}
### Frequency dependence
A **parasitic capacitor** from the gate to the source of an NMOS limits the bandwidth (gain). These represent physical limitations of electrodes. At the output, the current through the capacitor can be neglected. At the input, the current through the capacitor dominates.

View File

@ -1,290 +0,0 @@
# ECE 250: DSA
## Solving recurrences
The **master method** is used to solve recurrences. For expressions of the form $T(n)=aT(n/b)+f(n)$:
- If $f(n)=O(n^{\log_b a})$, we have $T(n)=\Theta(n^{\log_b a}\log n)$
- If $f(n) < O(n^{\log_b a})$, we have $T(n)=O(n^{\log_b a})$
- If $f(n) > \Omega(n^{\log_b a})$, and $af(n/b)\leq cf(n), c<0$, we have $T(n)=\Theta(f(n))$
## Heaps
A heap is a binary tree **stored in an array** in which all levels but the lowest are filled. It is guaranteed that the parent of index $i$ is greater than or equal to the element at index $i$.
- the parent of index $i$ is stored at $i/2$
- the left child of index $i$ is stored at $2i$
- the right child of index $i$ is stored at $2i+1$
<img src="https://upload.wikimedia.org/wikipedia/commons/c/c4/Max-Heap-new.svg" width=600>(Source: Wikimedia Commons)</img>
The **heapify** command takes a node and makes it and its children a valid heap.
```rust
fn heapify(&mut A: Vec, i: usize) {
if A[2*i] >= A[i] {
A.swap(2*i, i);
heapify(A, 2*i)
} else if A[2*i + 1] >= A[i] {
A.swap(2*i + 1, i);
heapify(A, 2*i + 1)
}
}
```
Repeatedly heapifying an array from middle to beginning converts it to a heap.
```rust
fn build_heap(A: Vec) {
let n = A.len()
for i in (n/2).floor()..0 { // this is technically not valid but it's much clearer
heapify(A, i);
}
}
```
### Heapsort
Heapsort constructs a heap annd then does magic things that I really cannot be bothered to figure out right now.
```rust
fn heapsort(A: Vec) {
build_heap(A);
let n = A.len();
for i in n..0 {
A.swap(1, i);
heapify(A, 1); // NOTE: heapify takes into account the changed value of n
}
}
```
### Priority queues
A priority queue is a heap with the property that it can remove the highest value in $O(\log n)$ time.
```rust
fn pop(A: Vec, &n: usize) {
let biggest = A[0];
A[0] = n;
*n -= 1;
heapify(A, 1);
return biggest;
}
```
```rust
fn insert(A: Vec, &n: usize, key: i32) {
*n += 1;
let i = n;
while i > 1 && A[parent(i)] < key {
A[i] = A[parent(i)];
i = parent(i);
}
A[i] = k;
}
```
## Sorting algorithms
### Quicksort
Quicksort operates by selecting a **pivot point** that ensures that everything to the left of the pivot is less than anything to the right of the pivot, which is what partitioning does.
```rust
fn partition(A: Vec, left_bound: usize, right_bound: usize) {
let i = left_bound;
let j = right_bound;
while true {
while A[j] <= A[right_bound] { j -= 1; }
while A[i] >= A[left_bound] { i += 1; }
if i < j { A.swap(i, j); }
else { return j } // new bound!
}
}
```
Sorting calls partitioning with smaller and smaller bounds until the collection is sorted.
```rust
fn sort(a: Vec, left: usize, right: usize) {
if left < right {
let pivot = partition(A, left, right);
sort(A, left, pivot);
sort(A, pivot+1, right);
}
}
```
- In the best case, if partitioning is even, the time complexity is $T(n)=T(n/2)+\Theta(n)=\Theta(n\log n)$.
- In the worst case, if one side only has one element, which occurs if the list is sorted, the time complexity is $\Theta(n^2)$.
### Counting sort
If items are or are linked to a number from $1..n$ (duplicates are allowed), counting sort counts the number of each number, then moves things to the correct position. Where $k$ is the size of the counter array, the time complexity is $O(n+k)$.
First, construct a count prefix sum array:
```rust
fn count(A: Vec, K: usize) {
let counter = vec![0; K];
for i in A {
counter[i] += 1;
}
for (index, val) in counter.iter_mut().enumerate() {
counter[index + 1] += val; // ignore bounds for cleanliness please :)
}
return counter
}
```
Next, the prefix sum represents the correct position for each item.
```rust
fn sort(A: Vec) {
let counter = count(A, 100);
let sorted = vec![0; A.len()];
for i in n..0 {
sorted[counter[A[i]]] = A[i];
counter[A[i]] -= 1;
}
}
```
## Graphs
!!! definition
- A **vertex** is a node.
- The **degree** of a node is the number of edges connected to it.
- A **connected graph** is such that there exists a path from any node in the graph to any other node.
- A **connected component** is a subgraph such that there exists a path from any node in the subgraph to any other node in the subgraph.
- A **tree** is a connected graph without cycles.
### Directed acyclic graphs
a DAG is acyclic if and only if there are no **back edges** — edges from a child to an ancestor.
### Bellman-Ford
The Bellman-Ford algorithm allows for negative edges and detects negative cycles.
```rust
fn bf(G: Graph, s: Node) {
let mut distance = Vec::new(INFINITY);
let mut adj_list = Vec::from(G);
distance[s] = 0;
for i in 1..G.vertices.len()-1 {
for (u,v) in G.edges {
if distance[v] > distance[u] + adj_list[u][v] {
distance[v] = distance[u] + adj_list[u][v];
}
}
}
for (u, v) in G.edges {
if distance[v] > distance[u] + adj_list[u][v] {
return false;
}
}
return true;
}
```
### Topological sort
This is used to find the shortest path in a DAG simply by DFS.
```rust
fn shortest_path(G: Graph, s: Node) {
let nodes: Vec<Node> = top_sort(G);
let mut adj_list = G.to_adj_list();
let mut distance = Vec::new(INFINITY);
for v in nodes {
for adjacent in adj_list[v] {
if distance[adjacent] > distance[v] + adjacent[v] {
distance[v] = distance[adjacent] + adjacent[v];
}
}
}
}
```
### Minimum spanning tree
!!! definition
- A **cut** $(S, V-S)$ is a partition of vertices into disjoint sets $S$ and $V-S$.
- An edge $u,v\in E$ **crosses the cut** $(S,V-S)$ if t`he endpoints are on different sides of the cut.
- A cut **respects** a set of edges $A$ if and only if no edge in $A$ crosses the cut.
- A **light edge** is the minimum of all edges that could cross the cut. There can be more than one light edge per cut.
A **spanning tree** of $G$ is a subgraph that contains all of its vertices. An MST minimises the sum of all edges in the spanning tree.
To create an MST:
1. Add edges from the spanning tree to an empty set, maintaining that the set is always a subset of an MST (only "safe edges" are added)
The **Prim-Jarnik algorithm** grows a tree one vertex at a time. $A$ is a subset of the already computed portion of $T$, and all vertices outside $A$ have a weight of infinity if there is no edge.
```rust
// r is the start vertex
fn create_mst_prim(G: Graph, r: Vertex) {
// clean all vertices
for vertex in G.vertices.iter_mut() {
vertex.min_weight = INFINITY;
vertex.parent = None;
}
let Q = BinaryHeap::from(G.vertices); // priority queue
while let Some(u) = Q.pop() {
for v in u.adjacent_vertices.iter_mut() {
if Q.contains(v) && v.edge_to(u).weight < v.min_weight {
v.min_weight = v.edge_to(u).weight;
Q."modify_key"(v);
v.parent = u;
}
}
}
}
```
**Kruskal's algorithm** is objectively better by relying on edges instead.
```rust
fn create_mst_kruskal(G: Graph) -> HashSet<Edge> {
let mut A = HashSet::new();
let mut S = DisjointSet::new(); // vertices set
for v in G.vertices.iter() {
S.add_as_new_set(v);
}
G.edges.sort(|edge| edge.weight);
for (from, dest) in G.edges {
if S.find_set_that_contains(from) != S.find_set_that_contains(dest) {
A.insert((from, to));
let X = S.pop(from);
let Y = S.pop(to);
S.insert({X.union(Y)});
}
}
return A;
}
```
The time complexity is $O(E\log V)$.
### All pairs shortest path
Also known as an adjacency matrix extended such that each point represents the minimum distance from one edge to that other edge.

View File

@ -1 +0,0 @@
# BIOL 240: Microbiology 1

View File

@ -1 +0,0 @@
# ECE 203: Probability

View File

@ -1,2 +0,0 @@
# ECE 207: Signals and Systems

View File

@ -1,22 +0,0 @@
# ECE 208: Discrete Math 2
## Hilbert system rules
**Axioms:**
- $\vdash (A\implies (B\implies A))$
- $\vdash (A\implies (B\implies C))\implies ((A\implies B)\implies (A\implies C))$
- $\vdash (\neg B\implies\neg A)\implies (A\implies B))$
**Inference (MP):**
- $\frac{\vdash A, \vdash A\implies B}{\vdash B}$
**Derived rules:**
- Deduction: $\frac{U\cup \{A\}\vdash B}{U\vdash A\implies B}$
- Contrapositive: $\frac{U\vdash \neg B\implies\neg A}{U\vdash A\implies B}$ (and vice versa)
- Transitivity: $\frac{u\vdash A\implies B, U\vdash B\implies C}{U\vdash A\implies C}$
- Exchange of antecedent: $\frac{U\vdash A\implies (B\implies C)}{U\vdash B\implies (A\implies C)}$
- Double negation: $\frac{U\vdash \neg\neg A}{U\vdash A}$ (and vice versa)
- Reductio ad absurdum: $\frac{U\vdash\neg A\implies false}{U\vdash A}$

View File

@ -1 +0,0 @@
# ECE 224: Embedded

View File

@ -1 +0,0 @@
# ECE 252: Concurrency

View File

@ -1,9 +0,0 @@
.md-typeset svg {
max-width: unset !important;
}
img {
display: block;
margin-left: auto;
margin-right: auto;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,11 @@
---
sidebarDepth: 2
footer: Thanks to James Su, Lakshy Gupta, and Vincent Guo for providing supplementary data for accuracy and conciseness.
---
# Home
Eifueo (eh-FWAY-oh) is intended to be primarily for personal use, with documentation here licensed under the GNU Free Documentation License.
This website is intended to be primarily for personal use, but is available publicly online.
Testing math rendering: $a^2+b^2=c^2$
@ -10,12 +15,10 @@ Testing math rendering: $a^2+b^2=c^2$
## Contact
If you would like to contribute by submitting fixes, requesting pages, and/or complaining about issues, feel free to open an issue on the [issue tracker](https://git.eggworld.tk/eggy/eifueo/issues) or submit a [pull request](https://git.eggworld.tk/eggy/eifueo/pulls), or contact the site administrator at d7chen at uwaterloo.ca.
If you would like to contribute by submitting fixes, requesting pages, and/or complaining about issues, feel free to open an issue on the [issue tracker](https://git.eggworld.tk/eggy/eifueo/issues) or submit a [pull request](https://git.eggworld.tk/eggy/eifueo/pulls), or contact the site administrator at 341213551 at gapps.yrdsb.ca
## Source
The source for Eifueo is available [here](https://git.eggworld.me/eggy/eifueo).
The source for Eifueo is available [here](https://git.eggworld.tk/eggy/eifueo).
## Acknowledgements
Thanks to James Su, Lakshy Gupta, and Vincent Guo for providing supplementary data for accuracy and conciseness.

View File

@ -699,7 +699,7 @@ The following **row operations** can be performed on the matrix to achieve this
- swapping (interchanging) the position of two rows
- $R_a \leftrightarrow R_b$
- multiplying a row by a non-zero constant **scalar**
- multiplying a row by a non-zero constant
- $AR_a \to R_a$
- adding/subtracting rows, overwriting the destination row
- $R_a\pm R_b\to R_b$

View File

@ -343,19 +343,15 @@ When a solution is **diluted** the moles of solute are the same before and after
$$c_iv_i=c_fv_f$$
A mass/mass percentage concentration (%m/m) is such that:
$$c\text{ (%m/m)}=\frac{\text{mass of solute (g)}}{\text{total mass of solution (g)}}×100\%$$
A mass/volume percentage concentration (%m/v) is easy to measure, but may be unreliable as volume changes with temperature. It is such that:
$$c\text{ (%m/v)}=\frac{\text{mass of solute (g)}}{\text{total volume of solution (100 cm}^3\text{)}}×100\%$$
A volume/volume percentage concentration (%v/v) has the same properties as the above but also has the caveat that there is no guarantee that the total volume of the solution is equal to the sums of the volumes of the solute and solvent. It is such that:
$$c\text{ (%v/v)}=\frac{\text{volume of solute (cm}^3\text{)}}{\text{total volume of solution (100 cm}^3\text{)}}×100\%$$
When dealing with very small concentrations, smaller units such as **parts per million (ppm)** or parts per billion (ppb) are used.
$$c\text{ (ppm)}=\frac{\text{mass of solute (g)}}{\text{mass of solution (g)}}×10^6$$
### Standard solutions
@ -469,10 +465,8 @@ Isotopes are atoms of the same element but with different masses, or alternative
The mass of every atom is represented relative to 1/12th of a carbon-12 atom. This mass is either unitless or expressed in terms of **atomic mass units (amu or u)**. On the periodic table, the **relative atomic mass** ($A_r$) is shown, which is the sum of the masses of each isotope combined with their natural abundance (%abundance).
$$
A_r = \text{%abundance}×\text{mass number of isotope} \\
m_a = \Sigma A_r
$$
$$A_r = \text{%abundance}×\text{mass number of isotope}$$
$$m_a = \Sigma A_r$$
When calculating the atomic mass from the graph from a **mass spectrometer**, the sum of the natural abundances of each isotope may not equal 100 or 1 (not in %abundance). In this case, calculation of %abundance will need to be done before solving for $m_a$.

View File

@ -712,8 +712,7 @@ $$\ce{14 = pH + pOH}$$
### Acid/base dissociation
An equilibrium will be reached when a weak acid or base dissociates/ionises in water. The extent that the acid or base has dissociated/ionised can be quantified with **percent dissociation/ionisation**.
$$\text{\% ionisation} = \frac{\text{[acid ionised]}}{\text{[original acid]}}\times 100\%$$
$$\text{% ionisation} = \frac{\text{[acid ionised]}}{\text{[original acid]}}\times 100\%$$
!!! note
When performing an approximation assumption in an ICE table, the assumption is also valid if the % ionisation is less than 5%.

View File

@ -1024,7 +1024,7 @@ Circular motion is any motion along a circular path. The instantaneous velocity
!!! definition
- An object is in **uniform circular motion** when all instantaneous velocities are equal in magnitude or when all accelerations are equal in magnitude.
- **Period** ($T$) represents the time required to complete one revolution ($360°$ or $2\pi$ radians).
- **Frequency** ($f$) represents the revolutions per second represented in hertz ($\text{1 Hz=1 s}^{-1}$), and is the inverse of period.
- **Frequency** ($f$) represents the revolutions per second represented in hertz ($\text{1 Hz=1s^{-1}}$), and is the inverse of period.
!!! warning
As velocity and acceleration are vectors, direction must be considered when manipulating them. This means that the **kinematic equations** cannot be used.

View File

@ -1,76 +0,0 @@
site_name: Eifueo
site_description: "A collection of personal notes throughout school"
site_author: "Daniel Chen"
copyright: "Text licensed under the GNU Free Documentation License"
site_url: "https://eifueo.eggworld.me"
repo_url: "https://git.eggworld.me/eggy/eifueo"
repo_name: Gitea
nav:
- Home: index.md
- Grade 11 IB:
- SL Physics 1: g11/sph3u7.md
- SL Physics 2: g11/sph4u7.md
- SL Math - Analysis and Approaches 1: g11/mhf4u7.md
- SL Math - Analysis and Approaches 2: g11/mcv4u7.md
- SL French 1: g11/fsf3u7.md
- HL English 1: g11/eng3uz.md
- HL Chemistry 1: g11/sch3uz.md
- HL History 1: g11/chw3mz.md
- Theory of Knowledge: g11/tok.md
- Grade 12 IB:
- SL French 2: g12/fsf3uz.md
- HL Chemistry 2: g12/sch4uz.md
- HL Chemistry 3: g12/snc4mz.md
- HL English 2: g12/eng4uz.md
- HL History 2: g12/chy4uz.md
- Computer Engineering 1A:
- "ECE 105: Classical Mechanics": 1a/ece105.md
- "ECE 150: C++": 1a/ece150.md
- "MATH 115: Linear Algebra": 1a/math115.md
- "MATH 117: Calculus 1": 1a/math117.md
- Computer Engineering 1B:
- "ECE 106: Electricity & Magnets": 1b/ece106.md
- "ECE 108: Discrete Math 1": 1b/ece108.md
- "ECE 124: Digital Circuits": 1b/ece124.md
- "ECE 140: Linear Circuits": 1b/ece140.md
- "ECE 192: Engineering Economics": 1b/ece192.md
- "MATH 119: Calculus 2": 1b/math119.md
- Computer Engineering 2A:
- "ECE 109: Materials Chemistry": 2a/ece109.md
- "ECE 240: Electronic Circuits": 2a/ece240.md
- "ECE 222: Digital Computers": 2a/ece222.md
- "ECE 250: DSA": 2a/ece250.md
- "ECE 205: Advanced Calculus 1": 2a/ece205.md
- "ECE 204: Numerical Methods": 2a/ece204.md
- Computer Engineering 2B:
- "ECE 208: Discrete Math 2": 2b/ece208.md
- "ECE 207: Signals": 2b/ece207.md
- "BIOL 240: Microbiology 1": 2b/biol240.md
- "ECE 203: Probability": 2b/ece203.md
- "ECE 224: Embedded": 2b/ece224.md
- "ECE 252: Concurrency": 2b/ece252.md
theme:
name: material
markdown_extensions:
- mdx_math:
enable_dollar_delimiter: True
- admonition
- pymdownx.details
- pymdownx.superfences
- attr_list
- def_list
- footnotes
- toc:
permalink: True
extra_javascript:
[
"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.2/katex.min.js",
"https://cdn.jsdelivr.net/npm/katex@0.16.2/dist/contrib/mhchem.min.js",
"https://cdn.jsdelivr.net/npm/katex/dist/contrib/mathtex-script-type.min.js",
]
extra_css:
["https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.2/katex.min.css", "fix_katex.css"]

30
package.json Normal file
View File

@ -0,0 +1,30 @@
{
"name": "eifueo",
"version": "0.1.0",
"description": "A VitePress version of the Eifueo project",
"main": "index.js",
"scripts": {
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:serve": "vitepress serve docs",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://git.eggworld.tk/eggy/eifueo.git"
},
"author": "eggy",
"license": "GPLv3",
"bugs": {
"url": "https://git.eggworld.tk/eggy/eifueo/issues"
},
"homepage": "https://git.eggworld.tk/eggy/eifueo",
"dependencies": {},
"devDependencies": {
"markdown-it-mathjax3": "^4.3.1",
"pug": "^3.0.2",
"pug-plain-loader": "^1.1.0",
"sass": "^1.51.0",
"vitepress": "^0.22.4"
}
}

View File

@ -1,6 +0,0 @@
mkdocs
mkdocs-material
mkdocs-material-extensions
# get latest commit bc pypi is outdated and is missing some fixes
git+https://github.com/oprypin/markdown-callouts.git#egg=markdown-callouts