Solutions for FCUP's Numerical Analysis Assignments
674
1 - Numerical Series Approximation/LICENSE
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
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.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"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.
|
||||
|
||||
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.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
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 charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
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:
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
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:
|
||||
|
||||
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.
|
||||
|
||||
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, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
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, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
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.
|
||||
|
||||
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 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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
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.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
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.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
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.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
256
1 - Numerical Series Approximation/README.md
Normal file
@ -0,0 +1,256 @@
|
||||
---
|
||||
title: "Análise Numérica - Trabalho Prático 1"
|
||||
author:
|
||||
- Diogo Cordeiro
|
||||
- Hugo Sales
|
||||
- Pedro Costa
|
||||
geometry: margin=2cm
|
||||
output: pdf_document
|
||||
---
|
||||
|
||||
## Motivação
|
||||
|
||||
Perceber e analisar técnicas de aproximação de séries numéricas e estratégias
|
||||
para controlo do erro de cálculos em computador, assim como implementar
|
||||
algoritmos com recurso a métodos numéricos adequados e interpretar os resultados.
|
||||
|
||||
## Questão 1
|
||||
|
||||
O _eps_ está definido como a diferença entre 1.0 e o menor valor
|
||||
representável superior a um, por exemplo, 2^-23^, em precisão simples, e 2^-52^
|
||||
em precisão dupla (em ambos os casos $Base^{-(precisão-1)}$). O ISO 9899 C define:
|
||||
|
||||
"a diferença entre 1 e o menor valor superior a 1 que é
|
||||
representável num dado tipo de ponto flutuante"
|
||||
|
||||
Verificamos a existência de uma definição alternativa: "o menor número que
|
||||
somado com 1 resulta num número maior do que 1". Não usamos esta definição, uma
|
||||
vez que devido ao arredondamento para o valor mais próximo, bastaria usar um
|
||||
valor ligeiramente maior do que metade do nosso _eps_ para satisfazer
|
||||
a condição. E também porque os standards ISO
|
||||
optam por "passo entre valores adjacentes".
|
||||
|
||||
O código seguinte implementa o cálculo de
|
||||
|
||||
$$ (2 - \sum _{n=1}^{\infty}\:\frac{1}{2^n}) - 1 = \textit{eps} $$
|
||||
|
||||
onde
|
||||
|
||||
$$ \lim _{n\to \infty }\sum _{n=1}^{\infty}\:\frac{1}{2^n} = 1^{-} $$
|
||||
|
||||
Logo este cálculo converge para 1 por números superiores.
|
||||
|
||||
\pagebreak
|
||||
|
||||
double machine_eps() {
|
||||
// Pela definição, este valor tem que ser superior a 1, e
|
||||
// como a máquina usa um sistema de vírgula flutuante de base 2,
|
||||
// este tem que ser uma potência de 2
|
||||
double epsilon_candidate = 2.0,
|
||||
epsilon = epsilon_candidate,
|
||||
// Primeiro termo da série geométrica com proporção 1/2,
|
||||
// que converge para 1
|
||||
power = 2.0;
|
||||
|
||||
// Diferente de 1 pela definição
|
||||
while (epsilon_candidate != 1.0) {
|
||||
epsilon = epsilon_candidate;
|
||||
// Aproximar o epsilon candidate do epsilon,
|
||||
// reduzindo este com a acumulação do termo da sucessão
|
||||
epsilon_candidate -= 1/power;
|
||||
// Razão da sucessão
|
||||
power *= 2;
|
||||
}
|
||||
|
||||
return epsilon-1.0;
|
||||
}
|
||||
|
||||
Com a execução deste código obtivemos 2.2204460492503131e-16, o mesmo valor
|
||||
definido, para aritmética IEEE, na C library `float.h`.
|
||||
|
||||
#define DBL_EPSILON 2.2204460492503131e-16
|
||||
|
||||
## Questão 2
|
||||
|
||||
Utilizamos o seguinte código na linguagem Java para computar a série dada e
|
||||
obtivemos os resultados apresentados na tabela que segue.
|
||||
Para evitar o cálculo de fatoriais e de grande magnitude, o que diminuiria a
|
||||
performace e aumentaria o erro e a possibilidade de overflow,
|
||||
optamos usar a definição por recorrência e por simplificar algebricamente o
|
||||
cálculo dos termos da série, obtendo uma expressão mais simples.
|
||||
|
||||
$$a_{k+1} = a_k \cdot \frac{k + 1}{4 \cdot k + 6}$$
|
||||
|
||||
/**
|
||||
* Computar a série 2 com um erro absoluto inferior a um dado
|
||||
* epsilon
|
||||
*/
|
||||
public static double compute_series_2(double epsilon) {
|
||||
// Fator constante
|
||||
double factor = 9.0/(double)(2.0*Math.sqrt(3));
|
||||
// Tirado do critério D'Alembert para L = 0.5 < 1
|
||||
double super_L = 1.0/(double)(1-0.25);
|
||||
|
||||
// Index do sumatório
|
||||
int k = 0;
|
||||
// Acumulação do sumatório
|
||||
double acc = 0;
|
||||
|
||||
// O valor do termo actual da série
|
||||
double a = 1.0f; // a with k = 0
|
||||
// Enquanto o nosso erro absoluto é superior ao
|
||||
// epsilon dado
|
||||
while(epsilon < factor*a*super_L) {
|
||||
// Acumula com o termo anterior
|
||||
acc += a;
|
||||
// Computa o termo seguinte e posteriormente
|
||||
// incrementa k
|
||||
a = compute_serie_2_term(k++) * a;
|
||||
}
|
||||
System.out.println(factor*acc + " " + (k - 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Computa o termo k da série 2 dado um anterior
|
||||
*/
|
||||
public static double compute_serie_2_term(int k) {
|
||||
return (double)(k+1.0f)/(double)(4.0f*k+6.0f);
|
||||
}
|
||||
|
||||
### Tabela de resultados
|
||||
|
||||
$-log(\epsilon)$ | $S_n$ | Iterações | Tempo (s)
|
||||
-----------------|---------------------|-------------|----------
|
||||
8 | 3.141592651 | 13 | 0.094
|
||||
9 | 3.1415926529 | 14 | 0.099
|
||||
10 | 3.14159265355 | 16 | 0.100
|
||||
11 | 3.141592653587 | 18 | 0.100
|
||||
12 | 3.1415926535892 | 19 | 0.095
|
||||
13 | 3.14159265358976 | 21 | 0.101
|
||||
14 | 3.141592653589785 | 22 | 0.097
|
||||
15 | 3.1415926535897936 | 24 | 0.097
|
||||
|
||||
|
||||
A série aparenta aproximar o valor de $\pi$.
|
||||
|
||||
Reparamos que geralmente a ordem de grandeza do erro indica o número de casas
|
||||
decimais exatas obtidas, contudo o valor obtido para $-log(\epsilon)$ igual a
|
||||
9 e 14 produz um resultado com menos uma casa decimal exata. Ainda assim
|
||||
o valor apresentado representa $\pi$ com erro absoluto inferior a
|
||||
$5 \cdot 10^{-10}$ e $5 \cdot 10^{-15}$ respetivamente.
|
||||
|
||||
## Questão 3
|
||||
|
||||
Inicialmente implementamos o cálculo do valor aproximado desta série em Java,
|
||||
mas deparamo-nos com um longo tempo de execução devido ao elevado número de
|
||||
iterações necessárias para aproximar a série com o $\epsilon$ pretendido, pelo
|
||||
que decidimos testar uma implementação na linguagem C++, na qual obtivemos maior
|
||||
performace, o que permitiu o cãlculo para um valor menor de $\epsilon$ em tempo
|
||||
útil.
|
||||
|
||||
double compute_serie_3_term(unsigned long n) {
|
||||
return -((double)(2*n+1))/(double)(2*n+3);
|
||||
}
|
||||
|
||||
void compute_serie_3(double err) {
|
||||
// Termo atual
|
||||
unsigned long k = 0;
|
||||
// Valor do termo atual
|
||||
double ak = 1;
|
||||
// Acumulador do valor da série
|
||||
double acc = 1;
|
||||
// Parar quando o erro obtido for inferior ao pretendido
|
||||
while (err < 4*std::abs(ak)) {
|
||||
// Calcular o termo seguinte e incrementar k
|
||||
ak = compute_serie_3_term(k++) * ak;
|
||||
// Somar o termo ao total
|
||||
acc += ak;
|
||||
}
|
||||
|
||||
std::cout << k << " " << 4*acc << '\n';
|
||||
}
|
||||
|
||||
### Tabela de Resultados em Java
|
||||
|
||||
$-log(\epsilon)$ | $S_n$ | Iterações | Tempo (s)
|
||||
-----------------|---------------|-------------|-----------
|
||||
8 | 3.141592659 | 200000000 | 2.237
|
||||
9 | 3.1415926541 | 2000000000 | 21.522
|
||||
10 | 3.14159265364 | 20000000012 | 215.442
|
||||
|
||||
|
||||
### Tabela de Resultados em C++
|
||||
|
||||
$-log(\epsilon)$ | $S_n$ | Iterações | Tempo (s)
|
||||
------------------|--------------------|----------------|----------
|
||||
8 | 3.141592659 | 200000000 | 0.787
|
||||
9 | 3.1415926541 | 2000000000 | 7.862
|
||||
10 | 3.14159265364 | 20000000012 | 79.130
|
||||
11 | 3.141592653593 | 200000002870 | 791.625
|
||||
12 | 3.1415926535878 | 2000000614027 | 7871.842
|
||||
|
||||
Observando as tabelas notamos um padrão, e, motivados por establecer uma relação
|
||||
entre $\epsilon$ e tanto o números de iterações e o tempo de execução, decidimos
|
||||
traçar um gráfico com estes valores.
|
||||
|
||||
![Tempo em função de $\epsilon$](graficos/questao3_tempos.png){ width=12cm }
|
||||
|
||||
![Iterações em função de $\epsilon$](graficos/questao3_iteracoes.png){ width=12cm }
|
||||
|
||||
\pagebreak
|
||||
|
||||
Destes dois gráficos concluímos que o tempo cresce exponencialmente em função do
|
||||
valor de $-log(\epsilon)$, sendo que ambos crescem com um fator de 10,
|
||||
correspondendo aproximadamente a um número da forma $5*10^{-(\epsilon + 1)}$, mas
|
||||
não exatamente a este valor, sendo que quando $\epsilon$ diminuiu, o valor
|
||||
de $n$ afasta-se do valor $5*10^{-(\epsilon + 1)}$.
|
||||
Descobrimos que se utilizarmos mais precisão nos cálculos (nomeadamente através
|
||||
do uso de `long double` em C++, ou seja, 128 bits), o padrão verifica-se para
|
||||
todos os casos testados.
|
||||
Concluímos disto que este desvio se deve ao erro de
|
||||
arredondamento ($|S_n - \hat{S}_n|$), que neste caso se deve à elevada magnitude
|
||||
de $n$.
|
||||
|
||||
## Questão 4
|
||||
|
||||
Usamos como referência
|
||||
|
||||
$$ \pi = 3.14159265358979324$$
|
||||
|
||||
sendo este valor arredondado a 18 algarismos significativos, para que o erro de
|
||||
arredondamento aqui utilizado não altere os resultados do cálculo do erro
|
||||
absoluto efetivo.
|
||||
|
||||
Erro efetivo obtido na questão 2:
|
||||
|
||||
$-log(\epsilon)$ | $\Delta x$
|
||||
-----------------|---------------------
|
||||
8 | $2.6 \cdot 10^{-09}$
|
||||
9 | $6.9 \cdot 10^{-10}$
|
||||
10 | $4.0 \cdot 10^{-11}$
|
||||
11 | $2.8 \cdot 10^{-12}$
|
||||
12 | $6.0 \cdot 10^{-13}$
|
||||
13 | $3.4 \cdot 10^{-14}$
|
||||
14 | $8.0 \cdot 10^{-15}$
|
||||
15 | $4.5 \cdot 10^{-16}$
|
||||
|
||||
Erro efetivo obtido na questão 3:
|
||||
|
||||
$-log(\epsilon)$ | $\delta x$
|
||||
-----------------|---------------------
|
||||
8 | $5.5 \cdot 10^{-09}$
|
||||
9 | $5.2 \cdot 10^{-10}$
|
||||
10 | $5.1 \cdot 10^{-11}$
|
||||
11 | $3.3 \cdot 10^{-12}$
|
||||
12 | $2.0 \cdot 10^{-12}$
|
||||
|
||||
Notamos que para $\epsilon = 10^{-12}$ o erro efetivamente cometido é maior que
|
||||
o erro pretendido. Justificamos este facto com a elevada magnitude de $n$, o que
|
||||
leva a termos de pequena magnitude, o que induz erros de cancelamento.
|
||||
|
||||
Concluímos que a série utilizada na questão dois possibilita o cálculo da
|
||||
aproximação do valor de $\pi$ usando um número de termos muito menor, para uma
|
||||
mesma precisão. Sendo que a série da questão dois dá resultados
|
||||
com erro inferior a $10^{-15}$ com um número de iterações na ordem das dezenas,
|
||||
enquanto que a série da questão três requer iterações na ordem das centenas de
|
||||
milhões para obter um erro inferior a $10^{-8}$.
|
BIN
1 - Numerical Series Approximation/assignment.pdf
Normal file
18
1 - Numerical Series Approximation/graficos/erro.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
int main() {
|
||||
double vals[] = { 3.1415926029605323,
|
||||
3.1415926506432696,
|
||||
3.1415926528764806,
|
||||
3.1415926535477534,
|
||||
3.1415926535795631,
|
||||
3.1415926535891852,
|
||||
3.1415926535897571,
|
||||
3.1415926535897851};
|
||||
|
||||
std::cout.precision(17);
|
||||
for(double v : vals) {
|
||||
std::cout << std::abs(3.14159265358979324 - v);
|
||||
}
|
||||
}
|
173
1 - Numerical Series Approximation/graficos/erro2.cpp
Normal file
@ -0,0 +1,173 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
int main() {
|
||||
|
||||
// double vals[] = { 3.1415926029605323,
|
||||
// 3.1415926506432696,
|
||||
// 3.1415926528764806,
|
||||
// 3.1415926535477534,
|
||||
// 3.1415926535795631,
|
||||
// 3.1415926535891852,
|
||||
// 3.1415926535897571,
|
||||
// 3.1415926535897851};
|
||||
|
||||
double vals[] = {
|
||||
|
||||
// 3.1415925645296694,
|
||||
// 3.1415926484100587,
|
||||
// 3.1415926523361879,
|
||||
// 3.1415926535159437,
|
||||
// 3.1415926535718257,
|
||||
// 3.1415926535887251,
|
||||
// 3.1415926535897296,
|
||||
// 3.1415926535897780
|
||||
|
||||
// 1.2091995566689335,
|
||||
// 1.2091995750220277
|
||||
// ,
|
||||
// 1.209199575881591
|
||||
// ,
|
||||
// 1.2091995761399641
|
||||
// ,
|
||||
// 1.2091995761522076
|
||||
// ,
|
||||
// 1.2091995761559111
|
||||
// ,
|
||||
// 1.2091995761561314,
|
||||
// 1.209199576156142
|
||||
|
||||
// 3.1415926413913953,
|
||||
// 3.1415926506432696,
|
||||
// 3.1415926534167733,
|
||||
// 3.1415926535795631,
|
||||
// 3.1415926535873004,
|
||||
// 3.1415926535896448,
|
||||
// 3.1415926535897571,
|
||||
// 3.1415926535897918
|
||||
|
||||
|
||||
// 3.1415926436246062,
|
||||
// 3.1415926511835623,
|
||||
// 3.141592653448583,
|
||||
// 3.1415926535814478,
|
||||
// 3.1415926535877601,
|
||||
// 3.1415926535896723,
|
||||
// 3.1415926535897643,
|
||||
// 3.1415926535897927
|
||||
|
||||
// 3.1415926441636568
|
||||
// ,
|
||||
// 3.1415926513142782
|
||||
// ,
|
||||
// 3.1415926534563079
|
||||
// ,
|
||||
// 3.141592653581907
|
||||
// ,
|
||||
// 3.141592653587872
|
||||
// ,
|
||||
// 3.1415926535896794
|
||||
// ,
|
||||
// 3.141592653589766
|
||||
// ,
|
||||
// 3.1415926535897927
|
||||
|
||||
|
||||
|
||||
// 3.1415926413913944
|
||||
// ,
|
||||
// 3.1415926506432688
|
||||
// ,
|
||||
// 3.1415926534167729
|
||||
// ,
|
||||
// 3.1415926535795626
|
||||
// ,
|
||||
// 3.1415926535873
|
||||
// ,
|
||||
// 3.1415926535896443
|
||||
// ,
|
||||
// 3.1415926535897567
|
||||
// ,
|
||||
// 3.1415926535897909
|
||||
|
||||
// 3.1415926413913948
|
||||
// ,
|
||||
// 3.1415926506432692
|
||||
// ,
|
||||
// 3.1415926534167732
|
||||
// ,
|
||||
// 3.1415926535795628
|
||||
// ,
|
||||
// 3.1415926535873003
|
||||
// ,
|
||||
// 3.1415926535896447
|
||||
// ,
|
||||
// 3.141592653589757
|
||||
// ,
|
||||
// 3.1415926535897911
|
||||
|
||||
// 3.1415926413913948
|
||||
// ,
|
||||
// 3.1415926506432692
|
||||
// ,
|
||||
// 3.1415926534167733
|
||||
// ,
|
||||
// 3.1415926535795628
|
||||
// ,
|
||||
// 3.1415926535873003
|
||||
// ,
|
||||
// 3.1415926535896447
|
||||
// ,
|
||||
// 3.141592653589757
|
||||
// ,
|
||||
// 3.1415926535897911
|
||||
|
||||
// 3.1415926413913948
|
||||
// ,
|
||||
// 3.1415926506432692
|
||||
// ,
|
||||
// 3.1415926534167733
|
||||
// ,
|
||||
// 3.1415926535795628
|
||||
// ,
|
||||
// 3.1415926535873003
|
||||
// ,
|
||||
// 3.1415926535896447
|
||||
// ,
|
||||
// 3.141592653589757
|
||||
// ,
|
||||
// 3.1415926535897911
|
||||
|
||||
// 3.1415926585894502,
|
||||
// 3.1415926540880963,
|
||||
// 3.1415926536384982,
|
||||
// 3.1415926535932850,
|
||||
// 3.1415926535877814
|
||||
|
||||
|
||||
// 3.1415926506432696,
|
||||
// 3.1415926528764806,
|
||||
// 3.1415926535477534,
|
||||
// 3.1415926535873004,
|
||||
// 3.1415926535891850,
|
||||
// 3.1415926535897570,
|
||||
// 3.1415926535897850,
|
||||
// 3.1415926535897936
|
||||
|
||||
3.141592651 ,
|
||||
3.1415926529 ,
|
||||
3.14159265355 ,
|
||||
3.141592653587 ,
|
||||
3.1415926535892 ,
|
||||
3.14159265358976 ,
|
||||
3.141592653589785,
|
||||
3.1415926535897936
|
||||
|
||||
};
|
||||
|
||||
|
||||
std::cout.precision(17);
|
||||
for(double v : vals) {
|
||||
std::cout << std::abs(3.14159265358979324 - v) << '\n';
|
||||
}
|
||||
}
|
30
1 - Numerical Series Approximation/graficos/erro3.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
int main() {
|
||||
double vals[] = {
|
||||
|
||||
// 3.1415926335902893,
|
||||
// 3.1415926515893244,
|
||||
// 3.1415926533883067,
|
||||
// 3.1415926535683196,
|
||||
// 3.1415926535862631
|
||||
|
||||
// 3.1415926585894502,
|
||||
// 3.1415926540880963,
|
||||
// 3.1415926536384982,
|
||||
// 3.1415926535932850,
|
||||
// 3.1415926535877814
|
||||
|
||||
3.141592659 ,
|
||||
3.1415926541 ,
|
||||
3.14159265364 ,
|
||||
3.141592653593,
|
||||
3.1415926535878
|
||||
};
|
||||
|
||||
std::cout.precision(17);
|
||||
for(double v : vals) {
|
||||
std::cout << std::abs(3.14159265358979324 - v) << '\n';
|
||||
}
|
||||
}
|
23
1 - Numerical Series Approximation/graficos/generate_graphics.gnuplot
Executable file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/gnuplot
|
||||
set output "questao3_tempos.png";
|
||||
set terminal png size 1200,900 enhanced font "Helvetica,20"
|
||||
set autoscale;
|
||||
set xr [7:13];
|
||||
set logscale y;
|
||||
set xlabel "-log(epsilon)"
|
||||
set ylabel "Tempo (s)"
|
||||
set linetype 1 lc rgb 'black'
|
||||
set linetype 2 lc rgb 'black
|
||||
plot "../questao3_tempo_java.txt" with linespoints dashtype 0 lw 4 t "Java", "../questao3_tempo_Cpp.txt" with linespoints dashtype 2 lw 4 t "C++";
|
||||
|
||||
set output "questao3_iteracoes.png";
|
||||
set terminal png size 1200,900 enhanced font "Helvetica,20"
|
||||
set autoscale;
|
||||
set xr [7:13];
|
||||
set logscale y;
|
||||
set xlabel "-log(epsilon)"
|
||||
set ylabel "Iterações"
|
||||
set linetype 1 lc rgb 'black'
|
||||
set linetype 2 lc rgb 'black
|
||||
plot "../questao3_iteracoes_java.txt" with linespoints dashtype 0 lw 4 t "Java", "../questao3_iteracoes_Cpp.txt" with linespoints dashtype 2 lw 4 t "C++";
|
||||
|
After Width: | Height: | Size: 11 KiB |
@ -0,0 +1,5 @@
|
||||
8 200000000
|
||||
9 2000000000
|
||||
10 20000000012
|
||||
11 200000002870
|
||||
12 2000000614027
|
@ -0,0 +1,3 @@
|
||||
8 200000000
|
||||
9 2000000000
|
||||
10 20000000012
|
@ -0,0 +1,5 @@
|
||||
8 0.787
|
||||
9 7.862
|
||||
10 79.130
|
||||
11 791.625
|
||||
12 7871.842
|
@ -0,0 +1,3 @@
|
||||
8 2.237
|
||||
9 21.522
|
||||
10 215.442
|
BIN
1 - Numerical Series Approximation/graficos/questao3_tempos.png
Normal file
After Width: | Height: | Size: 10 KiB |
@ -0,0 +1,10 @@
|
||||
8 200000000 3.1415926585894502 0.787
|
||||
9 2000000000 3.1415926540880963 7.862
|
||||
10 20000000012 3.1415926536384982 79.130
|
||||
11 200000002870 3.141592653593285 791.625
|
||||
12 2000000614027 3.1415926535877814 7908.842
|
||||
|
||||
|
||||
14
|
||||
|
||||
[0.787]
|
45
1 - Numerical Series Approximation/graficos/scratch
Normal file
@ -0,0 +1,45 @@
|
||||
8 | 3.1415926029605323 | 12 | 0m0.002s
|
||||
9 | 3.1415926506432696 | 14 | 0m0.002s
|
||||
10 | 3.1415926528764806 | 15 | 0m0.002s
|
||||
11 | 3.1415926535477534 | 17 | 0m0.002s
|
||||
12 | 3.1415926535795631 | 18 | 0m0.002s
|
||||
13 | 3.1415926535891852 | 20 | 0m0.002s
|
||||
14 | 3.1415926535897571 | 22 | 0m0.002s
|
||||
15 | 3.1415926535897851 | 23 | 0m0.001s
|
||||
|
||||
|
||||
8 | 3.1415926335902893 | 50000000 |0m0.200s
|
||||
9 | 3.1415926515893244 | 500000000 |0m1.979s
|
||||
10 | 3.1415926533883067 | 5000000000 |0m19.783s
|
||||
11 | 3.1415926535683196 | 50000000086 |3m18.003s
|
||||
12 | ^C | 1m10.621s | 0m0.000s
|
||||
|
||||
|
||||
8 | 50000000 | 3.1415926335902893 | 0.553s
|
||||
9 | 500000000 | 3.1415926515893244 | 4.608s
|
||||
10 | 5000000000 | 3.1415926533883067 | 45.069s
|
||||
11 | 50000000086 | | 450.325s
|
||||
|
||||
3.1415926535683196
|
||||
3.14159265358979324 (arredondado a 18 algorismos significativos, para que o erro de arredondamento aqui utilizado não altere os resultados do cálculo do erro absoluto efetivo)
|
||||
|
||||
|
||||
8 | 3.1415926029605323 | 12 | 0m0.002s
|
||||
9 | 3.1415926506432696 | 14 | 0m0.002s
|
||||
10 | 3.1415926528764806 | 15 | 0m0.002s
|
||||
11 | 3.1415926535477534 | 17 | 0m0.002s
|
||||
12 | 3.1415926535795631 | 18 | 0m0.002s
|
||||
13 | 3.1415926535891852 | 20 | 0m0.002s
|
||||
14 | 3.1415926535897571 | 22 | 0m0.002s
|
||||
15 | 3.1415926535897851 | 23 | 0m0.002s
|
||||
|
||||
|
||||
|
||||
8 | 3.1415926122124067 | 12 | 0m0.002s
|
||||
9 | 3.1415926511835623 | 14 | 0m0.002s
|
||||
10 | 3.1415926530074607 | 15 | 0m0.001s
|
||||
11 | 3.1415926535554908 | 17 | 0m0.002s
|
||||
12 | 3.1415926535814478 | 18 | 0m0.001s
|
||||
13 | 3.1415926535892975 | 20 | 0m0.002s
|
||||
14 | 3.1415926535897643 | 22 | 0m0.002s
|
||||
15 | 3.1415926535897869 | 23 | 0m0.002s
|
BIN
1 - Numerical Series Approximation/print.pdf
Normal file
27
1 - Numerical Series Approximation/source/Question1.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include <iostream>
|
||||
|
||||
double machine_eps() {
|
||||
double epsilon_candidate = 2.0,
|
||||
epsilon = epsilon_candidate,
|
||||
power = 2.0;
|
||||
|
||||
while (epsilon_candidate != 1.0)
|
||||
{
|
||||
epsilon = epsilon_candidate;
|
||||
epsilon_candidate -= 1/power;
|
||||
power *= 2;
|
||||
}
|
||||
|
||||
return epsilon-1.0;
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::cout.precision(17);
|
||||
|
||||
std::cout << machine_eps() << " - macheps" << '\n';
|
||||
|
||||
/*for(double step = 0.0f; step < 100'000'000; step += 1.0)
|
||||
{
|
||||
std::cout << step << " " << machine_eps(step) << '\n';
|
||||
}*/
|
||||
}
|
22
1 - Numerical Series Approximation/source/Question1wrong.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include <iostream>
|
||||
|
||||
double
|
||||
machine_eps(double start)
|
||||
{
|
||||
double epsilon = 1.0f;
|
||||
|
||||
while ((start + 0.5f * epsilon) != start)
|
||||
{
|
||||
epsilon = 0.5f * epsilon;
|
||||
}
|
||||
|
||||
return epsilon;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::cout.precision(17);
|
||||
|
||||
std::cout << machine_eps(1) << " - macheps" << '\n';
|
||||
}
|
56
1 - Numerical Series Approximation/source/Question2.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
/**
|
||||
* Compute k term of Serie 2 given the previous one
|
||||
*/
|
||||
double _compute_serie_2_term(unsigned long k, double ak) {
|
||||
return double(k+1)/(double(4*k+6)) * ak;
|
||||
}
|
||||
|
||||
// double c(int k) {
|
||||
// return std::pow(std::tgamma(k + 1), 2.0)/std::tgamma(2*k + 2);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Compute serie 2 with absole error below a given epsilon
|
||||
*/
|
||||
void compute_serie_2(double epsilon) {
|
||||
// Constant factor
|
||||
double factor = 9.0/(2.0*std::sqrt(3));
|
||||
// Taken from D'Alembert criterion for given that L = 0.5 < 1
|
||||
double super_L = 1.0/(1.0-0.25);
|
||||
|
||||
// Summation index
|
||||
unsigned long k = 0;
|
||||
// Acumulation for the Summation
|
||||
double acc = 0;
|
||||
|
||||
// Previous and current value on the series
|
||||
// double a_prev = 1.0f, // a with k = 0
|
||||
double a = 1.0; // _compute_serie_2_term(k, a_prev); // compute next
|
||||
// While our absolute error is higher than the given epsilon
|
||||
while(epsilon < factor*a*super_L) {
|
||||
// Accumulate with previous term
|
||||
|
||||
acc += a;
|
||||
// Update previous term to current term
|
||||
// a_prev = a;
|
||||
// Compute current term
|
||||
// a = c(k);
|
||||
a = _compute_serie_2_term(k++, a);
|
||||
}
|
||||
|
||||
std::cout << k << " " << std::abs(M_PI - factor*acc) << '\n';
|
||||
std::cout << factor * acc << " | " << k;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int, char **argv) {
|
||||
std::cout.precision(17);
|
||||
double power_of_ten = std::pow(10.0, -std::atoi(argv[1]));
|
||||
compute_serie_2(power_of_ten);
|
||||
}
|
31
1 - Numerical Series Approximation/source/Question3.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <numeric>
|
||||
#include <ios>
|
||||
#include <cstdlib>
|
||||
|
||||
double compute_serie_3_term(unsigned long n) {
|
||||
return -((double)(2*n+1))/(double)(2*n+3);
|
||||
}
|
||||
|
||||
double compute_serie_3(double err) {
|
||||
|
||||
unsigned long k = 0;
|
||||
double ak = 1;
|
||||
double acc = 1;
|
||||
|
||||
while (err < 4*std::abs(ak)) {
|
||||
ak *= compute_serie_3_term(k++);
|
||||
acc += ak;
|
||||
}
|
||||
|
||||
std::cout << k << " " << 4*acc << " " << std::abs(3.14159265358979324$$ - 4*acc) << '\n';
|
||||
return 4*acc;
|
||||
}
|
||||
|
||||
|
||||
int main(int, char **argv) {
|
||||
const double err = std::pow(10.0, -std::atof(argv[1]));
|
||||
std::cout.precision(17);
|
||||
compute_serie_3(err);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
public class Question1 {
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println(machine_eps());
|
||||
}
|
||||
|
||||
public static float machine_eps() {
|
||||
float epsilon = 1.0f;
|
||||
|
||||
while ((1.0f + 0.5f * epsilon) != 1.0f){
|
||||
epsilon = 0.5f * epsilon;
|
||||
}
|
||||
|
||||
return epsilon;
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
public class Question2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
double power_of_ten = Math.pow(10,-1 * Integer.parseInt(args[0]));
|
||||
compute_serie_2(power_of_ten);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute serie 2 with absole error below a given epsilon
|
||||
*/
|
||||
public static void
|
||||
compute_serie_2(double epsilon)
|
||||
{
|
||||
// Constant factor
|
||||
double factor = 9.0f/(double)(2.0f*Math.sqrt(3));
|
||||
// Taken from D'Alembert criterion for given that L = 0.5 < 1
|
||||
double super_L = 1.0f/(double)(1-0.25);
|
||||
|
||||
// Summation index
|
||||
int k = 0;
|
||||
// Acumulation for the Summation
|
||||
double acc = 0;
|
||||
|
||||
// Previous and current value on the series
|
||||
double a = 1.0f; // a with k = 0
|
||||
// While our absolute error is higher than the given epsilon
|
||||
while(epsilon < factor*a*super_L)
|
||||
{
|
||||
// Accumulate with previous term
|
||||
acc += a;
|
||||
// Compute current term
|
||||
a = _compute_serie_2_term(k++) * a;
|
||||
}
|
||||
// System.out.println(epsilon);
|
||||
// System.out.println("Value: " + factor*acc);
|
||||
// System.out.println("Error: " + (3.1415926535897932 - factor*acc));
|
||||
// System.out.println("K: " +(k-1) + "\n--------------");
|
||||
System.out.println(factor*acc + " " + (k - 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute k term of Serie 2 given the previous one
|
||||
*/
|
||||
public static double
|
||||
_compute_serie_2_term(int k)
|
||||
{
|
||||
return (double)(k+1.0f)/(double)(4.0f*k+6.0f);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
public class Question3 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
double err = Math.pow(10, -Integer.parseInt(args[0].trim()));
|
||||
compute_serie_2(err);
|
||||
}
|
||||
|
||||
public static double compute_serie_3_term(long n)
|
||||
{
|
||||
return -((double)(2*n+1))/(double)(2*n+3);
|
||||
}
|
||||
|
||||
public static void compute_serie_2(double err)
|
||||
{
|
||||
long k = 0;
|
||||
double ak = 1;
|
||||
double acc = 1;
|
||||
|
||||
while (err < 4 * Math.abs(ak)) {
|
||||
ak = compute_serie_3_term(k++) * ak;
|
||||
acc += ak;
|
||||
}
|
||||
|
||||
System.out.println(k + " " + 4 * acc);
|
||||
}
|
||||
|
||||
}
|
||||
|
674
2 - Newton and Iterative methods/LICENSE
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
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.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"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.
|
||||
|
||||
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.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
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 charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
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:
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
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:
|
||||
|
||||
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.
|
||||
|
||||
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, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
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, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
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.
|
||||
|
||||
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 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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
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.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
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.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
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.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
158
2 - Newton and Iterative methods/README.md
Normal file
@ -0,0 +1,158 @@
|
||||
---
|
||||
title: "Análise Numérica - Trabalho Prático 2"
|
||||
author:
|
||||
- Diogo Cordeiro
|
||||
- Hugo Sales
|
||||
- Pedro Costa
|
||||
geometry: margin=2cm
|
||||
output: pdf_document
|
||||
---
|
||||
|
||||
### Motivação
|
||||
|
||||
Pretende-se usar os métodos de Newton e iterativo simples para determinar um valor aproximado de um zero de
|
||||
|
||||
$$x^2 - cos(x)^2$$
|
||||
|
||||
|
||||
|
||||
### 1.a)
|
||||
Optamos por implementar o algoritmo pedido em C++ devido à possiblidade da aplicação de
|
||||
templates e lambdas. Deste modo, foi-nos possível implementar os dois métodos pedidos partindo
|
||||
de um algoritmo genérico pois a diferença entre o método de Newton
|
||||
e o método iterativo consiste apenas na fórmula de recorrência. Assim, o método de Newton
|
||||
pode ser visto como uma forma do método iterativo simples.
|
||||
|
||||
template<typename step_func>
|
||||
double find_root(double x0, double epsilon, step_func step, long iter_limit) {
|
||||
double x1 = x0, err;
|
||||
long iter = 1;
|
||||
do {
|
||||
x0 = x1;
|
||||
x1 = step(x0);
|
||||
err = std::abs(x1 - x0);
|
||||
} while(err > epsilon && iter++ < iter_limit);
|
||||
return x1;
|
||||
}
|
||||
|
||||
template<typename F_t, typename dF_t>
|
||||
double newton(double x0, double epsilon, F_t F, dF_t dF, long iter_limit) {
|
||||
return find_root(x0, epsilon,
|
||||
[&F, &dF](double x0){ return x0 - F(x0)/dF(x0); },
|
||||
iter_limit);
|
||||
}
|
||||
|
||||
int main() {
|
||||
auto F = [](double x){ return std::pow(x, 2.0) - std::pow(std::cos(x), 2.0); };
|
||||
auto dF = [](double x){ return 2.0 * x + std::sin(2.0 * x); };
|
||||
|
||||
double epsilon = 5.0 * std::pow(10.0, -12.0);
|
||||
|
||||
std::cout << newton(0.8, epsilon, F, dF, 100000) << '\n';
|
||||
}
|
||||
|
||||
\pagebreak
|
||||
|
||||
### 1.b)
|
||||
|
||||
![Gráfico para $x \in [-1;1]$](./graph.png){ width=8cm }
|
||||
|
||||
Como $\forall{x}: cos^2(x) \in [0:1]$, temos que $x^2 \geq cos^2(x)$ para $|x| > 1$, sabemos que o comportamento de $f(x)$ é dominado pelo comportamento de $x^2$, a qual só tem duas raízes.
|
||||
|
||||
A menor das raízes encontra-se no intervalo $]-\infty;0]$ e a maior destas em $[0;\infty[$.
|
||||
|
||||
Através da análise do gráfico, verificamos que o intervalo $[0.7;0.8]$ contém uma raíz. Definimos então $a = 0.7$ e $b = 0.8$.
|
||||
|
||||
![Gráfico para $x \in [0.7;0.8]$](./graph_small.png){ width=6cm }
|
||||
|
||||
|
||||
|
||||
### 1.c)
|
||||
|
||||
Queremos mostrar que as condições de aplicabilidade do método de Newton são satisfeitas no intervalo. Assim,
|
||||
|
||||
$$F(x) = x^2 - cos(x)^2$$
|
||||
|
||||
$$F'(x) = 2 \cdot x + sin(2 \cdot x)$$
|
||||
|
||||
$$F''(x) = 2 + 2 \cdot cos(2 \cdot x)$$
|
||||
|
||||
Como todas estas funções são compostas partindo de somas de funções contínuas em $\mathbb{R}$, são também continuas no intervalo considerado, verificando-se assim o primeiro critério.
|
||||
|
||||
Dado que,
|
||||
|
||||
$$F(a) < 0, F(b) < 0 \Rightarrow F(a) \cdot F(b) < 0$$
|
||||
|
||||
Verifica-se também o segundo critério.
|
||||
|
||||
Temos que $F''(x) = 2 + 2 \cdot cos(2 \cdot x)$, logo $cos(2 \cdot x) \in [-1;1]$, por isso $2 \cdot cos(2 \cdot x) \in [-2; 2]$, e $2 \cdot cos(2 \cdot x) + 2 \in [0;4]$ o que implica que $F''(x) \geq 0$, para $x \in \mathbb{R}$ e por isso $F'(x)$ é não decrescente em $\mathbb{R}$, ou seja, $F'(b) \geq F'(a)$ e $F'(a) > 3$ e por isso $F'(x) \neq 0 \forall{x} : \in [a;b]$, o que verifica o terceiro critério.
|
||||
|
||||
Como foi dito anteriormente, $F''(x) \geq 0$ em $\mathbb{R}$ e, por isso, também para $\forall{x} : \in [a;b]$, verificando-se a quarta condição.
|
||||
|
||||
Para $x_0 = b$, temos que $F(x_0) > 0$ e $F''(x_0) > 0$, logo $F(x_0) \cdot F''(x_0) > 0$, verificando-se a quinta condição.
|
||||
|
||||
Então a sucessão gerada converge para a unica raíz no intervalo $[a;b]$.
|
||||
|
||||
### 1.d)
|
||||
|
||||
Aplicamos o programa apresentado em $1.a$ e obtivemos os seguintes resultados.
|
||||
|
||||
Iterações | Erro estimado | Valor
|
||||
----------|---------------|---------------
|
||||
1 | 5.9e-02 | 0.740528800196
|
||||
2 | 1.4e-03 | 0.739086050826
|
||||
3 | 9.2e-07 | 0.739085133216
|
||||
4 | 3.7e-13 | 0.739085133215
|
||||
|
||||
Verficamos que o erro estimado é aproximadamente metade do erro estimado da iteração amterior,
|
||||
o que justificamos com o facto de que o resultado teórico
|
||||
nos dizer que o erro converge segundo uma secessão de segunda ordem.
|
||||
|
||||
### 1.e)
|
||||
|
||||
Aplicando a fórmula
|
||||
|
||||
$$M = \frac{1}{2} \cdot \frac{\max\limits_{a \leq x \leq b} | F''(x) |}{\min\limits_{a \leq x \leq b} | F'(x) |}$$
|
||||
|
||||
Como $F''(x)$ é decrescente em $[0;\pi/2]$, então $\max\limits_{a \leq x \leq b} | F''(x) | = |F''(a)|$ e como $F'(x)$ é não decrescente em $\mathbb{R}$, $\min\limits_{a \leq x \leq b} | F'(x) | = F'(a)$.
|
||||
|
||||
Assim, obtemos $M = \frac{F''(0.7)}{2F'(0.7)} \leq \frac{2.4}{2 \cdot 2.3} \leq 0.53$ e
|
||||
$n \geq \frac{ln(\alpha)}{ln(2)}, \alpha = \frac{ln(5 \cdot 10^{-14}) + ln(0.53)}{ln(0.53) + ln(10^{-1})}$, logo $\alpha \leq \frac{-32}{2.9} \leq 12$ e $n \geq 4$, ou seja que com 4 iterações conseguimos um erro absoluto inferior a $5 \cdot 10^{-14}$.
|
||||
|
||||
### 2.a)
|
||||
|
||||
Dada a implementação genérica do algoritmo, o método iterativo simples pode ser
|
||||
implementado sucintamente como:
|
||||
|
||||
template<typename F_t>
|
||||
double fixed_point(double x0, double epsilon, F_t f, long iter_limit) {
|
||||
return find_root(x0, epsilon, f, iter_limit);
|
||||
}
|
||||
|
||||
e usado como
|
||||
|
||||
auto f = [](double x){ return std::cos(x); };
|
||||
std::cout << fixed_point(0.8, epsilon, f, 100000) << '\n';
|
||||
|
||||
A expressão de $\texttt{f}$ foi obtida por manipulação algébrica do seguinte modo:
|
||||
|
||||
$$F(x) = 0 \iff x^2 - cos^2(x) = 0 \iff x^2 = cos^2(x) \iff x = \pm cos(x)$$
|
||||
|
||||
Logo no intervalo $[a;b]$, temos que $x = cos(x)$ ou seja $f(x) = cos(x)$.
|
||||
|
||||
### 2.b)
|
||||
|
||||
Aplicando o programa supra apresentado, obtivemos os seguintes erros:
|
||||
|
||||
![Gŕafico da comparação do erro estimado dos dois métodos](err_fixed_point.png){ width=12cm }
|
||||
|
||||
Partindo destes resultados, verificamos empiricameente a diferença na ordem de convergência dos dois métodos.
|
||||
|
||||
Obtivemos como valor final para este método o valor $0.739085133217$, que difere do valor calculado
|
||||
como o método de Newton em $-2 \cdot 10^{-12}$, por isso concluimos numericamente que, para os valores iniciais usados, este método pode ser aplicado, sendo que aproxima o valor real.
|
||||
|
||||
Verificando as condições de aplicabilidade deste método, temos que $f(x)$ é continua em $[a;b]$, verificando-se a primeira condição,
|
||||
que $f(0.7) \approx 0.76484219$ e $f(0.7) \approx 0.69670671$ o que implica que $f([a;b]) \notin [a;b]$, o implica que não se verifica a segunda condição
|
||||
e que $\forall x \in [0.7;0.8] : |-sin(x)| < 1$, o que significa que se verifica a terceira condição.
|
||||
|
||||
Apesar de não se verificar a segunda condição, verificamos na mesma a convergência da sucessão, o que não contradiz os resultados teóricos, uma vez que estas condições são suficientes, mas não necessárias para esta convergência.
|
BIN
2 - Newton and Iterative methods/assignment.pdf
Normal file
BIN
2 - Newton and Iterative methods/err_fixed_point.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
2 - Newton and Iterative methods/graph.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
2 - Newton and Iterative methods/graph_small.png
Normal file
After Width: | Height: | Size: 13 KiB |
@ -0,0 +1,62 @@
|
||||
1.0e-01 1
|
||||
7.0e-02 2
|
||||
4.7e-02 3
|
||||
3.2e-02 4
|
||||
2.1e-02 5
|
||||
1.4e-02 6
|
||||
9.7e-03 7
|
||||
6.5e-03 8
|
||||
4.4e-03 9
|
||||
3.0e-03 10
|
||||
2.0e-03 11
|
||||
1.3e-03 12
|
||||
9.0e-04 13
|
||||
6.1e-04 14
|
||||
4.1e-04 15
|
||||
2.8e-04 16
|
||||
1.9e-04 17
|
||||
1.3e-04 18
|
||||
8.5e-05 19
|
||||
5.7e-05 20
|
||||
3.8e-05 21
|
||||
2.6e-05 22
|
||||
1.7e-05 23
|
||||
1.2e-05 24
|
||||
7.9e-06 25
|
||||
5.3e-06 26
|
||||
3.6e-06 27
|
||||
2.4e-06 28
|
||||
1.6e-06 29
|
||||
1.1e-06 30
|
||||
7.4e-07 31
|
||||
5.0e-07 32
|
||||
3.3e-07 33
|
||||
2.3e-07 34
|
||||
1.5e-07 35
|
||||
1.0e-07 36
|
||||
6.9e-08 37
|
||||
4.6e-08 38
|
||||
3.1e-08 39
|
||||
2.1e-08 40
|
||||
1.4e-08 41
|
||||
9.6e-09 42
|
||||
6.4e-09 43
|
||||
4.3e-09 44
|
||||
2.9e-09 45
|
||||
2.0e-09 46
|
||||
1.3e-09 47
|
||||
8.9e-10 48
|
||||
6.0e-10 49
|
||||
4.1e-10 50
|
||||
2.7e-10 51
|
||||
1.8e-10 52
|
||||
1.2e-10 53
|
||||
8.3e-11 54
|
||||
5.6e-11 55
|
||||
3.8e-11 56
|
||||
2.6e-11 57
|
||||
1.7e-11 58
|
||||
1.2e-11 59
|
||||
7.8e-12 60
|
||||
5.3e-12 61
|
||||
3.5e-12 62
|
3
2 - Newton and Iterative methods/graphics/err_newton.txt
Normal file
@ -0,0 +1,3 @@
|
||||
1.4e-03 1
|
||||
9.2e-07 2
|
||||
3.7e-13 3
|
27
2 - Newton and Iterative methods/graphics/generate_graphics.gnuplot
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/gnuplot
|
||||
set output "err_fixed_point.png";
|
||||
set terminal png size 1200,900 enhanced font "Helvetica,20"
|
||||
set autoscale;
|
||||
set logscale x;
|
||||
set xlabel "Erro"
|
||||
set ylabel "Iterações"
|
||||
set xrange [] reverse;
|
||||
set linetype 1 lc rgb 'black'
|
||||
set linetype 2 lc rgb 'black
|
||||
plot "err_fixed_point.txt" with points pointtype 1 pointsize 2 lw 4 t "Fixed Point", "err_newton.txt" with points pointtype 2 pointsize 2 lw 4 t "Newton";
|
||||
|
||||
set terminal png size 1200,900 enhanced font "Helvetica,35"
|
||||
set output "graph.png";
|
||||
unset logscale x;
|
||||
set xr [-1:1];
|
||||
set zeroaxis ls 1 lw 3;
|
||||
set xlabel "x"
|
||||
set ylabel "y"
|
||||
|
||||
f(x)= x**2 - cos(x)**2;
|
||||
plot f(x) lw 3 t "x^2 - cos(x)^2";
|
||||
|
||||
set output "graph_small.png";
|
||||
|
||||
set xr [0.7:0.8];
|
||||
plot f(x) lw 3 t "x^2 - cos(x)^2";
|
BIN
2 - Newton and Iterative methods/print.pdf
Normal file
1
2 - Newton and Iterative methods/slides/css/all.css
Normal file
40
2 - Newton and Iterative methods/slides/css/css.css
Normal file
@ -0,0 +1,40 @@
|
||||
/* cyrillic-ext */
|
||||
@font-face {
|
||||
font-family: 'Merriweather';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Merriweather Regular'), local('Merriweather-Regular'), url(https://fonts.gstatic.com/s/merriweather/v19/u-440qyriQwlOrhSvowK_l5-cSZMZ-Y.woff2) format('woff2');
|
||||
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
|
||||
}
|
||||
/* cyrillic */
|
||||
@font-face {
|
||||
font-family: 'Merriweather';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Merriweather Regular'), local('Merriweather-Regular'), url(https://fonts.gstatic.com/s/merriweather/v19/u-440qyriQwlOrhSvowK_l5-eCZMZ-Y.woff2) format('woff2');
|
||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
||||
}
|
||||
/* vietnamese */
|
||||
@font-face {
|
||||
font-family: 'Merriweather';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Merriweather Regular'), local('Merriweather-Regular'), url(https://fonts.gstatic.com/s/merriweather/v19/u-440qyriQwlOrhSvowK_l5-cyZMZ-Y.woff2) format('woff2');
|
||||
unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Merriweather';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Merriweather Regular'), local('Merriweather-Regular'), url(https://fonts.gstatic.com/s/merriweather/v19/u-440qyriQwlOrhSvowK_l5-ciZMZ-Y.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Merriweather';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Merriweather Regular'), local('Merriweather-Regular'), url(https://fonts.gstatic.com/s/merriweather/v19/u-440qyriQwlOrhSvowK_l5-fCZM.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
32
2 - Newton and Iterative methods/slides/css/css2.css
Normal file
@ -0,0 +1,32 @@
|
||||
/* cyrillic */
|
||||
@font-face {
|
||||
font-family: 'Oswald';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Oswald Regular'), local('Oswald-Regular'), url(https://fonts.gstatic.com/s/oswald/v16/TK3iWkUHHAIjg752HT8Ghe4.woff2) format('woff2');
|
||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
||||
}
|
||||
/* vietnamese */
|
||||
@font-face {
|
||||
font-family: 'Oswald';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Oswald Regular'), local('Oswald-Regular'), url(https://fonts.gstatic.com/s/oswald/v16/TK3iWkUHHAIjg752Fj8Ghe4.woff2) format('woff2');
|
||||
unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Oswald';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Oswald Regular'), local('Oswald-Regular'), url(https://fonts.gstatic.com/s/oswald/v16/TK3iWkUHHAIjg752Fz8Ghe4.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Oswald';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Oswald Regular'), local('Oswald-Regular'), url(https://fonts.gstatic.com/s/oswald/v16/TK3iWkUHHAIjg752GT8G.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
48
2 - Newton and Iterative methods/slides/css/css3.css
Normal file
@ -0,0 +1,48 @@
|
||||
/* cyrillic-ext */
|
||||
@font-face {
|
||||
font-family: 'Ubuntu Mono';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Ubuntu Mono'), local('UbuntuMono-Regular'), url(https://fonts.gstatic.com/s/ubuntumono/v8/KFOjCneDtsqEr0keqCMhbCc3CsTKlA.woff2) format('woff2');
|
||||
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
|
||||
}
|
||||
/* cyrillic */
|
||||
@font-face {
|
||||
font-family: 'Ubuntu Mono';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Ubuntu Mono'), local('UbuntuMono-Regular'), url(https://fonts.gstatic.com/s/ubuntumono/v8/KFOjCneDtsqEr0keqCMhbCc-CsTKlA.woff2) format('woff2');
|
||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
||||
}
|
||||
/* greek-ext */
|
||||
@font-face {
|
||||
font-family: 'Ubuntu Mono';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Ubuntu Mono'), local('UbuntuMono-Regular'), url(https://fonts.gstatic.com/s/ubuntumono/v8/KFOjCneDtsqEr0keqCMhbCc2CsTKlA.woff2) format('woff2');
|
||||
unicode-range: U+1F00-1FFF;
|
||||
}
|
||||
/* greek */
|
||||
@font-face {
|
||||
font-family: 'Ubuntu Mono';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Ubuntu Mono'), local('UbuntuMono-Regular'), url(https://fonts.gstatic.com/s/ubuntumono/v8/KFOjCneDtsqEr0keqCMhbCc5CsTKlA.woff2) format('woff2');
|
||||
unicode-range: U+0370-03FF;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Ubuntu Mono';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Ubuntu Mono'), local('UbuntuMono-Regular'), url(https://fonts.gstatic.com/s/ubuntumono/v8/KFOjCneDtsqEr0keqCMhbCc0CsTKlA.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Ubuntu Mono';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Ubuntu Mono'), local('UbuntuMono-Regular'), url(https://fonts.gstatic.com/s/ubuntumono/v8/KFOjCneDtsqEr0keqCMhbCc6CsQ.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
224
2 - Newton and Iterative methods/slides/css/css4.css
Normal file
@ -0,0 +1,224 @@
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Quattrocento'), url(https://fonts.gstatic.com/s/quattrocento/v10/OZpEg_xvsDZQL_LKIF7q4jP3zWj6T4g.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Quattrocento'), url(https://fonts.gstatic.com/s/quattrocento/v10/OZpEg_xvsDZQL_LKIF7q4jP3w2j6.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Quattrocento Bold'), local('Quattrocento-Bold'), url(https://fonts.gstatic.com/s/quattrocento/v10/OZpbg_xvsDZQL_LKIF7q4jP_eE3vfqnYgXc.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Quattrocento Bold'), local('Quattrocento-Bold'), url(https://fonts.gstatic.com/s/quattrocento/v10/OZpbg_xvsDZQL_LKIF7q4jP_eE3vcKnY.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento Sans';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: local('Quattrocento Sans Italic'), local('QuattrocentoSans-Italic'), url(https://fonts.gstatic.com/s/quattrocentosans/v11/va9a4lja2NVIDdIAAoMR5MfuElaRB0zMh0P2GEHJ.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento Sans';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: local('Quattrocento Sans Italic'), local('QuattrocentoSans-Italic'), url(https://fonts.gstatic.com/s/quattrocentosans/v11/va9a4lja2NVIDdIAAoMR5MfuElaRB0zMh032GA.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento Sans';
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
src: local('Quattrocento Sans Bold Italic'), local('QuattrocentoSans-BoldItalic'), url(https://fonts.gstatic.com/s/quattrocentosans/v11/va9X4lja2NVIDdIAAoMR5MfuElaRB0zMj_bTDXDojYsJ.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento Sans';
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
src: local('Quattrocento Sans Bold Italic'), local('QuattrocentoSans-BoldItalic'), url(https://fonts.gstatic.com/s/quattrocentosans/v11/va9X4lja2NVIDdIAAoMR5MfuElaRB0zMj_bTDX7ojQ.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento Sans';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Quattrocento Sans'), local('QuattrocentoSans'), url(https://fonts.gstatic.com/s/quattrocentosans/v11/va9c4lja2NVIDdIAAoMR5MfuElaRB0zHt0_uHA.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento Sans';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Quattrocento Sans'), local('QuattrocentoSans'), url(https://fonts.gstatic.com/s/quattrocentosans/v11/va9c4lja2NVIDdIAAoMR5MfuElaRB0zJt08.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento Sans';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Quattrocento Sans Bold'), local('QuattrocentoSans-Bold'), url(https://fonts.gstatic.com/s/quattrocentosans/v11/va9Z4lja2NVIDdIAAoMR5MfuElaRB0RyklrfPXzwiQ.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento Sans';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Quattrocento Sans Bold'), local('QuattrocentoSans-Bold'), url(https://fonts.gstatic.com/s/quattrocentosans/v11/va9Z4lja2NVIDdIAAoMR5MfuElaRB0RyklrRPXw.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* cyrillic */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: local('Spectral Italic'), local('Spectral-Italic'), url(https://fonts.gstatic.com/s/spectral/v5/rnCt-xNNww_2s0amA9M8on7mTMuk.woff2) format('woff2');
|
||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
||||
}
|
||||
/* vietnamese */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: local('Spectral Italic'), local('Spectral-Italic'), url(https://fonts.gstatic.com/s/spectral/v5/rnCt-xNNww_2s0amA9M8onXmTMuk.woff2) format('woff2');
|
||||
unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: local('Spectral Italic'), local('Spectral-Italic'), url(https://fonts.gstatic.com/s/spectral/v5/rnCt-xNNww_2s0amA9M8onTmTMuk.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: local('Spectral Italic'), local('Spectral-Italic'), url(https://fonts.gstatic.com/s/spectral/v5/rnCt-xNNww_2s0amA9M8onrmTA.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* cyrillic */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
src: local('Spectral Bold Italic'), local('Spectral-BoldItalic'), url(https://fonts.gstatic.com/s/spectral/v5/rnCu-xNNww_2s0amA9M8qsHDWfCFXUIJ.woff2) format('woff2');
|
||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
||||
}
|
||||
/* vietnamese */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
src: local('Spectral Bold Italic'), local('Spectral-BoldItalic'), url(https://fonts.gstatic.com/s/spectral/v5/rnCu-xNNww_2s0amA9M8qsHDWfuFXUIJ.woff2) format('woff2');
|
||||
unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
src: local('Spectral Bold Italic'), local('Spectral-BoldItalic'), url(https://fonts.gstatic.com/s/spectral/v5/rnCu-xNNww_2s0amA9M8qsHDWfqFXUIJ.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
src: local('Spectral Bold Italic'), local('Spectral-BoldItalic'), url(https://fonts.gstatic.com/s/spectral/v5/rnCu-xNNww_2s0amA9M8qsHDWfSFXQ.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* cyrillic */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Spectral Regular'), local('Spectral-Regular'), url(https://fonts.gstatic.com/s/spectral/v5/rnCr-xNNww_2s0amA9M9knj-SA.woff2) format('woff2');
|
||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
||||
}
|
||||
/* vietnamese */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Spectral Regular'), local('Spectral-Regular'), url(https://fonts.gstatic.com/s/spectral/v5/rnCr-xNNww_2s0amA9M2knj-SA.woff2) format('woff2');
|
||||
unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Spectral Regular'), local('Spectral-Regular'), url(https://fonts.gstatic.com/s/spectral/v5/rnCr-xNNww_2s0amA9M3knj-SA.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Spectral Regular'), local('Spectral-Regular'), url(https://fonts.gstatic.com/s/spectral/v5/rnCr-xNNww_2s0amA9M5kng.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* cyrillic */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Spectral Bold'), local('Spectral-Bold'), url(https://fonts.gstatic.com/s/spectral/v5/rnCs-xNNww_2s0amA9uCt23FafadWQ.woff2) format('woff2');
|
||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
||||
}
|
||||
/* vietnamese */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Spectral Bold'), local('Spectral-Bold'), url(https://fonts.gstatic.com/s/spectral/v5/rnCs-xNNww_2s0amA9uCt23OafadWQ.woff2) format('woff2');
|
||||
unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Spectral Bold'), local('Spectral-Bold'), url(https://fonts.gstatic.com/s/spectral/v5/rnCs-xNNww_2s0amA9uCt23PafadWQ.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Spectral Bold'), local('Spectral-Bold'), url(https://fonts.gstatic.com/s/spectral/v5/rnCs-xNNww_2s0amA9uCt23BafY.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
1
2 - Newton and Iterative methods/slides/css/katex.min.css
vendored
Normal file
8779
2 - Newton and Iterative methods/slides/css/style.css
Normal file
BIN
2 - Newton and Iterative methods/slides/err_fixed_point.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
2 - Newton and Iterative methods/slides/graph.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
2 - Newton and Iterative methods/slides/graph_small.png
Normal file
After Width: | Height: | Size: 13 KiB |
71
2 - Newton and Iterative methods/slides/index.html
Executable file
@ -0,0 +1,71 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="robots" content="noindex">
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>Numerical Analysis - Slides</title>
|
||||
<link rel="stylesheet" href="css/all.css">
|
||||
<link href="css/css.css" rel="stylesheet">
|
||||
<link href="css/css2.css" rel="stylesheet">
|
||||
<link href="css/css3.css" rel="stylesheet">
|
||||
<link href="css/css4.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link rel="stylesheet" href="css/katex.min.css">
|
||||
<link rel="icon" href="https://hackersatporto.com/images/favicon.png">
|
||||
<meta name="description" content="Porto's student computing society. We are a community focused on learning about and building things with technology.">
|
||||
<script src="js/remark-latest.min.js"></script>
|
||||
<script src="js/jquery.min.js"></script>
|
||||
<script src="js/mark.min.js"></script>
|
||||
<script src="js/MathJax.js"></script>
|
||||
<script src="js/katex.min.js"></script>
|
||||
<script src="js/auto-render.min.js"></script>
|
||||
<script src="js/abcjs_basic_5.6.3-min.js"></script>
|
||||
<script src="js/story.js"></script>
|
||||
</head>
|
||||
|
||||
<body id="content" class="ma0 bg-white section-slides page-kind-page is-page-true feature-math feature-qrcode feature-nohighlight feature-music">
|
||||
<script>
|
||||
var hljs = remark.highlighter.engine;
|
||||
var slideshow = remark.create({
|
||||
ratio: "16:9",
|
||||
countIncrementalSlides: false,
|
||||
sourceUrl: 'text.md',
|
||||
slideNumberFormat: '%current%',
|
||||
highlightLanguage: "xaprb",
|
||||
placeholder: "dummy value to end the list without a comma"
|
||||
});
|
||||
|
||||
$(".remark-slide-content.fit-h1 h1").each(function(i, e) {
|
||||
var $e = $(e);
|
||||
var $p = $e.closest('div.remark-slide-container');
|
||||
var needsToggle = !$p.hasClass('remark-visible');
|
||||
if ( needsToggle ) $p.toggleClass('remark-visible');
|
||||
while (e.scrollHeight > e.clientHeight + 1 && $e.css('font-size') != '1px') {
|
||||
$e.css('font-size', (parseInt($e.css('font-size')) - 1) + "px");
|
||||
|
||||
|
||||
}
|
||||
if ( needsToggle ) $p.toggleClass('remark-visible');
|
||||
});
|
||||
|
||||
$( function() {
|
||||
if ( $( "body.feature-qrcode:not(.feature-noqrcode)" ).length ) {
|
||||
if ( $( ".qrcode" ).length ) {
|
||||
new QRCode($(".qrcode")[0], {
|
||||
"useSVG": true,
|
||||
"text": window.location.href.replace(/#\d*$/, "")
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Setup MathJax
|
||||
MathJax.Hub.Config({
|
||||
tex2jax: {
|
||||
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre']
|
||||
}
|
||||
});
|
||||
MathJax.Hub.Configured();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
19
2 - Newton and Iterative methods/slides/js/MathJax.js
Normal file
3
2 - Newton and Iterative methods/slides/js/abcjs_basic_5.6.3-min.js
vendored
Normal file
1
2 - Newton and Iterative methods/slides/js/auto-render.min.js
vendored
Normal file
2
2 - Newton and Iterative methods/slides/js/jquery.min.js
vendored
Normal file
1
2 - Newton and Iterative methods/slides/js/katex.min.js
vendored
Normal file
7
2 - Newton and Iterative methods/slides/js/mark.min.js
vendored
Normal file
18
2 - Newton and Iterative methods/slides/js/remark-latest.min.js
vendored
Normal file
146
2 - Newton and Iterative methods/slides/js/story.js
Normal file
@ -0,0 +1,146 @@
|
||||
// Render KaTeX math typesetting, but only if the <body> has the class
|
||||
// feature-math
|
||||
$( function() {
|
||||
if ( $( "body.feature-math:not(.feature-nomath)" ).length ) {
|
||||
renderMathInElement(document.body);
|
||||
}
|
||||
});
|
||||
|
||||
// Render abcjs sheet music, but only if the <body> has the class
|
||||
// feature-music. Do this by removing the <pre><code class="language-abc">
|
||||
// and replacing it with a <p id="music-X"> which will be used to hold the
|
||||
// generated sheet music. Remark's code syntax highlighting transforms the
|
||||
// <code> block into a bunch of
|
||||
// <div class="remark-code-line">K: Emin</div>
|
||||
// one per line, so we have to reassemble those to get back linebreaks.
|
||||
$( function() {
|
||||
if ( $( "body.feature-music:not(.feature-nomusic)" ).length ) {
|
||||
$( "code.language-abc, code.abc" ).each(function(i, e){
|
||||
var $this = $(this);
|
||||
var abc = $this.text();
|
||||
if ( $this.hasClass("remark-code") ) {
|
||||
abc = "";
|
||||
$this.children().each(function(i, e) {
|
||||
abc += "\n" + $(this).text();
|
||||
});
|
||||
abc = abc.trim();
|
||||
}
|
||||
var p = $this.parent().before('<p id="music-' + (i+1) + '">');
|
||||
$this.parent().hide();
|
||||
ABCJS.renderAbc("music-" + (i+1), abc, {
|
||||
paddingtop: 0,
|
||||
paddingbottom: 0,
|
||||
paddingright: 0,
|
||||
paddingleft: 0,
|
||||
responsive: "resize"
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Render tweet-styled blockquotes, if <body> has the class feature-tweetquote and the blockquote ends
|
||||
// with a twitter permalink URL.
|
||||
$( function() {
|
||||
if ( $( "body.feature-tweetquote:not(.feature-notweetquote)" ).length ) {
|
||||
$("blockquote p:first-child a[href*='twitter.com']").each(function(i, e){
|
||||
$(this.parentElement.parentElement).addClass("tweet sans-serif mw6");
|
||||
$(this).addClass("no-underline b");
|
||||
$(this).prepend('<i class="fl mr2 fab fa-twitter fa-2x pa2 ba br3">');
|
||||
var m = $(this).attr('href').match(/twitter.com\/([^\/]*)\//);
|
||||
if (m.length > 1) {
|
||||
$(this).append('<br><span class="normal gray">@' + m[1] + '</span>');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Render perspective book images, if <body> has the class
|
||||
// feature-3dbook-covers
|
||||
$( function() {
|
||||
$( "body.feature-3dbook-covers article a" ).has( "img[src~='3dbook']" ).each(function(i, e) {
|
||||
$( this ).addClass("book");
|
||||
$( this ).parent().addClass("books");
|
||||
});
|
||||
});
|
||||
|
||||
// Highlight code listings, if <body> has the class
|
||||
// feature-highlight
|
||||
$( function() {
|
||||
if ( $( "body.feature-highlight:not(.feature-nohighlight)" ).length ) {
|
||||
hljs.initHighlightingOnLoad();
|
||||
}
|
||||
});
|
||||
|
||||
/* Turn images into figures with captions. Several scenarios are handled, in
|
||||
* order:
|
||||
* If the img is followed by an <em>, then transform the <em> into a caption.
|
||||
* If the img has a title, use that as the caption.
|
||||
* If the img has an alt, use that.
|
||||
* The following features have to be enabled:
|
||||
* - feature-figcaption has to be enabled or the whole thing is disabled
|
||||
* - feature-figcaption-hidden makes the captions invisible till you hover
|
||||
* - feature-fignum adds figure numbering
|
||||
* - feature-figlink adds automatic links of text like "Figure 4"
|
||||
*/
|
||||
$( function() {
|
||||
$("body.feature-figcaption:not(.feature-nofigcaption) article img").each(function(i, e) {
|
||||
var $this = $(this);
|
||||
// Don't put captions on images that have URL fragment pseudo-classes.
|
||||
if ( $this.attr('src').match(/#/) ) return;
|
||||
var $txt = false;
|
||||
if ( $this.next().is("em") ) {
|
||||
$txt = $this.next().html();
|
||||
$this.next().remove();
|
||||
} else {
|
||||
$txt = $this.attr('title') ? $this.attr('title')
|
||||
: $this.attr('alt') ? $this.attr('alt')
|
||||
: false;
|
||||
}
|
||||
if ( $txt ) {
|
||||
var $fig = $this.wrap('<figure id="fig-' + (i+1) + '">')
|
||||
.after('<figcaption class="f5 lh-copy i ph3">' + $txt + '</figcaption>')
|
||||
.parent();
|
||||
}
|
||||
});
|
||||
if ( $("body.feature-figlink").length ) {
|
||||
$("article p, article li").each(function(i, e) {
|
||||
var $old = $(this).html();
|
||||
var $new = $old.replace(/Figure\s+(\d+)/g, '<a href="#fig-$1">Figure $1</a>');
|
||||
if ( $old !== $new ) {
|
||||
$(this).html($new);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/* Add captions to tables.
|
||||
* If the table is followed by a <p><em>, then transform the <em> into a caption.
|
||||
* The following features have to be enabled:
|
||||
* - feature-tablecaption has to be enabled or the whole thing is disabled
|
||||
* - feature-fignum adds table numbering
|
||||
* - feature-figlink adds automatic links of text like "Table 4"
|
||||
*/
|
||||
$( function() {
|
||||
$("body.feature-tablecaption article table").each(function(i, e) {
|
||||
var $this = $(this);
|
||||
var $txt = false;
|
||||
if ( $this.next().is("p") ) {
|
||||
if ( $this.next().children().first().is("em:only-child") ) {
|
||||
$txt = $this.next().children().first().html();
|
||||
$this.next().remove();
|
||||
}
|
||||
}
|
||||
if ( $txt ) {
|
||||
$this.prepend('<caption id="tbl-' + (i+1) + '">' + $txt + '</caption>');
|
||||
}
|
||||
});
|
||||
if ( $("body.feature-figlink").length ) {
|
||||
$("article p, article li").each(function(i, e) {
|
||||
var $old = $(this).html();
|
||||
var $new = $old.replace(/Table\s+(\d+)/g, '<a href="#tbl-$1">Table $1</a>');
|
||||
if ( $old !== $new ) {
|
||||
$(this).html($new);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
216
2 - Newton and Iterative methods/slides/text.md
Normal file
@ -0,0 +1,216 @@
|
||||
class: title, smokescreen, shelf, no-footer
|
||||
# Análise Numérica - Trabalho Prático 1
|
||||
### Diogo Cordeiro | Hugo Sales | Pedro Costa | Ricardo Pimenta
|
||||
|
||||
---
|
||||
name: motivacao
|
||||
class: roomy
|
||||
|
||||
# Motivação
|
||||
|
||||
Pretende-se usar os métodos de Newton e iterativo simples para determinar um valor aproximado de um zero de
|
||||
|
||||
$$x^2 - cos(x)^2$$
|
||||
|
||||
---
|
||||
name: 1a
|
||||
class: compact
|
||||
|
||||
# 1.a)
|
||||
Optamos por implementar o algoritmo pedido em C++ devido à possiblidade da aplicação de
|
||||
templates e lambdas. Deste modo, foi-nos possível implementar os dois métodos pedidos partindo
|
||||
de um algoritmo genérico pois a diferença entre o método de Newton
|
||||
e o método iterativo consiste apenas na fórmula de recorrência. Assim, o método de Newton
|
||||
pode ser visto como uma forma do método iterativo simples.
|
||||
|
||||
int main() {
|
||||
auto F = [](double x){ return std::pow(x, 2.0) - std::pow(std::cos(x), 2.0); };
|
||||
auto dF = [](double x){ return 2.0 * x + std::sin(2.0 * x); };
|
||||
|
||||
double epsilon = 5.0 * std::pow(10.0, -12.0);
|
||||
|
||||
std::cout << newton(0.8, epsilon, F, dF, 100000) << `\n`;
|
||||
}
|
||||
|
||||
---
|
||||
name: 1a
|
||||
class: compact
|
||||
# 1.a)
|
||||
|
||||
template<typename step_func>
|
||||
double find_root(double x0, double epsilon, step_func step, long iter_limit) {
|
||||
double x1 = x0, err;
|
||||
long iter = 1;
|
||||
do {
|
||||
x0 = x1;
|
||||
x1 = step(x0);
|
||||
err = std::abs(x1 - x0);
|
||||
} while(err > epsilon && iter++ < iter_limit);
|
||||
return x1;
|
||||
}
|
||||
|
||||
template<typename F_t, typename dF_t>
|
||||
double newton(double x0, double epsilon, F_t F, dF_t dF, long iter_limit) {
|
||||
return find_root(x0, epsilon,
|
||||
[&F, &dF](double x0){ return x0 - F(x0)/dF(x0); },
|
||||
iter_limit);
|
||||
}
|
||||
|
||||
---
|
||||
name: 1b
|
||||
class: compact, img-right
|
||||
|
||||
# 1.b)
|
||||
|
||||
![Gráfico para `\(x \in [-1;1]\)`](./graph.png)
|
||||
|
||||
Como `\(\forall{x}: cos^2(x) \in [0:1]\)`, temos que `\(x^2 \geq cos^2(x)\)` para `\(|x| > 1\)`, sabemos que o comportamento de `\(f(x)\)` é dominado pelo comportamento de `\(x^2\)`, a qual só tem duas raízes.
|
||||
|
||||
A menor das raízes encontra-se no intervalo `\(]-\infty;0]\)` e a maior destas em `\([0;\infty[\)`.
|
||||
|
||||
---
|
||||
name: 1b-cont
|
||||
class: compact, img-right
|
||||
|
||||
# 1.b)
|
||||
|
||||
![Gráfico para `\(x \in [0.7;0.8]\)`](./graph_small.png)
|
||||
|
||||
Através da análise do gráfico, verificamos que o intervalo `\([0.7;0.8]\)` contém uma raíz. Definimos então `\(a = 0.7\)` e `\(b = 0.8\)`.
|
||||
|
||||
---
|
||||
name: 1c
|
||||
class: compact
|
||||
|
||||
# 1.c)
|
||||
|
||||
Queremos mostrar que as condições de aplicabilidade do método de Newton são satisfeitas no intervalo. Assim,
|
||||
|
||||
$$F(x) = x^2 - cos(x)^2$$
|
||||
|
||||
$$F'(x) = 2 \cdot x + sin(2 \cdot x)$$
|
||||
|
||||
$$F''(x) = 2 + 2 \cdot cos(2 \cdot x)$$
|
||||
|
||||
Como todas estas funções são compostas partindo de somas de funções contínuas em `\(\mathbb{R}\)`, são também continuas no intervalo considerado, verificando-se assim o primeiro critério.
|
||||
|
||||
Dado que,
|
||||
|
||||
$$F(a) < 0, F(b) < 0 \Rightarrow F(a) \cdot F(b) < 0$$
|
||||
|
||||
---
|
||||
name: 1c-cont
|
||||
class: compact
|
||||
|
||||
# 1.c)
|
||||
|
||||
Verifica-se também o segundo critério.
|
||||
|
||||
Temos que `\(F''(x) = 2 + 2 \cdot cos(2 \cdot x)\)`, logo `\(cos(2 \cdot x) \in [-1;1]\)`, por isso `\(2 \cdot cos(2 \cdot x) \in [-2; 2]\)`, e `\(2 \cdot cos(2 \cdot x) + 2 \in [0;4]\)` o que implica que `\(F''(x) \geq 0\)`, para `\(x \in \mathbb{R}\)` e por isso `\(F'(x)\)` é não decrescente em `\(\mathbb{R}\)`, ou seja, `\(F'(b) \geq F'(a)\)` e `\(F'(a) > 3\)` e por isso `\(F'(x) \neq 0 \forall{x} : \in [a;b]\)`, o que verifica o terceiro critério.
|
||||
|
||||
Como foi dito anteriormente, `\(F''(x) \geq 0\)` em `\(\mathbb{R}\)` e, por isso, também para `\(\forall{x} : \in [a;b]\)`, verificando-se a quarta condição.
|
||||
|
||||
Para `\(x_0 = b\)`, temos que `\(F(x_0) > 0\)` e `\(F''(x_0) > 0\)`, logo `\(F(x_0) \cdot F''(x_0) > 0\)`, verificando-se a quinta condição.
|
||||
|
||||
Então a sucessão gerada converge para a unica raíz no intervalo `\([a;b]\)`.
|
||||
|
||||
---
|
||||
name: 1d
|
||||
class: compact
|
||||
|
||||
# 1.d)
|
||||
|
||||
Aplicamos o programa apresentado em `\(1.a\)` e obtivemos os seguintes resultados.
|
||||
|
||||
Iterações | Erro estimado | Valor
|
||||
----------|---------------|---------------
|
||||
1 | 5.9e-02 | 0.740528800196
|
||||
2 | 1.4e-03 | 0.739086050826
|
||||
3 | 9.2e-07 | 0.739085133216
|
||||
4 | 3.7e-13 | 0.739085133215
|
||||
|
||||
Verficamos que o erro estimado é aproximadamente metade do erro estimado da iteração amterior,
|
||||
o que justificamos com o facto de que o resultado teórico
|
||||
nos dizer que o erro converge segundo uma secessão de segunda ordem.
|
||||
|
||||
---
|
||||
name: 1e
|
||||
class: compact
|
||||
|
||||
# 1.e)
|
||||
|
||||
Aplicando a fórmula
|
||||
|
||||
<center>\( M = \frac{1}{2} \cdot \frac{\max \limits_{a \leq x \leq b} | F''(x) | }{\min \limits_{a \leq x \leq b} | F'(x) | } \)</center>
|
||||
|
||||
Como `\(F''(x)\)` é decrescente em `\([0;\pi/2]\)`, então `\(\max\limits_{a \leq x \leq b} | F''(x) | = |F''(a)|\)` e como `\(F'(x)\)` é não decrescente em `\(\mathbb{R}\)`, `\(\min\limits_{a \leq x \leq b} | F'(x) | = F'(a)\)`.
|
||||
|
||||
Assim, obtemos `\(M = \frac{F''(0.7)}{2F'(0.7)} \leq \frac{2.4}{2 \cdot 2.3} \leq 0.53\)` e
|
||||
`\(n \geq \frac{ln(\alpha)}{ln(2)}, \alpha = \frac{ln(5 \cdot 10^{-14}) + ln(0.53)}{ln(0.53) + ln(10^{-1})}\)`, logo `\(\alpha \leq \frac{-32}{2.9} \leq 12\)` e `\(n \geq 4\)`, ou seja que com 4 iterações conseguimos um erro absoluto inferior a `\(5 \cdot 10^{-14}\)`.
|
||||
|
||||
---
|
||||
name: 2a
|
||||
class: compact
|
||||
|
||||
# 2.a)
|
||||
|
||||
Dada a implementação genérica do algoritmo, o método iterativo simples pode ser
|
||||
implementado sucintamente como:
|
||||
|
||||
template<typename F_t>
|
||||
double fixed_point(double x0, double epsilon, F_t f, long iter_limit) {
|
||||
return find_root(x0, epsilon, f, iter_limit);
|
||||
}
|
||||
|
||||
---
|
||||
name: 2a-cont
|
||||
class: compact
|
||||
|
||||
# 2.a)
|
||||
|
||||
e usado como
|
||||
|
||||
auto f = [](double x){ return std::cos(x); };
|
||||
std::cout << fixed_point(0.8, epsilon, f, 100000) << `\n`;
|
||||
|
||||
A expressão de `\(\texttt{f}\)` foi obtida por manipulação algébrica do seguinte modo:
|
||||
|
||||
$$F(x) = 0 \iff x^2 - cos^2(x) = 0 \iff x^2 = cos^2(x) \iff x = \pm cos(x)$$
|
||||
|
||||
Logo no intervalo `\([a;b]\)`, temos que `\(x = cos(x)\)` ou seja `\(f(x) = cos(x)\)`.
|
||||
|
||||
|
||||
---
|
||||
name: 2b
|
||||
class: img-right
|
||||
|
||||
![Gŕafico da comparação do erro estimado dos dois métodos](err_fixed_point.png)
|
||||
|
||||
# 2.b)
|
||||
|
||||
Partindo destes resultados, verificamos empiricameente a diferença na ordem de convergência dos dois métodos.
|
||||
|
||||
Obtivemos como valor final para este método o valor `\(0.739085133217\)`, que difere do valor calculado
|
||||
como o método de Newton em `\(-2 \cdot 10^{-12}\)`, por isso concluimos numericamente que, para os valores iniciais usados, este método pode ser aplicado, sendo que aproxima o valor real.
|
||||
|
||||
---
|
||||
name: 2b
|
||||
class: img-right
|
||||
|
||||
![Gŕafico da comparação do erro estimado dos dois métodos](err_fixed_point.png)
|
||||
|
||||
# 2.b)
|
||||
|
||||
Verificando as condições de aplicabilidade deste método, temos que `\(f(x)\)` é continua em `\([a;b]\)`, verificando-se a primeira condição,
|
||||
que `\(f(0.7) \approx 0.76484219\)` e `\(f(0.7) \approx 0.69670671\)` o que implica que `\(f([a;b]) \notin [a;b]\)`, o implica que não se verifica a segunda condição
|
||||
e que `\(\forall x \in [0.7;0.8] : |-sin(x)| < 1\)`, o que significa que se verifica a terceira condição.
|
||||
|
||||
---
|
||||
name: 2b
|
||||
class: img-right
|
||||
|
||||
![Gŕafico da comparação do erro estimado dos dois métodos](err_fixed_point.png)
|
||||
|
||||
# 2.b)
|
||||
|
||||
Apesar de não se verificar a segunda condição, verificamos na mesma a convergência da sucessão, o que não contradiz os resultados teóricos, uma vez que estas condições são suficientes, mas não necessárias para esta convergência.
|
45
2 - Newton and Iterative methods/source/roots.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
|
||||
template<typename step_func>
|
||||
double find_root(double x0, double epsilon, step_func step, long iter_limit) {
|
||||
double x1 = x0, err;
|
||||
long iter = 1;
|
||||
std::cout << "Erros: ";
|
||||
do {
|
||||
x0 = x1;
|
||||
x1 = step(x0);
|
||||
err = std::abs(x1 - x0);
|
||||
|
||||
std::cout << iter << " "
|
||||
<< std::setprecision(1) << std::scientific << err << " "
|
||||
<< std::defaultfloat << std::setprecision(12) << x1 << '\n';
|
||||
} while(err > epsilon && iter++ < iter_limit);
|
||||
std::cout << '\n';
|
||||
// std::cout << std::defaultfloat << std::setprecision(12);
|
||||
return x1;
|
||||
}
|
||||
|
||||
template<typename F_t, typename dF_t>
|
||||
double newton(double x0, double epsilon, F_t F, dF_t dF, long iter_limit) {
|
||||
return find_root(x0, epsilon, [&F, &dF](double x0){ return x0 - F(x0)/dF(x0); }, iter_limit);
|
||||
}
|
||||
|
||||
template<typename F_t>
|
||||
double fixed_point(double x0, double epsilon, F_t F, long iter_limit) {
|
||||
return find_root(x0, epsilon, F, iter_limit);
|
||||
}
|
||||
|
||||
int main() {
|
||||
auto F = [](double x){ return std::pow(x, 2.0) - std::pow(std::cos(x), 2.0); };
|
||||
auto dF = [](double x){ return 2.0 * x + std::sin(2.0 * x); };
|
||||
// std::cout.precision(17);
|
||||
|
||||
double epsilon = 5.0 * std::pow(10.0, -12.0);
|
||||
|
||||
std::cout << newton(0.8, epsilon, F, dF, 100000) << '\n';
|
||||
|
||||
auto F2 = [](double x){ return std::cos(x); };
|
||||
std::cout << fixed_point(0.8, epsilon, F2, 100000) << '\n';
|
||||
}
|
674
3 - Splines/LICENSE
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
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.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"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.
|
||||
|
||||
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.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
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 charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
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:
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
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:
|
||||
|
||||
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.
|
||||
|
||||
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, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
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, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
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.
|
||||
|
||||
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 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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
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.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
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.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
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.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
255
3 - Splines/README.md
Normal file
@ -0,0 +1,255 @@
|
||||
---
|
||||
title: "Análise Numérica - Trabalho Prático 3"
|
||||
author:
|
||||
- Diogo Cordeiro
|
||||
- Hugo Sales
|
||||
- Pedro Costa
|
||||
geometry: margin=2cm
|
||||
output: pdf_document
|
||||
---
|
||||
|
||||
### Motivação
|
||||
|
||||
Pretende-se interpolar uma função através do método de Newton em diferenças divididas,
|
||||
construir o spline cúbico natural e proceder a uma comparação e interpretação dos resultados obtidos.
|
||||
|
||||
### 1.a)
|
||||
|
||||
using points_t = std::pair<std::vector<double>, std::vector<double>>;
|
||||
using matrix_t = std::vector<std::vector<double>>;
|
||||
|
||||
std::vector<double> newton_differences(points_t points) {
|
||||
std::vector<double> factors{};
|
||||
auto &[x, fx] = points;
|
||||
int n = points.first.size();
|
||||
for (int i = 1; i <= n; ++i) {
|
||||
factors.push_back(fx[0]);
|
||||
for (int j = 0; j < (n - i); ++j) {
|
||||
fx[j] = (fx[j + 1] - fx[j]) / (x[j + i] - x[j]);
|
||||
}
|
||||
|
||||
}
|
||||
return factors;
|
||||
}
|
||||
|
||||
double newton_polynomial(points_t points, std::vector<double> factors, double x) {
|
||||
auto xs = points.first;
|
||||
int n = points.second.size() - 1;
|
||||
double val = 0;
|
||||
for (int k = 0; k <= n; ++k) {
|
||||
double acc = 1;
|
||||
for(int i = 0; i < k; ++i) {
|
||||
acc *= (x - xs[i]);
|
||||
}
|
||||
val += acc * factors[k];
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
\pagebreak
|
||||
|
||||
void exercise_a(points_t points) {
|
||||
auto &[xs, fx] = points;
|
||||
auto factors = newton_differences(points);
|
||||
std::ofstream poly{"a_polynomial.txt"};
|
||||
for(double x = 0; x < 4; x += 0.001)
|
||||
poly << x << " " << newton_polynomial(points, factors, x) << '\n';
|
||||
|
||||
std::ofstream spline{"a_spline.txt"};
|
||||
unsigned long n = xs.size();
|
||||
matrix_t mat(n, std::vector<double>(n + 1));
|
||||
calculate_natural_cubic_spline_matrix(points, mat);
|
||||
for(double x = 0; x < 4; x += 0.001)
|
||||
spline << x << " " << natural_cubic_spline(points, mat, x) << '\n';
|
||||
}
|
||||
|
||||
### 1.b)
|
||||
|
||||
void calculate_natural_cubic_spline_matrix(points_t points, matrix_t &mat) {
|
||||
auto &[xs, fx] = points;
|
||||
int n = xs.size();
|
||||
|
||||
// Construção da matriz
|
||||
for (int i = 1; i < n - 1; ++i) {
|
||||
mat[i][i - 1] = (xs[i] - xs[i - 1])/6;
|
||||
mat[i][i] = (xs[i + 1] - xs[i - 1])/3;
|
||||
mat[i][i + 1] = (xs[i + 1] - xs[i])/6;
|
||||
mat[i][n] = (fx[i + 1] - fx[i])/(xs[i + 1] - xs[i]) -
|
||||
(fx[i] - fx[i - 1])/(xs[i] - xs[i - 1]);
|
||||
}
|
||||
mat[0][0] = 1;
|
||||
mat[0][n - 1] = 0;
|
||||
mat[n - 1][n - 1] = 1;
|
||||
mat[n - 1][n] = 0;
|
||||
|
||||
// Passar para a forma triangular
|
||||
for (int k = 0; k < n; ++k) {
|
||||
for (int i = k + 1; i < n; ++i) {
|
||||
if (mat[k][k] != 0) {
|
||||
double mul = mat[i][k]/mat[k][k];
|
||||
for (int j = k; j < n; ++j) {
|
||||
mat[i][j] -= mul * mat[k][j];
|
||||
}
|
||||
mat[i][n] -= mul * mat[k][n];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\pagebreak
|
||||
|
||||
// Resolução da matriz
|
||||
for (int i = n - 1; i > 0; --i) {
|
||||
if (mat[i][i] != 0) {
|
||||
double mul = mat[i - 1][i]/mat[i][i];
|
||||
for (int j = 0; j < n + 1; ++j) {
|
||||
mat[i - 1][j] -= mul * mat[i][j];
|
||||
}
|
||||
mat[i][n] /= mat[i][i];
|
||||
mat[i][i] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double natural_cubic_spline(points_t points, matrix_t &mat, double x) {
|
||||
|
||||
auto &[xs, fx] = points;
|
||||
int n = xs.size();
|
||||
|
||||
int i = 0;
|
||||
for (int i_ = 0; i_ < n; ++i_) {
|
||||
if (xs[i_] > x){
|
||||
i = i_;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double hi = xs[i] - xs[i - 1];
|
||||
return mat[i - 1][n] * std::pow((xs[i] - x), 3)/(6 * hi) +
|
||||
mat[i][n] * std::pow((x - xs[i - 1]), 3)/(6 * hi) +
|
||||
(fx[i - 1] - mat[i - 1][n] * (hi * hi)/6)*(xs[i] - x)/hi +
|
||||
(fx[i] - mat[i][n] * (hi * hi)/6)*(x - xs[i - 1])/hi;
|
||||
|
||||
}
|
||||
|
||||
void exercise_b() {
|
||||
points_t points;
|
||||
auto &[xs, fx] = points;
|
||||
auto f = [](double x) { return 4 * std::pow(x, 2) + std::sin(9 * x); };
|
||||
|
||||
for (double x = -1; x <= 1; x += (1 - -1)/8.0) {
|
||||
xs.push_back(x);
|
||||
fx.push_back(f(x));
|
||||
}
|
||||
|
||||
std::ofstream poly{"b_polynomial.txt"};
|
||||
auto factors = newton_differences(points);
|
||||
for(double x = -1; x < 1; x += 0.001)
|
||||
poly << x << " " << newton_polynomial(points, factors, x) << '\n';
|
||||
|
||||
std::ofstream spline{"b_spline.txt"};
|
||||
unsigned long n = xs.size();
|
||||
matrix_t mat(n, std::vector<double>(n + 1));
|
||||
calculate_natural_cubic_spline_matrix(points, mat);
|
||||
for(double x = -1; x < 1; x += 0.001)
|
||||
spline << x << " " << natural_cubic_spline(points, mat, x) << '\n';
|
||||
}
|
||||
|
||||
### 2.a)
|
||||
|
||||
![Comparação Polinómio e Spline](a.png){ width=10cm }
|
||||
|
||||
Através dos graficos é possivel verificar que os valores das funções coincidem
|
||||
no pontos de interpolação, como era esperado. Não é possivel determinal qual a
|
||||
melhor aproximação sem conhecer a função original. O programa foi modificado para
|
||||
imprimir a matriz inicial assim como o resultado final, que foi utilizado para calcular
|
||||
o vetor resíduo e a norma deste. Este script encontra-se em baixo.
|
||||
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import numpy as np
|
||||
from scipy.linalg import solve
|
||||
from numpy.linalg import norm
|
||||
|
||||
# Matriz construída pelo programa em C++
|
||||
A = np.matrix([[1, 0, 0, 0, 0, 0],
|
||||
[0.166667, 0.666667, 0.166667, 0, 0, 0],
|
||||
[0, 0.166667, 0.5, 0.0833333, 0, 0],
|
||||
[0, 0, 0.0833333, 0.333333, 0.0833333, 0],
|
||||
[0, 0, 0, 0.0833333, 0.5, 0.166667],
|
||||
[0, 0, 0, 0, 0, 1]])
|
||||
|
||||
b = np.array([0, 1.2, -1.2, 0.8, 0.4, 0])
|
||||
|
||||
x2 = np.array([0, 2.76846, -3.87386, 3.30622, 0.248963, 0])
|
||||
|
||||
x = solve(A, b)
|
||||
|
||||
print(norm(x - x2))
|
||||
|
||||
Obteu-se para a norma do vetor resíduo o valor $1.0e-05$ que
|
||||
é considerado aceitável visto que os dados são apresentados
|
||||
com dois algarismos significativos.
|
||||
|
||||
\pagebreak
|
||||
|
||||
### 2.b)
|
||||
|
||||
#### i)
|
||||
|
||||
$$
|
||||
\begin{array}{c|ccccccccc}{x_{i}} & {-1} & {-0.75} & {-0.5} & {-0.25} & {0} &
|
||||
{0.25} & {0.5} & {0.75} & {1} \\ \hline {f_{i}} & {3.58788} & {1.79996} &
|
||||
{1.97753} & {-0.528073} & {0} & {1.02807} & {0.0224699} & {2.70004} & {4.41212}
|
||||
\end{array}
|
||||
$$
|
||||
|
||||
#### ii)
|
||||
|
||||
![Comparação de polinomio, spline e a função](b.png){ width=10cm }
|
||||
|
||||
De forma análoga ao exercício 2.a) foi calculada a norma do vetor resíduo
|
||||
usando o seguinte script:
|
||||
|
||||
A = np.matrix(
|
||||
[[1, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0.0416667, 0.166667, 0.0416667, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0.0416667, 0.166667, 0.0416667, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0.0416667, 0.166667, 0.0416667, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0.0416667, 0.166667, 0.0416667, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0.0416667, 0.166667, 0.0416667, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0.0416667, 0.166667, 0.0416667, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0.0416667, 0.166667, 0.0416667],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 1]])
|
||||
|
||||
b = np.array([0, 7.862, -10.7327, 12.1347, 2, -8.13471, 14.7327, -3.862, 0])
|
||||
|
||||
x2 = np.array([0, 73.9996, -107.31, 97.6564, 7.91753, -81.3265, 122.156, -53.7109, 0])
|
||||
|
||||
x = solve(A, b)
|
||||
|
||||
print(norm(x - x2))
|
||||
|
||||
Obteu-se para a norma do vetor resíduo o valor $9.0e-04$ que
|
||||
é considerado aceitável visto que este valor tem uma magnitude pequena.
|
||||
|
||||
\pagebreak
|
||||
|
||||
#### iii)
|
||||
|
||||
x | f(x) | p(x) | abs(f(x)-p(x)) | s(x) | f(x)-s(x)
|
||||
-----|------------|----------|--------------------|-------------------|-------------------
|
||||
0.30 | 0.78737988 | 0.923318 | $$ 1.4*10^{-1} $$ | 0.826621 | $$ 4.0*10^{-2} $$
|
||||
0.83 | 3.68278040 | 4.834190 | 1.2 | $$ 2.4*10^{-1} $$ | $$ 2.4*10^{-1} $$
|
||||
|
||||
Verificamos que o erro do spline cubico é inferior em ambos os casos. Além disso
|
||||
em ambos os casos o erro é maior quando a abcissa é mais distante do centro do
|
||||
intervalo.
|
||||
|
||||
#### iv)
|
||||
|
||||
|
||||
É possivel observar que a interpolação pelo spline aproxima, em geral, melhor a
|
||||
função dada do que o polinomio. Em particular verifica-se que o erro do polinomio
|
||||
acentua-se à medida que as abcissas se afastam do centro do intervalo de
|
||||
interpolação.
|
||||
|
BIN
3 - Splines/a.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
3 - Splines/b.png
Normal file
After Width: | Height: | Size: 15 KiB |
4001
3 - Splines/graphics/a_polynomial.txt
Normal file
4001
3 - Splines/graphics/a_spline.txt
Normal file
2000
3 - Splines/graphics/b_polynomial.txt
Normal file
2000
3 - Splines/graphics/b_spline.txt
Normal file
11
3 - Splines/graphics/graphs.gnuplot
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/gnuplot
|
||||
|
||||
set output "a.png";
|
||||
set terminal png size 1200,900 enhanced font "Helvetica, 20";
|
||||
|
||||
plot "a_polynomial.txt" with l lw 4 t "Polinomial", "a_spline.txt" with l lw 4 t "Spline Cúbico";
|
||||
|
||||
set output "b.png";
|
||||
|
||||
f(x) = 4*x**2 + sin(9*x)
|
||||
plot f(x) with l lw 4 t "f(x)", "b_polynomial.txt" with l lw 4 t "Polinomial", "b_spline.txt" with l lw 4 t "Spline Cúbico";
|
BIN
3 - Splines/print.pdf
Normal file
6
3 - Splines/source/input.txt
Normal file
@ -0,0 +1,6 @@
|
||||
0 1.4
|
||||
1 0.6
|
||||
2 1.0
|
||||
2.5 0.6
|
||||
3 0.6
|
||||
4 1.0
|
51
3 - Splines/source/matriz.txt
Normal file
@ -0,0 +1,51 @@
|
||||
mat:
|
||||
1,0,0,0,0,0,
|
||||
0.166667,0.666667,0.166667,0,0,0,
|
||||
0,0.166667,0.5,0.0833333,0,0,
|
||||
0,0,0.0833333,0.333333,0.0833333,0,
|
||||
0,0,0,0.0833333,0.5,0.166667,
|
||||
0,0,0,0,0,1,
|
||||
b:
|
||||
0
|
||||
1.2
|
||||
-1.2
|
||||
0.8
|
||||
0.4
|
||||
0
|
||||
x:
|
||||
0
|
||||
2.76846
|
||||
-3.87386
|
||||
3.30622
|
||||
0.248963
|
||||
0
|
||||
mat:
|
||||
1,0,0,0,0,0,0,0,0,
|
||||
0.0416667,0.166667,0.0416667,0,0,0,0,0,0,
|
||||
0,0.0416667,0.166667,0.0416667,0,0,0,0,0,
|
||||
0,0,0.0416667,0.166667,0.0416667,0,0,0,0,
|
||||
0,0,0,0.0416667,0.166667,0.0416667,0,0,0,
|
||||
0,0,0,0,0.0416667,0.166667,0.0416667,0,0,
|
||||
0,0,0,0,0,0.0416667,0.166667,0.0416667,0,
|
||||
0,0,0,0,0,0,0.0416667,0.166667,0.0416667,
|
||||
0,0,0,0,0,0,0,0,1,
|
||||
b:
|
||||
0
|
||||
7.862
|
||||
-10.7327
|
||||
12.1347
|
||||
2
|
||||
-8.13471
|
||||
14.7327
|
||||
-3.862
|
||||
0
|
||||
x:
|
||||
0
|
||||
73.9996
|
||||
-107.31
|
||||
97.6564
|
||||
7.91753
|
||||
-81.3265
|
||||
122.156
|
||||
-53.7109
|
||||
0
|
0
3 - Splines/source/new.foo
Normal file
211
3 - Splines/source/newton.cpp
Normal file
@ -0,0 +1,211 @@
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <ios>
|
||||
#include <iostream>
|
||||
#include <numeric>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
using points_t = std::pair<std::vector<double>, std::vector<double>>;
|
||||
using matrix_t = std::vector<std::vector<double>>;
|
||||
|
||||
std::vector<double> newton_differences(points_t points) {
|
||||
std::vector<double> factors{};
|
||||
auto &[x, fx] = points;
|
||||
int n = points.first.size();
|
||||
for (int i = 1; i <= n; ++i) {
|
||||
factors.push_back(fx[0]);
|
||||
for (int j = 0; j < (n - i); ++j) {
|
||||
fx[j] = (fx[j + 1] - fx[j]) / (x[j + i] - x[j]);
|
||||
}
|
||||
|
||||
}
|
||||
return factors;
|
||||
}
|
||||
|
||||
double newton_polynomial(points_t points, std::vector<double> factors, double x) {
|
||||
auto xs = points.first;
|
||||
int n = points.second.size() - 1;
|
||||
double val = 0;
|
||||
for (int k = 0; k <= n; ++k) {
|
||||
double acc = 1;
|
||||
for(int i = 0; i < k; ++i) {
|
||||
acc *= (x - xs[i]);
|
||||
}
|
||||
val += acc * factors[k];
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
void calculate_natural_cubic_spline_matrix(points_t points, matrix_t &mat) {
|
||||
auto &[xs, fx] = points;
|
||||
int n = xs.size();
|
||||
|
||||
// Construção da matriz
|
||||
for (int i = 1; i < n - 1; ++i) {
|
||||
mat[i][i - 1] = (xs[i] - xs[i - 1])/6;
|
||||
mat[i][i] = (xs[i + 1] - xs[i - 1])/3;
|
||||
mat[i][i + 1] = (xs[i + 1] - xs[i])/6;
|
||||
mat[i][n] = (fx[i + 1] - fx[i])/(xs[i + 1] - xs[i]) - (fx[i] - fx[i - 1])/(xs[i] - xs[i - 1]);
|
||||
}
|
||||
mat[0][0] = 1;
|
||||
mat[0][n - 1] = 0;
|
||||
mat[n - 1][n - 1] = 1;
|
||||
mat[n - 1][n] = 0;
|
||||
|
||||
std::ofstream matriz("matriz.txt", std::ios_base::app);
|
||||
|
||||
matriz << "mat:\n";
|
||||
for (auto i : mat){
|
||||
for (auto j = i.begin(); j != i.end() - 1; ++ j)
|
||||
matriz << *j << ",";
|
||||
matriz << "\n";
|
||||
}
|
||||
|
||||
matriz << "b:\n";
|
||||
for (auto i : mat){
|
||||
matriz << i[n] << '\n';
|
||||
}
|
||||
|
||||
// Passar para a forma triangular
|
||||
for (int k = 0; k < n; ++k) {
|
||||
for (int i = k + 1; i < n; ++i) {
|
||||
if (mat[k][k] != 0) {
|
||||
double mul = mat[i][k]/mat[k][k];
|
||||
for (int j = k; j < n; ++j) {
|
||||
mat[i][j] -= mul * mat[k][j];
|
||||
}
|
||||
mat[i][n] -= mul * mat[k][n];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Resolução da matriz
|
||||
for (int i = n - 1; i > 0; --i) {
|
||||
if (mat[i][i] != 0) {
|
||||
double mul = mat[i - 1][i]/mat[i][i];
|
||||
for (int j = 1; j < n + 1; ++j) {
|
||||
mat[i - 1][j] -= mul * mat[i][j];
|
||||
}
|
||||
mat[i - 1][i] = 0;
|
||||
mat[i][n] /= mat[i][i];
|
||||
mat[i][i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
matriz << "x:\n";
|
||||
for (auto i : mat){
|
||||
matriz << i[n] << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
double natural_cubic_spline(points_t points, matrix_t &mat, double x) {
|
||||
|
||||
auto &[xs, fx] = points;
|
||||
int n = xs.size();
|
||||
|
||||
int i = 0;
|
||||
for (int i_ = 0; i_ < n; ++i_) {
|
||||
if (xs[i_] > x){
|
||||
i = i_;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double hi = xs[i] - xs[i - 1];
|
||||
return mat[i - 1][n] * std::pow((xs[i] - x), 3)/(6 * hi) +
|
||||
mat[i][n] * std::pow((x - xs[i - 1]), 3)/(6 * hi) +
|
||||
(fx[i - 1] - mat[i - 1][n] * (hi * hi)/6)*(xs[i] - x)/hi +
|
||||
(fx[i] - mat[i][n] * (hi * hi)/6)*(x - xs[i - 1])/hi;
|
||||
|
||||
}
|
||||
|
||||
void exercise_a(points_t points) {
|
||||
auto &[xs, fx] = points;
|
||||
auto factors = newton_differences(points);
|
||||
std::ofstream poly{"a_polynomial.txt"};
|
||||
for(double x = 0; x < 4; x += 0.001)
|
||||
poly << x << " " << newton_polynomial(points, factors, x) << '\n';
|
||||
|
||||
std::ofstream spline{"a_spline.txt"};
|
||||
unsigned long n = xs.size();
|
||||
matrix_t mat(n, std::vector<double>(n + 1));
|
||||
calculate_natural_cubic_spline_matrix(points, mat);
|
||||
for(double x = 0; x < 4; x += 0.001)
|
||||
spline << x << " " << natural_cubic_spline(points, mat, x) << '\n';
|
||||
}
|
||||
|
||||
void exercise_b() {
|
||||
points_t points;
|
||||
auto &[xs, fx] = points;
|
||||
auto f = [](double x) { return 4 * std::pow(x, 2) + std::sin(9 * x); };
|
||||
|
||||
for (double x = -1; x <= 1; x += (1 - -1)/8.0) {
|
||||
xs.push_back(x);
|
||||
fx.push_back(f(x));
|
||||
}
|
||||
|
||||
std::ofstream poly{"b_polynomial.txt"};
|
||||
auto factors = newton_differences(points);
|
||||
for(double x = -1; x < 1; x += 0.001)
|
||||
poly << x << " " << newton_polynomial(points, factors, x) << '\n';
|
||||
|
||||
std::ofstream spline{"b_spline.txt"};
|
||||
unsigned long n = xs.size();
|
||||
matrix_t mat(n, std::vector<double>(n + 1));
|
||||
calculate_natural_cubic_spline_matrix(points, mat);
|
||||
for(double x = -1; x < 1; x += 0.001)
|
||||
spline << x << " " << natural_cubic_spline(points, mat, x) << '\n';
|
||||
|
||||
std::cout << "Erros poly: "
|
||||
<< std::abs(std::round((f(0.3) - newton_polynomial(points, factors, 0.3)) * 100.0) / 100.0) << " "
|
||||
<< std::abs(std::round((f(0.83) - newton_polynomial(points, factors, 0.83)) * 100.0) / 100.0) << '\n';
|
||||
|
||||
std::cout << "Erros spline: "
|
||||
<< std::abs(std::round((f(0.3) - natural_cubic_spline(points, mat, 0.3))*100.0)/100.0) << " "
|
||||
<< std::abs(std::round((f(0.83) - natural_cubic_spline(points, mat,0.83))*100.0)/100.0) << '\n';
|
||||
|
||||
std::cout << "p(0.3) = " << newton_polynomial(points, factors, 0.3) << ' '
|
||||
<< "p(0.83) = " << newton_polynomial(points, factors, 0.83) << '\n';
|
||||
|
||||
std::cout << "p(0.3) = " << natural_cubic_spline(points, mat, 0.3) << ' '
|
||||
<< "p(0.83) = " << natural_cubic_spline(points, mat, 0.83) << '\n';
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
std::istream *s;
|
||||
std::ifstream file;
|
||||
if (argc == 2) {
|
||||
if (argv[1] == "-"s) {
|
||||
s = &std::cin;
|
||||
} else {
|
||||
file.open(argv[1]);
|
||||
s = &file;
|
||||
}
|
||||
} else{
|
||||
std::cerr << "An argument required\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
points_t points;
|
||||
std::pair<double, double> p;
|
||||
while(true) {
|
||||
*s >> p.first >> p.second;
|
||||
if(s->eof())
|
||||
break;
|
||||
|
||||
points.first.push_back(p.first);
|
||||
points.second.push_back(p.second);
|
||||
}
|
||||
|
||||
exercise_a(points);
|
||||
exercise_b();
|
||||
|
||||
}
|
17
3 - Splines/source/old.foo
Normal file
@ -0,0 +1,17 @@
|
||||
Mat:
|
||||
1,0,0,0,0,0,0,
|
||||
0,1,-7.14916e-18,2.73077e-18,-4.18062e-19,0,2.76846,
|
||||
0,0,1,-7.50963e-18,1.14967e-18,0,-3.87386,
|
||||
0,0,-3.57458e-18,1,-4.38965e-18,0,3.30622,
|
||||
0,0,0,-7.50963e-18,1,0,0.248963,
|
||||
0,0,0,0,0,1,0,
|
||||
Mat:
|
||||
1,0,0,0,0,0,0,0,0,0,
|
||||
0,1,-1.73472e-18,4.64061e-19,2.85733e-19,5.30686e-20,-1.26382e-20,-4.49207e-21,0,73.9996,
|
||||
0,0,1,-1.74023e-18,-1.0715e-18,-1.99007e-19,4.73931e-20,1.68453e-20,0,-107.31,
|
||||
0,0,-1.73472e-18,1,4.00026e-18,7.4296e-19,-1.76934e-19,-6.2889e-20,0,97.6564,
|
||||
0,0,0,-1.74023e-18,1,-2.77283e-18,6.60344e-19,2.34711e-19,0,7.91753,
|
||||
0,0,0,0,4.00026e-18,1,-2.46444e-18,-8.75954e-19,0,-81.3265,
|
||||
0,0,0,0,0,-2.77283e-18,1,3.26911e-18,0,122.156,
|
||||
0,0,0,0,0,0,-2.46444e-18,1,0,-53.7109,
|
||||
0,0,0,0,0,0,0,0,1,0,
|
39
3 - Splines/source/residue.py
Executable file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import numpy as np
|
||||
from scipy.linalg import solve
|
||||
from numpy.linalg import norm
|
||||
|
||||
# Matriz construída pelo programa em C++
|
||||
A = np.matrix([[1, 0, 0, 0, 0, 0],
|
||||
[0.166667, 0.666667, 0.166667, 0, 0, 0],
|
||||
[0, 0.166667, 0.5, 0.0833333, 0, 0],
|
||||
[0, 0, 0.0833333, 0.333333, 0.0833333, 0],
|
||||
[0, 0, 0, 0.0833333, 0.5, 0.166667],
|
||||
[0, 0, 0, 0, 0, 1]])
|
||||
|
||||
b = np.array([0, 1.2, -1.2, 0.8, 0.4, 0])
|
||||
|
||||
x2 = np.array([0, 2.76846, -3.87386, 3.30622, 0.248963, 0])
|
||||
|
||||
x = solve(A, b)
|
||||
|
||||
print(norm(x - x2))
|
||||
|
||||
A = np.matrix([[1, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0.0416667, 0.166667, 0.0416667, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0.0416667, 0.166667, 0.0416667, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0.0416667, 0.166667, 0.0416667, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0.0416667, 0.166667, 0.0416667, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0.0416667, 0.166667, 0.0416667, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0.0416667, 0.166667, 0.0416667, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0.0416667, 0.166667, 0.0416667],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 1]])
|
||||
|
||||
b = np.array([0, 7.862, -10.7327, 12.1347, 2, -8.13471, 14.7327, -3.862, 0])
|
||||
|
||||
x2 = np.array([0, 73.9996, -107.31, 97.6564, 7.91753, -81.3265, 122.156, -53.7109, 0])
|
||||
|
||||
x = solve(A, b)
|
||||
|
||||
print(norm(x - x2))
|
17
3 - Splines/source/test.foo
Normal file
@ -0,0 +1,17 @@
|
||||
Mat:
|
||||
1,0,0,0,0,0,0,
|
||||
0,1,0,0,0,0,2.76846,
|
||||
0,0,1,0,0,0,-3.87386,
|
||||
0,0,-3.57458e-18,1,0,0,3.30622,
|
||||
0,0,0,-7.50963e-18,1,0,0.248963,
|
||||
0,0,0,0,0,1,0,
|
||||
Mat:
|
||||
1,0,0,0,0,0,0,0,0,0,
|
||||
0,1,0,0,0,0,0,0,0,73.9996,
|
||||
0,0,1,0,0,0,0,0,0,-107.31,
|
||||
0,0,-1.73472e-18,1,0,0,0,0,0,97.6564,
|
||||
0,0,0,-1.74023e-18,1,0,0,0,0,7.91753,
|
||||
0,0,0,0,4.00026e-18,1,0,0,0,-81.3265,
|
||||
0,0,0,0,0,-2.77283e-18,1,0,0,122.156,
|
||||
0,0,0,0,0,0,-2.46444e-18,1,0,-53.7109,
|
||||
0,0,0,0,0,0,0,0,1,0,
|
150
4 - Simpson and Trapezoidal rules/README.md
Executable file
@ -0,0 +1,150 @@
|
||||
---
|
||||
title: "Análise Numérica - Trabalho Prático 3"
|
||||
author:
|
||||
- Diogo Cordeiro
|
||||
- Hugo Sales
|
||||
- Pedro Costa
|
||||
geometry: margin=2cm
|
||||
output: pdf_document
|
||||
---
|
||||
|
||||
### Motivação
|
||||
|
||||
Pretende-se compreender o funcionamento conceptual bem como os desafios da implementação de dois métodos de integração
|
||||
numéricos: `Regra de Simpson` e `Regra dos Trapézios.`
|
||||
|
||||
### 1
|
||||
|
||||
<!-- $$ \frac{d^4}{dx^4}_{x \in [0;2]}sin(sin(sin(sin(x)))) $$ -->
|
||||
|
||||
Através da análise do gráfico abaixo, verificamos que o majorante, em valor absoluto, da 4ª derivada
|
||||
da função é menor que 12, este valor é usado para majorar a formula do erro para o calculo de n.
|
||||
|
||||
![Quarta derivada da função enunciada](majorante_erro_1.png){ width=8cm }
|
||||
|
||||
|
||||
/* Função que implementa o método de Simpson */
|
||||
double simpson (Function f, double a, double b, int n)
|
||||
{
|
||||
// Intervalo de passo
|
||||
double h = (b - a)/n;
|
||||
// Valor de f nos pontos de indice par
|
||||
double evens = summation(f, 2, n - 2, 2, h, a);
|
||||
// Valor de f nos pontos de indice impar
|
||||
double odds = summation(f, 1, n - 1, 2, h, a);
|
||||
// Aplicação da método de Simpson
|
||||
value = (h/3)*(f(a) + f(b) + 2 * evens + 4 * odds);
|
||||
}
|
||||
|
||||
\pagebreak
|
||||
|
||||
/* Função para calcular o sumatório de F entre os pontos de indice init
|
||||
e stop saltando step pontos, usando h como intervalo de passo */
|
||||
double summation (Function f, int init, int stop, int step, double h, double a)
|
||||
{
|
||||
// Acumulador
|
||||
double total = 0;
|
||||
for (int i = init; i <= stop; i += step) {
|
||||
// Adicionamos o valor de f correspondente ao x de indice i
|
||||
total += f(a + i * h);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
/* Função para calcular o número de pontos necessários para o calculo
|
||||
do integral com erro menor que error */
|
||||
int calculateN (double A, double B, double error) {
|
||||
int n = ceil( (B - A) / pow((15.0 * error) / 2.0, 1.0 / 4) );
|
||||
return n + (n % 2);
|
||||
}
|
||||
|
||||
void main ()
|
||||
{
|
||||
Function f(x) = sin(sin(sin(sin(x))));
|
||||
// com 7 casas decimais correctas
|
||||
print(simpson(f, 0, 2, calculateN(0, 2, pow(10, -7))));
|
||||
// com 12 casas decimais correctas
|
||||
print(simpson(f, 0, 2, calculateN(0, 2, pow(10, -12))));
|
||||
}
|
||||
|
||||
#### Output
|
||||
|
||||
Erro | Resultado
|
||||
---------------|-------------------
|
||||
$$ 10^{-7} $$ | 1.0548418906594816
|
||||
$$ 10^{-12} $$ | 1.0548418772492483
|
||||
|
||||
### 2)
|
||||
|
||||
// Valor exacto do integral calculado com o WolframAlpha, arredondado
|
||||
// com 15 algarismos significativos, um a mais do que o erro majorado
|
||||
// máximo para o caso de 2^20 pontos.
|
||||
double I = 1.05484187724912;
|
||||
|
||||
/* Função para calcular o integral recorrendo ao método do Trapézio */
|
||||
double trapezio (Function f, double a, double b) {
|
||||
// Acumulador
|
||||
double summation = 0;
|
||||
|
||||
// Intervalo de passo com n inicial = 2
|
||||
double h = (b - a)/2;
|
||||
|
||||
// Valor constante
|
||||
double fa_fb = f(a) + f(b);
|
||||
|
||||
// Para cada expoente de 1 a 20 (com passo 1)
|
||||
for (int k = 1; k <= 20; ++k) {
|
||||
// Guarda sumatorio dos pontos anteriores
|
||||
double partial_sum = 0;
|
||||
// Número de intervalos
|
||||
// Com o left shift fazemos a potência de 2^k
|
||||
int n = 1 << k;
|
||||
// Evitamos recalcular pontos da função previamente computados
|
||||
// guardando o sumatório destes em partial_sum e adicionamos a cada
|
||||
// iteração os pontos novos, sendo estes de indice impar
|
||||
for (int i = 1; i < n; i += 2) {
|
||||
// Adicionamos o valor de f correspondente ao x de indice i
|
||||
partial_sum += f(a + i * h);
|
||||
}
|
||||
|
||||
summation += partial_sum;
|
||||
|
||||
// Aplicação da formula do Trapézio
|
||||
double value = (h/2)*fa_fb + h * summation;
|
||||
|
||||
print(k + "\t| " + value + "\t| " + (I - value));
|
||||
|
||||
// Dividimos o intervalo por 2
|
||||
h /= 2;
|
||||
}
|
||||
}
|
||||
|
||||
void main () {
|
||||
Function f(x) = sin(sin(sin(sin(x))));
|
||||
print(trapezio(f, 0, 2);
|
||||
}
|
||||
|
||||
#### Output
|
||||
|
||||
k | $$ I_{n_{k}} $$ | $$ \mid I - I_{n_{k}} \mid $$
|
||||
----|---------------------|--------------------------
|
||||
1 | 0.9533749638740736 | $$ 1.1 \cdot 10^{-1} $$
|
||||
2 | 1.0308378382617962 | $$ 2.5 \cdot 10^{-2} $$
|
||||
3 | 1.0489039934457873 | $$ 6.0 \cdot 10^{-3} $$
|
||||
4 | 1.053360809734676 | $$ 1.5 \cdot 10^{-3} $$
|
||||
5 | 1.0544718169560368 | $$ 3.8 \cdot 10^{-4} $$
|
||||
6 | 1.054749374997165 | $$ 9.3 \cdot 10^{-5} $$
|
||||
7 | 1.0548187524860693 | $$ 2.4 \cdot 10^{-5} $$
|
||||
8 | 1.0548360961083287 | $$ 5.8 \cdot 10^{-6} $$
|
||||
9 | 1.054840431967042 | $$ 1.5 \cdot 10^{-6} $$
|
||||
10 | 1.0548415159287925 | $$ 3.6 \cdot 10^{-7} $$
|
||||
11 | 1.0548417869190467 | $$ 9.1 \cdot 10^{-8} $$
|
||||
12 | 1.0548418546666 | $$ 2.3 \cdot 10^{-8} $$
|
||||
13 | 1.054841871603487 | $$ 5.7 \cdot 10^{-9} $$
|
||||
14 | 1.0548418758377078 | $$ 1.5 \cdot 10^{-9} $$
|
||||
15 | 1.0548418768962615 | $$ 3.5 \cdot 10^{-10} $$
|
||||
16 | 1.0548418771608998 | $$ 8.9 \cdot 10^{-11} $$
|
||||
17 | 1.0548418772270582 | $$ 2.3 \cdot 10^{-11} $$
|
||||
18 | 1.0548418772436017 | $$ 5.6 \cdot 10^{-12} $$
|
||||
19 | 1.0548418772477444 | $$ 1.4 \cdot 10^{-12} $$
|
||||
20 | 1.0548418772487873 | $$ 3.3 \cdot 10^{-13} $$
|
BIN
4 - Simpson and Trapezoidal rules/assignment.pdf
Executable file
BIN
4 - Simpson and Trapezoidal rules/majorante_erro_1.png
Executable file
After Width: | Height: | Size: 26 KiB |
BIN
4 - Simpson and Trapezoidal rules/print.pdf
Executable file
1
4 - Simpson and Trapezoidal rules/slides/css/all.css
Normal file
40
4 - Simpson and Trapezoidal rules/slides/css/css.css
Normal file
@ -0,0 +1,40 @@
|
||||
/* cyrillic-ext */
|
||||
@font-face {
|
||||
font-family: 'Merriweather';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Merriweather Regular'), local('Merriweather-Regular'), url(https://fonts.gstatic.com/s/merriweather/v19/u-440qyriQwlOrhSvowK_l5-cSZMZ-Y.woff2) format('woff2');
|
||||
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
|
||||
}
|
||||
/* cyrillic */
|
||||
@font-face {
|
||||
font-family: 'Merriweather';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Merriweather Regular'), local('Merriweather-Regular'), url(https://fonts.gstatic.com/s/merriweather/v19/u-440qyriQwlOrhSvowK_l5-eCZMZ-Y.woff2) format('woff2');
|
||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
||||
}
|
||||
/* vietnamese */
|
||||
@font-face {
|
||||
font-family: 'Merriweather';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Merriweather Regular'), local('Merriweather-Regular'), url(https://fonts.gstatic.com/s/merriweather/v19/u-440qyriQwlOrhSvowK_l5-cyZMZ-Y.woff2) format('woff2');
|
||||
unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Merriweather';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Merriweather Regular'), local('Merriweather-Regular'), url(https://fonts.gstatic.com/s/merriweather/v19/u-440qyriQwlOrhSvowK_l5-ciZMZ-Y.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Merriweather';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Merriweather Regular'), local('Merriweather-Regular'), url(https://fonts.gstatic.com/s/merriweather/v19/u-440qyriQwlOrhSvowK_l5-fCZM.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
32
4 - Simpson and Trapezoidal rules/slides/css/css2.css
Normal file
@ -0,0 +1,32 @@
|
||||
/* cyrillic */
|
||||
@font-face {
|
||||
font-family: 'Oswald';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Oswald Regular'), local('Oswald-Regular'), url(https://fonts.gstatic.com/s/oswald/v16/TK3iWkUHHAIjg752HT8Ghe4.woff2) format('woff2');
|
||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
||||
}
|
||||
/* vietnamese */
|
||||
@font-face {
|
||||
font-family: 'Oswald';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Oswald Regular'), local('Oswald-Regular'), url(https://fonts.gstatic.com/s/oswald/v16/TK3iWkUHHAIjg752Fj8Ghe4.woff2) format('woff2');
|
||||
unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Oswald';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Oswald Regular'), local('Oswald-Regular'), url(https://fonts.gstatic.com/s/oswald/v16/TK3iWkUHHAIjg752Fz8Ghe4.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Oswald';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Oswald Regular'), local('Oswald-Regular'), url(https://fonts.gstatic.com/s/oswald/v16/TK3iWkUHHAIjg752GT8G.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
48
4 - Simpson and Trapezoidal rules/slides/css/css3.css
Normal file
@ -0,0 +1,48 @@
|
||||
/* cyrillic-ext */
|
||||
@font-face {
|
||||
font-family: 'Ubuntu Mono';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Ubuntu Mono'), local('UbuntuMono-Regular'), url(https://fonts.gstatic.com/s/ubuntumono/v8/KFOjCneDtsqEr0keqCMhbCc3CsTKlA.woff2) format('woff2');
|
||||
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
|
||||
}
|
||||
/* cyrillic */
|
||||
@font-face {
|
||||
font-family: 'Ubuntu Mono';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Ubuntu Mono'), local('UbuntuMono-Regular'), url(https://fonts.gstatic.com/s/ubuntumono/v8/KFOjCneDtsqEr0keqCMhbCc-CsTKlA.woff2) format('woff2');
|
||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
||||
}
|
||||
/* greek-ext */
|
||||
@font-face {
|
||||
font-family: 'Ubuntu Mono';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Ubuntu Mono'), local('UbuntuMono-Regular'), url(https://fonts.gstatic.com/s/ubuntumono/v8/KFOjCneDtsqEr0keqCMhbCc2CsTKlA.woff2) format('woff2');
|
||||
unicode-range: U+1F00-1FFF;
|
||||
}
|
||||
/* greek */
|
||||
@font-face {
|
||||
font-family: 'Ubuntu Mono';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Ubuntu Mono'), local('UbuntuMono-Regular'), url(https://fonts.gstatic.com/s/ubuntumono/v8/KFOjCneDtsqEr0keqCMhbCc5CsTKlA.woff2) format('woff2');
|
||||
unicode-range: U+0370-03FF;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Ubuntu Mono';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Ubuntu Mono'), local('UbuntuMono-Regular'), url(https://fonts.gstatic.com/s/ubuntumono/v8/KFOjCneDtsqEr0keqCMhbCc0CsTKlA.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Ubuntu Mono';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Ubuntu Mono'), local('UbuntuMono-Regular'), url(https://fonts.gstatic.com/s/ubuntumono/v8/KFOjCneDtsqEr0keqCMhbCc6CsQ.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
224
4 - Simpson and Trapezoidal rules/slides/css/css4.css
Normal file
@ -0,0 +1,224 @@
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Quattrocento'), url(https://fonts.gstatic.com/s/quattrocento/v10/OZpEg_xvsDZQL_LKIF7q4jP3zWj6T4g.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Quattrocento'), url(https://fonts.gstatic.com/s/quattrocento/v10/OZpEg_xvsDZQL_LKIF7q4jP3w2j6.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Quattrocento Bold'), local('Quattrocento-Bold'), url(https://fonts.gstatic.com/s/quattrocento/v10/OZpbg_xvsDZQL_LKIF7q4jP_eE3vfqnYgXc.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Quattrocento Bold'), local('Quattrocento-Bold'), url(https://fonts.gstatic.com/s/quattrocento/v10/OZpbg_xvsDZQL_LKIF7q4jP_eE3vcKnY.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento Sans';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: local('Quattrocento Sans Italic'), local('QuattrocentoSans-Italic'), url(https://fonts.gstatic.com/s/quattrocentosans/v11/va9a4lja2NVIDdIAAoMR5MfuElaRB0zMh0P2GEHJ.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento Sans';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: local('Quattrocento Sans Italic'), local('QuattrocentoSans-Italic'), url(https://fonts.gstatic.com/s/quattrocentosans/v11/va9a4lja2NVIDdIAAoMR5MfuElaRB0zMh032GA.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento Sans';
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
src: local('Quattrocento Sans Bold Italic'), local('QuattrocentoSans-BoldItalic'), url(https://fonts.gstatic.com/s/quattrocentosans/v11/va9X4lja2NVIDdIAAoMR5MfuElaRB0zMj_bTDXDojYsJ.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento Sans';
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
src: local('Quattrocento Sans Bold Italic'), local('QuattrocentoSans-BoldItalic'), url(https://fonts.gstatic.com/s/quattrocentosans/v11/va9X4lja2NVIDdIAAoMR5MfuElaRB0zMj_bTDX7ojQ.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento Sans';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Quattrocento Sans'), local('QuattrocentoSans'), url(https://fonts.gstatic.com/s/quattrocentosans/v11/va9c4lja2NVIDdIAAoMR5MfuElaRB0zHt0_uHA.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento Sans';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Quattrocento Sans'), local('QuattrocentoSans'), url(https://fonts.gstatic.com/s/quattrocentosans/v11/va9c4lja2NVIDdIAAoMR5MfuElaRB0zJt08.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento Sans';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Quattrocento Sans Bold'), local('QuattrocentoSans-Bold'), url(https://fonts.gstatic.com/s/quattrocentosans/v11/va9Z4lja2NVIDdIAAoMR5MfuElaRB0RyklrfPXzwiQ.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Quattrocento Sans';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Quattrocento Sans Bold'), local('QuattrocentoSans-Bold'), url(https://fonts.gstatic.com/s/quattrocentosans/v11/va9Z4lja2NVIDdIAAoMR5MfuElaRB0RyklrRPXw.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* cyrillic */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: local('Spectral Italic'), local('Spectral-Italic'), url(https://fonts.gstatic.com/s/spectral/v5/rnCt-xNNww_2s0amA9M8on7mTMuk.woff2) format('woff2');
|
||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
||||
}
|
||||
/* vietnamese */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: local('Spectral Italic'), local('Spectral-Italic'), url(https://fonts.gstatic.com/s/spectral/v5/rnCt-xNNww_2s0amA9M8onXmTMuk.woff2) format('woff2');
|
||||
unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: local('Spectral Italic'), local('Spectral-Italic'), url(https://fonts.gstatic.com/s/spectral/v5/rnCt-xNNww_2s0amA9M8onTmTMuk.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: local('Spectral Italic'), local('Spectral-Italic'), url(https://fonts.gstatic.com/s/spectral/v5/rnCt-xNNww_2s0amA9M8onrmTA.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* cyrillic */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
src: local('Spectral Bold Italic'), local('Spectral-BoldItalic'), url(https://fonts.gstatic.com/s/spectral/v5/rnCu-xNNww_2s0amA9M8qsHDWfCFXUIJ.woff2) format('woff2');
|
||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
||||
}
|
||||
/* vietnamese */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
src: local('Spectral Bold Italic'), local('Spectral-BoldItalic'), url(https://fonts.gstatic.com/s/spectral/v5/rnCu-xNNww_2s0amA9M8qsHDWfuFXUIJ.woff2) format('woff2');
|
||||
unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
src: local('Spectral Bold Italic'), local('Spectral-BoldItalic'), url(https://fonts.gstatic.com/s/spectral/v5/rnCu-xNNww_2s0amA9M8qsHDWfqFXUIJ.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
src: local('Spectral Bold Italic'), local('Spectral-BoldItalic'), url(https://fonts.gstatic.com/s/spectral/v5/rnCu-xNNww_2s0amA9M8qsHDWfSFXQ.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* cyrillic */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Spectral Regular'), local('Spectral-Regular'), url(https://fonts.gstatic.com/s/spectral/v5/rnCr-xNNww_2s0amA9M9knj-SA.woff2) format('woff2');
|
||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
||||
}
|
||||
/* vietnamese */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Spectral Regular'), local('Spectral-Regular'), url(https://fonts.gstatic.com/s/spectral/v5/rnCr-xNNww_2s0amA9M2knj-SA.woff2) format('woff2');
|
||||
unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Spectral Regular'), local('Spectral-Regular'), url(https://fonts.gstatic.com/s/spectral/v5/rnCr-xNNww_2s0amA9M3knj-SA.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Spectral Regular'), local('Spectral-Regular'), url(https://fonts.gstatic.com/s/spectral/v5/rnCr-xNNww_2s0amA9M5kng.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
/* cyrillic */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Spectral Bold'), local('Spectral-Bold'), url(https://fonts.gstatic.com/s/spectral/v5/rnCs-xNNww_2s0amA9uCt23FafadWQ.woff2) format('woff2');
|
||||
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
||||
}
|
||||
/* vietnamese */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Spectral Bold'), local('Spectral-Bold'), url(https://fonts.gstatic.com/s/spectral/v5/rnCs-xNNww_2s0amA9uCt23OafadWQ.woff2) format('woff2');
|
||||
unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
|
||||
}
|
||||
/* latin-ext */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Spectral Bold'), local('Spectral-Bold'), url(https://fonts.gstatic.com/s/spectral/v5/rnCs-xNNww_2s0amA9uCt23PafadWQ.woff2) format('woff2');
|
||||
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
||||
}
|
||||
/* latin */
|
||||
@font-face {
|
||||
font-family: 'Spectral';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Spectral Bold'), local('Spectral-Bold'), url(https://fonts.gstatic.com/s/spectral/v5/rnCs-xNNww_2s0amA9uCt23BafY.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
1
4 - Simpson and Trapezoidal rules/slides/css/katex.min.css
vendored
Normal file
8779
4 - Simpson and Trapezoidal rules/slides/css/style.css
Normal file
BIN
4 - Simpson and Trapezoidal rules/slides/imgs/majorante_erro_1.png
Executable file
After Width: | Height: | Size: 26 KiB |
71
4 - Simpson and Trapezoidal rules/slides/index.html
Executable file
@ -0,0 +1,71 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="robots" content="noindex">
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>Numerical Analysis - Slides</title>
|
||||
<link rel="stylesheet" href="css/all.css">
|
||||
<link href="css/css.css" rel="stylesheet">
|
||||
<link href="css/css2.css" rel="stylesheet">
|
||||
<link href="css/css3.css" rel="stylesheet">
|
||||
<link href="css/css4.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link rel="stylesheet" href="css/katex.min.css">
|
||||
<link rel="icon" href="https://hackersatporto.com/images/favicon.png">
|
||||
<meta name="description" content="Porto's student computing society. We are a community focused on learning about and building things with technology.">
|
||||
<script src="js/remark-latest.min.js"></script>
|
||||
<script src="js/jquery.min.js"></script>
|
||||
<script src="js/mark.min.js"></script>
|
||||
<script src="js/MathJax.js"></script>
|
||||
<script src="js/katex.min.js"></script>
|
||||
<script src="js/auto-render.min.js"></script>
|
||||
<script src="js/abcjs_basic_5.6.3-min.js"></script>
|
||||
<script src="js/story.js"></script>
|
||||
</head>
|
||||
|
||||
<body id="content" class="ma0 bg-white section-slides page-kind-page is-page-true feature-math feature-qrcode feature-nohighlight feature-music">
|
||||
<script>
|
||||
var hljs = remark.highlighter.engine;
|
||||
var slideshow = remark.create({
|
||||
ratio: "16:9",
|
||||
countIncrementalSlides: false,
|
||||
sourceUrl: 'text.md',
|
||||
slideNumberFormat: '%current%',
|
||||
highlightLanguage: "xaprb",
|
||||
placeholder: "dummy value to end the list without a comma"
|
||||
});
|
||||
|
||||
$(".remark-slide-content.fit-h1 h1").each(function(i, e) {
|
||||
var $e = $(e);
|
||||
var $p = $e.closest('div.remark-slide-container');
|
||||
var needsToggle = !$p.hasClass('remark-visible');
|
||||
if ( needsToggle ) $p.toggleClass('remark-visible');
|
||||
while (e.scrollHeight > e.clientHeight + 1 && $e.css('font-size') != '1px') {
|
||||
$e.css('font-size', (parseInt($e.css('font-size')) - 1) + "px");
|
||||
|
||||
|
||||
}
|
||||
if ( needsToggle ) $p.toggleClass('remark-visible');
|
||||
});
|
||||
|
||||
$( function() {
|
||||
if ( $( "body.feature-qrcode:not(.feature-noqrcode)" ).length ) {
|
||||
if ( $( ".qrcode" ).length ) {
|
||||
new QRCode($(".qrcode")[0], {
|
||||
"useSVG": true,
|
||||
"text": window.location.href.replace(/#\d*$/, "")
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Setup MathJax
|
||||
MathJax.Hub.Config({
|
||||
tex2jax: {
|
||||
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre']
|
||||
}
|
||||
});
|
||||
MathJax.Hub.Configured();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|