All Projects → taketo1024 → Swiftymath

taketo1024 / Swiftymath

Licence: mit
Pure Math in Pure Swift.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Swiftymath

swm-core
Pure Math in Pure Swift.
Stars: ✭ 190 (+4.4%)
Mutual labels:  topology, algebra, mathematics
Mather
zzllrr mather(an offline tool for Math learning, education and research)小乐数学,离线可用的数学学习(自学或教学)、研究辅助工具。计划覆盖数学全部学科的解题、作图、演示、探索工具箱。目前是演示Demo版(抛转引玉),但已经支持数学公式编辑显示,部分作图功能,部分学科,如线性代数、离散数学的部分解题功能。最终目标是推动专业数学家、编程专家、教育工作者、科普工作者共同打造出更加专业级的Mather数学工具
Stars: ✭ 270 (+48.35%)
Mutual labels:  topology, mathematics, algebra
manifolds
Coordinate-free hypersurfaces as Haskell types
Stars: ✭ 37 (-79.67%)
Mutual labels:  topology, mathematics
Math Php
Powerful modern math library for PHP: Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra
Stars: ✭ 2,009 (+1003.85%)
Mutual labels:  mathematics, algebra
Awesome-Math-Learning
📜 Collection of the most awesome Math learning resources in the form of notes, videos and cheatsheets.
Stars: ✭ 73 (-59.89%)
Mutual labels:  topology, mathematics
Mathematics for Machine Learning
Learn mathematics behind machine learning and explore different mathematics in machine learning.
Stars: ✭ 28 (-84.62%)
Mutual labels:  algebra, mathematics
Euler
The open-source computational framework for the Swift language
Stars: ✭ 37 (-79.67%)
Mutual labels:  algebra, mathematics
Cmathtuts
trying to collect all useful tutorials for famous C math and linear algebra libraries such as CBLAS, CLAPACK, GSL...
Stars: ✭ 266 (+46.15%)
Mutual labels:  mathematics, algebra
Grassmann.jl
⟨Leibniz-Grassmann-Clifford⟩ differential geometric algebra / multivector simplicial complex
Stars: ✭ 289 (+58.79%)
Mutual labels:  topology, algebra
Basic Mathematics For Machine Learning
The motive behind Creating this repo is to feel the fear of mathematics and do what ever you want to do in Machine Learning , Deep Learning and other fields of AI
Stars: ✭ 300 (+64.84%)
Mutual labels:  mathematics, algebra
Rings
Rings: efficient JVM library for polynomial rings
Stars: ✭ 50 (-72.53%)
Mutual labels:  mathematics, algebra
Gap
Main development repository for GAP - Groups, Algorithms, Programming, a System for Computational Discrete Algebra
Stars: ✭ 447 (+145.6%)
Mutual labels:  mathematics, algebra
Numbas
A completely browser-based e-assessment/e-learning system, with an emphasis on mathematics
Stars: ✭ 144 (-20.88%)
Mutual labels:  mathematics, algebra
Q.js
Quantum computing in your browser.
Stars: ✭ 158 (-13.19%)
Mutual labels:  algebra
Symja android library
☕️ Symja - computer algebra language & symbolic math library. A collection of popular algorithms implemented in pure Java.
Stars: ✭ 170 (-6.59%)
Mutual labels:  algebra
Resources
Resources on various topics being worked on at IvLabs
Stars: ✭ 158 (-13.19%)
Mutual labels:  mathematics
C Plus Plus
Collection of various algorithms in mathematics, machine learning, computer science and physics implemented in C++ for educational purposes.
Stars: ✭ 17,151 (+9323.63%)
Mutual labels:  mathematics
Computator.net
Computator.NET is a special kind of numerical software that is fast and easy to use but not worse than others feature-wise. It's features include: - Real and complex functions charts - Real and complex calculator - Real functions numerical calculations including different methods - Over 107 Elementary functions - Over 141 Special functions - Over 21 Matrix functions and operations - Scripting language with power to easy computations including matrices - You can declare your own custom functions with scripting language
Stars: ✭ 174 (-4.4%)
Mutual labels:  mathematics
Reduce.jl
Symbolic parser generator for Julia language expressions using REDUCE algebra term rewriter
Stars: ✭ 172 (-5.49%)
Mutual labels:  algebra
Pytda
Topological Data Analysis in Python
Stars: ✭ 156 (-14.29%)
Mutual labels:  topology

SwiftyMath

ss1

The aim of this project is to understand Mathematics by realizing abstract concepts as codes. Mathematical axioms correspond to protocols, and objects satisfying some axioms correspond to structs.

Submodules

Getting Started

Using SwiftyMathREPL

ss2

Creating Your Own Project

1. Initialize a Package

$ mkdir YourProject
$ cd YourProject
$ swift package init --type executable

2. Edit Package.swift

 // swift-tools-version:5.1
 // The swift-tools-version declares the minimum version of Swift required to build this package.
 
 import PackageDescription
 
 let package = Package(
     name: "YourProject",
     dependencies: [
         // Dependencies declare other packages that this package depends on.
-        // .package(url: /* package url */, from: "1.0.0"),
+        .package(url: "https://github.com/taketo1024/SwiftyMath.git", from: "1.0.0"),
     ],
     targets: [
         // Targets are the basic building blocks of a package. A target can define a module or a test suite.
         // Targets can depend on other targets in this package, and on products in packages which this package depends on.
         .target(
             name: "YourProject",
-            dependencies: []),
+            dependencies: ["SwiftyMath"]),
     ]
 )

3. Edit Sources/YourProject/main.swift

import SwiftyMath

let a = RationalNumber(4, 5)  // 4/5
let b = RationalNumber(3, 2)  // 3/2

print(a + b)     // 23/10

4. Run

$ swift run
 23/10

Using Mathematical Symbols

We make use of mathematical symbols such as sets 𝐙, 𝐐, 𝐑, 𝐂 and operators ⊕, ⊗ etc. Copy the folder CodeSnippets to ~/Library/Developer/Xcode/UserData/ then you can quickly input these symbols by the completion of Xcode.

ss3.png

Examples

Rational Numbers

let a = 𝐐(4, 5)  // 4/5
let b = 𝐐(3, 2)  // 3/2

a + b  // 23/10
a * b  // 6/5
b / a  // 15/8

Matrices

typealias M = SquareMatrix<_2, 𝐙> // Matrix of integers with fixed size 2×2.

let a = M(1, 2, 3, 4)  // [1, 2; 3, 4]
let b = M(2, 1, 1, 2)  // [2, 1; 1, 2]

a + b  // [3, 3; 4, 6]
a * b  // [4, 5; 10, 11]

a + b == b + a  // true: addition is commutative
a * b == b * a  // false: multiplication is noncommutative

Permutation (Symmetric Group)

typealias S_5 = Permutation<_5>

let s = S_5(cyclic: 0, 1, 2) // cyclic notation
let t = S_5([0: 2, 1: 3, 2: 4, 3: 0, 4: 1]) // two-line notation

s[1]  // 2
t[2]  // 4

(s * t)[3]  // 3 -> 0 -> 1
(t * s)[3]  // 3 -> 3 -> 0

Polynomials

typealias P = Polynomial<𝐐>

let f = P(0, 2, -3, 1) // x^3 − 3x^2 + 2x
let g = P(6, -5, 1)    // x^2 − 5x + 6
    
f + g  // x^3 - 2x^2 - 3x + 6
f * g  // x^5 - 8x^4 + 23x^3 - 28x^2 + 12x
f % g  // 6x - 12
    
gcd(f, g) // 6x - 12

Integer Quotients, Finite Fields

typealias Z_4 = IntegerQuotientRing<_4>
Z_4.printAddTable()
+   |   0   1   2   3
----------------------
0   |   0   1   2   3
1   |   1   2   3   0
2   |   2   3   0   1
3   |   3   0   1   2
typealias F_5 = IntegerQuotientField<_5>
F_5.printMulTable()
*   |   0   1   2   3   4
--------------------------
0   |   0   0   0   0   0
1   |   0   1   2   3   4
2   |   0   2   4   1   3
3   |   0   3   1   4   2
4   |   0   4   3   2   1

Algebraic Extension

// Construct an algebraic extension over 𝐐:
// K = 𝐐(√2) = 𝐐[x]/(x^2 - 2).

struct p: _Polynomial {                            // p = x^2 - 2, as a struct
    typealias K = 𝐐
    static let value = Polynomial<𝐐>(-2, 0, 1)
}

typealias I = PolynomialIdeal<p>                   // I = (x^2 - 2)
typealias K = QuotientField<Polynomial<𝐐>, I>      // K = 𝐐[x]/I

let a = Polynomial<𝐐>(0, 1).asQuotient(in: K.self) // a = x mod I
a * a == 2                                         // true!

License

Swifty Math is released under MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].