Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢

Ruoyi Lin karenin-overseas

🐢
View GitHub Profile
@karenin-overseas
karenin-overseas / knn.py
Created Aug 6, 2018
KNN example from Grokking Algorithms.
View knn.py
import numpy as np
import math
import unittest
import sys
import matplotlib.pyplot as plt
import heapq
# k neighbours for oranges and grapefruits. tested function calls before running.
def knn(k, datastore, fruit):
@karenin-overseas
karenin-overseas / symsolve.mpl
Last active Nov 10, 2017
This is a small extension I wrote in the Maple programming language during a summer research project in 2017. Maple is a symbolic and numerical mathematical computation engine, like Mathematica and MATLAB: https://www.maplesoft.com/products/Maple/ .
View symsolve.mpl
# Last updated: July 31 2017
# Author: Caroline Lin
# Written for Maple 2016, on Ubuntu Linux 16.04 LTS.
#
# Typical usage
#
# Comments
# * for approximate case, inequalities must be specified in terms of the approximated functions
# e.g. f(u) <> 3 should be replaced by f(v[0][0]) <> 3
# otherwise rifsimp will error later on.
@karenin-overseas
karenin-overseas / symsolve.mpl
Created Nov 10, 2017
This is a small extension I wrote in the Maple programming language during a summer research project in 2017. Maple is a C-like programming language.
View symsolve.mpl
# Last updated: July 31 2017
# Author: Caroline Lin
# Written for Maple 2016, on Ubuntu Linux 16.04 LTS.
#
# Typical usage
#
# Comments
# * for approximate case, inequalities must be specified in terms of the approximated functions
# e.g. f(u) <> 3 should be replaced by f(v[0][0]) <> 3
# otherwise rifsimp will error later on.
View gist:0e69e568c8910b04e5a2da21744f89aa
Two libraries:
* GLUT
* GLUI
* Mesa-utils
**ASIDE**
do
sudo apt-cache search "your search here"
to do a search of the ubuntu repo.
View math-riddle-may25.tex
math riddle of the day: Recall that orthogonal matrices are defined to be the (n by n) matrices over R^n for which (A^T A = A A^T = Identity), or equivalently, dotprod(x,y) = dotprod(Ax,Ay) for all x,y in R^n (inner-product preserving).
If A is an orthogonal matrix, we can show that its determinant must be either +-1.
Is the converse true? e.g. do all matrices with det 1 preserve inner products?
if so, prove it, if not, provide a counterexample.
i. Proof. First note that det A = det A^T by a handy theorem in Ch. 4 of FIS. Also det A det B = det AB by the same book.
So that A A^T = I implies (det A)^2 = 1 implies det A = +- 1.
ii. The converse is not true: let A be the matrix [1 1][1 0]. The basis vectors e_1, e_2 are sent to e_1, (1, 1) by this transformation
respectively. The dot product of the former is 0 (yay orthogonality) but the dot product of the latter is 1.
You can’t perform that action at this time.