This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import cStringIO | |
import codecs | |
import glob | |
import json | |
import requests | |
def fetch_jsons(): | |
url = ('https://summerofcode.withgoogle.com/api/program/current/project/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [ ]: solveset(2*sin(x) - 1<0,x, S.Reals) | |
Out[ ]: | |
⎛ π⎞ ⎛5⋅π ⎞ | |
⎜-∞, ─⎟ ∪ ⎜───, ∞⎟ | |
⎝ 6⎠ ⎝ 6 ⎠ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################## | |
# ------------------------------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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################## | |
# ------------------------------nonlinsolve ---------------------------------# | |
############################################################################## | |
def substitution(system, symbols=None, result=[{}], known_symbols=[], | |
exclude=[], all_symbols=None): | |
r""" Solves the `system` using substitution method. |