Skip to content

Instantly share code, notes, and snippets.

View Shekharrajak's full-sized avatar
📚
Being Geek!

Shekhar Prasad Rajak Shekharrajak

📚
Being Geek!
View GitHub Profile
@Shekharrajak
Shekharrajak / hermite.py
Created October 24, 2015 07:24 — forked from cheery/first_fundamental_form.py
Sympy funnies & Cubic hermite
from sympy import *
# https://www.rose-hulman.edu/~finn/CCLI/Notes/day09.pdf
a0, a1, a2, a3, t = symbols('a0 a1 a2 a3 t')
polynomial = a0 + a1*t + a2*t**2 + a3*t**3
polynomial_d = diff(polynomial, t)
p0, v0, p1, v1 = symbols('p0 v0 p1 v1')
@Shekharrajak
Shekharrajak / matrix.py
Created April 3, 2016 16:33 — forked from bpgergo/matrix.py
Concurrent matrix multiplication
import random
import multiprocessing
from itertools import starmap, izip, repeat, imap
from operator import mul
def calc_row_of_product_matrix(a_row, b, izip=izip):
'''Calculate a row of the product matrix P = A * B
Arguments:
a_row is af A
b is the B matrix
import csv
import cStringIO
import codecs
import glob
import json
import requests
def fetch_jsons():
url = ('https://summerofcode.withgoogle.com/api/program/current/project/'
def nlinsolve_matrix(system, symbols):
r"""
reference : http://people.math.gatech.edu/~aleykin3/math4803spr13/BOOK/chapter1.pdf
page :9 example = 2.2
currently for 2 equations
Examples
>>> from sympy.solvers.solveset import nlinsolve_matrix
>>> nlinsolve_matrix([x*y - 1, 4*x**2 + y**2 - 5],[x,y])
>>> {(-1, -1), (-1/2, -2), (1/2, 2), (1, 1)}
In [ ]: solveset(2*sin(x) - 1<0,x, S.Reals)
Out[ ]:
⎛ π⎞ ⎛5⋅π ⎞
⎜-∞, ─⎟ ∪ ⎜───, ∞⎟
⎝ 6⎠ ⎝ 6 ⎠
def reduce_imageset(soln):
"""
Try to reduce number of imageset in the args.
It is mostly helper to _solve_trig method defined in
solvers/solveset.py.
First extract the expression of imageset and
sort the negative and positive expression.
and using interpolate defined in polys/polyfuncs.py
generates a function in `n`, which can return all the
@Shekharrajak
Shekharrajak / reduce_imageset_v2.py
Created June 10, 2016 19:36
Secod attempt for reduce_imageset methoid
def reduce_imageset(new_imgset, imgset = S.EmptySet):
"""
Try to reduce number of imageset in the args.
It is mostly helper to _solve_trig method defined in
solvers/solveset.py.
First extract the expression of imageset and put in list in new_list
(for new_imgset expr) and final_list(for imgset expr). If there is any
expr in new_list have difference of pi or -pi with any final_list expr.
def solveset_univariate_trig_inequality(expr, gen, relational=True):
"""Solves a real univariate inequality.
Examples
========
>>> from sympy.solvers.inequalities import solveset_univariate_trig_inequality
>>> from sympy.core.symbol import Symbol
>>> x = Symbol('x')
>>> solveset((2*cos(x)+1)/(2*cos(x)-1) > 0, x, S.Reals)
##############################################################################
# ------------------------------nonlinsolve ---------------------------------#
##############################################################################
def substitution(system, symbols=None, result=[{}], known_symbols=[], exclude=[],
all_symbols=None):
r""" Solves the `system` using substitution method.
A helper function for `nonlinsolve`. This will be called from
`nonlinsolve` when any equation(s) is non polynomial equation.
##############################################################################
# ------------------------------nonlinsolve ---------------------------------#
##############################################################################
def substitution(system, symbols=None, result=[{}], known_symbols=[],
exclude=[], all_symbols=None):
r""" Solves the `system` using substitution method.