diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0119961 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ + +.idea/ + +*.pyc diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e9e6a80 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "python.testing.unittestArgs": [ + "-v", + "-s", + "./tests", + "-p", + "test_*.py" + ], + "python.testing.pytestEnabled": false, + "python.testing.unittestEnabled": true +} \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.2.tar.gz b/Older Versions/yoshi-otter1.2.tar.gz deleted file mode 100644 index d743ea5..0000000 Binary files a/Older Versions/yoshi-otter1.2.tar.gz and /dev/null differ diff --git a/Older Versions/yoshi-otter1.2/LICENSE b/Older Versions/yoshi-otter1.2/LICENSE deleted file mode 100644 index d2c5abe..0000000 --- a/Older Versions/yoshi-otter1.2/LICENSE +++ /dev/null @@ -1,278 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) 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 -this service 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 make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. 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. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -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 -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the 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 a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE 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. \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.2/Otter/Otter.py b/Older Versions/yoshi-otter1.2/Otter/Otter.py deleted file mode 100755 index 0412302..0000000 --- a/Older Versions/yoshi-otter1.2/Otter/Otter.py +++ /dev/null @@ -1,499 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. -# -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. -# -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import math -import numpy as np -import Seals - -sl = Seals.method() - -class Algebra: - - def __init__(self, function): - self.f = function - self.integral = self.Integral(self.f) - self.roots = self.Roots(self.f) - self.edo = self.Edo(self.f) - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - class Integral: - - def __init__(self,function): - self.f = function - self.simple = self.Simple(function) - self.double = self.Double(function) - - class Simple: - def __init__(self, function): - self.f = function - - def riemann(self,a,b,n=None): - - if n is None: - n = 10**6 - - delta = (b-a)/n - - psi = a - theta = 0 - - while((psi+delta) <= b): - - theta += (self.f(psi) + self.f(psi + delta))/2 - psi += delta - - integral = delta*theta - - return integral - - def simpson(self,a,b,n=None): - - if n is None: - n = 10**6 - - def x(i): - return a + i*h - - h = (b-a)/n - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta = eta + self.f(x(2*psi - 1)) - psi = psi + 1 - - while(kappa <= ((n/2)-1)): - - theta = theta + self.f(x(2*kappa)) - kappa = kappa + 1 - - return (h/3)*( self.f(x(0)) + self.f(x(n)) + 4*eta + 2*theta) - - - class Double: - - def __init__(self,function): - self.f = function - - def riemann(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - kappa = a - psi = c - theta = 0 - - while((psi + dy) < d): - - while((kappa + dx) < b): - - theta = theta + self.f(kappa, psi) - kappa = kappa + dx - - psi = psi + dy - kappa = a - - return theta*(dx)*(dy) - - def simpson(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - - def x(i): - - x = a + i*dx - - return x - - def y(i): - - y = c + i*dy - - return y - - def g(i): - - sigma = 0 - upsilon = 0 - - zeta = 1 - csi = 1 - - while(zeta <= (m/2)): - - sigma += self.f(x(i),y(2*zeta - 1)) - zeta += 1 - - while(csi <= ((m/2)-1)): - - upsilon += self.f(x(i),y(2*csi)) - csi += 1 - - return (dy/3)*( self.f(x(i),y(0)) + self.f(x(i),y(m)) + 4*sigma + 2*upsilon ) - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta += g(2*psi - 1) - psi += 1 - - while(kappa <= ((n/2)-1)): - - theta += g(2*kappa) - kappa += 1 - - return (dx/3)*( g(0) + g(n) + 4*eta + 2*theta) - - class Roots: - - def __init__(self, function=None): - if function is not None: - self.f = function - - def bissec(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - while abs(a-b) > e: - - c = (a+b)/2 - fc = self.f(c) - - if (fa*fc) < 0: - - b = c - - else: - - a = c - fa = fc - - c = (a+b)/2 - - return c - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - def newton(self,a,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - da = self.d(a,e) - b = a - fa/da - - - while abs(a-b) > e: - - b = a - a -= (fa/da) - fa = self.f(a) - da = self.d(a,e) - - return a - - def bissec_newton(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - c = (a+b)/2 # 'c' é a raiz calculada - - while abs(a-b) > 0.1: - - fc = self.f(c) - - if fa*fc < 0: - - b = c - - else: - - a = c - fa = self.f(a) - - c = (a+b)/2 - - fc = self.f(c) - dc = self.d(c,e) - h = c - fc/dc # 'h' é uma variável de controle - - while abs(c-h) > e: - - h = c - c -= (fc/dc) - fc = self.f(c) - dc = self.d(c,e) - - return (c) - - - class Edo: - - def __init__(self, function): - self.f = function - - def euler(self,a,y,b,n=None): - - if n is None: - n = 10**7 - - dx = (b-a)/n - - def x(i): - return a + i*dx - - for i in range(n): - - y = y + (self.f(x(i),y))*dx - - return y - - def runge(self,a,y,b,n=None): - - if n is None: - n = 10**7 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - y = y + (dx/2)*(self.f(x(i),y)+self.f(x(i+1),(y+(dx*self.f(x(i),y))))) - - return y - -class Interpolation: - """ Data should be organized in two columns: X and Y""" - - def __init__(self, data): - - self.data = data - self.polinomial = self.Polinomial(self.data) - - def minimus(self,x): - - theta = 0 - # somatorio de x - for i in range(self.data.shape[0]): - - theta += self.data[i][0] - - eta = 0 - #somatorio de y - for i in range(self.data.shape[0]): - - eta += self.data[i][1] - - sigma = 0 - #somatorio de xy - for i in range(self.data.shape[0]): - - sigma += self.data[i][0]*self.data[i][1] - - omega = 0 - #somatorio de x^2 - for i in range(self.data.shape[0]): - - omega += self.data[i][0]**2 - - - self.a = (self.data.shape[0]*sigma - theta*eta)/(self.data.shape[0]*omega - (theta**2)) - - self.b = (theta*sigma - eta*omega)/((theta**2) - self.data.shape[0]*omega) - - ym = 0 - - for i in range(self.data.shape[0]): - - ym += self.data[i][1]/self.data.shape[0] - - sqreq = 0 - - for i in range(self.data.shape[0]): - - sqreq += ((self.a*self.data[i][0] + self.b) - ym)**2 - - sqtot = 0 - - for i in range(self.data.shape[0]): - - sqtot += (self.data[i][1] - ym)**2 - - self.r2 = sqreq/sqtot - - return self.a*x + self.b - - class Polinomial: - - def __init__(self, data): - self.data = data - - def vandermonde(self, x): - - matrix = np.zeros((self.data.shape[0],self.data.shape[0])) - - for k in range(0, self.data.shape[0]): - - matrix[:,k] = self.data[:,0]**k - - self.A = sl.gauss(np.c_[matrix,self.data[:,1]]) - - y = 0 - - for i in range(0,self.A.shape[0]): - - y += self.A[i]*(x**i) - - return float(y) - - def lagrange(self, x): - - data_x = self.data[:,0] - data_y = self.data[:,1] - - def L(k,x): - - up = down = 1 - - for i in [x for x in range(data_x.shape[0]) if x != k]: - up = up*(x - data_x[i]) - - for i in [x for x in range(data_x.shape[0]) if x != k]: - down = down*(data_x[k] - data_x[i]) - - return up/down - - y = 0 - - for i in range(data_x.shape[0]): - - y += data_y[i]*L(i,x) - - return y - - def newton(self,x): - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data[:,1] - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/(self.data[(i+1)+j][0]-self.data[j][0]) - j += 1 - - i += 1 - j = 0 - - def f(x): - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data[k][0]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y - - self.f = f - - return f(x) - - def gregory(self,x): - - h = self.data[0][0] - self.data[1][0] - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data[:,1] - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/((i+1)*h) - j += 1 - - i += 1 - j = 0 - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data[k][0]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.2/Otter/__init__.py b/Older Versions/yoshi-otter1.2/Otter/__init__.py deleted file mode 100644 index 08ce1fe..0000000 --- a/Older Versions/yoshi-otter1.2/Otter/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. - -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. - -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -from .Otter import Algebra as algebra -from .Otter import Interpolation as interpolation \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.2/README.md b/Older Versions/yoshi-otter1.2/README.md deleted file mode 100644 index 05245f1..0000000 --- a/Older Versions/yoshi-otter1.2/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# Otter - Numeric Calculus - -This python package is made for applied Numeric Calculus of Algebra Functions. It is made with the following objectives in mind: - -* Receive one variable function from user input - -* Receive two variable function from user input - -* Performe derivatives with one variable functions - -* Performe integral with received functions - -* Use methods to proccess the matrices. - -* Find root of functions throw method of bissection and method of newton - -* Solve Diferential Equations throw method of euler and runge - -* Performe Minimus Interpolation and Polinomial Interpolation - -## Syntax - -To initialize a Otter instance linked to functions use the following syntax `otr = Otter.algebra(f)`, where `otr` will be a arbitrary name for the instance and `f` is a function of *one variable*. - -To initialize a Otter instance linked to data and interpolation use the following syntax `otr = Otter.interpolation(data)`, where `otr` will be a arbitrary name for the instance and data will be a *numpy* matrix where the first columns has to contain the values for `x` and the second column contains the values for `y`. - -### Algebra - -Algebra is a Python Class where some of the features described previously are defined as Classes as well, like: `Integral`, `Roots`, `EDO` (diferential equations). - -#### Integral - -To call the class *Integral* append the sufix with lower case in front of the instance like: `otr.integral`. The Integral class has two other class defined inside, `Simple` and `Double`, to call them append the sufix with lower case in front as `otr.integral.simple` or `otr.integral.double`. Then pick between Riemann's Method or Simpson's Method by appending the sufix `riemann` or `simpson` as well. - -After that the syntax will be something like `otr.integral.double.riemann(a,b,c,d,n,m)`, where `a` and `c` will be the first value of the interval of integration respectively in x and y, `b` and `d` will be the last, `n` and `m` will be the number of partitions. - -The syntax for one variable integrations will be `otr.integral.simple.riemann(a,b,n)`. - -If `n` is not defined the standart value in 10^6 partitions for one variable and 10^4 for double. And if `m` is not defined the standart value will be equal to `n`. - -#### Roots - -To call the class *Root* append the sufix with lower case in front of the instance like: `otr.roots`. The Roots class has three methods defined inside, `bissec`, `newton` and `bissec_newton`, to call them append the sufix with lower case in front as `otr.roots.bissec` or `otr.roots.newton` or even `otr.roots.bissecnewton`. - -The syntax for the bissection method and bissec_newton is equal to `otr.roots.bissec(a,b,e)` and `otr.roots.bissec_newton(a,b,e)`, where `a` is the first element of the interval containing the root and `b` is the last, `e` being the precision. - -The syntax for the newton method is equal to `otr.roots.newton(a,e)`, where `a` is the element closest to the root and `e` is the precision. - -If `e` is not defined the standart value is 10^(-6). - -#### Diferential Equations - -To call the class *EDO* (*E*quações *D*iferenciais *O*rdinárias) append the sufix with lower case in front of the instance like: `otr.edo`. The *EDO* class has two methods defined inside: `euler` and `runge`, to call them append the sufix with lower case in front as `otr.edo.euler` or `otr.edo.runge`. - -The syntax for the diferential equations method is equal to `otr.edo.euler(a,y,b,n)` or `otr.edo.runge(a,y,b,n)`, where `a` and `y` will be the inintial point and `b` is the value in *x* which you want to know the corresponding value in *y* and `n` is the number of operations. - -If `n` is not defined the standart value is 10^7. - -### Interpolation - -The python class *Interpolation* is divided in one method, minimus interpolation, and one class, polinomial interpolation. - -To call the method *minimus* use a syntax like `otr = Otter.interpolation(data)`, where `otr` is an instance and append the method in front of the instance like: `otr.minimus(x)`, where *x* is value of *f(x)* you want to estimate. - -To call the class *Polinomial* append the sufix with lower case in front of the instance like: `otr.polinomial`. The *Polinomial* class has four methods defined inside: `vandermonde`, `lagrange`, `newton` and `gregory`, to call them append the sufix with lower case in front like `otr.edo.gregory(x)` where *x* is value of *f(x)* you want to estimate. - -## Installation - -To install the package from source `cd` into the directory and run: - -`pip install .` - -or run - -`pip install yoshi-otter` diff --git a/Older Versions/yoshi-otter1.2/build/lib/Otter/Otter.py b/Older Versions/yoshi-otter1.2/build/lib/Otter/Otter.py deleted file mode 100644 index c2ec3b7..0000000 --- a/Older Versions/yoshi-otter1.2/build/lib/Otter/Otter.py +++ /dev/null @@ -1,480 +0,0 @@ -import math -import numpy as np -import Seals - -sl = Seals.method() - -class Algebra: - - def __init__(self, function): - self.f = function - self.integral = self.Integral(self.f) - self.roots = self.Roots(self.f) - self.edo = self.Edo(self.f) - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - class Integral: - - def __init__(self,function): - self.f = function - self.simple = self.Simple(function) - self.double = self.Double(function) - - class Simple: - def __init__(self, function): - self.f = function - - def riemann(self,a,b,n=None): - - if n is None: - n = 10**6 - - delta = (b-a)/n - - psi = a - theta = 0 - - while((psi+delta) <= b): - - theta += (self.f(psi) + self.f(psi + delta))/2 - psi += delta - - integral = delta*theta - - return integral - - def simpson(self,a,b,n=None): - - if n is None: - n = 10**6 - - def x(i): - return a + i*h - - h = (b-a)/n - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta = eta + self.f(x(2*psi - 1)) - psi = psi + 1 - - while(kappa <= ((n/2)-1)): - - theta = theta + self.f(x(2*kappa)) - kappa = kappa + 1 - - return (h/3)*( self.f(x(0)) + self.f(x(n)) + 4*eta + 2*theta) - - - class Double: - - def __init__(self,function): - self.f = function - - def riemann(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - kappa = a - psi = c - theta = 0 - - while((psi + dy) < d): - - while((kappa + dx) < b): - - theta = theta + self.f(kappa, psi) - kappa = kappa + dx - - psi = psi + dy - kappa = a - - return theta*(dx)*(dy) - - def simpson(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - - def x(i): - - x = a + i*dx - - return x - - def y(i): - - y = c + i*dy - - return y - - def g(i): - - sigma = 0 - upsilon = 0 - - zeta = 1 - csi = 1 - - while(zeta <= (m/2)): - - sigma += self.f(x(i),y(2*zeta - 1)) - zeta += 1 - - while(csi <= ((m/2)-1)): - - upsilon += self.f(x(i),y(2*csi)) - csi += 1 - - return (dy/3)*( self.f(x(i),y(0)) + self.f(x(i),y(m)) + 4*sigma + 2*upsilon ) - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta += g(2*psi - 1) - psi += 1 - - while(kappa <= ((n/2)-1)): - - theta += g(2*kappa) - kappa += 1 - - return (dx/3)*( g(0) + g(n) + 4*eta + 2*theta) - - class Roots: - - def __init__(self, function=None): - if function is not None: - self.f = function - - def bissec(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - while abs(a-b) > e: - - c = (a+b)/2 - fc = self.f(c) - - if (fa*fc) < 0: - - b = c - - else: - - a = c - fa = fc - - c = (a+b)/2 - - return c - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - def newton(self,a,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - da = self.d(a,e) - b = a - fa/da - - - while abs(a-b) > e: - - b = a - a -= (fa/da) - fa = self.f(a) - da = self.d(a,e) - - return a - - def bissec_newton(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - c = (a+b)/2 # 'c' é a raiz calculada - - while abs(a-b) > 0.1: - - fc = self.f(c) - - if fa*fc < 0: - - b = c - - else: - - a = c - fa = self.f(a) - - c = (a+b)/2 - - fc = self.f(c) - dc = self.d(c,e) - h = c - fc/dc # 'h' é uma variável de controle - - while abs(c-h) > e: - - h = c - c -= (fc/dc) - fc = self.f(c) - dc = self.d(c,e) - - return (c) - - - class Edo: - - def __init__(self, function): - self.f = function - - def euler(self,a,y,b,n=None): - - if n is None: - n = 10**7 - - dx = (b-a)/n - - def x(i): - return a + i*dx - - for i in range(n): - - y = y + (self.f(x(i),y))*dx - - return y - - def runge(self,a,y,b,n=None): - - if n is None: - n = 10**7 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - y = y + (dx/2)*(self.f(x(i),y)+self.f(x(i+1),(y+(dx*self.f(x(i),y))))) - - return y - -class Interpolation: - """ Data should be organized in two columns: X and Y""" - - def __init__(self, data): - - self.data = data - self.polinomial = self.Polinomial(self.data) - - def minimus(self,x): - - theta = 0 - # somatorio de x - for i in range(self.data.shape[0]): - - theta += self.data[i][0] - - eta = 0 - #somatorio de y - for i in range(self.data.shape[0]): - - eta += self.data[i][1] - - sigma = 0 - #somatorio de xy - for i in range(self.data.shape[0]): - - sigma += self.data[i][0]*self.data[i][1] - - omega = 0 - #somatorio de x^2 - for i in range(self.data.shape[0]): - - omega += self.data[i][0]**2 - - - self.a = (self.data.shape[0]*sigma - theta*eta)/(self.data.shape[0]*omega - (theta**2)) - - self.b = (theta*sigma - eta*omega)/((theta**2) - self.data.shape[0]*omega) - - ym = 0 - - for i in range(self.data.shape[0]): - - ym += self.data[i][1]/self.data.shape[0] - - sqreq = 0 - - for i in range(self.data.shape[0]): - - sqreq += ((self.a*self.data[i][0] + self.b) - ym)**2 - - sqtot = 0 - - for i in range(self.data.shape[0]): - - sqtot += (self.data[i][1] - ym)**2 - - self.r2 = sqreq/sqtot - - return self.a*x + self.b - - class Polinomial: - - def __init__(self, data): - self.data = data - - def vandermonde(self, x): - - matrix = np.zeros((self.data.shape[0],self.data.shape[0])) - - for k in range(0, self.data.shape[0]): - - matrix[:,k] = self.data[:,0]**k - - self.A = sl.gauss(np.c_[matrix,self.data[:,1]]) - - y = 0 - - for i in range(0,self.A.shape[0]): - - y += self.A[i]*(x**i) - - return float(y) - - def lagrange(self, x): - - data_x = self.data[:,0] - data_y = self.data[:,1] - - def L(k,x): - - up = down = 1 - - for i in [x for x in range(data_x.shape[0]) if x != k]: - up = up*(x - data_x[i]) - - for i in [x for x in range(data_x.shape[0]) if x != k]: - down = down*(data_x[k] - data_x[i]) - - return up/down - - y = 0 - - for i in range(data_x.shape[0]): - - y += data_y[i]*L(i,x) - - return y - - def newton(self,x): - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data[:,1] - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/(self.data[(i+1)+j][0]-self.data[j][0]) - j += 1 - - i += 1 - j = 0 - - def f(x): - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data[k][0]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y - - self.f = f - - return f(x) - - def gregory(self,x): - - h = self.data[0][0] - self.data[1][0] - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data[:,1] - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/((i+1)*h) - j += 1 - - i += 1 - j = 0 - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data[k][0]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.2/build/lib/Otter/__init__.py b/Older Versions/yoshi-otter1.2/build/lib/Otter/__init__.py deleted file mode 100644 index 4132067..0000000 --- a/Older Versions/yoshi-otter1.2/build/lib/Otter/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from .Otter import Algebra as algebra -from .Otter import Interpolation as interpolation \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.2/dist/yoshi-otter-1.1.tar.gz b/Older Versions/yoshi-otter1.2/dist/yoshi-otter-1.1.tar.gz deleted file mode 100644 index 8d832a9..0000000 Binary files a/Older Versions/yoshi-otter1.2/dist/yoshi-otter-1.1.tar.gz and /dev/null differ diff --git a/Older Versions/yoshi-otter1.2/dist/yoshi_otter-1.1-py3-none-any.whl b/Older Versions/yoshi-otter1.2/dist/yoshi_otter-1.1-py3-none-any.whl deleted file mode 100644 index 52412b3..0000000 Binary files a/Older Versions/yoshi-otter1.2/dist/yoshi_otter-1.1-py3-none-any.whl and /dev/null differ diff --git a/Older Versions/yoshi-otter1.2/yoshi_otter.egg-info/PKG-INFO b/Older Versions/yoshi-otter1.2/yoshi_otter.egg-info/PKG-INFO deleted file mode 100644 index b2d399e..0000000 --- a/Older Versions/yoshi-otter1.2/yoshi_otter.egg-info/PKG-INFO +++ /dev/null @@ -1,91 +0,0 @@ -Metadata-Version: 2.1 -Name: yoshi-otter -Version: 1.1 -Summary: Numeric Calculus python module in the topic of Algebra Functions -Home-page: https://github.com/HideyoshiNakazone/Otter-NumericCalculus.git -Author: Vitor Hideyoshi -Author-email: vitor.h.n.batista@gmail.com -License: UNKNOWN -Description: # Otter - Numeric Calculus - - This python package is made for applied Numeric Calculus of Algebra Functions. It is made with the following objectives in mind: - - * Receive one variable function from user input - - * Receive two variable function from user input - - * Performe derivatives with one variable functions - - * Performe integral with received functions - - * Use methods to proccess the matrices. - - * Find root of functions throw method of bissection and method of newton - - * Solve Diferential Equations throw method of euler and runge - - * Performe Minimus Interpolation and Polinomial Interpolation - - ## Syntax - - To initialize a Otter instance linked to functions use the following syntax `otr = Otter.algebra(f)`, where `otr` will be a arbitrary name for the instance and `f` is a function of *one variable*. - - To initialize a Otter instance linked to data and interpolation use the following syntax `otr = Otter.interpolation(data)`, where `otr` will be a arbitrary name for the instance and data will be a *numpy* matrix where the first columns has to contain the values for `x` and the second column contains the values for `y`. - - ### Algebra - - Algebra is a Python Class where some of the features described previously are defined as Classes as well, like: `Integral`, `Roots`, `EDO` (diferential equations). - - #### Integral - - To call the class *Integral* append the sufix with lower case in front of the instance like: `otr.integral`. The Integral class has two other class defined inside, `Simple` and `Double`, to call them append the sufix with lower case in front as `otr.integral.simple` or `otr.integral.double`. Then pick between Riemann's Method or Simpson's Method by appending the sufix `riemann` or `simpson` as well. - - After that the syntax will be something like `otr.integral.double.riemann(a,b,c,d,n,m)`, where `a` and `c` will be the first value of the interval of integration respectively in x and y, `b` and `d` will be the last, `n` and `m` will be the number of partitions. - - The syntax for one variable integrations will be `otr.integral.simple.riemann(a,b,n)`. - - If `n` is not defined the standart value in 10^6 partitions for one variable and 10^4 for double. And if `m` is not defined the standart value will be equal to `n`. - - #### Roots - - To call the class *Root* append the sufix with lower case in front of the instance like: `otr.roots`. The Roots class has three methods defined inside, `bissec`, `newton` and `bissec_newton`, to call them append the sufix with lower case in front as `otr.roots.bissec` or `otr.roots.newton` or even `otr.roots.bissecnewton`. - - The syntax for the bissection method and bissec_newton is equal to `otr.roots.bissec(a,b,e)` and `otr.roots.bissec_newton(a,b,e)`, where `a` is the first element of the interval containing the root and `b` is the last, `e` being the precision. - - The syntax for the newton method is equal to `otr.roots.newton(a,e)`, where `a` is the element closest to the root and `e` is the precision. - - If `e` is not defined the standart value is 10^(-6). - - #### Diferential Equations - - To call the class *EDO* (*E*quações *D*iferenciais *O*rdinárias) append the sufix with lower case in front of the instance like: `otr.edo`. The *EDO* class has two methods defined inside: `euler` and `runge`, to call them append the sufix with lower case in front as `otr.edo.euler` or `otr.edo.runge`. - - The syntax for the diferential equations method is equal to `otr.edo.euler(a,y,b,n)` or `otr.edo.runge(a,y,b,n)`, where `a` and `y` will be the inintial point and `b` is the value in *x* which you want to know the corresponding value in *y* and `n` is the number of operations. - - If `n` is not defined the standart value is 10^7. - - ### Interpolation - - The python class *Interpolation* is divided in one method, minimus interpolation, and one class, polinomial interpolation. - - To call the method *minimus* use a syntax like `otr = Otter.interpolation(data)`, where `otr` is an instance and append the method in front of the instance like: `otr.minimus(x)`, where *x* is value of *f(x)* you want to estimate. - - To call the class *Polinomial* append the sufix with lower case in front of the instance like: `otr.polinomial`. The *Polinomial* class has four methods defined inside: `vandermonde`, `lagrange`, `newton` and `gregory`, to call them append the sufix with lower case in front like `otr.edo.gregory(x)` where *x* is value of *f(x)* you want to estimate. - - ## Installation - - To install the package from source `cd` into the directory and run: - - `pip install .` - - or run - - `pip install otter` - -Platform: UNKNOWN -Classifier: Programming Language :: Python :: 3 -Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2) -Classifier: Operating System :: OS Independent -Classifier: Development Status :: 2 - Pre-Alpha -Requires-Python: >=3.6 -Description-Content-Type: text/markdown diff --git a/Older Versions/yoshi-otter1.2/yoshi_otter.egg-info/SOURCES.txt b/Older Versions/yoshi-otter1.2/yoshi_otter.egg-info/SOURCES.txt deleted file mode 100644 index 5dc205c..0000000 --- a/Older Versions/yoshi-otter1.2/yoshi_otter.egg-info/SOURCES.txt +++ /dev/null @@ -1,9 +0,0 @@ -README.md -setup.py -Otter/Otter.py -Otter/__init__.py -yoshi_otter.egg-info/PKG-INFO -yoshi_otter.egg-info/SOURCES.txt -yoshi_otter.egg-info/dependency_links.txt -yoshi_otter.egg-info/requires.txt -yoshi_otter.egg-info/top_level.txt \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.2/yoshi_otter.egg-info/dependency_links.txt b/Older Versions/yoshi-otter1.2/yoshi_otter.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/Older Versions/yoshi-otter1.2/yoshi_otter.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Older Versions/yoshi-otter1.2/yoshi_otter.egg-info/requires.txt b/Older Versions/yoshi-otter1.2/yoshi_otter.egg-info/requires.txt deleted file mode 100644 index 11c1c26..0000000 --- a/Older Versions/yoshi-otter1.2/yoshi_otter.egg-info/requires.txt +++ /dev/null @@ -1,3 +0,0 @@ -numpy -pandas -yoshi-seals diff --git a/Older Versions/yoshi-otter1.2/yoshi_otter.egg-info/top_level.txt b/Older Versions/yoshi-otter1.2/yoshi_otter.egg-info/top_level.txt deleted file mode 100644 index ccaaf54..0000000 --- a/Older Versions/yoshi-otter1.2/yoshi_otter.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -Otter diff --git a/Older Versions/yoshi-otter1.3.1.tar.gz b/Older Versions/yoshi-otter1.3.1.tar.gz deleted file mode 100644 index 5f228f4..0000000 Binary files a/Older Versions/yoshi-otter1.3.1.tar.gz and /dev/null differ diff --git a/Older Versions/yoshi-otter1.3.1/LICENSE b/Older Versions/yoshi-otter1.3.1/LICENSE deleted file mode 100644 index d2c5abe..0000000 --- a/Older Versions/yoshi-otter1.3.1/LICENSE +++ /dev/null @@ -1,278 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) 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 -this service 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 make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. 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. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -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 -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the 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 a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE 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. \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3.1/Otter/Otter.py b/Older Versions/yoshi-otter1.3.1/Otter/Otter.py deleted file mode 100755 index 0e246e5..0000000 --- a/Older Versions/yoshi-otter1.3.1/Otter/Otter.py +++ /dev/null @@ -1,517 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. -# -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. -# -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import math -import numpy as np -import pandas as pd -import Seals - -sl = Seals.process() - -class Algebra: - - def __init__(self, function): - self.f = function - self.integral = self.Integral(self.f) - self.roots = self.Roots(self.f) - self.edo = self.Edo(self.f) - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - class Integral: - - def __init__(self,function): - self.f = function - self.simple = self.Simple(function) - self.double = self.Double(function) - - class Simple: - def __init__(self, function): - self.f = function - - def riemann(self,a,b,n=None): - - if n is None: - n = 10**6 - - delta = (b-a)/n - - psi = a - theta = 0 - - while((psi+delta) <= b): - - theta += (self.f(psi) + self.f(psi + delta))/2 - psi += delta - - integral = delta*theta - - return integral - - def simpson(self,a,b,n=None): - - if n is None: - n = 10**6 - - def x(i): - return a + i*h - - h = (b-a)/n - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta = eta + self.f(x(2*psi - 1)) - psi = psi + 1 - - while(kappa <= ((n/2)-1)): - - theta = theta + self.f(x(2*kappa)) - kappa = kappa + 1 - - return (h/3)*( self.f(x(0)) + self.f(x(n)) + 4*eta + 2*theta) - - - class Double: - - def __init__(self,function): - self.f = function - - def riemann(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - kappa = a - psi = c - theta = 0 - - while((psi + dy) < d): - - while((kappa + dx) < b): - - theta = theta + self.f(kappa, psi) - kappa = kappa + dx - - psi = psi + dy - kappa = a - - return theta*(dx)*(dy) - - def simpson(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - - def x(i): - - x = a + i*dx - - return x - - def y(i): - - y = c + i*dy - - return y - - def g(i): - - sigma = 0 - upsilon = 0 - - zeta = 1 - csi = 1 - - while(zeta <= (m/2)): - - sigma += self.f(x(i),y(2*zeta - 1)) - zeta += 1 - - while(csi <= ((m/2)-1)): - - upsilon += self.f(x(i),y(2*csi)) - csi += 1 - - return (dy/3)*( self.f(x(i),y(0)) + self.f(x(i),y(m)) + 4*sigma + 2*upsilon ) - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta += g(2*psi - 1) - psi += 1 - - while(kappa <= ((n/2)-1)): - - theta += g(2*kappa) - kappa += 1 - - return (dx/3)*( g(0) + g(n) + 4*eta + 2*theta) - - class Roots: - - def __init__(self, function=None): - if function is not None: - self.f = function - - def bissec(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - while abs(a-b) > e: - - c = (a+b)/2 - fc = self.f(c) - - if (fa*fc) < 0: - - b = c - - else: - - a = c - fa = fc - - c = (a+b)/2 - - return c - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - def newton(self,a,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - da = self.d(a,e) - b = a - fa/da - - - while abs(a-b) > e: - - b = a - a -= (fa/da) - fa = self.f(a) - da = self.d(a,e) - - return a - - def bissec_newton(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - c = (a+b)/2 # 'c' é a raiz calculada - - while abs(a-b) > 0.1: - - fc = self.f(c) - - if fa*fc < 0: - - b = c - - else: - - a = c - fa = self.f(a) - - c = (a+b)/2 - - fc = self.f(c) - dc = self.d(c,e) - h = c - fc/dc # 'h' é uma variável de controle - - while abs(c-h) > e: - - h = c - c -= (fc/dc) - fc = self.f(c) - dc = self.d(c,e) - - return (c) - - - class Edo: - - def __init__(self, function): - self.F = function - - def euler(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return a + i*dx - - for i in range(n): - - y = y + (self.F(x(i),y))*dx - - return y - - def runge(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - y = y + (dx/2)*(self.F(x(i),y)+self.F(x(i+1),(y+(dx*self.F(x(i),y))))) - - return y - - def adams(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - f0 = self.F(x(i),y) - f1 = self.F(x(i+1),y + dx*self.F(x(i)+(dx/2),y+(dx/2)*self.F(x(i),y))) - f2 = self.F(x(i+2),y + (dx/2)*(3*f1-f0)) - - y += (dx/12)*(5*f2 + 8*f1 - f0) - - return y - -class Interpolation: - """ Data should be organized in two columns: X and Y""" - - def __init__(self, data): - - self.data = data - self.polinomial = self.Polinomial(self.data) - - def minimus(self,x): - - theta = 0 - # somatorio de x - for i in range(self.data.shape[0]): - - theta += self.data.x[i] - - eta = 0 - #somatorio de y - for i in range(self.data.shape[0]): - - eta += self.data.y[i] - - sigma = 0 - #somatorio de xy - for i in range(self.data.shape[0]): - - sigma += self.data.x[i]*self.data.y[i] - - omega = 0 - #somatorio de x^2self.dself.dself.d - for i in range(self.data.shape[0]): - - omega += self.data.x[i]**2 - - - self.a = (self.data.shape[0]*sigma - theta*eta)/(self.data.shape[0]*omega - (theta**2)) - - self.b = (theta*sigma - eta*omega)/((theta**2) - self.data.shape[0]*omega) - - ym = 0 - - for i in range(self.data.shape[0]): - - ym += self.data.y[i]/self.data.shape[0] - - sqreq = 0 - - for i in range(self.data.shape[0]): - - sqreq += ((self.a*self.data.x[i] + self.b) - ym)**2 - - sqtot = 0 - - for i in range(self.data.shape[0]): - - sqtot += (self.data.y[i] - ym)**2 - - self.r2 = sqreq/sqtot - - return self.a*x + self.b - - class Polinomial: - - def __init__(self, data): - self.data = data - - def vandermonde(self, x): - - matrix = np.zeros((self.data.shape[0],self.data.shape[0])) - - for k in range(0, self.data.shape[0]): - - matrix[:,k] = self.data.x[:]**k - - self.A = sl.gauss(np.c_[matrix,self.data[:,1]]) - - y = 0 - - for i in range(0,self.A.shape[0]): - - y += self.A[i]*(x**i) - - return float(y) - - def lagrange(self, x): - - def L(k,x): - - up = down = 1 - - for i in [x for x in range(self.data.x.shape[0]) if x != k]: - up = up*(x - self.data.x[i]) - - for i in [x for x in range(self.data.x.shape[0]) if x != k]: - down = down*(self.data.x[k] - self.data.x[i]) - - return up/down - - y = 0 - - for i in range(self.data.x.shape[0]): - - y += self.data.y[i]*L(i,x) - - return y - - def newton(self,x): - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data.y - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/(self.data.x[(i+1)+j]-self.data.x[j]) - j += 1 - - i += 1 - j = 0 - - def f(x): - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data.x[k]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y - - self.f = f - - return f(x) - - def gregory(self,x): - - h = self.data.x[0] - self.data.x[1] - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data.y - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/((i+1)*h) - j += 1 - - i += 1 - j = 0 - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data.x[k]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3.1/Otter/__init__.py b/Older Versions/yoshi-otter1.3.1/Otter/__init__.py deleted file mode 100644 index 08ce1fe..0000000 --- a/Older Versions/yoshi-otter1.3.1/Otter/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. - -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. - -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -from .Otter import Algebra as algebra -from .Otter import Interpolation as interpolation \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3.1/README.md b/Older Versions/yoshi-otter1.3.1/README.md deleted file mode 100644 index 167eb4e..0000000 --- a/Older Versions/yoshi-otter1.3.1/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# Otter - Numeric Calculus - -This python package is made for applied Numeric Calculus of Algebra Functions. It is made with the following objectives in mind: - -* Receive one variable function from user input - -* Receive two variable function from user input - -* Performe derivatives with one variable functions - -* Performe integral with received functions - -* Use methods to proccess the matrices. - -* Find root of functions throw method of bissection and method of newton - -* Solve Diferential Equations throw method of euler and runge - -* Performe Minimus Interpolation and Polinomial Interpolation - -## Syntax - -To initialize a Otter instance linked to functions use the following syntax `otr = Otter.algebra(f)`, where `otr` will be a arbitrary name for the instance and `f` is a function of *one variable*. - -To initialize a Otter instance linked to data and interpolation use the following syntax `otr = Otter.interpolation(data)`, where `otr` will be a arbitrary name for the instance and data will be a *numpy* matrix where the first columns has to contain the values for `x` and the second column contains the values for `y`. - -### Algebra - -Algebra is a Python Class where some of the features described previously are defined as Classes as well, like: `Integral`, `Roots`, `EDO` (diferential equations). - -#### Integral - -To call the class *Integral* append the sufix with lower case in front of the instance like: `otr.integral`. The Integral class has two other class defined inside, `Simple` and `Double`, to call them append the sufix with lower case in front as `otr.integral.simple` or `otr.integral.double`. Then pick between Riemann's Method or Simpson's Method by appending the sufix `riemann` or `simpson` as well. - -After that the syntax will be something like `otr.integral.double.riemann(a,b,c,d,n,m)`, where `a` and `c` will be the first value of the interval of integration respectively in x and y, `b` and `d` will be the last, `n` and `m` will be the number of partitions. - -The syntax for one variable integrations will be `otr.integral.simple.riemann(a,b,n)`. - -If `n` is not defined the standart value in 10^6 partitions for one variable and 10^4 for double. And if `m` is not defined the standart value will be equal to `n`. - -#### Roots - -To call the class *Root* append the sufix with lower case in front of the instance like: `otr.roots`. The Roots class has three methods defined inside, `bissec`, `newton` and `bissec_newton`, to call them append the sufix with lower case in front as `otr.roots.bissec` or `otr.roots.newton` or even `otr.roots.bissecnewton`. - -The syntax for the bissection method and bissec_newton is equal to `otr.roots.bissec(a,b,e)` and `otr.roots.bissec_newton(a,b,e)`, where `a` is the first element of the interval containing the root and `b` is the last, `e` being the precision. - -The syntax for the newton method is equal to `otr.roots.newton(a,e)`, where `a` is the element closest to the root and `e` is the precision. - -If `e` is not defined the standart value is 10^(-6). - -#### Diferential Equations - -To call the class *EDO* (*E*quações *D*iferenciais *O*rdinárias) append the sufix with lower case in front of the instance like: `otr.edo`. The *EDO* class has two methods defined inside: `euler` and `runge`, to call them append the sufix with lower case in front as `otr.edo.euler` or `otr.edo.runge`. - -The syntax for the diferential equations method is equal to `otr.edo.euler(a,y,b,n)` or `otr.edo.runge(a,y,b,n)`, where `a` and `y` will be the inintial point and `b` is the value in *x* which you want to know the corresponding value in *y* and `n` is the number of operations. - -If `n` is not defined the standart value is 10^7. - -### Interpolation - -The python class *Interpolation* is divided in one method, minimus interpolation, and one class, polinomial interpolation. - -To call the method *minimus* use a syntax like `otr = Otter.interpolation(data)`, where `data` is a data frame containing values for *x* and *y*, `otr` is an instance and append the method in front of the instance like: `otr.minimus(x)`, where *x* is value of *f(x)* you want to estimate. - -To call the class *Polinomial* append the sufix with lower case in front of the instance like: `otr.polinomial`. The *Polinomial* class has four methods defined inside: `vandermonde`, `lagrange`, `newton` and `gregory`, to call them append the sufix with lower case in front like `otr.edo.gregory(x)` where *x* is value of *f(x)* you want to estimate. - -## Installation - -To install the package from source `cd` into the directory and run: - -`pip install .` - -or run - -`pip install yoshi-otter` diff --git a/Older Versions/yoshi-otter1.3.1/build/lib/Otter/Otter.py b/Older Versions/yoshi-otter1.3.1/build/lib/Otter/Otter.py deleted file mode 100644 index 0e246e5..0000000 --- a/Older Versions/yoshi-otter1.3.1/build/lib/Otter/Otter.py +++ /dev/null @@ -1,517 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. -# -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. -# -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import math -import numpy as np -import pandas as pd -import Seals - -sl = Seals.process() - -class Algebra: - - def __init__(self, function): - self.f = function - self.integral = self.Integral(self.f) - self.roots = self.Roots(self.f) - self.edo = self.Edo(self.f) - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - class Integral: - - def __init__(self,function): - self.f = function - self.simple = self.Simple(function) - self.double = self.Double(function) - - class Simple: - def __init__(self, function): - self.f = function - - def riemann(self,a,b,n=None): - - if n is None: - n = 10**6 - - delta = (b-a)/n - - psi = a - theta = 0 - - while((psi+delta) <= b): - - theta += (self.f(psi) + self.f(psi + delta))/2 - psi += delta - - integral = delta*theta - - return integral - - def simpson(self,a,b,n=None): - - if n is None: - n = 10**6 - - def x(i): - return a + i*h - - h = (b-a)/n - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta = eta + self.f(x(2*psi - 1)) - psi = psi + 1 - - while(kappa <= ((n/2)-1)): - - theta = theta + self.f(x(2*kappa)) - kappa = kappa + 1 - - return (h/3)*( self.f(x(0)) + self.f(x(n)) + 4*eta + 2*theta) - - - class Double: - - def __init__(self,function): - self.f = function - - def riemann(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - kappa = a - psi = c - theta = 0 - - while((psi + dy) < d): - - while((kappa + dx) < b): - - theta = theta + self.f(kappa, psi) - kappa = kappa + dx - - psi = psi + dy - kappa = a - - return theta*(dx)*(dy) - - def simpson(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - - def x(i): - - x = a + i*dx - - return x - - def y(i): - - y = c + i*dy - - return y - - def g(i): - - sigma = 0 - upsilon = 0 - - zeta = 1 - csi = 1 - - while(zeta <= (m/2)): - - sigma += self.f(x(i),y(2*zeta - 1)) - zeta += 1 - - while(csi <= ((m/2)-1)): - - upsilon += self.f(x(i),y(2*csi)) - csi += 1 - - return (dy/3)*( self.f(x(i),y(0)) + self.f(x(i),y(m)) + 4*sigma + 2*upsilon ) - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta += g(2*psi - 1) - psi += 1 - - while(kappa <= ((n/2)-1)): - - theta += g(2*kappa) - kappa += 1 - - return (dx/3)*( g(0) + g(n) + 4*eta + 2*theta) - - class Roots: - - def __init__(self, function=None): - if function is not None: - self.f = function - - def bissec(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - while abs(a-b) > e: - - c = (a+b)/2 - fc = self.f(c) - - if (fa*fc) < 0: - - b = c - - else: - - a = c - fa = fc - - c = (a+b)/2 - - return c - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - def newton(self,a,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - da = self.d(a,e) - b = a - fa/da - - - while abs(a-b) > e: - - b = a - a -= (fa/da) - fa = self.f(a) - da = self.d(a,e) - - return a - - def bissec_newton(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - c = (a+b)/2 # 'c' é a raiz calculada - - while abs(a-b) > 0.1: - - fc = self.f(c) - - if fa*fc < 0: - - b = c - - else: - - a = c - fa = self.f(a) - - c = (a+b)/2 - - fc = self.f(c) - dc = self.d(c,e) - h = c - fc/dc # 'h' é uma variável de controle - - while abs(c-h) > e: - - h = c - c -= (fc/dc) - fc = self.f(c) - dc = self.d(c,e) - - return (c) - - - class Edo: - - def __init__(self, function): - self.F = function - - def euler(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return a + i*dx - - for i in range(n): - - y = y + (self.F(x(i),y))*dx - - return y - - def runge(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - y = y + (dx/2)*(self.F(x(i),y)+self.F(x(i+1),(y+(dx*self.F(x(i),y))))) - - return y - - def adams(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - f0 = self.F(x(i),y) - f1 = self.F(x(i+1),y + dx*self.F(x(i)+(dx/2),y+(dx/2)*self.F(x(i),y))) - f2 = self.F(x(i+2),y + (dx/2)*(3*f1-f0)) - - y += (dx/12)*(5*f2 + 8*f1 - f0) - - return y - -class Interpolation: - """ Data should be organized in two columns: X and Y""" - - def __init__(self, data): - - self.data = data - self.polinomial = self.Polinomial(self.data) - - def minimus(self,x): - - theta = 0 - # somatorio de x - for i in range(self.data.shape[0]): - - theta += self.data.x[i] - - eta = 0 - #somatorio de y - for i in range(self.data.shape[0]): - - eta += self.data.y[i] - - sigma = 0 - #somatorio de xy - for i in range(self.data.shape[0]): - - sigma += self.data.x[i]*self.data.y[i] - - omega = 0 - #somatorio de x^2self.dself.dself.d - for i in range(self.data.shape[0]): - - omega += self.data.x[i]**2 - - - self.a = (self.data.shape[0]*sigma - theta*eta)/(self.data.shape[0]*omega - (theta**2)) - - self.b = (theta*sigma - eta*omega)/((theta**2) - self.data.shape[0]*omega) - - ym = 0 - - for i in range(self.data.shape[0]): - - ym += self.data.y[i]/self.data.shape[0] - - sqreq = 0 - - for i in range(self.data.shape[0]): - - sqreq += ((self.a*self.data.x[i] + self.b) - ym)**2 - - sqtot = 0 - - for i in range(self.data.shape[0]): - - sqtot += (self.data.y[i] - ym)**2 - - self.r2 = sqreq/sqtot - - return self.a*x + self.b - - class Polinomial: - - def __init__(self, data): - self.data = data - - def vandermonde(self, x): - - matrix = np.zeros((self.data.shape[0],self.data.shape[0])) - - for k in range(0, self.data.shape[0]): - - matrix[:,k] = self.data.x[:]**k - - self.A = sl.gauss(np.c_[matrix,self.data[:,1]]) - - y = 0 - - for i in range(0,self.A.shape[0]): - - y += self.A[i]*(x**i) - - return float(y) - - def lagrange(self, x): - - def L(k,x): - - up = down = 1 - - for i in [x for x in range(self.data.x.shape[0]) if x != k]: - up = up*(x - self.data.x[i]) - - for i in [x for x in range(self.data.x.shape[0]) if x != k]: - down = down*(self.data.x[k] - self.data.x[i]) - - return up/down - - y = 0 - - for i in range(self.data.x.shape[0]): - - y += self.data.y[i]*L(i,x) - - return y - - def newton(self,x): - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data.y - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/(self.data.x[(i+1)+j]-self.data.x[j]) - j += 1 - - i += 1 - j = 0 - - def f(x): - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data.x[k]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y - - self.f = f - - return f(x) - - def gregory(self,x): - - h = self.data.x[0] - self.data.x[1] - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data.y - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/((i+1)*h) - j += 1 - - i += 1 - j = 0 - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data.x[k]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3.1/dist/yoshi-otter-1.3.1.tar.gz b/Older Versions/yoshi-otter1.3.1/dist/yoshi-otter-1.3.1.tar.gz deleted file mode 100644 index d7a7c40..0000000 Binary files a/Older Versions/yoshi-otter1.3.1/dist/yoshi-otter-1.3.1.tar.gz and /dev/null differ diff --git a/Older Versions/yoshi-otter1.3.1/dist/yoshi-otter-1.3.tar.gz b/Older Versions/yoshi-otter1.3.1/dist/yoshi-otter-1.3.tar.gz deleted file mode 100644 index e85b65b..0000000 Binary files a/Older Versions/yoshi-otter1.3.1/dist/yoshi-otter-1.3.tar.gz and /dev/null differ diff --git a/Older Versions/yoshi-otter1.3.1/dist/yoshi_otter-1.3-py3-none-any.whl b/Older Versions/yoshi-otter1.3.1/dist/yoshi_otter-1.3-py3-none-any.whl deleted file mode 100644 index 995b130..0000000 Binary files a/Older Versions/yoshi-otter1.3.1/dist/yoshi_otter-1.3-py3-none-any.whl and /dev/null differ diff --git a/Older Versions/yoshi-otter1.3.1/dist/yoshi_otter-1.3.1-py3-none-any.whl b/Older Versions/yoshi-otter1.3.1/dist/yoshi_otter-1.3.1-py3-none-any.whl deleted file mode 100644 index 99d6c0f..0000000 Binary files a/Older Versions/yoshi-otter1.3.1/dist/yoshi_otter-1.3.1-py3-none-any.whl and /dev/null differ diff --git a/Older Versions/yoshi-otter1.3.1/setup.py b/Older Versions/yoshi-otter1.3.1/setup.py deleted file mode 100644 index 10d5b33..0000000 --- a/Older Versions/yoshi-otter1.3.1/setup.py +++ /dev/null @@ -1,28 +0,0 @@ -import setuptools - -with open("README.md", "r") as fh: - long_description = fh.read() - -setuptools.setup( - name="yoshi-otter", # Replace with your own username - version="1.3.1", - author="Vitor Hideyoshi", - author_email="vitor.h.n.batista@gmail.com", - description="Numeric Calculus python module in the topic of Algebra Functions", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/HideyoshiNakazone/Otter-NumericCalculus.git", - packages=setuptools.find_packages(), - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", - "Operating System :: OS Independent", - "Development Status :: 2 - Pre-Alpha", - ], - python_requires='>=3.6', - install_requires=[ - 'numpy', - 'pandas', - 'yoshi-seals' - ], -) \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3.1/yoshi_otter.egg-info/PKG-INFO b/Older Versions/yoshi-otter1.3.1/yoshi_otter.egg-info/PKG-INFO deleted file mode 100644 index 455b1cc..0000000 --- a/Older Versions/yoshi-otter1.3.1/yoshi_otter.egg-info/PKG-INFO +++ /dev/null @@ -1,91 +0,0 @@ -Metadata-Version: 2.1 -Name: yoshi-otter -Version: 1.3.1 -Summary: Numeric Calculus python module in the topic of Algebra Functions -Home-page: https://github.com/HideyoshiNakazone/Otter-NumericCalculus.git -Author: Vitor Hideyoshi -Author-email: vitor.h.n.batista@gmail.com -License: UNKNOWN -Description: # Otter - Numeric Calculus - - This python package is made for applied Numeric Calculus of Algebra Functions. It is made with the following objectives in mind: - - * Receive one variable function from user input - - * Receive two variable function from user input - - * Performe derivatives with one variable functions - - * Performe integral with received functions - - * Use methods to proccess the matrices. - - * Find root of functions throw method of bissection and method of newton - - * Solve Diferential Equations throw method of euler and runge - - * Performe Minimus Interpolation and Polinomial Interpolation - - ## Syntax - - To initialize a Otter instance linked to functions use the following syntax `otr = Otter.algebra(f)`, where `otr` will be a arbitrary name for the instance and `f` is a function of *one variable*. - - To initialize a Otter instance linked to data and interpolation use the following syntax `otr = Otter.interpolation(data)`, where `otr` will be a arbitrary name for the instance and data will be a *numpy* matrix where the first columns has to contain the values for `x` and the second column contains the values for `y`. - - ### Algebra - - Algebra is a Python Class where some of the features described previously are defined as Classes as well, like: `Integral`, `Roots`, `EDO` (diferential equations). - - #### Integral - - To call the class *Integral* append the sufix with lower case in front of the instance like: `otr.integral`. The Integral class has two other class defined inside, `Simple` and `Double`, to call them append the sufix with lower case in front as `otr.integral.simple` or `otr.integral.double`. Then pick between Riemann's Method or Simpson's Method by appending the sufix `riemann` or `simpson` as well. - - After that the syntax will be something like `otr.integral.double.riemann(a,b,c,d,n,m)`, where `a` and `c` will be the first value of the interval of integration respectively in x and y, `b` and `d` will be the last, `n` and `m` will be the number of partitions. - - The syntax for one variable integrations will be `otr.integral.simple.riemann(a,b,n)`. - - If `n` is not defined the standart value in 10^6 partitions for one variable and 10^4 for double. And if `m` is not defined the standart value will be equal to `n`. - - #### Roots - - To call the class *Root* append the sufix with lower case in front of the instance like: `otr.roots`. The Roots class has three methods defined inside, `bissec`, `newton` and `bissec_newton`, to call them append the sufix with lower case in front as `otr.roots.bissec` or `otr.roots.newton` or even `otr.roots.bissecnewton`. - - The syntax for the bissection method and bissec_newton is equal to `otr.roots.bissec(a,b,e)` and `otr.roots.bissec_newton(a,b,e)`, where `a` is the first element of the interval containing the root and `b` is the last, `e` being the precision. - - The syntax for the newton method is equal to `otr.roots.newton(a,e)`, where `a` is the element closest to the root and `e` is the precision. - - If `e` is not defined the standart value is 10^(-6). - - #### Diferential Equations - - To call the class *EDO* (*E*quações *D*iferenciais *O*rdinárias) append the sufix with lower case in front of the instance like: `otr.edo`. The *EDO* class has two methods defined inside: `euler` and `runge`, to call them append the sufix with lower case in front as `otr.edo.euler` or `otr.edo.runge`. - - The syntax for the diferential equations method is equal to `otr.edo.euler(a,y,b,n)` or `otr.edo.runge(a,y,b,n)`, where `a` and `y` will be the inintial point and `b` is the value in *x* which you want to know the corresponding value in *y* and `n` is the number of operations. - - If `n` is not defined the standart value is 10^7. - - ### Interpolation - - The python class *Interpolation* is divided in one method, minimus interpolation, and one class, polinomial interpolation. - - To call the method *minimus* use a syntax like `otr = Otter.interpolation(data)`, where `data` is a data frame containing values for *x* and *y*, `otr` is an instance and append the method in front of the instance like: `otr.minimus(x)`, where *x* is value of *f(x)* you want to estimate. - - To call the class *Polinomial* append the sufix with lower case in front of the instance like: `otr.polinomial`. The *Polinomial* class has four methods defined inside: `vandermonde`, `lagrange`, `newton` and `gregory`, to call them append the sufix with lower case in front like `otr.edo.gregory(x)` where *x* is value of *f(x)* you want to estimate. - - ## Installation - - To install the package from source `cd` into the directory and run: - - `pip install .` - - or run - - `pip install yoshi-otter` - -Platform: UNKNOWN -Classifier: Programming Language :: Python :: 3 -Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2) -Classifier: Operating System :: OS Independent -Classifier: Development Status :: 2 - Pre-Alpha -Requires-Python: >=3.6 -Description-Content-Type: text/markdown diff --git a/Older Versions/yoshi-otter1.3.1/yoshi_otter.egg-info/SOURCES.txt b/Older Versions/yoshi-otter1.3.1/yoshi_otter.egg-info/SOURCES.txt deleted file mode 100644 index 5dc205c..0000000 --- a/Older Versions/yoshi-otter1.3.1/yoshi_otter.egg-info/SOURCES.txt +++ /dev/null @@ -1,9 +0,0 @@ -README.md -setup.py -Otter/Otter.py -Otter/__init__.py -yoshi_otter.egg-info/PKG-INFO -yoshi_otter.egg-info/SOURCES.txt -yoshi_otter.egg-info/dependency_links.txt -yoshi_otter.egg-info/requires.txt -yoshi_otter.egg-info/top_level.txt \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3.1/yoshi_otter.egg-info/dependency_links.txt b/Older Versions/yoshi-otter1.3.1/yoshi_otter.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/Older Versions/yoshi-otter1.3.1/yoshi_otter.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Older Versions/yoshi-otter1.3.1/yoshi_otter.egg-info/requires.txt b/Older Versions/yoshi-otter1.3.1/yoshi_otter.egg-info/requires.txt deleted file mode 100644 index 11c1c26..0000000 --- a/Older Versions/yoshi-otter1.3.1/yoshi_otter.egg-info/requires.txt +++ /dev/null @@ -1,3 +0,0 @@ -numpy -pandas -yoshi-seals diff --git a/Older Versions/yoshi-otter1.3.1/yoshi_otter.egg-info/top_level.txt b/Older Versions/yoshi-otter1.3.1/yoshi_otter.egg-info/top_level.txt deleted file mode 100644 index ccaaf54..0000000 --- a/Older Versions/yoshi-otter1.3.1/yoshi_otter.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -Otter diff --git a/Older Versions/yoshi-otter1.3.2.tar.xz b/Older Versions/yoshi-otter1.3.2.tar.xz deleted file mode 100644 index 71945ad..0000000 Binary files a/Older Versions/yoshi-otter1.3.2.tar.xz and /dev/null differ diff --git a/Older Versions/yoshi-otter1.3.2/LICENSE b/Older Versions/yoshi-otter1.3.2/LICENSE deleted file mode 100644 index d2c5abe..0000000 --- a/Older Versions/yoshi-otter1.3.2/LICENSE +++ /dev/null @@ -1,278 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) 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 -this service 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 make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. 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. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -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 -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the 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 a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE 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. \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3.2/Otter/Otter.py b/Older Versions/yoshi-otter1.3.2/Otter/Otter.py deleted file mode 100755 index 967c47a..0000000 --- a/Older Versions/yoshi-otter1.3.2/Otter/Otter.py +++ /dev/null @@ -1,517 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. -# -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. -# -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import math -import numpy as np -import pandas as pd -import Seals - -sl = Seals.process - -class Algebra: - - def __init__(self, function): - self.f = function - self.integral = self.Integral(self.f) - self.roots = self.Roots(self.f) - self.edo = self.Edo(self.f) - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - class Integral: - - def __init__(self,function): - self.f = function - self.simple = self.Simple(function) - self.double = self.Double(function) - - class Simple: - def __init__(self, function): - self.f = function - - def riemann(self,a,b,n=None): - - if n is None: - n = 10**6 - - delta = (b-a)/n - - psi = a - theta = 0 - - while((psi+delta) <= b): - - theta += (self.f(psi) + self.f(psi + delta))/2 - psi += delta - - integral = delta*theta - - return integral - - def simpson(self,a,b,n=None): - - if n is None: - n = 10**6 - - def x(i): - return a + i*h - - h = (b-a)/n - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta = eta + self.f(x(2*psi - 1)) - psi = psi + 1 - - while(kappa <= ((n/2)-1)): - - theta = theta + self.f(x(2*kappa)) - kappa = kappa + 1 - - return (h/3)*( self.f(x(0)) + self.f(x(n)) + 4*eta + 2*theta) - - - class Double: - - def __init__(self,function): - self.f = function - - def riemann(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - kappa = a - psi = c - theta = 0 - - while((psi + dy) < d): - - while((kappa + dx) < b): - - theta = theta + self.f(kappa, psi) - kappa = kappa + dx - - psi = psi + dy - kappa = a - - return theta*(dx)*(dy) - - def simpson(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - - def x(i): - - x = a + i*dx - - return x - - def y(i): - - y = c + i*dy - - return y - - def g(i): - - sigma = 0 - upsilon = 0 - - zeta = 1 - csi = 1 - - while(zeta <= (m/2)): - - sigma += self.f(x(i),y(2*zeta - 1)) - zeta += 1 - - while(csi <= ((m/2)-1)): - - upsilon += self.f(x(i),y(2*csi)) - csi += 1 - - return (dy/3)*( self.f(x(i),y(0)) + self.f(x(i),y(m)) + 4*sigma + 2*upsilon ) - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta += g(2*psi - 1) - psi += 1 - - while(kappa <= ((n/2)-1)): - - theta += g(2*kappa) - kappa += 1 - - return (dx/3)*( g(0) + g(n) + 4*eta + 2*theta) - - class Roots: - - def __init__(self, function=None): - if function is not None: - self.f = function - - def bissec(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - while abs(a-b) > e: - - c = (a+b)/2 - fc = self.f(c) - - if (fa*fc) < 0: - - b = c - - else: - - a = c - fa = fc - - c = (a+b)/2 - - return c - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - def newton(self,a,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - da = self.d(a,e) - b = a - fa/da - - - while abs(a-b) > e: - - b = a - a -= (fa/da) - fa = self.f(a) - da = self.d(a,e) - - return a - - def bissec_newton(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - c = (a+b)/2 # 'c' é a raiz calculada - - while abs(a-b) > 0.1: - - fc = self.f(c) - - if fa*fc < 0: - - b = c - - else: - - a = c - fa = self.f(a) - - c = (a+b)/2 - - fc = self.f(c) - dc = self.d(c,e) - h = c - fc/dc # 'h' é uma variável de controle - - while abs(c-h) > e: - - h = c - c -= (fc/dc) - fc = self.f(c) - dc = self.d(c,e) - - return (c) - - - class Edo: - - def __init__(self, function): - self.F = function - - def euler(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return a + i*dx - - for i in range(n): - - y = y + (self.F(x(i),y))*dx - - return y - - def runge(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - y = y + (dx/2)*(self.F(x(i),y)+self.F(x(i+1),(y+(dx*self.F(x(i),y))))) - - return y - - def adams(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - f0 = self.F(x(i),y) - f1 = self.F(x(i+1),y + dx*self.F(x(i)+(dx/2),y+(dx/2)*self.F(x(i),y))) - f2 = self.F(x(i+2),y + (dx/2)*(3*f1-f0)) - - y += (dx/12)*(5*f2 + 8*f1 - f0) - - return y - -class Interpolation: - """ Data should be organized in two columns: X and Y""" - - def __init__(self, data): - - self.data = data - self.polinomial = self.Polinomial(self.data) - - def minimus(self,x): - - theta = 0 - # somatorio de x - for i in range(self.data.shape[0]): - - theta += self.data.x[i] - - eta = 0 - #somatorio de y - for i in range(self.data.shape[0]): - - eta += self.data.y[i] - - sigma = 0 - #somatorio de xy - for i in range(self.data.shape[0]): - - sigma += self.data.x[i]*self.data.y[i] - - omega = 0 - #somatorio de x^2self.dself.dself.d - for i in range(self.data.shape[0]): - - omega += self.data.x[i]**2 - - - self.a = (self.data.shape[0]*sigma - theta*eta)/(self.data.shape[0]*omega - (theta**2)) - - self.b = (theta*sigma - eta*omega)/((theta**2) - self.data.shape[0]*omega) - - ym = 0 - - for i in range(self.data.shape[0]): - - ym += self.data.y[i]/self.data.shape[0] - - sqreq = 0 - - for i in range(self.data.shape[0]): - - sqreq += ((self.a*self.data.x[i] + self.b) - ym)**2 - - sqtot = 0 - - for i in range(self.data.shape[0]): - - sqtot += (self.data.y[i] - ym)**2 - - self.r2 = sqreq/sqtot - - return self.a*x + self.b - - class Polinomial: - - def __init__(self, data): - self.data = data - - def vandermonde(self, x): - - matrix = np.zeros((self.data.shape[0],self.data.shape[0])) - - for k in range(0, self.data.shape[0]): - - matrix[:,k] = self.data.x[:]**k - - self.A = sl.gauss(np.c_[matrix,self.data[:,1]]) - - y = 0 - - for i in range(0,self.A.shape[0]): - - y += self.A[i]*(x**i) - - return float(y) - - def lagrange(self, x): - - def L(k,x): - - up = down = 1 - - for i in [x for x in range(self.data.x.shape[0]) if x != k]: - up = up*(x - self.data.x[i]) - - for i in [x for x in range(self.data.x.shape[0]) if x != k]: - down = down*(self.data.x[k] - self.data.x[i]) - - return up/down - - y = 0 - - for i in range(self.data.x.shape[0]): - - y += self.data.y[i]*L(i,x) - - return y - - def newton(self,x): - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data.y - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/(self.data.x[(i+1)+j]-self.data.x[j]) - j += 1 - - i += 1 - j = 0 - - def f(x): - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data.x[k]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y - - self.f = f - - return f(x) - - def gregory(self,x): - - h = self.data.x[0] - self.data.x[1] - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data.y - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/((i+1)*h) - j += 1 - - i += 1 - j = 0 - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data.x[k]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3.2/Otter/__init__.py b/Older Versions/yoshi-otter1.3.2/Otter/__init__.py deleted file mode 100644 index 08ce1fe..0000000 --- a/Older Versions/yoshi-otter1.3.2/Otter/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. - -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. - -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -from .Otter import Algebra as algebra -from .Otter import Interpolation as interpolation \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3.2/README.md b/Older Versions/yoshi-otter1.3.2/README.md deleted file mode 100644 index 167eb4e..0000000 --- a/Older Versions/yoshi-otter1.3.2/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# Otter - Numeric Calculus - -This python package is made for applied Numeric Calculus of Algebra Functions. It is made with the following objectives in mind: - -* Receive one variable function from user input - -* Receive two variable function from user input - -* Performe derivatives with one variable functions - -* Performe integral with received functions - -* Use methods to proccess the matrices. - -* Find root of functions throw method of bissection and method of newton - -* Solve Diferential Equations throw method of euler and runge - -* Performe Minimus Interpolation and Polinomial Interpolation - -## Syntax - -To initialize a Otter instance linked to functions use the following syntax `otr = Otter.algebra(f)`, where `otr` will be a arbitrary name for the instance and `f` is a function of *one variable*. - -To initialize a Otter instance linked to data and interpolation use the following syntax `otr = Otter.interpolation(data)`, where `otr` will be a arbitrary name for the instance and data will be a *numpy* matrix where the first columns has to contain the values for `x` and the second column contains the values for `y`. - -### Algebra - -Algebra is a Python Class where some of the features described previously are defined as Classes as well, like: `Integral`, `Roots`, `EDO` (diferential equations). - -#### Integral - -To call the class *Integral* append the sufix with lower case in front of the instance like: `otr.integral`. The Integral class has two other class defined inside, `Simple` and `Double`, to call them append the sufix with lower case in front as `otr.integral.simple` or `otr.integral.double`. Then pick between Riemann's Method or Simpson's Method by appending the sufix `riemann` or `simpson` as well. - -After that the syntax will be something like `otr.integral.double.riemann(a,b,c,d,n,m)`, where `a` and `c` will be the first value of the interval of integration respectively in x and y, `b` and `d` will be the last, `n` and `m` will be the number of partitions. - -The syntax for one variable integrations will be `otr.integral.simple.riemann(a,b,n)`. - -If `n` is not defined the standart value in 10^6 partitions for one variable and 10^4 for double. And if `m` is not defined the standart value will be equal to `n`. - -#### Roots - -To call the class *Root* append the sufix with lower case in front of the instance like: `otr.roots`. The Roots class has three methods defined inside, `bissec`, `newton` and `bissec_newton`, to call them append the sufix with lower case in front as `otr.roots.bissec` or `otr.roots.newton` or even `otr.roots.bissecnewton`. - -The syntax for the bissection method and bissec_newton is equal to `otr.roots.bissec(a,b,e)` and `otr.roots.bissec_newton(a,b,e)`, where `a` is the first element of the interval containing the root and `b` is the last, `e` being the precision. - -The syntax for the newton method is equal to `otr.roots.newton(a,e)`, where `a` is the element closest to the root and `e` is the precision. - -If `e` is not defined the standart value is 10^(-6). - -#### Diferential Equations - -To call the class *EDO* (*E*quações *D*iferenciais *O*rdinárias) append the sufix with lower case in front of the instance like: `otr.edo`. The *EDO* class has two methods defined inside: `euler` and `runge`, to call them append the sufix with lower case in front as `otr.edo.euler` or `otr.edo.runge`. - -The syntax for the diferential equations method is equal to `otr.edo.euler(a,y,b,n)` or `otr.edo.runge(a,y,b,n)`, where `a` and `y` will be the inintial point and `b` is the value in *x* which you want to know the corresponding value in *y* and `n` is the number of operations. - -If `n` is not defined the standart value is 10^7. - -### Interpolation - -The python class *Interpolation* is divided in one method, minimus interpolation, and one class, polinomial interpolation. - -To call the method *minimus* use a syntax like `otr = Otter.interpolation(data)`, where `data` is a data frame containing values for *x* and *y*, `otr` is an instance and append the method in front of the instance like: `otr.minimus(x)`, where *x* is value of *f(x)* you want to estimate. - -To call the class *Polinomial* append the sufix with lower case in front of the instance like: `otr.polinomial`. The *Polinomial* class has four methods defined inside: `vandermonde`, `lagrange`, `newton` and `gregory`, to call them append the sufix with lower case in front like `otr.edo.gregory(x)` where *x* is value of *f(x)* you want to estimate. - -## Installation - -To install the package from source `cd` into the directory and run: - -`pip install .` - -or run - -`pip install yoshi-otter` diff --git a/Older Versions/yoshi-otter1.3.2/build/lib/Otter/Otter.py b/Older Versions/yoshi-otter1.3.2/build/lib/Otter/Otter.py deleted file mode 100644 index 967c47a..0000000 --- a/Older Versions/yoshi-otter1.3.2/build/lib/Otter/Otter.py +++ /dev/null @@ -1,517 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. -# -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. -# -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import math -import numpy as np -import pandas as pd -import Seals - -sl = Seals.process - -class Algebra: - - def __init__(self, function): - self.f = function - self.integral = self.Integral(self.f) - self.roots = self.Roots(self.f) - self.edo = self.Edo(self.f) - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - class Integral: - - def __init__(self,function): - self.f = function - self.simple = self.Simple(function) - self.double = self.Double(function) - - class Simple: - def __init__(self, function): - self.f = function - - def riemann(self,a,b,n=None): - - if n is None: - n = 10**6 - - delta = (b-a)/n - - psi = a - theta = 0 - - while((psi+delta) <= b): - - theta += (self.f(psi) + self.f(psi + delta))/2 - psi += delta - - integral = delta*theta - - return integral - - def simpson(self,a,b,n=None): - - if n is None: - n = 10**6 - - def x(i): - return a + i*h - - h = (b-a)/n - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta = eta + self.f(x(2*psi - 1)) - psi = psi + 1 - - while(kappa <= ((n/2)-1)): - - theta = theta + self.f(x(2*kappa)) - kappa = kappa + 1 - - return (h/3)*( self.f(x(0)) + self.f(x(n)) + 4*eta + 2*theta) - - - class Double: - - def __init__(self,function): - self.f = function - - def riemann(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - kappa = a - psi = c - theta = 0 - - while((psi + dy) < d): - - while((kappa + dx) < b): - - theta = theta + self.f(kappa, psi) - kappa = kappa + dx - - psi = psi + dy - kappa = a - - return theta*(dx)*(dy) - - def simpson(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - - def x(i): - - x = a + i*dx - - return x - - def y(i): - - y = c + i*dy - - return y - - def g(i): - - sigma = 0 - upsilon = 0 - - zeta = 1 - csi = 1 - - while(zeta <= (m/2)): - - sigma += self.f(x(i),y(2*zeta - 1)) - zeta += 1 - - while(csi <= ((m/2)-1)): - - upsilon += self.f(x(i),y(2*csi)) - csi += 1 - - return (dy/3)*( self.f(x(i),y(0)) + self.f(x(i),y(m)) + 4*sigma + 2*upsilon ) - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta += g(2*psi - 1) - psi += 1 - - while(kappa <= ((n/2)-1)): - - theta += g(2*kappa) - kappa += 1 - - return (dx/3)*( g(0) + g(n) + 4*eta + 2*theta) - - class Roots: - - def __init__(self, function=None): - if function is not None: - self.f = function - - def bissec(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - while abs(a-b) > e: - - c = (a+b)/2 - fc = self.f(c) - - if (fa*fc) < 0: - - b = c - - else: - - a = c - fa = fc - - c = (a+b)/2 - - return c - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - def newton(self,a,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - da = self.d(a,e) - b = a - fa/da - - - while abs(a-b) > e: - - b = a - a -= (fa/da) - fa = self.f(a) - da = self.d(a,e) - - return a - - def bissec_newton(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - c = (a+b)/2 # 'c' é a raiz calculada - - while abs(a-b) > 0.1: - - fc = self.f(c) - - if fa*fc < 0: - - b = c - - else: - - a = c - fa = self.f(a) - - c = (a+b)/2 - - fc = self.f(c) - dc = self.d(c,e) - h = c - fc/dc # 'h' é uma variável de controle - - while abs(c-h) > e: - - h = c - c -= (fc/dc) - fc = self.f(c) - dc = self.d(c,e) - - return (c) - - - class Edo: - - def __init__(self, function): - self.F = function - - def euler(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return a + i*dx - - for i in range(n): - - y = y + (self.F(x(i),y))*dx - - return y - - def runge(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - y = y + (dx/2)*(self.F(x(i),y)+self.F(x(i+1),(y+(dx*self.F(x(i),y))))) - - return y - - def adams(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - f0 = self.F(x(i),y) - f1 = self.F(x(i+1),y + dx*self.F(x(i)+(dx/2),y+(dx/2)*self.F(x(i),y))) - f2 = self.F(x(i+2),y + (dx/2)*(3*f1-f0)) - - y += (dx/12)*(5*f2 + 8*f1 - f0) - - return y - -class Interpolation: - """ Data should be organized in two columns: X and Y""" - - def __init__(self, data): - - self.data = data - self.polinomial = self.Polinomial(self.data) - - def minimus(self,x): - - theta = 0 - # somatorio de x - for i in range(self.data.shape[0]): - - theta += self.data.x[i] - - eta = 0 - #somatorio de y - for i in range(self.data.shape[0]): - - eta += self.data.y[i] - - sigma = 0 - #somatorio de xy - for i in range(self.data.shape[0]): - - sigma += self.data.x[i]*self.data.y[i] - - omega = 0 - #somatorio de x^2self.dself.dself.d - for i in range(self.data.shape[0]): - - omega += self.data.x[i]**2 - - - self.a = (self.data.shape[0]*sigma - theta*eta)/(self.data.shape[0]*omega - (theta**2)) - - self.b = (theta*sigma - eta*omega)/((theta**2) - self.data.shape[0]*omega) - - ym = 0 - - for i in range(self.data.shape[0]): - - ym += self.data.y[i]/self.data.shape[0] - - sqreq = 0 - - for i in range(self.data.shape[0]): - - sqreq += ((self.a*self.data.x[i] + self.b) - ym)**2 - - sqtot = 0 - - for i in range(self.data.shape[0]): - - sqtot += (self.data.y[i] - ym)**2 - - self.r2 = sqreq/sqtot - - return self.a*x + self.b - - class Polinomial: - - def __init__(self, data): - self.data = data - - def vandermonde(self, x): - - matrix = np.zeros((self.data.shape[0],self.data.shape[0])) - - for k in range(0, self.data.shape[0]): - - matrix[:,k] = self.data.x[:]**k - - self.A = sl.gauss(np.c_[matrix,self.data[:,1]]) - - y = 0 - - for i in range(0,self.A.shape[0]): - - y += self.A[i]*(x**i) - - return float(y) - - def lagrange(self, x): - - def L(k,x): - - up = down = 1 - - for i in [x for x in range(self.data.x.shape[0]) if x != k]: - up = up*(x - self.data.x[i]) - - for i in [x for x in range(self.data.x.shape[0]) if x != k]: - down = down*(self.data.x[k] - self.data.x[i]) - - return up/down - - y = 0 - - for i in range(self.data.x.shape[0]): - - y += self.data.y[i]*L(i,x) - - return y - - def newton(self,x): - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data.y - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/(self.data.x[(i+1)+j]-self.data.x[j]) - j += 1 - - i += 1 - j = 0 - - def f(x): - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data.x[k]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y - - self.f = f - - return f(x) - - def gregory(self,x): - - h = self.data.x[0] - self.data.x[1] - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data.y - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/((i+1)*h) - j += 1 - - i += 1 - j = 0 - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data.x[k]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3.2/build/lib/Otter/__init__.py b/Older Versions/yoshi-otter1.3.2/build/lib/Otter/__init__.py deleted file mode 100644 index 08ce1fe..0000000 --- a/Older Versions/yoshi-otter1.3.2/build/lib/Otter/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. - -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. - -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -from .Otter import Algebra as algebra -from .Otter import Interpolation as interpolation \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3.2/dist/yoshi-otter-1.3.2.tar.gz b/Older Versions/yoshi-otter1.3.2/dist/yoshi-otter-1.3.2.tar.gz deleted file mode 100644 index fa873ac..0000000 Binary files a/Older Versions/yoshi-otter1.3.2/dist/yoshi-otter-1.3.2.tar.gz and /dev/null differ diff --git a/Older Versions/yoshi-otter1.3.2/dist/yoshi_otter-1.3.2-py3-none-any.whl b/Older Versions/yoshi-otter1.3.2/dist/yoshi_otter-1.3.2-py3-none-any.whl deleted file mode 100644 index 3c22218..0000000 Binary files a/Older Versions/yoshi-otter1.3.2/dist/yoshi_otter-1.3.2-py3-none-any.whl and /dev/null differ diff --git a/Older Versions/yoshi-otter1.3.2/setup.py b/Older Versions/yoshi-otter1.3.2/setup.py deleted file mode 100644 index c29b1e8..0000000 --- a/Older Versions/yoshi-otter1.3.2/setup.py +++ /dev/null @@ -1,28 +0,0 @@ -import setuptools - -with open("README.md", "r") as fh: - long_description = fh.read() - -setuptools.setup( - name="yoshi-otter", # Replace with your own username - version="1.3.2", - author="Vitor Hideyoshi", - author_email="vitor.h.n.batista@gmail.com", - description="Numeric Calculus python module in the topic of Algebra Functions", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/HideyoshiNakazone/Otter-NumericCalculus.git", - packages=setuptools.find_packages(), - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", - "Operating System :: OS Independent", - "Development Status :: 2 - Pre-Alpha", - ], - python_requires='>=3.6', - install_requires=[ - 'numpy', - 'pandas', - 'yoshi-seals' - ], -) \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3.2/yoshi_otter.egg-info/PKG-INFO b/Older Versions/yoshi-otter1.3.2/yoshi_otter.egg-info/PKG-INFO deleted file mode 100644 index a0f9ee7..0000000 --- a/Older Versions/yoshi-otter1.3.2/yoshi_otter.egg-info/PKG-INFO +++ /dev/null @@ -1,91 +0,0 @@ -Metadata-Version: 2.1 -Name: yoshi-otter -Version: 1.3.2 -Summary: Numeric Calculus python module in the topic of Algebra Functions -Home-page: https://github.com/HideyoshiNakazone/Otter-NumericCalculus.git -Author: Vitor Hideyoshi -Author-email: vitor.h.n.batista@gmail.com -License: UNKNOWN -Description: # Otter - Numeric Calculus - - This python package is made for applied Numeric Calculus of Algebra Functions. It is made with the following objectives in mind: - - * Receive one variable function from user input - - * Receive two variable function from user input - - * Performe derivatives with one variable functions - - * Performe integral with received functions - - * Use methods to proccess the matrices. - - * Find root of functions throw method of bissection and method of newton - - * Solve Diferential Equations throw method of euler and runge - - * Performe Minimus Interpolation and Polinomial Interpolation - - ## Syntax - - To initialize a Otter instance linked to functions use the following syntax `otr = Otter.algebra(f)`, where `otr` will be a arbitrary name for the instance and `f` is a function of *one variable*. - - To initialize a Otter instance linked to data and interpolation use the following syntax `otr = Otter.interpolation(data)`, where `otr` will be a arbitrary name for the instance and data will be a *numpy* matrix where the first columns has to contain the values for `x` and the second column contains the values for `y`. - - ### Algebra - - Algebra is a Python Class where some of the features described previously are defined as Classes as well, like: `Integral`, `Roots`, `EDO` (diferential equations). - - #### Integral - - To call the class *Integral* append the sufix with lower case in front of the instance like: `otr.integral`. The Integral class has two other class defined inside, `Simple` and `Double`, to call them append the sufix with lower case in front as `otr.integral.simple` or `otr.integral.double`. Then pick between Riemann's Method or Simpson's Method by appending the sufix `riemann` or `simpson` as well. - - After that the syntax will be something like `otr.integral.double.riemann(a,b,c,d,n,m)`, where `a` and `c` will be the first value of the interval of integration respectively in x and y, `b` and `d` will be the last, `n` and `m` will be the number of partitions. - - The syntax for one variable integrations will be `otr.integral.simple.riemann(a,b,n)`. - - If `n` is not defined the standart value in 10^6 partitions for one variable and 10^4 for double. And if `m` is not defined the standart value will be equal to `n`. - - #### Roots - - To call the class *Root* append the sufix with lower case in front of the instance like: `otr.roots`. The Roots class has three methods defined inside, `bissec`, `newton` and `bissec_newton`, to call them append the sufix with lower case in front as `otr.roots.bissec` or `otr.roots.newton` or even `otr.roots.bissecnewton`. - - The syntax for the bissection method and bissec_newton is equal to `otr.roots.bissec(a,b,e)` and `otr.roots.bissec_newton(a,b,e)`, where `a` is the first element of the interval containing the root and `b` is the last, `e` being the precision. - - The syntax for the newton method is equal to `otr.roots.newton(a,e)`, where `a` is the element closest to the root and `e` is the precision. - - If `e` is not defined the standart value is 10^(-6). - - #### Diferential Equations - - To call the class *EDO* (*E*quações *D*iferenciais *O*rdinárias) append the sufix with lower case in front of the instance like: `otr.edo`. The *EDO* class has two methods defined inside: `euler` and `runge`, to call them append the sufix with lower case in front as `otr.edo.euler` or `otr.edo.runge`. - - The syntax for the diferential equations method is equal to `otr.edo.euler(a,y,b,n)` or `otr.edo.runge(a,y,b,n)`, where `a` and `y` will be the inintial point and `b` is the value in *x* which you want to know the corresponding value in *y* and `n` is the number of operations. - - If `n` is not defined the standart value is 10^7. - - ### Interpolation - - The python class *Interpolation* is divided in one method, minimus interpolation, and one class, polinomial interpolation. - - To call the method *minimus* use a syntax like `otr = Otter.interpolation(data)`, where `data` is a data frame containing values for *x* and *y*, `otr` is an instance and append the method in front of the instance like: `otr.minimus(x)`, where *x* is value of *f(x)* you want to estimate. - - To call the class *Polinomial* append the sufix with lower case in front of the instance like: `otr.polinomial`. The *Polinomial* class has four methods defined inside: `vandermonde`, `lagrange`, `newton` and `gregory`, to call them append the sufix with lower case in front like `otr.edo.gregory(x)` where *x* is value of *f(x)* you want to estimate. - - ## Installation - - To install the package from source `cd` into the directory and run: - - `pip install .` - - or run - - `pip install yoshi-otter` - -Platform: UNKNOWN -Classifier: Programming Language :: Python :: 3 -Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2) -Classifier: Operating System :: OS Independent -Classifier: Development Status :: 2 - Pre-Alpha -Requires-Python: >=3.6 -Description-Content-Type: text/markdown diff --git a/Older Versions/yoshi-otter1.3.2/yoshi_otter.egg-info/SOURCES.txt b/Older Versions/yoshi-otter1.3.2/yoshi_otter.egg-info/SOURCES.txt deleted file mode 100644 index 5dc205c..0000000 --- a/Older Versions/yoshi-otter1.3.2/yoshi_otter.egg-info/SOURCES.txt +++ /dev/null @@ -1,9 +0,0 @@ -README.md -setup.py -Otter/Otter.py -Otter/__init__.py -yoshi_otter.egg-info/PKG-INFO -yoshi_otter.egg-info/SOURCES.txt -yoshi_otter.egg-info/dependency_links.txt -yoshi_otter.egg-info/requires.txt -yoshi_otter.egg-info/top_level.txt \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3.2/yoshi_otter.egg-info/dependency_links.txt b/Older Versions/yoshi-otter1.3.2/yoshi_otter.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/Older Versions/yoshi-otter1.3.2/yoshi_otter.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Older Versions/yoshi-otter1.3.2/yoshi_otter.egg-info/requires.txt b/Older Versions/yoshi-otter1.3.2/yoshi_otter.egg-info/requires.txt deleted file mode 100644 index 11c1c26..0000000 --- a/Older Versions/yoshi-otter1.3.2/yoshi_otter.egg-info/requires.txt +++ /dev/null @@ -1,3 +0,0 @@ -numpy -pandas -yoshi-seals diff --git a/Older Versions/yoshi-otter1.3.2/yoshi_otter.egg-info/top_level.txt b/Older Versions/yoshi-otter1.3.2/yoshi_otter.egg-info/top_level.txt deleted file mode 100644 index ccaaf54..0000000 --- a/Older Versions/yoshi-otter1.3.2/yoshi_otter.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -Otter diff --git a/Older Versions/yoshi-otter1.3.tar.gz b/Older Versions/yoshi-otter1.3.tar.gz deleted file mode 100644 index 9996e11..0000000 Binary files a/Older Versions/yoshi-otter1.3.tar.gz and /dev/null differ diff --git a/Older Versions/yoshi-otter1.3/LICENSE b/Older Versions/yoshi-otter1.3/LICENSE deleted file mode 100644 index d2c5abe..0000000 --- a/Older Versions/yoshi-otter1.3/LICENSE +++ /dev/null @@ -1,278 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) 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 -this service 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 make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. 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. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -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 -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the 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 a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE 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. \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3/Otter/Otter.py b/Older Versions/yoshi-otter1.3/Otter/Otter.py deleted file mode 100755 index ae4a8cd..0000000 --- a/Older Versions/yoshi-otter1.3/Otter/Otter.py +++ /dev/null @@ -1,499 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. -# -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. -# -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import math -import numpy as np -import Seals - -sl = Seals.process() - -class Algebra: - - def __init__(self, function): - self.f = function - self.integral = self.Integral(self.f) - self.roots = self.Roots(self.f) - self.edo = self.Edo(self.f) - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - class Integral: - - def __init__(self,function): - self.f = function - self.simple = self.Simple(function) - self.double = self.Double(function) - - class Simple: - def __init__(self, function): - self.f = function - - def riemann(self,a,b,n=None): - - if n is None: - n = 10**6 - - delta = (b-a)/n - - psi = a - theta = 0 - - while((psi+delta) <= b): - - theta += (self.f(psi) + self.f(psi + delta))/2 - psi += delta - - integral = delta*theta - - return integral - - def simpson(self,a,b,n=None): - - if n is None: - n = 10**6 - - def x(i): - return a + i*h - - h = (b-a)/n - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta = eta + self.f(x(2*psi - 1)) - psi = psi + 1 - - while(kappa <= ((n/2)-1)): - - theta = theta + self.f(x(2*kappa)) - kappa = kappa + 1 - - return (h/3)*( self.f(x(0)) + self.f(x(n)) + 4*eta + 2*theta) - - - class Double: - - def __init__(self,function): - self.f = function - - def riemann(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - kappa = a - psi = c - theta = 0 - - while((psi + dy) < d): - - while((kappa + dx) < b): - - theta = theta + self.f(kappa, psi) - kappa = kappa + dx - - psi = psi + dy - kappa = a - - return theta*(dx)*(dy) - - def simpson(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - - def x(i): - - x = a + i*dx - - return x - - def y(i): - - y = c + i*dy - - return y - - def g(i): - - sigma = 0 - upsilon = 0 - - zeta = 1 - csi = 1 - - while(zeta <= (m/2)): - - sigma += self.f(x(i),y(2*zeta - 1)) - zeta += 1 - - while(csi <= ((m/2)-1)): - - upsilon += self.f(x(i),y(2*csi)) - csi += 1 - - return (dy/3)*( self.f(x(i),y(0)) + self.f(x(i),y(m)) + 4*sigma + 2*upsilon ) - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta += g(2*psi - 1) - psi += 1 - - while(kappa <= ((n/2)-1)): - - theta += g(2*kappa) - kappa += 1 - - return (dx/3)*( g(0) + g(n) + 4*eta + 2*theta) - - class Roots: - - def __init__(self, function=None): - if function is not None: - self.f = function - - def bissec(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - while abs(a-b) > e: - - c = (a+b)/2 - fc = self.f(c) - - if (fa*fc) < 0: - - b = c - - else: - - a = c - fa = fc - - c = (a+b)/2 - - return c - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - def newton(self,a,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - da = self.d(a,e) - b = a - fa/da - - - while abs(a-b) > e: - - b = a - a -= (fa/da) - fa = self.f(a) - da = self.d(a,e) - - return a - - def bissec_newton(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - c = (a+b)/2 # 'c' é a raiz calculada - - while abs(a-b) > 0.1: - - fc = self.f(c) - - if fa*fc < 0: - - b = c - - else: - - a = c - fa = self.f(a) - - c = (a+b)/2 - - fc = self.f(c) - dc = self.d(c,e) - h = c - fc/dc # 'h' é uma variável de controle - - while abs(c-h) > e: - - h = c - c -= (fc/dc) - fc = self.f(c) - dc = self.d(c,e) - - return (c) - - - class Edo: - - def __init__(self, function): - self.f = function - - def euler(self,a,y,b,n=None): - - if n is None: - n = 10**7 - - dx = (b-a)/n - - def x(i): - return a + i*dx - - for i in range(n): - - y = y + (self.f(x(i),y))*dx - - return y - - def runge(self,a,y,b,n=None): - - if n is None: - n = 10**7 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - y = y + (dx/2)*(self.f(x(i),y)+self.f(x(i+1),(y+(dx*self.f(x(i),y))))) - - return y - -class Interpolation: - """ Data should be organized in two columns: X and Y""" - - def __init__(self, data): - - self.data = data - self.polinomial = self.Polinomial(self.data) - - def minimus(self,x): - - theta = 0 - # somatorio de x - for i in range(self.data.shape[0]): - - theta += self.data[i][0] - - eta = 0 - #somatorio de y - for i in range(self.data.shape[0]): - - eta += self.data[i][1] - - sigma = 0 - #somatorio de xy - for i in range(self.data.shape[0]): - - sigma += self.data[i][0]*self.data[i][1] - - omega = 0 - #somatorio de x^2 - for i in range(self.data.shape[0]): - - omega += self.data[i][0]**2 - - - self.a = (self.data.shape[0]*sigma - theta*eta)/(self.data.shape[0]*omega - (theta**2)) - - self.b = (theta*sigma - eta*omega)/((theta**2) - self.data.shape[0]*omega) - - ym = 0 - - for i in range(self.data.shape[0]): - - ym += self.data[i][1]/self.data.shape[0] - - sqreq = 0 - - for i in range(self.data.shape[0]): - - sqreq += ((self.a*self.data[i][0] + self.b) - ym)**2 - - sqtot = 0 - - for i in range(self.data.shape[0]): - - sqtot += (self.data[i][1] - ym)**2 - - self.r2 = sqreq/sqtot - - return self.a*x + self.b - - class Polinomial: - - def __init__(self, data): - self.data = data - - def vandermonde(self, x): - - matrix = np.zeros((self.data.shape[0],self.data.shape[0])) - - for k in range(0, self.data.shape[0]): - - matrix[:,k] = self.data[:,0]**k - - self.A = sl.gauss(np.c_[matrix,self.data[:,1]]) - - y = 0 - - for i in range(0,self.A.shape[0]): - - y += self.A[i]*(x**i) - - return float(y) - - def lagrange(self, x): - - data_x = self.data[:,0] - data_y = self.data[:,1] - - def L(k,x): - - up = down = 1 - - for i in [x for x in range(data_x.shape[0]) if x != k]: - up = up*(x - data_x[i]) - - for i in [x for x in range(data_x.shape[0]) if x != k]: - down = down*(data_x[k] - data_x[i]) - - return up/down - - y = 0 - - for i in range(data_x.shape[0]): - - y += data_y[i]*L(i,x) - - return y - - def newton(self,x): - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data[:,1] - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/(self.data[(i+1)+j][0]-self.data[j][0]) - j += 1 - - i += 1 - j = 0 - - def f(x): - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data[k][0]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y - - self.f = f - - return f(x) - - def gregory(self,x): - - h = self.data[0][0] - self.data[1][0] - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data[:,1] - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/((i+1)*h) - j += 1 - - i += 1 - j = 0 - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data[k][0]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3/Otter/__init__.py b/Older Versions/yoshi-otter1.3/Otter/__init__.py deleted file mode 100644 index 08ce1fe..0000000 --- a/Older Versions/yoshi-otter1.3/Otter/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. - -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. - -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -from .Otter import Algebra as algebra -from .Otter import Interpolation as interpolation \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3/README.md b/Older Versions/yoshi-otter1.3/README.md deleted file mode 100644 index 05245f1..0000000 --- a/Older Versions/yoshi-otter1.3/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# Otter - Numeric Calculus - -This python package is made for applied Numeric Calculus of Algebra Functions. It is made with the following objectives in mind: - -* Receive one variable function from user input - -* Receive two variable function from user input - -* Performe derivatives with one variable functions - -* Performe integral with received functions - -* Use methods to proccess the matrices. - -* Find root of functions throw method of bissection and method of newton - -* Solve Diferential Equations throw method of euler and runge - -* Performe Minimus Interpolation and Polinomial Interpolation - -## Syntax - -To initialize a Otter instance linked to functions use the following syntax `otr = Otter.algebra(f)`, where `otr` will be a arbitrary name for the instance and `f` is a function of *one variable*. - -To initialize a Otter instance linked to data and interpolation use the following syntax `otr = Otter.interpolation(data)`, where `otr` will be a arbitrary name for the instance and data will be a *numpy* matrix where the first columns has to contain the values for `x` and the second column contains the values for `y`. - -### Algebra - -Algebra is a Python Class where some of the features described previously are defined as Classes as well, like: `Integral`, `Roots`, `EDO` (diferential equations). - -#### Integral - -To call the class *Integral* append the sufix with lower case in front of the instance like: `otr.integral`. The Integral class has two other class defined inside, `Simple` and `Double`, to call them append the sufix with lower case in front as `otr.integral.simple` or `otr.integral.double`. Then pick between Riemann's Method or Simpson's Method by appending the sufix `riemann` or `simpson` as well. - -After that the syntax will be something like `otr.integral.double.riemann(a,b,c,d,n,m)`, where `a` and `c` will be the first value of the interval of integration respectively in x and y, `b` and `d` will be the last, `n` and `m` will be the number of partitions. - -The syntax for one variable integrations will be `otr.integral.simple.riemann(a,b,n)`. - -If `n` is not defined the standart value in 10^6 partitions for one variable and 10^4 for double. And if `m` is not defined the standart value will be equal to `n`. - -#### Roots - -To call the class *Root* append the sufix with lower case in front of the instance like: `otr.roots`. The Roots class has three methods defined inside, `bissec`, `newton` and `bissec_newton`, to call them append the sufix with lower case in front as `otr.roots.bissec` or `otr.roots.newton` or even `otr.roots.bissecnewton`. - -The syntax for the bissection method and bissec_newton is equal to `otr.roots.bissec(a,b,e)` and `otr.roots.bissec_newton(a,b,e)`, where `a` is the first element of the interval containing the root and `b` is the last, `e` being the precision. - -The syntax for the newton method is equal to `otr.roots.newton(a,e)`, where `a` is the element closest to the root and `e` is the precision. - -If `e` is not defined the standart value is 10^(-6). - -#### Diferential Equations - -To call the class *EDO* (*E*quações *D*iferenciais *O*rdinárias) append the sufix with lower case in front of the instance like: `otr.edo`. The *EDO* class has two methods defined inside: `euler` and `runge`, to call them append the sufix with lower case in front as `otr.edo.euler` or `otr.edo.runge`. - -The syntax for the diferential equations method is equal to `otr.edo.euler(a,y,b,n)` or `otr.edo.runge(a,y,b,n)`, where `a` and `y` will be the inintial point and `b` is the value in *x* which you want to know the corresponding value in *y* and `n` is the number of operations. - -If `n` is not defined the standart value is 10^7. - -### Interpolation - -The python class *Interpolation* is divided in one method, minimus interpolation, and one class, polinomial interpolation. - -To call the method *minimus* use a syntax like `otr = Otter.interpolation(data)`, where `otr` is an instance and append the method in front of the instance like: `otr.minimus(x)`, where *x* is value of *f(x)* you want to estimate. - -To call the class *Polinomial* append the sufix with lower case in front of the instance like: `otr.polinomial`. The *Polinomial* class has four methods defined inside: `vandermonde`, `lagrange`, `newton` and `gregory`, to call them append the sufix with lower case in front like `otr.edo.gregory(x)` where *x* is value of *f(x)* you want to estimate. - -## Installation - -To install the package from source `cd` into the directory and run: - -`pip install .` - -or run - -`pip install yoshi-otter` diff --git a/Older Versions/yoshi-otter1.3/build/lib/Otter/Otter.py b/Older Versions/yoshi-otter1.3/build/lib/Otter/Otter.py deleted file mode 100644 index ae4a8cd..0000000 --- a/Older Versions/yoshi-otter1.3/build/lib/Otter/Otter.py +++ /dev/null @@ -1,499 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. -# -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. -# -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import math -import numpy as np -import Seals - -sl = Seals.process() - -class Algebra: - - def __init__(self, function): - self.f = function - self.integral = self.Integral(self.f) - self.roots = self.Roots(self.f) - self.edo = self.Edo(self.f) - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - class Integral: - - def __init__(self,function): - self.f = function - self.simple = self.Simple(function) - self.double = self.Double(function) - - class Simple: - def __init__(self, function): - self.f = function - - def riemann(self,a,b,n=None): - - if n is None: - n = 10**6 - - delta = (b-a)/n - - psi = a - theta = 0 - - while((psi+delta) <= b): - - theta += (self.f(psi) + self.f(psi + delta))/2 - psi += delta - - integral = delta*theta - - return integral - - def simpson(self,a,b,n=None): - - if n is None: - n = 10**6 - - def x(i): - return a + i*h - - h = (b-a)/n - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta = eta + self.f(x(2*psi - 1)) - psi = psi + 1 - - while(kappa <= ((n/2)-1)): - - theta = theta + self.f(x(2*kappa)) - kappa = kappa + 1 - - return (h/3)*( self.f(x(0)) + self.f(x(n)) + 4*eta + 2*theta) - - - class Double: - - def __init__(self,function): - self.f = function - - def riemann(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - kappa = a - psi = c - theta = 0 - - while((psi + dy) < d): - - while((kappa + dx) < b): - - theta = theta + self.f(kappa, psi) - kappa = kappa + dx - - psi = psi + dy - kappa = a - - return theta*(dx)*(dy) - - def simpson(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - - def x(i): - - x = a + i*dx - - return x - - def y(i): - - y = c + i*dy - - return y - - def g(i): - - sigma = 0 - upsilon = 0 - - zeta = 1 - csi = 1 - - while(zeta <= (m/2)): - - sigma += self.f(x(i),y(2*zeta - 1)) - zeta += 1 - - while(csi <= ((m/2)-1)): - - upsilon += self.f(x(i),y(2*csi)) - csi += 1 - - return (dy/3)*( self.f(x(i),y(0)) + self.f(x(i),y(m)) + 4*sigma + 2*upsilon ) - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta += g(2*psi - 1) - psi += 1 - - while(kappa <= ((n/2)-1)): - - theta += g(2*kappa) - kappa += 1 - - return (dx/3)*( g(0) + g(n) + 4*eta + 2*theta) - - class Roots: - - def __init__(self, function=None): - if function is not None: - self.f = function - - def bissec(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - while abs(a-b) > e: - - c = (a+b)/2 - fc = self.f(c) - - if (fa*fc) < 0: - - b = c - - else: - - a = c - fa = fc - - c = (a+b)/2 - - return c - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - def newton(self,a,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - da = self.d(a,e) - b = a - fa/da - - - while abs(a-b) > e: - - b = a - a -= (fa/da) - fa = self.f(a) - da = self.d(a,e) - - return a - - def bissec_newton(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - c = (a+b)/2 # 'c' é a raiz calculada - - while abs(a-b) > 0.1: - - fc = self.f(c) - - if fa*fc < 0: - - b = c - - else: - - a = c - fa = self.f(a) - - c = (a+b)/2 - - fc = self.f(c) - dc = self.d(c,e) - h = c - fc/dc # 'h' é uma variável de controle - - while abs(c-h) > e: - - h = c - c -= (fc/dc) - fc = self.f(c) - dc = self.d(c,e) - - return (c) - - - class Edo: - - def __init__(self, function): - self.f = function - - def euler(self,a,y,b,n=None): - - if n is None: - n = 10**7 - - dx = (b-a)/n - - def x(i): - return a + i*dx - - for i in range(n): - - y = y + (self.f(x(i),y))*dx - - return y - - def runge(self,a,y,b,n=None): - - if n is None: - n = 10**7 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - y = y + (dx/2)*(self.f(x(i),y)+self.f(x(i+1),(y+(dx*self.f(x(i),y))))) - - return y - -class Interpolation: - """ Data should be organized in two columns: X and Y""" - - def __init__(self, data): - - self.data = data - self.polinomial = self.Polinomial(self.data) - - def minimus(self,x): - - theta = 0 - # somatorio de x - for i in range(self.data.shape[0]): - - theta += self.data[i][0] - - eta = 0 - #somatorio de y - for i in range(self.data.shape[0]): - - eta += self.data[i][1] - - sigma = 0 - #somatorio de xy - for i in range(self.data.shape[0]): - - sigma += self.data[i][0]*self.data[i][1] - - omega = 0 - #somatorio de x^2 - for i in range(self.data.shape[0]): - - omega += self.data[i][0]**2 - - - self.a = (self.data.shape[0]*sigma - theta*eta)/(self.data.shape[0]*omega - (theta**2)) - - self.b = (theta*sigma - eta*omega)/((theta**2) - self.data.shape[0]*omega) - - ym = 0 - - for i in range(self.data.shape[0]): - - ym += self.data[i][1]/self.data.shape[0] - - sqreq = 0 - - for i in range(self.data.shape[0]): - - sqreq += ((self.a*self.data[i][0] + self.b) - ym)**2 - - sqtot = 0 - - for i in range(self.data.shape[0]): - - sqtot += (self.data[i][1] - ym)**2 - - self.r2 = sqreq/sqtot - - return self.a*x + self.b - - class Polinomial: - - def __init__(self, data): - self.data = data - - def vandermonde(self, x): - - matrix = np.zeros((self.data.shape[0],self.data.shape[0])) - - for k in range(0, self.data.shape[0]): - - matrix[:,k] = self.data[:,0]**k - - self.A = sl.gauss(np.c_[matrix,self.data[:,1]]) - - y = 0 - - for i in range(0,self.A.shape[0]): - - y += self.A[i]*(x**i) - - return float(y) - - def lagrange(self, x): - - data_x = self.data[:,0] - data_y = self.data[:,1] - - def L(k,x): - - up = down = 1 - - for i in [x for x in range(data_x.shape[0]) if x != k]: - up = up*(x - data_x[i]) - - for i in [x for x in range(data_x.shape[0]) if x != k]: - down = down*(data_x[k] - data_x[i]) - - return up/down - - y = 0 - - for i in range(data_x.shape[0]): - - y += data_y[i]*L(i,x) - - return y - - def newton(self,x): - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data[:,1] - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/(self.data[(i+1)+j][0]-self.data[j][0]) - j += 1 - - i += 1 - j = 0 - - def f(x): - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data[k][0]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y - - self.f = f - - return f(x) - - def gregory(self,x): - - h = self.data[0][0] - self.data[1][0] - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data[:,1] - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/((i+1)*h) - j += 1 - - i += 1 - j = 0 - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data[k][0]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3/build/lib/Otter/__init__.py b/Older Versions/yoshi-otter1.3/build/lib/Otter/__init__.py deleted file mode 100644 index 08ce1fe..0000000 --- a/Older Versions/yoshi-otter1.3/build/lib/Otter/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. - -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. - -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -from .Otter import Algebra as algebra -from .Otter import Interpolation as interpolation \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3/dist/yoshi-otter-1.3.tar.gz b/Older Versions/yoshi-otter1.3/dist/yoshi-otter-1.3.tar.gz deleted file mode 100644 index e85b65b..0000000 Binary files a/Older Versions/yoshi-otter1.3/dist/yoshi-otter-1.3.tar.gz and /dev/null differ diff --git a/Older Versions/yoshi-otter1.3/dist/yoshi_otter-1.3-py3-none-any.whl b/Older Versions/yoshi-otter1.3/dist/yoshi_otter-1.3-py3-none-any.whl deleted file mode 100644 index 995b130..0000000 Binary files a/Older Versions/yoshi-otter1.3/dist/yoshi_otter-1.3-py3-none-any.whl and /dev/null differ diff --git a/Older Versions/yoshi-otter1.3/setup.py b/Older Versions/yoshi-otter1.3/setup.py deleted file mode 100644 index b2f36a1..0000000 --- a/Older Versions/yoshi-otter1.3/setup.py +++ /dev/null @@ -1,28 +0,0 @@ -import setuptools - -with open("README.md", "r") as fh: - long_description = fh.read() - -setuptools.setup( - name="yoshi-otter", # Replace with your own username - version="1.3", - author="Vitor Hideyoshi", - author_email="vitor.h.n.batista@gmail.com", - description="Numeric Calculus python module in the topic of Algebra Functions", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/HideyoshiNakazone/Otter-NumericCalculus.git", - packages=setuptools.find_packages(), - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", - "Operating System :: OS Independent", - "Development Status :: 2 - Pre-Alpha", - ], - python_requires='>=3.6', - install_requires=[ - 'numpy', - 'pandas', - 'yoshi-seals' - ], -) \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3/yoshi_otter.egg-info/PKG-INFO b/Older Versions/yoshi-otter1.3/yoshi_otter.egg-info/PKG-INFO deleted file mode 100644 index 6fdbac1..0000000 --- a/Older Versions/yoshi-otter1.3/yoshi_otter.egg-info/PKG-INFO +++ /dev/null @@ -1,91 +0,0 @@ -Metadata-Version: 2.1 -Name: yoshi-otter -Version: 1.3 -Summary: Numeric Calculus python module in the topic of Algebra Functions -Home-page: https://github.com/HideyoshiNakazone/Otter-NumericCalculus.git -Author: Vitor Hideyoshi -Author-email: vitor.h.n.batista@gmail.com -License: UNKNOWN -Description: # Otter - Numeric Calculus - - This python package is made for applied Numeric Calculus of Algebra Functions. It is made with the following objectives in mind: - - * Receive one variable function from user input - - * Receive two variable function from user input - - * Performe derivatives with one variable functions - - * Performe integral with received functions - - * Use methods to proccess the matrices. - - * Find root of functions throw method of bissection and method of newton - - * Solve Diferential Equations throw method of euler and runge - - * Performe Minimus Interpolation and Polinomial Interpolation - - ## Syntax - - To initialize a Otter instance linked to functions use the following syntax `otr = Otter.algebra(f)`, where `otr` will be a arbitrary name for the instance and `f` is a function of *one variable*. - - To initialize a Otter instance linked to data and interpolation use the following syntax `otr = Otter.interpolation(data)`, where `otr` will be a arbitrary name for the instance and data will be a *numpy* matrix where the first columns has to contain the values for `x` and the second column contains the values for `y`. - - ### Algebra - - Algebra is a Python Class where some of the features described previously are defined as Classes as well, like: `Integral`, `Roots`, `EDO` (diferential equations). - - #### Integral - - To call the class *Integral* append the sufix with lower case in front of the instance like: `otr.integral`. The Integral class has two other class defined inside, `Simple` and `Double`, to call them append the sufix with lower case in front as `otr.integral.simple` or `otr.integral.double`. Then pick between Riemann's Method or Simpson's Method by appending the sufix `riemann` or `simpson` as well. - - After that the syntax will be something like `otr.integral.double.riemann(a,b,c,d,n,m)`, where `a` and `c` will be the first value of the interval of integration respectively in x and y, `b` and `d` will be the last, `n` and `m` will be the number of partitions. - - The syntax for one variable integrations will be `otr.integral.simple.riemann(a,b,n)`. - - If `n` is not defined the standart value in 10^6 partitions for one variable and 10^4 for double. And if `m` is not defined the standart value will be equal to `n`. - - #### Roots - - To call the class *Root* append the sufix with lower case in front of the instance like: `otr.roots`. The Roots class has three methods defined inside, `bissec`, `newton` and `bissec_newton`, to call them append the sufix with lower case in front as `otr.roots.bissec` or `otr.roots.newton` or even `otr.roots.bissecnewton`. - - The syntax for the bissection method and bissec_newton is equal to `otr.roots.bissec(a,b,e)` and `otr.roots.bissec_newton(a,b,e)`, where `a` is the first element of the interval containing the root and `b` is the last, `e` being the precision. - - The syntax for the newton method is equal to `otr.roots.newton(a,e)`, where `a` is the element closest to the root and `e` is the precision. - - If `e` is not defined the standart value is 10^(-6). - - #### Diferential Equations - - To call the class *EDO* (*E*quações *D*iferenciais *O*rdinárias) append the sufix with lower case in front of the instance like: `otr.edo`. The *EDO* class has two methods defined inside: `euler` and `runge`, to call them append the sufix with lower case in front as `otr.edo.euler` or `otr.edo.runge`. - - The syntax for the diferential equations method is equal to `otr.edo.euler(a,y,b,n)` or `otr.edo.runge(a,y,b,n)`, where `a` and `y` will be the inintial point and `b` is the value in *x* which you want to know the corresponding value in *y* and `n` is the number of operations. - - If `n` is not defined the standart value is 10^7. - - ### Interpolation - - The python class *Interpolation* is divided in one method, minimus interpolation, and one class, polinomial interpolation. - - To call the method *minimus* use a syntax like `otr = Otter.interpolation(data)`, where `otr` is an instance and append the method in front of the instance like: `otr.minimus(x)`, where *x* is value of *f(x)* you want to estimate. - - To call the class *Polinomial* append the sufix with lower case in front of the instance like: `otr.polinomial`. The *Polinomial* class has four methods defined inside: `vandermonde`, `lagrange`, `newton` and `gregory`, to call them append the sufix with lower case in front like `otr.edo.gregory(x)` where *x* is value of *f(x)* you want to estimate. - - ## Installation - - To install the package from source `cd` into the directory and run: - - `pip install .` - - or run - - `pip install yoshi-otter` - -Platform: UNKNOWN -Classifier: Programming Language :: Python :: 3 -Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2) -Classifier: Operating System :: OS Independent -Classifier: Development Status :: 2 - Pre-Alpha -Requires-Python: >=3.6 -Description-Content-Type: text/markdown diff --git a/Older Versions/yoshi-otter1.3/yoshi_otter.egg-info/SOURCES.txt b/Older Versions/yoshi-otter1.3/yoshi_otter.egg-info/SOURCES.txt deleted file mode 100644 index 5dc205c..0000000 --- a/Older Versions/yoshi-otter1.3/yoshi_otter.egg-info/SOURCES.txt +++ /dev/null @@ -1,9 +0,0 @@ -README.md -setup.py -Otter/Otter.py -Otter/__init__.py -yoshi_otter.egg-info/PKG-INFO -yoshi_otter.egg-info/SOURCES.txt -yoshi_otter.egg-info/dependency_links.txt -yoshi_otter.egg-info/requires.txt -yoshi_otter.egg-info/top_level.txt \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.3/yoshi_otter.egg-info/dependency_links.txt b/Older Versions/yoshi-otter1.3/yoshi_otter.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/Older Versions/yoshi-otter1.3/yoshi_otter.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Older Versions/yoshi-otter1.3/yoshi_otter.egg-info/requires.txt b/Older Versions/yoshi-otter1.3/yoshi_otter.egg-info/requires.txt deleted file mode 100644 index 11c1c26..0000000 --- a/Older Versions/yoshi-otter1.3/yoshi_otter.egg-info/requires.txt +++ /dev/null @@ -1,3 +0,0 @@ -numpy -pandas -yoshi-seals diff --git a/Older Versions/yoshi-otter1.3/yoshi_otter.egg-info/top_level.txt b/Older Versions/yoshi-otter1.3/yoshi_otter.egg-info/top_level.txt deleted file mode 100644 index ccaaf54..0000000 --- a/Older Versions/yoshi-otter1.3/yoshi_otter.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -Otter diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..9bfd426 --- /dev/null +++ b/Pipfile @@ -0,0 +1,16 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +pandas = "*" +numpy = "*" +yoshi-seals = "*" + +[dev-packages] +black = "*" +coverage = "*" + +[requires] +python_version = "3.10" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..d9d1730 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,241 @@ +{ + "_meta": { + "hash": { + "sha256": "931881177d120d4c175ea11b88e6b666330e9519c0aec2dd1bd089a53e7e8694" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.10" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "numpy": { + "hashes": [ + "sha256:01dd17cbb340bf0fc23981e52e1d18a9d4050792e8fb8363cecbf066a84b827d", + "sha256:06005a2ef6014e9956c09ba07654f9837d9e26696a0470e42beedadb78c11b07", + "sha256:09b7847f7e83ca37c6e627682f145856de331049013853f344f37b0c9690e3df", + "sha256:0aaee12d8883552fadfc41e96b4c82ee7d794949e2a7c3b3a7201e968c7ecab9", + "sha256:0cbe9848fad08baf71de1a39e12d1b6310f1d5b2d0ea4de051058e6e1076852d", + "sha256:1b1766d6f397c18153d40015ddfc79ddb715cabadc04d2d228d4e5a8bc4ded1a", + "sha256:33161613d2269025873025b33e879825ec7b1d831317e68f4f2f0f84ed14c719", + "sha256:5039f55555e1eab31124a5768898c9e22c25a65c1e0037f4d7c495a45778c9f2", + "sha256:522e26bbf6377e4d76403826ed689c295b0b238f46c28a7251ab94716da0b280", + "sha256:56e454c7833e94ec9769fa0f86e6ff8e42ee38ce0ce1fa4cbb747ea7e06d56aa", + "sha256:58f545efd1108e647604a1b5aa809591ccd2540f468a880bedb97247e72db387", + "sha256:5e05b1c973a9f858c74367553e236f287e749465f773328c8ef31abe18f691e1", + "sha256:7903ba8ab592b82014713c491f6c5d3a1cde5b4a3bf116404e08f5b52f6daf43", + "sha256:8969bfd28e85c81f3f94eb4a66bc2cf1dbdc5c18efc320af34bffc54d6b1e38f", + "sha256:92c8c1e89a1f5028a4c6d9e3ccbe311b6ba53694811269b992c0b224269e2398", + "sha256:9c88793f78fca17da0145455f0d7826bcb9f37da4764af27ac945488116efe63", + "sha256:a7ac231a08bb37f852849bbb387a20a57574a97cfc7b6cabb488a4fc8be176de", + "sha256:abdde9f795cf292fb9651ed48185503a2ff29be87770c3b8e2a14b0cd7aa16f8", + "sha256:af1da88f6bc3d2338ebbf0e22fe487821ea4d8e89053e25fa59d1d79786e7481", + "sha256:b2a9ab7c279c91974f756c84c365a669a887efa287365a8e2c418f8b3ba73fb0", + "sha256:bf837dc63ba5c06dc8797c398db1e223a466c7ece27a1f7b5232ba3466aafe3d", + "sha256:ca51fcfcc5f9354c45f400059e88bc09215fb71a48d3768fb80e357f3b457e1e", + "sha256:ce571367b6dfe60af04e04a1834ca2dc5f46004ac1cc756fb95319f64c095a96", + "sha256:d208a0f8729f3fb790ed18a003f3a57895b989b40ea4dce4717e9cf4af62c6bb", + "sha256:dbee87b469018961d1ad79b1a5d50c0ae850000b639bcb1b694e9981083243b6", + "sha256:e9f4c4e51567b616be64e05d517c79a8a22f3606499941d97bb76f2ca59f982d", + "sha256:f063b69b090c9d918f9df0a12116029e274daf0181df392839661c4c7ec9018a", + "sha256:f9a909a8bae284d46bbfdefbdd4a262ba19d3bc9921b1e76126b1d21c3c34135" + ], + "index": "pypi", + "version": "==1.23.5" + }, + "pandas": { + "hashes": [ + "sha256:0183cb04a057cc38fde5244909fca9826d5d57c4a5b7390c0cc3fa7acd9fa883", + "sha256:1fc87eac0541a7d24648a001d553406f4256e744d92df1df8ebe41829a915028", + "sha256:220b98d15cee0b2cd839a6358bd1f273d0356bf964c1a1aeb32d47db0215488b", + "sha256:2552bffc808641c6eb471e55aa6899fa002ac94e4eebfa9ec058649122db5824", + "sha256:315e19a3e5c2ab47a67467fc0362cb36c7c60a93b6457f675d7d9615edad2ebe", + "sha256:344021ed3e639e017b452aa8f5f6bf38a8806f5852e217a7594417fb9bbfa00e", + "sha256:375262829c8c700c3e7cbb336810b94367b9c4889818bbd910d0ecb4e45dc261", + "sha256:457d8c3d42314ff47cc2d6c54f8fc0d23954b47977b2caed09cd9635cb75388b", + "sha256:4aed257c7484d01c9a194d9a94758b37d3d751849c05a0050c087a358c41ad1f", + "sha256:530948945e7b6c95e6fa7aa4be2be25764af53fba93fe76d912e35d1c9ee46f5", + "sha256:5ae7e989f12628f41e804847a8cc2943d362440132919a69429d4dea1f164da0", + "sha256:71f510b0efe1629bf2f7c0eadb1ff0b9cf611e87b73cd017e6b7d6adb40e2b3a", + "sha256:73f219fdc1777cf3c45fde7f0708732ec6950dfc598afc50588d0d285fddaefc", + "sha256:8092a368d3eb7116e270525329a3e5c15ae796ccdf7ccb17839a73b4f5084a39", + "sha256:82ae615826da838a8e5d4d630eb70c993ab8636f0eff13cb28aafc4291b632b5", + "sha256:9608000a5a45f663be6af5c70c3cbe634fa19243e720eb380c0d378666bc7702", + "sha256:a40dd1e9f22e01e66ed534d6a965eb99546b41d4d52dbdb66565608fde48203f", + "sha256:b4f5a82afa4f1ff482ab8ded2ae8a453a2cdfde2001567b3ca24a4c5c5ca0db3", + "sha256:c009a92e81ce836212ce7aa98b219db7961a8b95999b97af566b8dc8c33e9519", + "sha256:c218796d59d5abd8780170c937b812c9637e84c32f8271bbf9845970f8c1351f", + "sha256:cc3cd122bea268998b79adebbb8343b735a5511ec14efb70a39e7acbc11ccbdc", + "sha256:d0d8fd58df5d17ddb8c72a5075d87cd80d71b542571b5f78178fb067fa4e9c72", + "sha256:e18bc3764cbb5e118be139b3b611bc3fbc5d3be42a7e827d1096f46087b395eb", + "sha256:e2b83abd292194f350bb04e188f9379d36b8dfac24dd445d5c87575f3beaf789", + "sha256:e7469271497960b6a781eaa930cba8af400dd59b62ec9ca2f4d31a19f2f91090", + "sha256:e9dbacd22555c2d47f262ef96bb4e30880e5956169741400af8b306bbb24a273", + "sha256:f6257b314fc14958f8122779e5a1557517b0f8e500cfb2bd53fa1f75a8ad0af2" + ], + "index": "pypi", + "version": "==1.5.2" + }, + "python-dateutil": { + "hashes": [ + "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86", + "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.8.2" + }, + "pytz": { + "hashes": [ + "sha256:222439474e9c98fced559f1709d89e6c9cbf8d79c794ff3eb9f8800064291427", + "sha256:e89512406b793ca39f5971bc999cc538ce125c0e51c27941bef4568b460095e2" + ], + "version": "==2022.6" + }, + "six": { + "hashes": [ + "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926", + "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==1.16.0" + }, + "yoshi-seals": { + "hashes": [ + "sha256:85e1697b289a135191362a3885db01bc568e0ca341da0eddeac69dabc86e35d8" + ], + "index": "pypi", + "version": "==2.0.3654593985" + } + }, + "develop": { + "black": { + "hashes": [ + "sha256:14ff67aec0a47c424bc99b71005202045dc09270da44a27848d534600ac64fc7", + "sha256:197df8509263b0b8614e1df1756b1dd41be6738eed2ba9e9769f3880c2b9d7b6", + "sha256:1e464456d24e23d11fced2bc8c47ef66d471f845c7b7a42f3bd77bf3d1789650", + "sha256:2039230db3c6c639bd84efe3292ec7b06e9214a2992cd9beb293d639c6402edb", + "sha256:21199526696b8f09c3997e2b4db8d0b108d801a348414264d2eb8eb2532e540d", + "sha256:2644b5d63633702bc2c5f3754b1b475378fbbfb481f62319388235d0cd104c2d", + "sha256:432247333090c8c5366e69627ccb363bc58514ae3e63f7fc75c54b1ea80fa7de", + "sha256:444ebfb4e441254e87bad00c661fe32df9969b2bf224373a448d8aca2132b395", + "sha256:5b9b29da4f564ba8787c119f37d174f2b69cdfdf9015b7d8c5c16121ddc054ae", + "sha256:5cc42ca67989e9c3cf859e84c2bf014f6633db63d1cbdf8fdb666dcd9e77e3fa", + "sha256:5d8f74030e67087b219b032aa33a919fae8806d49c867846bfacde57f43972ef", + "sha256:72ef3925f30e12a184889aac03d77d031056860ccae8a1e519f6cbb742736383", + "sha256:819dc789f4498ecc91438a7de64427c73b45035e2e3680c92e18795a839ebb66", + "sha256:915ace4ff03fdfff953962fa672d44be269deb2eaf88499a0f8805221bc68c87", + "sha256:9311e99228ae10023300ecac05be5a296f60d2fd10fff31cf5c1fa4ca4b1988d", + "sha256:974308c58d057a651d182208a484ce80a26dac0caef2895836a92dd6ebd725e0", + "sha256:b8b49776299fece66bffaafe357d929ca9451450f5466e997a7285ab0fe28e3b", + "sha256:c957b2b4ea88587b46cf49d1dc17681c1e672864fd7af32fc1e9664d572b3458", + "sha256:e41a86c6c650bcecc6633ee3180d80a025db041a8e2398dcc059b3afa8382cd4", + "sha256:f513588da599943e0cde4e32cc9879e825d58720d6557062d1098c5ad80080e1", + "sha256:fba8a281e570adafb79f7755ac8721b6cf1bbf691186a287e990c7929c7692ff" + ], + "index": "pypi", + "version": "==22.10.0" + }, + "click": { + "hashes": [ + "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e", + "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48" + ], + "markers": "python_version >= '3.7'", + "version": "==8.1.3" + }, + "coverage": { + "hashes": [ + "sha256:027018943386e7b942fa832372ebc120155fd970837489896099f5cfa2890f79", + "sha256:11b990d520ea75e7ee8dcab5bc908072aaada194a794db9f6d7d5cfd19661e5a", + "sha256:12adf310e4aafddc58afdb04d686795f33f4d7a6fa67a7a9d4ce7d6ae24d949f", + "sha256:1431986dac3923c5945271f169f59c45b8802a114c8f548d611f2015133df77a", + "sha256:1ef221513e6f68b69ee9e159506d583d31aa3567e0ae84eaad9d6ec1107dddaa", + "sha256:20c8ac5386253717e5ccc827caad43ed66fea0efe255727b1053a8154d952398", + "sha256:2198ea6fc548de52adc826f62cb18554caedfb1d26548c1b7c88d8f7faa8f6ba", + "sha256:255758a1e3b61db372ec2736c8e2a1fdfaf563977eedbdf131de003ca5779b7d", + "sha256:265de0fa6778d07de30bcf4d9dc471c3dc4314a23a3c6603d356a3c9abc2dfcf", + "sha256:33a7da4376d5977fbf0a8ed91c4dffaaa8dbf0ddbf4c8eea500a2486d8bc4d7b", + "sha256:42eafe6778551cf006a7c43153af1211c3aaab658d4d66fa5fcc021613d02518", + "sha256:4433b90fae13f86fafff0b326453dd42fc9a639a0d9e4eec4d366436d1a41b6d", + "sha256:4a5375e28c5191ac38cca59b38edd33ef4cc914732c916f2929029b4bfb50795", + "sha256:4a8dbc1f0fbb2ae3de73eb0bdbb914180c7abfbf258e90b311dcd4f585d44bd2", + "sha256:59f53f1dc5b656cafb1badd0feb428c1e7bc19b867479ff72f7a9dd9b479f10e", + "sha256:5dbec3b9095749390c09ab7c89d314727f18800060d8d24e87f01fb9cfb40b32", + "sha256:633713d70ad6bfc49b34ead4060531658dc6dfc9b3eb7d8a716d5873377ab745", + "sha256:6b07130585d54fe8dff3d97b93b0e20290de974dc8177c320aeaf23459219c0b", + "sha256:6c4459b3de97b75e3bd6b7d4b7f0db13f17f504f3d13e2a7c623786289dd670e", + "sha256:6d4817234349a80dbf03640cec6109cd90cba068330703fa65ddf56b60223a6d", + "sha256:723e8130d4ecc8f56e9a611e73b31219595baa3bb252d539206f7bbbab6ffc1f", + "sha256:784f53ebc9f3fd0e2a3f6a78b2be1bd1f5575d7863e10c6e12504f240fd06660", + "sha256:7b6be138d61e458e18d8e6ddcddd36dd96215edfe5f1168de0b1b32635839b62", + "sha256:7ccf362abd726b0410bf8911c31fbf97f09f8f1061f8c1cf03dfc4b6372848f6", + "sha256:83516205e254a0cb77d2d7bb3632ee019d93d9f4005de31dca0a8c3667d5bc04", + "sha256:851cf4ff24062c6aec510a454b2584f6e998cada52d4cb58c5e233d07172e50c", + "sha256:8f830ed581b45b82451a40faabb89c84e1a998124ee4212d440e9c6cf70083e5", + "sha256:94e2565443291bd778421856bc975d351738963071e9b8839ca1fc08b42d4bef", + "sha256:95203854f974e07af96358c0b261f1048d8e1083f2de9b1c565e1be4a3a48cfc", + "sha256:97117225cdd992a9c2a5515db1f66b59db634f59d0679ca1fa3fe8da32749cae", + "sha256:98e8a10b7a314f454d9eff4216a9a94d143a7ee65018dd12442e898ee2310578", + "sha256:a1170fa54185845505fbfa672f1c1ab175446c887cce8212c44149581cf2d466", + "sha256:a6b7d95969b8845250586f269e81e5dfdd8ff828ddeb8567a4a2eaa7313460c4", + "sha256:a8fb6cf131ac4070c9c5a3e21de0f7dc5a0fbe8bc77c9456ced896c12fcdad91", + "sha256:af4fffaffc4067232253715065e30c5a7ec6faac36f8fc8d6f64263b15f74db0", + "sha256:b4a5be1748d538a710f87542f22c2cad22f80545a847ad91ce45e77417293eb4", + "sha256:b5604380f3415ba69de87a289a2b56687faa4fe04dbee0754bfcae433489316b", + "sha256:b9023e237f4c02ff739581ef35969c3739445fb059b060ca51771e69101efffe", + "sha256:bc8ef5e043a2af066fa8cbfc6e708d58017024dc4345a1f9757b329a249f041b", + "sha256:c4ed2820d919351f4167e52425e096af41bfabacb1857186c1ea32ff9983ed75", + "sha256:cca4435eebea7962a52bdb216dec27215d0df64cf27fc1dd538415f5d2b9da6b", + "sha256:d900bb429fdfd7f511f868cedd03a6bbb142f3f9118c09b99ef8dc9bf9643c3c", + "sha256:d9ecf0829c6a62b9b573c7bb6d4dcd6ba8b6f80be9ba4fc7ed50bf4ac9aecd72", + "sha256:dbdb91cd8c048c2b09eb17713b0c12a54fbd587d79adcebad543bc0cd9a3410b", + "sha256:de3001a203182842a4630e7b8d1a2c7c07ec1b45d3084a83d5d227a3806f530f", + "sha256:e07f4a4a9b41583d6eabec04f8b68076ab3cd44c20bd29332c6572dda36f372e", + "sha256:ef8674b0ee8cc11e2d574e3e2998aea5df5ab242e012286824ea3c6970580e53", + "sha256:f4f05d88d9a80ad3cac6244d36dd89a3c00abc16371769f1340101d3cb899fc3", + "sha256:f642e90754ee3e06b0e7e51bce3379590e76b7f76b708e1a71ff043f87025c84", + "sha256:fc2af30ed0d5ae0b1abdb4ebdce598eafd5b35397d4d75deb341a614d333d987" + ], + "index": "pypi", + "version": "==6.5.0" + }, + "mypy-extensions": { + "hashes": [ + "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d", + "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8" + ], + "version": "==0.4.3" + }, + "pathspec": { + "hashes": [ + "sha256:88c2606f2c1e818b978540f73ecc908e13999c6c3a383daf3705652ae79807a5", + "sha256:8f6bf73e5758fd365ef5d58ce09ac7c27d2833a8d7da51712eac6e27e35141b0" + ], + "markers": "python_version >= '3.7'", + "version": "==0.10.2" + }, + "platformdirs": { + "hashes": [ + "sha256:1a89a12377800c81983db6be069ec068eee989748799b946cce2a6e80dcc54ca", + "sha256:b46ffafa316e6b83b47489d240ce17173f123a9b9c83282141c3daf26ad9ac2e" + ], + "markers": "python_version >= '3.7'", + "version": "==2.6.0" + }, + "tomli": { + "hashes": [ + "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", + "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f" + ], + "markers": "python_full_version < '3.11.0a7'", + "version": "==2.0.1" + } + } +} diff --git a/Source Code - Otter/Otter.py b/Source Code - Otter/Otter.py deleted file mode 100755 index 6a91ddc..0000000 --- a/Source Code - Otter/Otter.py +++ /dev/null @@ -1,515 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. -# -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. -# -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import math -import numpy as np -import pandas as pd -from Seals import process as sl - -class Algebra: - - def __init__(self, function): - self.f = function - self.integral = self.Integral(self.f) - self.roots = self.Roots(self.f) - self.edo = self.Edo(self.f) - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - class Integral: - - def __init__(self,function): - self.f = function - self.simple = self.Simple(function) - self.double = self.Double(function) - - class Simple: - def __init__(self, function): - self.f = function - - def riemann(self,a,b,n=None): - - if n is None: - n = 10**6 - - delta = (b-a)/n - - psi = a - theta = 0 - - while((psi+delta) <= b): - - theta += (self.f(psi) + self.f(psi + delta))/2 - psi += delta - - integral = delta*theta - - return integral - - def simpson(self,a,b,n=None): - - if n is None: - n = 10**6 - - def x(i): - return a + i*h - - h = (b-a)/n - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta = eta + self.f(x(2*psi - 1)) - psi = psi + 1 - - while(kappa <= ((n/2)-1)): - - theta = theta + self.f(x(2*kappa)) - kappa = kappa + 1 - - return (h/3)*( self.f(x(0)) + self.f(x(n)) + 4*eta + 2*theta) - - - class Double: - - def __init__(self,function): - self.f = function - - def riemann(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - kappa = a - psi = c - theta = 0 - - while((psi + dy) < d): - - while((kappa + dx) < b): - - theta = theta + self.f(kappa, psi) - kappa = kappa + dx - - psi = psi + dy - kappa = a - - return theta*(dx)*(dy) - - def simpson(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - - def x(i): - - x = a + i*dx - - return x - - def y(i): - - y = c + i*dy - - return y - - def g(i): - - sigma = 0 - upsilon = 0 - - zeta = 1 - csi = 1 - - while(zeta <= (m/2)): - - sigma += self.f(x(i),y(2*zeta - 1)) - zeta += 1 - - while(csi <= ((m/2)-1)): - - upsilon += self.f(x(i),y(2*csi)) - csi += 1 - - return (dy/3)*( self.f(x(i),y(0)) + self.f(x(i),y(m)) + 4*sigma + 2*upsilon ) - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta += g(2*psi - 1) - psi += 1 - - while(kappa <= ((n/2)-1)): - - theta += g(2*kappa) - kappa += 1 - - return (dx/3)*( g(0) + g(n) + 4*eta + 2*theta) - - class Roots: - - def __init__(self, function=None): - if function is not None: - self.f = function - - def bissec(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - while abs(a-b) > e: - - c = (a+b)/2 - fc = self.f(c) - - if (fa*fc) < 0: - - b = c - - else: - - a = c - fa = fc - - c = (a+b)/2 - - return c - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - def newton(self,a,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - da = self.d(a,e) - b = a - fa/da - - - while abs(a-b) > e: - - b = a - a -= (fa/da) - fa = self.f(a) - da = self.d(a,e) - - return a - - def bissec_newton(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - c = (a+b)/2 # 'c' é a raiz calculada - - while abs(a-b) > 0.1: - - fc = self.f(c) - - if fa*fc < 0: - - b = c - - else: - - a = c - fa = self.f(a) - - c = (a+b)/2 - - fc = self.f(c) - dc = self.d(c,e) - h = c - fc/dc # 'h' é uma variável de controle - - while abs(c-h) > e: - - h = c - c -= (fc/dc) - fc = self.f(c) - dc = self.d(c,e) - - return (c) - - - class Edo: - - def __init__(self, function): - self.F = function - - def euler(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return a + i*dx - - for i in range(n): - - y = y + (self.F(x(i),y))*dx - - return y - - def runge(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - y = y + (dx/2)*(self.F(x(i),y)+self.F(x(i+1),(y+(dx*self.F(x(i),y))))) - - return y - - def adams(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - f0 = self.F(x(i),y) - f1 = self.F(x(i+1),y + dx*self.F(x(i)+(dx/2),y+(dx/2)*self.F(x(i),y))) - f2 = self.F(x(i+2),y + (dx/2)*(3*f1-f0)) - - y += (dx/12)*(5*f2 + 8*f1 - f0) - - return y - -class Interpolation: - """ Data should be organized in two columns: X and Y""" - - def __init__(self, data): - - self.data = data - self.polinomial = self.Polinomial(self.data) - - def minimus(self,x): - - theta = 0 - # somatorio de x - for i in range(self.data.shape[0]): - - theta += self.data.x[i] - - eta = 0 - #somatorio de y - for i in range(self.data.shape[0]): - - eta += self.data.y[i] - - sigma = 0 - #somatorio de xy - for i in range(self.data.shape[0]): - - sigma += self.data.x[i]*self.data.y[i] - - omega = 0 - #somatorio de x^2self.dself.dself.d - for i in range(self.data.shape[0]): - - omega += self.data.x[i]**2 - - - self.a = (self.data.shape[0]*sigma - theta*eta)/(self.data.shape[0]*omega - (theta**2)) - - self.b = (theta*sigma - eta*omega)/((theta**2) - self.data.shape[0]*omega) - - ym = 0 - - for i in range(self.data.shape[0]): - - ym += self.data.y[i]/self.data.shape[0] - - sqreq = 0 - - for i in range(self.data.shape[0]): - - sqreq += ((self.a*self.data.x[i] + self.b) - ym)**2 - - sqtot = 0 - - for i in range(self.data.shape[0]): - - sqtot += (self.data.y[i] - ym)**2 - - self.r2 = sqreq/sqtot - - return self.a*x + self.b - - class Polinomial: - - def __init__(self, data): - self.data = data - - def vandermonde(self, x): - - matrix = np.zeros((self.data.shape[0],self.data.shape[0])) - - for k in range(0, self.data.shape[0]): - - matrix[:,k] = self.data.x[:]**k - - self.A = sl.gauss(np.c_[matrix,self.data[:,1]]) - - y = 0 - - for i in range(0,self.A.shape[0]): - - y += self.A[i]*(x**i) - - return float(y) - - def lagrange(self, x): - - def L(k,x): - - up = down = 1 - - for i in [x for x in range(self.data.x.shape[0]) if x != k]: - up = up*(x - self.data.x[i]) - - for i in [x for x in range(self.data.x.shape[0]) if x != k]: - down = down*(self.data.x[k] - self.data.x[i]) - - return up/down - - y = 0 - - for i in range(self.data.x.shape[0]): - - y += self.data.y[i]*L(i,x) - - return y - - def newton(self,x): - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data.y - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/(self.data.x[(i+1)+j]-self.data.x[j]) - j += 1 - - i += 1 - j = 0 - - def f(x): - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data.x[k]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y - - self.f = f - - return f(x) - - def gregory(self,x): - - h = self.data.x[0] - self.data.x[1] - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data.y - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/((i+1)*h) - j += 1 - - i += 1 - j = 0 - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data.x[k]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y \ No newline at end of file diff --git a/Source Code - Otter/__init__.py b/Source Code - Otter/__init__.py deleted file mode 100644 index 08ce1fe..0000000 --- a/Source Code - Otter/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. - -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. - -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -from .Otter import Algebra as algebra -from .Otter import Interpolation as interpolation \ No newline at end of file diff --git a/Older Versions/yoshi-otter1.2/setup.py b/setup.py similarity index 72% rename from Older Versions/yoshi-otter1.2/setup.py rename to setup.py index 6e4ad41..7ad231c 100644 --- a/Older Versions/yoshi-otter1.2/setup.py +++ b/setup.py @@ -1,15 +1,25 @@ import setuptools +import os + + +__name = "yoshi-otter" + +__version_sufix = os.environ.get('VERSION_SUFIX') +if not __version_sufix: + __version_sufix = "dev" + +__version = f"2.0.{__version_sufix}" with open("README.md", "r") as fh: - long_description = fh.read() + __long_description = fh.read() setuptools.setup( - name="yoshi-otter", # Replace with your own username - version="1.2", + name=__name, + version=__version, author="Vitor Hideyoshi", author_email="vitor.h.n.batista@gmail.com", description="Numeric Calculus python module in the topic of Algebra Functions", - long_description=long_description, + long_description=__long_description, long_description_content_type="text/markdown", url="https://github.com/HideyoshiNakazone/Otter-NumericCalculus.git", packages=setuptools.find_packages(), diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/algebra/__init__.py b/tests/algebra/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/algebra/edo/__init__.py b/tests/algebra/edo/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/algebra/edo/test_edo.py b/tests/algebra/edo/test_edo.py new file mode 100644 index 0000000..6392abf --- /dev/null +++ b/tests/algebra/edo/test_edo.py @@ -0,0 +1,38 @@ +from yoshi_otter.algebra.edo import Edo + +import unittest + + +class TestEdo(unittest.TestCase): + + def setUp(self): + def f(x, y): + return 2*x + + self.f = f + + def test_class_instantiation(self): + edo = Edo(self.f) + self.assertIsInstance(edo, Edo) + + def test_euler(self): + edo = Edo(self.f) + y = edo.euler(0, 0, 1) + + self.assertAlmostEqual(y, 1, 5) + + def test_runge(self): + edo = Edo(self.f) + y = edo.runge(0, 0, 1) + + self.assertAlmostEqual(y, 1, 5) + + def test_adams(self): + edo = Edo(self.f) + y = edo.adams(0, 0, 1) + + self.assertAlmostEqual(y, 1, 5) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/algebra/integral/__init__.py b/tests/algebra/integral/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/algebra/integral/test_integral_double.py b/tests/algebra/integral/test_integral_double.py new file mode 100644 index 0000000..0ce31a8 --- /dev/null +++ b/tests/algebra/integral/test_integral_double.py @@ -0,0 +1,35 @@ +from yoshi_otter.algebra.integral.double import Double + +import unittest + + +class MyTestCase(unittest.TestCase): + + def setUp(self): + def g(x, y): + return x*y + + self.g = g + + def test_class_instantiation(self): + Double(self.g) + + def test_riemann(self): + + double = Double(self.g) + + integral = double.riemann(0, 1, 0, 1, n=10**3) + + self.assertAlmostEqual(integral, .25, 2) + + def test_simpson(self): + + double = Double(self.g) + + integral = double.simpson(0, 1, 0, 1, n=10) + + self.assertAlmostEqual(integral, .25, 7) # add assertion here + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/algebra/integral/test_integral_simple.py b/tests/algebra/integral/test_integral_simple.py new file mode 100644 index 0000000..f9474c0 --- /dev/null +++ b/tests/algebra/integral/test_integral_simple.py @@ -0,0 +1,35 @@ +from yoshi_otter.algebra.integral.simple import Simple + +import unittest + + +class MyTestCase(unittest.TestCase): + + def setUp(self): + def f(x): + return 2*x + + self.f = f + + def test_class_instantiation(self): + Simple(self.f) + + def test_riemann(self): + + simple = Simple(self.f) + + integral = simple.riemann(0, 1) + + self.assertAlmostEqual(integral, 1, 5) + + def test_simpson(self): + + simple = Simple(self.f) + + integral = simple.simpson(0, 1) + + self.assertAlmostEqual(integral, 1, 5) # add assertion here + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/algebra/roots/__init__.py b/tests/algebra/roots/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/algebra/roots/test_roots.py b/tests/algebra/roots/test_roots.py new file mode 100644 index 0000000..fde168d --- /dev/null +++ b/tests/algebra/roots/test_roots.py @@ -0,0 +1,38 @@ +import unittest + +from yoshi_otter.algebra.roots import Roots + + +class TestRoots(unittest.TestCase): + + def setUp(self): + def f(x): + return x + + self.f = f + + def test_class_instantiation(self): + roots = Roots(self.f) + self.assertIsInstance(roots, Roots) + + def test_bissec(self): + roots = Roots(self.f) + result = roots.bissec(-1, 1) + + self.assertAlmostEqual(result, 0, 6) + + def test_newton(self): + roots = Roots(self.f) + result = roots.newton(-1) + + self.assertAlmostEqual(result, 0, 6) + + def test_bissec_newton(self): + roots = Roots(self.f) + result = roots.bissec_newton(-1, 1) + + self.assertAlmostEqual(result, 0, 6) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/algebra/test_algebra.py b/tests/algebra/test_algebra.py new file mode 100644 index 0000000..f7ecad7 --- /dev/null +++ b/tests/algebra/test_algebra.py @@ -0,0 +1,37 @@ +from yoshi_otter.shared import InvalidFunctionSignature +from yoshi_otter import algebra as ot + +import unittest + + +class TestOtterAlgebra(unittest.TestCase): + + def setUp(self): + def f(x): + return 2*x + + def g(x, y): + return x*y + + self.f = f + self.g = g + + def test_class_instantiation(self): + algebra = ot.Algebra(self.f) + self.assertIsInstance(algebra, ot.Algebra) + + def test_derivative(self): + algebra = ot.Algebra(self.f) + derivative = algebra.d(0) + + self.assertEqual(derivative, 2) + + def test_derivative_raises_exception(self): + algebra = ot.Algebra(self.g) + + with self.assertRaises(InvalidFunctionSignature): + algebra.d(0) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/interpolation/__init__.py b/tests/interpolation/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/interpolation/test_interpolation.py b/tests/interpolation/test_interpolation.py new file mode 100644 index 0000000..7c1e57e --- /dev/null +++ b/tests/interpolation/test_interpolation.py @@ -0,0 +1,59 @@ +from yoshi_otter.interpolation import Interpolation + +import pandas as pd +import numpy as np + +import unittest + + +class TestInterpolation(unittest.TestCase): + + def setUp(self) -> None: + def f(x): + return 2 * x + + X = np.linspace(0, 10, num=100) + Y = [f(x) for x in X] + + self.data = pd.DataFrame(data={'X': X, 'Y': Y}) + + def test_class_instantiation(self): + interpolation = Interpolation(self.data) + self.assertIsInstance(interpolation, Interpolation) + + def test_minimums(self): + interpolation = Interpolation(self.data) + func, r2 = interpolation.minimums() + + self.assertEqual(func(1), 2) + + def test_polynomial_vandermonde(self): + interpolation = Interpolation(self.data) + func = interpolation.polynomial.vandermonde() + + self.assertAlmostEqual(func(1), 2) + + @unittest.skip("Temporally not working") + def test_polynomial_lagrange(self): + interpolation = Interpolation(self.data) + result = interpolation.polynomial.lagrange(1) + + self.assertAlmostEqual(result, 2) + + # @unittest.skip("Temporally not working") + def test_polynomial_newton(self): + interpolation = Interpolation(self.data) + result = interpolation.polynomial.newton(1) + + self.assertAlmostEqual(result, 2) + + @unittest.skip("Temporally not working") + def test_polynomial_gregory(self): + interpolation = Interpolation(self.data) + result = interpolation.polynomial.gregory(1) + + self.assertAlmostEqual(result, 2) + + +if __name__ == '__main__': + unittest.main() diff --git a/yoshi-otter1.3.3.tar.xz b/yoshi-otter1.3.3.tar.xz deleted file mode 100644 index efe85e1..0000000 Binary files a/yoshi-otter1.3.3.tar.xz and /dev/null differ diff --git a/yoshi-otter1.3.3/LICENSE b/yoshi-otter1.3.3/LICENSE deleted file mode 100644 index d2c5abe..0000000 --- a/yoshi-otter1.3.3/LICENSE +++ /dev/null @@ -1,278 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) 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 -this service 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 make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. 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. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -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 -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the 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 a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE 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. \ No newline at end of file diff --git a/yoshi-otter1.3.3/Otter/Otter.py b/yoshi-otter1.3.3/Otter/Otter.py deleted file mode 100755 index 6a91ddc..0000000 --- a/yoshi-otter1.3.3/Otter/Otter.py +++ /dev/null @@ -1,515 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. -# -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. -# -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import math -import numpy as np -import pandas as pd -from Seals import process as sl - -class Algebra: - - def __init__(self, function): - self.f = function - self.integral = self.Integral(self.f) - self.roots = self.Roots(self.f) - self.edo = self.Edo(self.f) - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - class Integral: - - def __init__(self,function): - self.f = function - self.simple = self.Simple(function) - self.double = self.Double(function) - - class Simple: - def __init__(self, function): - self.f = function - - def riemann(self,a,b,n=None): - - if n is None: - n = 10**6 - - delta = (b-a)/n - - psi = a - theta = 0 - - while((psi+delta) <= b): - - theta += (self.f(psi) + self.f(psi + delta))/2 - psi += delta - - integral = delta*theta - - return integral - - def simpson(self,a,b,n=None): - - if n is None: - n = 10**6 - - def x(i): - return a + i*h - - h = (b-a)/n - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta = eta + self.f(x(2*psi - 1)) - psi = psi + 1 - - while(kappa <= ((n/2)-1)): - - theta = theta + self.f(x(2*kappa)) - kappa = kappa + 1 - - return (h/3)*( self.f(x(0)) + self.f(x(n)) + 4*eta + 2*theta) - - - class Double: - - def __init__(self,function): - self.f = function - - def riemann(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - kappa = a - psi = c - theta = 0 - - while((psi + dy) < d): - - while((kappa + dx) < b): - - theta = theta + self.f(kappa, psi) - kappa = kappa + dx - - psi = psi + dy - kappa = a - - return theta*(dx)*(dy) - - def simpson(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - - def x(i): - - x = a + i*dx - - return x - - def y(i): - - y = c + i*dy - - return y - - def g(i): - - sigma = 0 - upsilon = 0 - - zeta = 1 - csi = 1 - - while(zeta <= (m/2)): - - sigma += self.f(x(i),y(2*zeta - 1)) - zeta += 1 - - while(csi <= ((m/2)-1)): - - upsilon += self.f(x(i),y(2*csi)) - csi += 1 - - return (dy/3)*( self.f(x(i),y(0)) + self.f(x(i),y(m)) + 4*sigma + 2*upsilon ) - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta += g(2*psi - 1) - psi += 1 - - while(kappa <= ((n/2)-1)): - - theta += g(2*kappa) - kappa += 1 - - return (dx/3)*( g(0) + g(n) + 4*eta + 2*theta) - - class Roots: - - def __init__(self, function=None): - if function is not None: - self.f = function - - def bissec(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - while abs(a-b) > e: - - c = (a+b)/2 - fc = self.f(c) - - if (fa*fc) < 0: - - b = c - - else: - - a = c - fa = fc - - c = (a+b)/2 - - return c - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - def newton(self,a,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - da = self.d(a,e) - b = a - fa/da - - - while abs(a-b) > e: - - b = a - a -= (fa/da) - fa = self.f(a) - da = self.d(a,e) - - return a - - def bissec_newton(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - c = (a+b)/2 # 'c' é a raiz calculada - - while abs(a-b) > 0.1: - - fc = self.f(c) - - if fa*fc < 0: - - b = c - - else: - - a = c - fa = self.f(a) - - c = (a+b)/2 - - fc = self.f(c) - dc = self.d(c,e) - h = c - fc/dc # 'h' é uma variável de controle - - while abs(c-h) > e: - - h = c - c -= (fc/dc) - fc = self.f(c) - dc = self.d(c,e) - - return (c) - - - class Edo: - - def __init__(self, function): - self.F = function - - def euler(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return a + i*dx - - for i in range(n): - - y = y + (self.F(x(i),y))*dx - - return y - - def runge(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - y = y + (dx/2)*(self.F(x(i),y)+self.F(x(i+1),(y+(dx*self.F(x(i),y))))) - - return y - - def adams(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - f0 = self.F(x(i),y) - f1 = self.F(x(i+1),y + dx*self.F(x(i)+(dx/2),y+(dx/2)*self.F(x(i),y))) - f2 = self.F(x(i+2),y + (dx/2)*(3*f1-f0)) - - y += (dx/12)*(5*f2 + 8*f1 - f0) - - return y - -class Interpolation: - """ Data should be organized in two columns: X and Y""" - - def __init__(self, data): - - self.data = data - self.polinomial = self.Polinomial(self.data) - - def minimus(self,x): - - theta = 0 - # somatorio de x - for i in range(self.data.shape[0]): - - theta += self.data.x[i] - - eta = 0 - #somatorio de y - for i in range(self.data.shape[0]): - - eta += self.data.y[i] - - sigma = 0 - #somatorio de xy - for i in range(self.data.shape[0]): - - sigma += self.data.x[i]*self.data.y[i] - - omega = 0 - #somatorio de x^2self.dself.dself.d - for i in range(self.data.shape[0]): - - omega += self.data.x[i]**2 - - - self.a = (self.data.shape[0]*sigma - theta*eta)/(self.data.shape[0]*omega - (theta**2)) - - self.b = (theta*sigma - eta*omega)/((theta**2) - self.data.shape[0]*omega) - - ym = 0 - - for i in range(self.data.shape[0]): - - ym += self.data.y[i]/self.data.shape[0] - - sqreq = 0 - - for i in range(self.data.shape[0]): - - sqreq += ((self.a*self.data.x[i] + self.b) - ym)**2 - - sqtot = 0 - - for i in range(self.data.shape[0]): - - sqtot += (self.data.y[i] - ym)**2 - - self.r2 = sqreq/sqtot - - return self.a*x + self.b - - class Polinomial: - - def __init__(self, data): - self.data = data - - def vandermonde(self, x): - - matrix = np.zeros((self.data.shape[0],self.data.shape[0])) - - for k in range(0, self.data.shape[0]): - - matrix[:,k] = self.data.x[:]**k - - self.A = sl.gauss(np.c_[matrix,self.data[:,1]]) - - y = 0 - - for i in range(0,self.A.shape[0]): - - y += self.A[i]*(x**i) - - return float(y) - - def lagrange(self, x): - - def L(k,x): - - up = down = 1 - - for i in [x for x in range(self.data.x.shape[0]) if x != k]: - up = up*(x - self.data.x[i]) - - for i in [x for x in range(self.data.x.shape[0]) if x != k]: - down = down*(self.data.x[k] - self.data.x[i]) - - return up/down - - y = 0 - - for i in range(self.data.x.shape[0]): - - y += self.data.y[i]*L(i,x) - - return y - - def newton(self,x): - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data.y - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/(self.data.x[(i+1)+j]-self.data.x[j]) - j += 1 - - i += 1 - j = 0 - - def f(x): - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data.x[k]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y - - self.f = f - - return f(x) - - def gregory(self,x): - - h = self.data.x[0] - self.data.x[1] - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data.y - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/((i+1)*h) - j += 1 - - i += 1 - j = 0 - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data.x[k]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y \ No newline at end of file diff --git a/yoshi-otter1.3.3/Otter/__init__.py b/yoshi-otter1.3.3/Otter/__init__.py deleted file mode 100644 index 08ce1fe..0000000 --- a/yoshi-otter1.3.3/Otter/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. - -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. - -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -from .Otter import Algebra as algebra -from .Otter import Interpolation as interpolation \ No newline at end of file diff --git a/yoshi-otter1.3.3/README.md b/yoshi-otter1.3.3/README.md deleted file mode 100644 index 167eb4e..0000000 --- a/yoshi-otter1.3.3/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# Otter - Numeric Calculus - -This python package is made for applied Numeric Calculus of Algebra Functions. It is made with the following objectives in mind: - -* Receive one variable function from user input - -* Receive two variable function from user input - -* Performe derivatives with one variable functions - -* Performe integral with received functions - -* Use methods to proccess the matrices. - -* Find root of functions throw method of bissection and method of newton - -* Solve Diferential Equations throw method of euler and runge - -* Performe Minimus Interpolation and Polinomial Interpolation - -## Syntax - -To initialize a Otter instance linked to functions use the following syntax `otr = Otter.algebra(f)`, where `otr` will be a arbitrary name for the instance and `f` is a function of *one variable*. - -To initialize a Otter instance linked to data and interpolation use the following syntax `otr = Otter.interpolation(data)`, where `otr` will be a arbitrary name for the instance and data will be a *numpy* matrix where the first columns has to contain the values for `x` and the second column contains the values for `y`. - -### Algebra - -Algebra is a Python Class where some of the features described previously are defined as Classes as well, like: `Integral`, `Roots`, `EDO` (diferential equations). - -#### Integral - -To call the class *Integral* append the sufix with lower case in front of the instance like: `otr.integral`. The Integral class has two other class defined inside, `Simple` and `Double`, to call them append the sufix with lower case in front as `otr.integral.simple` or `otr.integral.double`. Then pick between Riemann's Method or Simpson's Method by appending the sufix `riemann` or `simpson` as well. - -After that the syntax will be something like `otr.integral.double.riemann(a,b,c,d,n,m)`, where `a` and `c` will be the first value of the interval of integration respectively in x and y, `b` and `d` will be the last, `n` and `m` will be the number of partitions. - -The syntax for one variable integrations will be `otr.integral.simple.riemann(a,b,n)`. - -If `n` is not defined the standart value in 10^6 partitions for one variable and 10^4 for double. And if `m` is not defined the standart value will be equal to `n`. - -#### Roots - -To call the class *Root* append the sufix with lower case in front of the instance like: `otr.roots`. The Roots class has three methods defined inside, `bissec`, `newton` and `bissec_newton`, to call them append the sufix with lower case in front as `otr.roots.bissec` or `otr.roots.newton` or even `otr.roots.bissecnewton`. - -The syntax for the bissection method and bissec_newton is equal to `otr.roots.bissec(a,b,e)` and `otr.roots.bissec_newton(a,b,e)`, where `a` is the first element of the interval containing the root and `b` is the last, `e` being the precision. - -The syntax for the newton method is equal to `otr.roots.newton(a,e)`, where `a` is the element closest to the root and `e` is the precision. - -If `e` is not defined the standart value is 10^(-6). - -#### Diferential Equations - -To call the class *EDO* (*E*quações *D*iferenciais *O*rdinárias) append the sufix with lower case in front of the instance like: `otr.edo`. The *EDO* class has two methods defined inside: `euler` and `runge`, to call them append the sufix with lower case in front as `otr.edo.euler` or `otr.edo.runge`. - -The syntax for the diferential equations method is equal to `otr.edo.euler(a,y,b,n)` or `otr.edo.runge(a,y,b,n)`, where `a` and `y` will be the inintial point and `b` is the value in *x* which you want to know the corresponding value in *y* and `n` is the number of operations. - -If `n` is not defined the standart value is 10^7. - -### Interpolation - -The python class *Interpolation* is divided in one method, minimus interpolation, and one class, polinomial interpolation. - -To call the method *minimus* use a syntax like `otr = Otter.interpolation(data)`, where `data` is a data frame containing values for *x* and *y*, `otr` is an instance and append the method in front of the instance like: `otr.minimus(x)`, where *x* is value of *f(x)* you want to estimate. - -To call the class *Polinomial* append the sufix with lower case in front of the instance like: `otr.polinomial`. The *Polinomial* class has four methods defined inside: `vandermonde`, `lagrange`, `newton` and `gregory`, to call them append the sufix with lower case in front like `otr.edo.gregory(x)` where *x* is value of *f(x)* you want to estimate. - -## Installation - -To install the package from source `cd` into the directory and run: - -`pip install .` - -or run - -`pip install yoshi-otter` diff --git a/yoshi-otter1.3.3/build/lib/Otter/Otter.py b/yoshi-otter1.3.3/build/lib/Otter/Otter.py deleted file mode 100644 index 6a91ddc..0000000 --- a/yoshi-otter1.3.3/build/lib/Otter/Otter.py +++ /dev/null @@ -1,515 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. -# -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. -# -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import math -import numpy as np -import pandas as pd -from Seals import process as sl - -class Algebra: - - def __init__(self, function): - self.f = function - self.integral = self.Integral(self.f) - self.roots = self.Roots(self.f) - self.edo = self.Edo(self.f) - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - class Integral: - - def __init__(self,function): - self.f = function - self.simple = self.Simple(function) - self.double = self.Double(function) - - class Simple: - def __init__(self, function): - self.f = function - - def riemann(self,a,b,n=None): - - if n is None: - n = 10**6 - - delta = (b-a)/n - - psi = a - theta = 0 - - while((psi+delta) <= b): - - theta += (self.f(psi) + self.f(psi + delta))/2 - psi += delta - - integral = delta*theta - - return integral - - def simpson(self,a,b,n=None): - - if n is None: - n = 10**6 - - def x(i): - return a + i*h - - h = (b-a)/n - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta = eta + self.f(x(2*psi - 1)) - psi = psi + 1 - - while(kappa <= ((n/2)-1)): - - theta = theta + self.f(x(2*kappa)) - kappa = kappa + 1 - - return (h/3)*( self.f(x(0)) + self.f(x(n)) + 4*eta + 2*theta) - - - class Double: - - def __init__(self,function): - self.f = function - - def riemann(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - kappa = a - psi = c - theta = 0 - - while((psi + dy) < d): - - while((kappa + dx) < b): - - theta = theta + self.f(kappa, psi) - kappa = kappa + dx - - psi = psi + dy - kappa = a - - return theta*(dx)*(dy) - - def simpson(self,a,b,c,d,n=None,m=None): - - if n is None: - n = 10**4 - - if m is None: - m = n - - dx = (b-a)/n - dy = (d-c)/m - - def x(i): - - x = a + i*dx - - return x - - def y(i): - - y = c + i*dy - - return y - - def g(i): - - sigma = 0 - upsilon = 0 - - zeta = 1 - csi = 1 - - while(zeta <= (m/2)): - - sigma += self.f(x(i),y(2*zeta - 1)) - zeta += 1 - - while(csi <= ((m/2)-1)): - - upsilon += self.f(x(i),y(2*csi)) - csi += 1 - - return (dy/3)*( self.f(x(i),y(0)) + self.f(x(i),y(m)) + 4*sigma + 2*upsilon ) - - eta = 0 - theta = 0 - - psi = 1 - kappa = 1 - - while(psi <= (n/2)): - - eta += g(2*psi - 1) - psi += 1 - - while(kappa <= ((n/2)-1)): - - theta += g(2*kappa) - kappa += 1 - - return (dx/3)*( g(0) + g(n) + 4*eta + 2*theta) - - class Roots: - - def __init__(self, function=None): - if function is not None: - self.f = function - - def bissec(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - while abs(a-b) > e: - - c = (a+b)/2 - fc = self.f(c) - - if (fa*fc) < 0: - - b = c - - else: - - a = c - fa = fc - - c = (a+b)/2 - - return c - - def d(self, x, e): - return (self.f(x + e) - self.f(x - e))/(2*e) - - def newton(self,a,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - da = self.d(a,e) - b = a - fa/da - - - while abs(a-b) > e: - - b = a - a -= (fa/da) - fa = self.f(a) - da = self.d(a,e) - - return a - - def bissec_newton(self,a,b,e=None): - - if e is None: - e = 10**(-6) - - fa = self.f(a) - - c = (a+b)/2 # 'c' é a raiz calculada - - while abs(a-b) > 0.1: - - fc = self.f(c) - - if fa*fc < 0: - - b = c - - else: - - a = c - fa = self.f(a) - - c = (a+b)/2 - - fc = self.f(c) - dc = self.d(c,e) - h = c - fc/dc # 'h' é uma variável de controle - - while abs(c-h) > e: - - h = c - c -= (fc/dc) - fc = self.f(c) - dc = self.d(c,e) - - return (c) - - - class Edo: - - def __init__(self, function): - self.F = function - - def euler(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return a + i*dx - - for i in range(n): - - y = y + (self.F(x(i),y))*dx - - return y - - def runge(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - y = y + (dx/2)*(self.F(x(i),y)+self.F(x(i+1),(y+(dx*self.F(x(i),y))))) - - return y - - def adams(self,a,y,b,n=None): - - if n is None: - n = 10**6 - - dx = (b-a)/n - - def x(i): - return (a + i*dx) - - for i in range(n): - - f0 = self.F(x(i),y) - f1 = self.F(x(i+1),y + dx*self.F(x(i)+(dx/2),y+(dx/2)*self.F(x(i),y))) - f2 = self.F(x(i+2),y + (dx/2)*(3*f1-f0)) - - y += (dx/12)*(5*f2 + 8*f1 - f0) - - return y - -class Interpolation: - """ Data should be organized in two columns: X and Y""" - - def __init__(self, data): - - self.data = data - self.polinomial = self.Polinomial(self.data) - - def minimus(self,x): - - theta = 0 - # somatorio de x - for i in range(self.data.shape[0]): - - theta += self.data.x[i] - - eta = 0 - #somatorio de y - for i in range(self.data.shape[0]): - - eta += self.data.y[i] - - sigma = 0 - #somatorio de xy - for i in range(self.data.shape[0]): - - sigma += self.data.x[i]*self.data.y[i] - - omega = 0 - #somatorio de x^2self.dself.dself.d - for i in range(self.data.shape[0]): - - omega += self.data.x[i]**2 - - - self.a = (self.data.shape[0]*sigma - theta*eta)/(self.data.shape[0]*omega - (theta**2)) - - self.b = (theta*sigma - eta*omega)/((theta**2) - self.data.shape[0]*omega) - - ym = 0 - - for i in range(self.data.shape[0]): - - ym += self.data.y[i]/self.data.shape[0] - - sqreq = 0 - - for i in range(self.data.shape[0]): - - sqreq += ((self.a*self.data.x[i] + self.b) - ym)**2 - - sqtot = 0 - - for i in range(self.data.shape[0]): - - sqtot += (self.data.y[i] - ym)**2 - - self.r2 = sqreq/sqtot - - return self.a*x + self.b - - class Polinomial: - - def __init__(self, data): - self.data = data - - def vandermonde(self, x): - - matrix = np.zeros((self.data.shape[0],self.data.shape[0])) - - for k in range(0, self.data.shape[0]): - - matrix[:,k] = self.data.x[:]**k - - self.A = sl.gauss(np.c_[matrix,self.data[:,1]]) - - y = 0 - - for i in range(0,self.A.shape[0]): - - y += self.A[i]*(x**i) - - return float(y) - - def lagrange(self, x): - - def L(k,x): - - up = down = 1 - - for i in [x for x in range(self.data.x.shape[0]) if x != k]: - up = up*(x - self.data.x[i]) - - for i in [x for x in range(self.data.x.shape[0]) if x != k]: - down = down*(self.data.x[k] - self.data.x[i]) - - return up/down - - y = 0 - - for i in range(self.data.x.shape[0]): - - y += self.data.y[i]*L(i,x) - - return y - - def newton(self,x): - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data.y - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/(self.data.x[(i+1)+j]-self.data.x[j]) - j += 1 - - i += 1 - j = 0 - - def f(x): - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data.x[k]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y - - self.f = f - - return f(x) - - def gregory(self,x): - - h = self.data.x[0] - self.data.x[1] - - d = np.array(np.zeros((self.data.shape[0],self.data.shape[0]))) - - d[0] = self.data.y - - i = j = 0 - - while (i < self.data.shape[0]): - - while (j < (self.data.shape[0]-(i+1))): - - d[i+1][j] = (d[i][j+1] - d[i][j])/((i+1)*h) - j += 1 - - i += 1 - j = 0 - - y = d[0][0] - i = 0 - - while ((i+1) < self.data.shape[0]): - - mult = 1 - k = 0 - while (k <= i): - mult = mult*(x - self.data.x[k]) - k += 1 - - y += d[i+1][0]*mult - i += 1 - - return y \ No newline at end of file diff --git a/yoshi-otter1.3.3/build/lib/Otter/__init__.py b/yoshi-otter1.3.3/build/lib/Otter/__init__.py deleted file mode 100644 index 08ce1fe..0000000 --- a/yoshi-otter1.3.3/build/lib/Otter/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# Otter - Program made for educational intent, can be freely distributed -# and can be used for economical intent. I will not take legal actions -# unless my intelectual propperty, the code, is stolen or change without permission. - -# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published by -# the Free Software Foundation. - -# 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, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -from .Otter import Algebra as algebra -from .Otter import Interpolation as interpolation \ No newline at end of file diff --git a/yoshi-otter1.3.3/dist/yoshi-otter-1.3.3.tar.gz b/yoshi-otter1.3.3/dist/yoshi-otter-1.3.3.tar.gz deleted file mode 100644 index 1c8cb11..0000000 Binary files a/yoshi-otter1.3.3/dist/yoshi-otter-1.3.3.tar.gz and /dev/null differ diff --git a/yoshi-otter1.3.3/dist/yoshi_otter-1.3.3-py3-none-any.whl b/yoshi-otter1.3.3/dist/yoshi_otter-1.3.3-py3-none-any.whl deleted file mode 100644 index 21ea7fc..0000000 Binary files a/yoshi-otter1.3.3/dist/yoshi_otter-1.3.3-py3-none-any.whl and /dev/null differ diff --git a/yoshi-otter1.3.3/setup.py b/yoshi-otter1.3.3/setup.py deleted file mode 100644 index 6c02dea..0000000 --- a/yoshi-otter1.3.3/setup.py +++ /dev/null @@ -1,28 +0,0 @@ -import setuptools - -with open("README.md", "r") as fh: - long_description = fh.read() - -setuptools.setup( - name="yoshi-otter", # Replace with your own username - version="1.3.3", - author="Vitor Hideyoshi", - author_email="vitor.h.n.batista@gmail.com", - description="Numeric Calculus python module in the topic of Algebra Functions", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/HideyoshiNakazone/Otter-NumericCalculus.git", - packages=setuptools.find_packages(), - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", - "Operating System :: OS Independent", - "Development Status :: 2 - Pre-Alpha", - ], - python_requires='>=3.6', - install_requires=[ - 'numpy', - 'pandas', - 'yoshi-seals' - ], -) \ No newline at end of file diff --git a/yoshi-otter1.3.3/yoshi_otter.egg-info/PKG-INFO b/yoshi-otter1.3.3/yoshi_otter.egg-info/PKG-INFO deleted file mode 100644 index 36a6cec..0000000 --- a/yoshi-otter1.3.3/yoshi_otter.egg-info/PKG-INFO +++ /dev/null @@ -1,91 +0,0 @@ -Metadata-Version: 2.1 -Name: yoshi-otter -Version: 1.3.3 -Summary: Numeric Calculus python module in the topic of Algebra Functions -Home-page: https://github.com/HideyoshiNakazone/Otter-NumericCalculus.git -Author: Vitor Hideyoshi -Author-email: vitor.h.n.batista@gmail.com -License: UNKNOWN -Description: # Otter - Numeric Calculus - - This python package is made for applied Numeric Calculus of Algebra Functions. It is made with the following objectives in mind: - - * Receive one variable function from user input - - * Receive two variable function from user input - - * Performe derivatives with one variable functions - - * Performe integral with received functions - - * Use methods to proccess the matrices. - - * Find root of functions throw method of bissection and method of newton - - * Solve Diferential Equations throw method of euler and runge - - * Performe Minimus Interpolation and Polinomial Interpolation - - ## Syntax - - To initialize a Otter instance linked to functions use the following syntax `otr = Otter.algebra(f)`, where `otr` will be a arbitrary name for the instance and `f` is a function of *one variable*. - - To initialize a Otter instance linked to data and interpolation use the following syntax `otr = Otter.interpolation(data)`, where `otr` will be a arbitrary name for the instance and data will be a *numpy* matrix where the first columns has to contain the values for `x` and the second column contains the values for `y`. - - ### Algebra - - Algebra is a Python Class where some of the features described previously are defined as Classes as well, like: `Integral`, `Roots`, `EDO` (diferential equations). - - #### Integral - - To call the class *Integral* append the sufix with lower case in front of the instance like: `otr.integral`. The Integral class has two other class defined inside, `Simple` and `Double`, to call them append the sufix with lower case in front as `otr.integral.simple` or `otr.integral.double`. Then pick between Riemann's Method or Simpson's Method by appending the sufix `riemann` or `simpson` as well. - - After that the syntax will be something like `otr.integral.double.riemann(a,b,c,d,n,m)`, where `a` and `c` will be the first value of the interval of integration respectively in x and y, `b` and `d` will be the last, `n` and `m` will be the number of partitions. - - The syntax for one variable integrations will be `otr.integral.simple.riemann(a,b,n)`. - - If `n` is not defined the standart value in 10^6 partitions for one variable and 10^4 for double. And if `m` is not defined the standart value will be equal to `n`. - - #### Roots - - To call the class *Root* append the sufix with lower case in front of the instance like: `otr.roots`. The Roots class has three methods defined inside, `bissec`, `newton` and `bissec_newton`, to call them append the sufix with lower case in front as `otr.roots.bissec` or `otr.roots.newton` or even `otr.roots.bissecnewton`. - - The syntax for the bissection method and bissec_newton is equal to `otr.roots.bissec(a,b,e)` and `otr.roots.bissec_newton(a,b,e)`, where `a` is the first element of the interval containing the root and `b` is the last, `e` being the precision. - - The syntax for the newton method is equal to `otr.roots.newton(a,e)`, where `a` is the element closest to the root and `e` is the precision. - - If `e` is not defined the standart value is 10^(-6). - - #### Diferential Equations - - To call the class *EDO* (*E*quações *D*iferenciais *O*rdinárias) append the sufix with lower case in front of the instance like: `otr.edo`. The *EDO* class has two methods defined inside: `euler` and `runge`, to call them append the sufix with lower case in front as `otr.edo.euler` or `otr.edo.runge`. - - The syntax for the diferential equations method is equal to `otr.edo.euler(a,y,b,n)` or `otr.edo.runge(a,y,b,n)`, where `a` and `y` will be the inintial point and `b` is the value in *x* which you want to know the corresponding value in *y* and `n` is the number of operations. - - If `n` is not defined the standart value is 10^7. - - ### Interpolation - - The python class *Interpolation* is divided in one method, minimus interpolation, and one class, polinomial interpolation. - - To call the method *minimus* use a syntax like `otr = Otter.interpolation(data)`, where `data` is a data frame containing values for *x* and *y*, `otr` is an instance and append the method in front of the instance like: `otr.minimus(x)`, where *x* is value of *f(x)* you want to estimate. - - To call the class *Polinomial* append the sufix with lower case in front of the instance like: `otr.polinomial`. The *Polinomial* class has four methods defined inside: `vandermonde`, `lagrange`, `newton` and `gregory`, to call them append the sufix with lower case in front like `otr.edo.gregory(x)` where *x* is value of *f(x)* you want to estimate. - - ## Installation - - To install the package from source `cd` into the directory and run: - - `pip install .` - - or run - - `pip install yoshi-otter` - -Platform: UNKNOWN -Classifier: Programming Language :: Python :: 3 -Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2) -Classifier: Operating System :: OS Independent -Classifier: Development Status :: 2 - Pre-Alpha -Requires-Python: >=3.6 -Description-Content-Type: text/markdown diff --git a/yoshi-otter1.3.3/yoshi_otter.egg-info/SOURCES.txt b/yoshi-otter1.3.3/yoshi_otter.egg-info/SOURCES.txt deleted file mode 100644 index 5dc205c..0000000 --- a/yoshi-otter1.3.3/yoshi_otter.egg-info/SOURCES.txt +++ /dev/null @@ -1,9 +0,0 @@ -README.md -setup.py -Otter/Otter.py -Otter/__init__.py -yoshi_otter.egg-info/PKG-INFO -yoshi_otter.egg-info/SOURCES.txt -yoshi_otter.egg-info/dependency_links.txt -yoshi_otter.egg-info/requires.txt -yoshi_otter.egg-info/top_level.txt \ No newline at end of file diff --git a/yoshi-otter1.3.3/yoshi_otter.egg-info/dependency_links.txt b/yoshi-otter1.3.3/yoshi_otter.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/yoshi-otter1.3.3/yoshi_otter.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yoshi-otter1.3.3/yoshi_otter.egg-info/requires.txt b/yoshi-otter1.3.3/yoshi_otter.egg-info/requires.txt deleted file mode 100644 index 11c1c26..0000000 --- a/yoshi-otter1.3.3/yoshi_otter.egg-info/requires.txt +++ /dev/null @@ -1,3 +0,0 @@ -numpy -pandas -yoshi-seals diff --git a/yoshi-otter1.3.3/yoshi_otter.egg-info/top_level.txt b/yoshi-otter1.3.3/yoshi_otter.egg-info/top_level.txt deleted file mode 100644 index ccaaf54..0000000 --- a/yoshi-otter1.3.3/yoshi_otter.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -Otter diff --git a/Older Versions/yoshi-otter1.3.1/build/lib/Otter/__init__.py b/yoshi_otter/__init__.py similarity index 90% rename from Older Versions/yoshi-otter1.3.1/build/lib/Otter/__init__.py rename to yoshi_otter/__init__.py index 08ce1fe..6d942f2 100644 --- a/Older Versions/yoshi-otter1.3.1/build/lib/Otter/__init__.py +++ b/yoshi_otter/__init__.py @@ -17,5 +17,5 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -from .Otter import Algebra as algebra -from .Otter import Interpolation as interpolation \ No newline at end of file +from yoshi_otter.algebra import Algebra +from yoshi_otter.interpolation import Interpolation diff --git a/yoshi_otter/algebra/__algebra.py b/yoshi_otter/algebra/__algebra.py new file mode 100644 index 0000000..9f81ae1 --- /dev/null +++ b/yoshi_otter/algebra/__algebra.py @@ -0,0 +1,52 @@ +# Otter - Program made for educational intent, can be freely distributed +# and can be used for economical intent. I will not take legal actions +# unless my intelectual propperty, the code, is stolen or change without permission. +# +# Copyright (C) 2020 VItor Hideyoshi Nakazone Batista +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# 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, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +from yoshi_otter.algebra.integral.double import Double +from yoshi_otter.algebra.integral.simple import Simple +from yoshi_otter.algebra.roots import Roots +from yoshi_otter.algebra.edo import Edo + +from typing import Callable, Union +from inspect import signature + +from yoshi_otter.shared import InvalidFunctionSignature + + +class Algebra: + + def __init__(self, function: Callable[[float], float] | Callable[[float, float], float]) -> None: + self.f = function + + self.integral = self.__Integral(self.f) + self.roots = Roots(self.f) + self.edo = Edo(self.f) + + def d(self, x: float, e: float = 10 ** -4) -> float: + if len(signature(self.f).parameters) == 1: + return (self.f(x + e) - self.f(x - e)) / (2 * e) + else: + raise InvalidFunctionSignature("This method is only valid for one dimensional functions.") + + class __Integral: + + def __init__(self, function: Union[Callable[[float], float], Callable[[float, float], float]]) -> None: + self.f = function + + self.simple = Simple(self.f) + self.double = Double(self.f) diff --git a/yoshi_otter/algebra/__init__.py b/yoshi_otter/algebra/__init__.py new file mode 100644 index 0000000..a0f9bb4 --- /dev/null +++ b/yoshi_otter/algebra/__init__.py @@ -0,0 +1 @@ +from .__algebra import Algebra \ No newline at end of file diff --git a/yoshi_otter/algebra/edo/__edo.py b/yoshi_otter/algebra/edo/__edo.py new file mode 100644 index 0000000..f33ecb4 --- /dev/null +++ b/yoshi_otter/algebra/edo/__edo.py @@ -0,0 +1,51 @@ +from typing import Callable + + +class Edo: + + def __init__(self, function: Callable[[float], float]) -> None: + self.F = function + + def euler(self, a: float, y: float, b: float, n: int = 10**6) -> float: + + dx = (b - a) / n + + def x(i): + return a + i * dx + + for i in range(n): + y = y + (self.F(x(i), y)) * dx + + return y + + def runge(self, a: float, y: float, b: float, n: int = 10**6) -> float: + + dx = (b - a) / n + + def x(i): + return a + i * dx + + for i in range(n): + y = y + (dx / 2) * (self.F(x(i), y) + self.F(x(i + 1), (y + (dx * self.F(x(i), y))))) + + return y + + def adams(self, a: float, y: float, b: float, n: int = None + ) -> float: + + if n is None: + n = 10 ** 6 + + dx = (b - a) / n + + def x(i): + return a + i * dx + + for i in range(n): + f0 = self.F(x(i), y) + f1 = self.F(x(i + 1), y + dx * self.F(x(i) + (dx / 2), y + (dx / 2) * self.F(x(i), y))) + f2 = self.F(x(i + 2), y + (dx / 2) * (3 * f1 - f0)) + + y += (dx / 12) * (5 * f2 + 8 * f1 - f0) + + return y \ No newline at end of file diff --git a/yoshi_otter/algebra/edo/__init__.py b/yoshi_otter/algebra/edo/__init__.py new file mode 100644 index 0000000..5efeb11 --- /dev/null +++ b/yoshi_otter/algebra/edo/__init__.py @@ -0,0 +1 @@ +from .__edo import Edo diff --git a/yoshi_otter/algebra/integral/__init__.py b/yoshi_otter/algebra/integral/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/yoshi_otter/algebra/integral/double.py b/yoshi_otter/algebra/integral/double.py new file mode 100644 index 0000000..ddcd89c --- /dev/null +++ b/yoshi_otter/algebra/integral/double.py @@ -0,0 +1,79 @@ +from typing import Callable + + +class Double: + + def __init__(self, function: Callable[[float, float], float]): + self.f = function + + def riemann(self, a: float, b: float, c: float, d: float, + n: int = 10 ** 4, m: int = None) -> float: + + if m is None: + m = n + + dx = (b - a) / n + dy = (d - c) / m + kappa = a + psi = c + theta = 0 + + while (psi + dy) < d: + + while (kappa + dx) < b: + theta = theta + self.f(kappa, psi) + kappa = kappa + dx + + psi = psi + dy + kappa = a + + return theta * dx * dy + + def simpson(self, a: float, b: float, c: float, d: float, + n: int = 10 ** 4, m: int = None) -> float: + + if m is None: + m = n + + dx = (b - a) / n + dy = (d - c) / m + + def x(i): + return a + i * dx + + def y(i): + return c + i * dy + + def g(i): + + sigma = 0 + upsilon = 0 + + zeta = 1 + csi = 1 + + while zeta <= (m / 2): + sigma += self.f(x(i), y(2 * zeta - 1)) + zeta += 1 + + while csi <= ((m / 2) - 1): + upsilon += self.f(x(i), y(2 * csi)) + csi += 1 + + return (dy / 3) * (self.f(x(i), y(0)) + self.f(x(i), y(m)) + 4 * sigma + 2 * upsilon) + + eta = 0 + theta = 0 + + psi = 1 + kappa = 1 + + while psi <= (n / 2): + eta += g(2 * psi - 1) + psi += 1 + + while kappa <= ((n / 2) - 1): + theta += g(2 * kappa) + kappa += 1 + + return (dx / 3) * (g(0) + g(n) + 4 * eta + 2 * theta) diff --git a/yoshi_otter/algebra/integral/simple.py b/yoshi_otter/algebra/integral/simple.py new file mode 100644 index 0000000..239916b --- /dev/null +++ b/yoshi_otter/algebra/integral/simple.py @@ -0,0 +1,44 @@ +from typing import Callable + + +class Simple: + def __init__(self, function: Callable[[float], float]) -> None: + self.f = function + + def riemann(self, a: float, b: float, n: int = 10 ** 6) -> float: + + delta = (b - a) / n + + psi = a + theta = 0 + + while (psi + delta) <= b: + theta += (self.f(psi) + self.f(psi + delta)) / 2 + psi += delta + + integral = delta * theta + + return integral + + def simpson(self, a: float, b: float, n: int = 10 ** 6) -> float: + + def x(i): + return a + i * h + + h = (b - a) / n + + eta = 0 + theta = 0 + + psi = 1 + kappa = 1 + + while psi <= (n / 2): + eta = eta + self.f(x(2 * psi - 1)) + psi = psi + 1 + + while kappa <= ((n / 2) - 1): + theta = theta + self.f(x(2 * kappa)) + kappa = kappa + 1 + + return (h / 3) * (self.f(x(0)) + self.f(x(n)) + 4 * eta + 2 * theta) \ No newline at end of file diff --git a/yoshi_otter/algebra/roots/__init__.py b/yoshi_otter/algebra/roots/__init__.py new file mode 100644 index 0000000..2a2e986 --- /dev/null +++ b/yoshi_otter/algebra/roots/__init__.py @@ -0,0 +1 @@ +from .__roots import Roots diff --git a/yoshi_otter/algebra/roots/__roots.py b/yoshi_otter/algebra/roots/__roots.py new file mode 100644 index 0000000..3570be8 --- /dev/null +++ b/yoshi_otter/algebra/roots/__roots.py @@ -0,0 +1,80 @@ +from typing import Callable + + +class Roots: + + def __init__(self, function: Callable[[float], float] = None + ) -> float: + if function is not None: + self.f = function + + def bissec(self, a: float, b: float, e: float = 10**-6) -> float: + + fa = self.f(a) + + while abs(a - b) > e: + + c = (a + b) / 2 + fc = self.f(c) + + if (fa * fc) < 0: + + b = c + + else: + + a = c + + c = (a + b) / 2 + + return c + + def __d(self, x: float, e: float) -> float: + return (self.f(x + e) - self.f(x - e)) / (2 * e) + + def newton(self, a: float, e: float = 10**-6) -> float: + + fa = self.f(a) + da = self.__d(a, e) + b = a - fa / da + + while abs(a - b) > e: + b = a + a -= (fa / da) + fa = self.f(a) + da = self.__d(a, e) + + return a + + def bissec_newton(self, a: float, b: float, e: float = 10**-6) -> float: + + fa = self.f(a) + + c = (a + b) / 2 # 'c' é a raiz calculada + + while abs(a - b) > 0.1: + + fc = self.f(c) + + if fa * fc < 0: + + b = c + + else: + + a = c + fa = self.f(a) + + c = (a + b) / 2 + + fc = self.f(c) + dc = self.__d(c, e) + h = c - fc / dc # 'h' é uma variável de controle + + while abs(c - h) > e: + h = c + c -= (fc / dc) + fc = self.f(c) + dc = self.__d(c, e) + + return c \ No newline at end of file diff --git a/yoshi_otter/interpolation/__init__.py b/yoshi_otter/interpolation/__init__.py new file mode 100644 index 0000000..c97c3ef --- /dev/null +++ b/yoshi_otter/interpolation/__init__.py @@ -0,0 +1 @@ +from .__interpolation import Interpolation diff --git a/yoshi_otter/interpolation/__interpolation.py b/yoshi_otter/interpolation/__interpolation.py new file mode 100644 index 0000000..f8e4a6f --- /dev/null +++ b/yoshi_otter/interpolation/__interpolation.py @@ -0,0 +1,178 @@ +from yoshi_seals import process as sl +from typing import Callable, Any +import numpy as np + + +class Interpolation: + """ + Data should be organized in a dataframe of two columns: X and Y + """ + + def __init__(self, data) -> None: + + self.data = data + self.polynomial = self.__Polynomial(self.data) + + def minimums(self) -> Callable[[Any], float]: + + theta = 0 + # somatorio de x + for i in range(self.data.shape[0]): + theta += self.data.X[i] + + eta = 0 + # somatorio de y + for i in range(self.data.shape[0]): + eta += self.data.Y[i] + + sigma = 0 + # somatorio de xy + for i in range(self.data.shape[0]): + sigma += self.data.X[i] * self.data.Y[i] + + omega = 0 + # somatorio de x^2self.dself.dself.d + for i in range(self.data.shape[0]): + omega += self.data.X[i] ** 2 + + a = (self.data.shape[0] * sigma - theta * eta) / (self.data.shape[0] * omega - (theta ** 2)) + + b = (theta * sigma - eta * omega) / ((theta ** 2) - self.data.shape[0] * omega) + + ym = 0 + + for i in range(self.data.shape[0]): + ym += self.data.Y[i] / self.data.shape[0] + + sqreq = 0 + + for i in range(self.data.shape[0]): + sqreq += ((a * self.data.X[i] + b) - ym) ** 2 + + sqtot = 0 + + for i in range(self.data.shape[0]): + sqtot += (self.data.Y[i] - ym) ** 2 + + r2 = sqreq / sqtot + + return lambda x: a * x + b, r2 + + class __Polynomial: + + def __init__(self, data) -> None: + self.data = data + + def vandermonde(self) -> Callable[[Any], float]: + + matrix = np.zeros((self.data.shape[0], self.data.shape[0])) + + for k in range(self.data.shape[0]): + matrix[:, k] = self.data.X[:].copy() ** k + + array = np.array(self.data.Y.tolist()).reshape(self.data.shape[0], 1) + coefficient_matrix = sl.gauss(matrix, array)[:] + + def __f(coefficients, x): + y = 0 + for i in range(0, coefficients.shape[0]): + y += float(coefficients[i]) * (x ** i) + + return y + + return lambda x: __f(coefficient_matrix, x) + + def lagrange(self, x: float) -> float: + + def L(k, x): + + up = 1 + down = 1 + + for i in [x for x in range(self.data.X.shape[0]) if x != k]: + up = up * (x - self.data.X[i]) + + for i in [x for x in range(self.data.X.shape[0]) if x != k]: + down = down * (self.data.X[k] - self.data.X[i]) + + return up / down + + y = 0 + + for i in range(self.data.X.shape[0]): + y += self.data.Y[i] * L(i, x) + + return y + + def newton(self, x: float) -> float: + + d = np.array(np.zeros((self.data.shape[0], self.data.shape[0]))) + + d[0] = self.data.Y + + i = j = 0 + + while i < self.data.shape[0]: + + while j < (self.data.shape[0] - (i + 1)): + d[i + 1][j] = (d[i][j + 1] - d[i][j]) / (self.data.X[(i + 1) + j] - self.data.X[j]) + j += 1 + + i += 1 + j = 0 + + def f(x): + + y = d[0][0] + i = 0 + + while (i + 1) < self.data.shape[0]: + + mult = 1 + k = 0 + while k <= i: + mult = mult * (x - self.data.X[k]) + k += 1 + + y += d[i + 1][0] * mult + i += 1 + + return y + + self.f = f + + return f(x) + + def gregory(self, x: float) -> float: + + h = self.data.X[0] - self.data.X[1] + + d = np.array(np.zeros((self.data.shape[0], self.data.shape[0]))) + + d[0] = self.data.Y + + i = 0 + while i < self.data.shape[0]: + + j = 0 + while j < (self.data.shape[0] - (i + 1)): + d[i + 1][j] = (d[i][j + 1] - d[i][j]) / ((i + 1) * h) + j += 1 + + i += 1 + + y = d[0][0] + + i = 0 + while (i + 1) < self.data.shape[0]: + mult = 1 + k = 0 + + while k <= i: + mult = mult * (x - self.data.X[k]) + k += 1 + + y += d[i + 1][0] * mult + i += 1 + + return -y diff --git a/yoshi_otter/shared/__init__.py b/yoshi_otter/shared/__init__.py new file mode 100644 index 0000000..b8fa735 --- /dev/null +++ b/yoshi_otter/shared/__init__.py @@ -0,0 +1 @@ +from .invalid_function_signature import InvalidFunctionSignature diff --git a/yoshi_otter/shared/invalid_function_signature.py b/yoshi_otter/shared/invalid_function_signature.py new file mode 100644 index 0000000..168a568 --- /dev/null +++ b/yoshi_otter/shared/invalid_function_signature.py @@ -0,0 +1,2 @@ +class InvalidFunctionSignature(Exception): + pass \ No newline at end of file