Skip to content

Instantly share code, notes, and snippets.

@smichr
smichr / sodydx
Created December 24, 2021 19:03
debug
Size = 2
k = 3
xstartswitchpoint = Matrix([[5.], [5.]]) # y,Vy
Aklinnonlin = Matrix([[k,1],[0,-0.5]])
b2x2 = Matrix([[5.], [-3.]])
dydx = zeros(Size,1)
dydx
def dxdt_y(Aklinnonlin, xstartswitchpoint, b2x2):
dydx[0,0] += xstartswitchpoint[1,0]
dydx[1,0] += -1 * Aklinnonlin[0,0] * (xstartswitchpoint[1,0]) - 9.81
@smichr
smichr / so683
Created June 2, 2020 17:48
answer
import sympy as sp
import math
import re
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z = sp.symbols('a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z')
formula = input('')
unknown_values = int(input('how many unknown values?: '))
unknown_array = []
@smichr
smichr / toy_mailmap.py
Last active December 8, 2017 00:24
toy mailmap and notes
"""
Each line in .mailmap is a comment, blank or mapping. A mapping
contains 1 or 2 email addresses and may terminate with a comment
that extends from the first # to the end of the physical line. An
address starts with a left angle bracket and extends through the
first unnested right angle bracket; it need not conform to a
valid email address and may contain space. A name is interpreted
as anything before the first address or between the two addresses
except for leading and trailing space.
@smichr
smichr / update log
Last active December 3, 2017 00:33
session to update AUTHORS
python.exe bin\authors_update.py
?[31m
Ambiguous email address error: entries must be added to .mailmap to
identify the canonical name and email address for each of them. Then
re-run this script.?[0m
Ramana Venkata <idlike2dream@gmail.com>
Venkata Ramana <idlike2dream@gmail.com>
Gaurav Dhingra <gauravdhingra.gxyd@gmail.com>
These are all of our assumptions in master:
['algebraic', 'antihermitian', 'commutative', 'complex', 'composite',
'even', 'finite', 'hermitian', 'imaginary', 'infinite', 'integer',
'irrational', 'negative', 'noninteger', 'nonnegative', 'nonpositive',
'nonzero', 'odd', 'positive', 'prime', 'rational', 'real',
'transcendental', 'zero']
Beta_rules gives the ways to prove different items. For example, we
know a number is odd if even is False and integer is True
@smichr
smichr / gut
Last active December 15, 2015 04:39
def gut(string):
"""gzip the string and return the uu -encoded version."""
import StringIO, uu, gzip, hashlib
def md5(e):
return hashlib.md5(str(e)).hexdigest()
zipp = StringIO.StringIO()
uuu = StringIO.StringIO()
g = gzip.GzipFile(fileobj=zipp, mode='wb') # gzip(path, 'wb')
g.write(string)
g.close()
DEMO
regular
>>> (1/x+1/y+1/z+1/w).as_numer_denom()
(w*x*y + w*x*z + w*y*z + x*y*z, w*x*y*z)
binary-horner
>>> (1/x+1/y+1/z+1/w+1/u).binary()
(u*x*y*z + w*(u*z*(x + y) + x*y*(u + z)), u*w*x*y*z)
TIMING
DEMO
regular
```python
>>> (1/x+1/y+1/z+1/w).as_numer_denom()
(w*x*y + w*x*z + w*y*z + x*y*z, w*x*y*z)
```
binary-horner
```python
>>> (1/x+1/y+1/z+1/w+1/u).binary()
(u*x*y*z + w*(u*z*(x + y) + x*y*(u + z)), u*w*x*y*z)
@smichr
smichr / Abs
Created January 13, 2011 06:13
"""Return a sympy object representing the absolute value of the argument.
This is an extension of the built-in function abs() to accept symbolic
values. If you pass a SymPy expression to the built-in abs(), it will
pass it automatically to Abs().
Examples::
>>> from sympy import Abs, Symbol, S
>>> x = Symbol('x', real=True)