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
diff --git a/sympy/core/add.py b/sympy/core/add.py | |
index c20c76b..a2d274e 100644 | |
--- a/sympy/core/add.py | |
+++ b/sympy/core/add.py | |
@@ -542,22 +542,26 @@ def primitive(self): | |
(1, 2*x/3 + 4.1*y) | |
""" | |
+ terms = [ arg.as_coeff_Mul() for arg in self.args ] | |
cont = S.Zero |
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 [1]: [-sqrt(x)*sqrt(log((log(2) + I*pi)/log(2))), | |
...: sqrt(x)*sqrt(log((log(2) + I*pi)/log(2)))] | |
Out[1]: | |
⎡ ___________________ ___________________⎤ | |
⎢ ___ ╱ ⎛log(2) + ⅈ⋅π⎞ ___ ╱ ⎛log(2) + ⅈ⋅π⎞ ⎥ | |
⎢-╲╱ x ⋅ ╱ log⎜────────────⎟ , ╲╱ x ⋅ ╱ log⎜────────────⎟ ⎥ | |
⎣ ╲╱ ⎝ log(2) ⎠ ╲╱ ⎝ log(2) ⎠ ⎦ | |
In [2]: [-sqrt(x)*sqrt(-log(log(2)) + log(log(2) + I*pi)), | |
...: sqrt(x)*sqrt(-log(log(2)) + log(log(2) + I*pi))] |
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 [1]: from sympy.integrals.heurisch import heurisch | |
In [2]: f = 1/((sin(x)+cos(x)+1)**2) | |
In [3]: heurisch(f, x) | |
Out[3]: | |
2 | |
⎛ ⎛x⎞ ⎞ ⎛x⎞ ⎛ ⎛x⎞ ⎞ ⎛x⎞ ⎛x⎞ | |
2⋅log⎜tan⎜─⎟ + 1⎟⋅tan⎜─⎟ 2⋅log⎜tan⎜─⎟ + 1⎟ tan ⎜─⎟ 3⋅tan⎜─⎟ | |
⎝ ⎝2⎠ ⎠ ⎝2⎠ ⎝ ⎝2⎠ ⎠ ⎝2⎠ ⎝2⎠ |
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 [1]: var('x1,x2,y1,y2,r1,r2') | |
Out[1]: (x₁, x₂, y₁, y₂, r₁, r₂) | |
In [2]: E=1/(2*x1**2 - 4*x1*x2 + 2*x2**2 + 2*y1**2 - 4*y1*y2 + 2*y2**2) * (-y1*r1**2 + y2*r1**2 + y1*r2**2 - y2*r2**2 + y1*x1**2 + y2*x1**2 - 2*x1*x2*y1 - 2*x1*x2*y2 + y1*x2**2 + y2*x2**2 + y1**3 - y2*y1**2 - y1*y2**2 + y2**3) | |
In [3]: n, d = E.as_numer_denom() | |
In [4]: _, D = factor(d).as_coeff_Mul() | |
In [5]: D |
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
# Run `bin/bokeh serve` and in a new terminal run `python conway.py`. | |
# Based on https://github.com/thearn/game-of-life. | |
from bokeh.plotting import figure, curdoc | |
from bokeh.client import push_session | |
from numpy.fft import fft2, ifft2, fftshift | |
import numpy as np | |
def fft_convolve2d(x,y): |
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 numpy as np | |
from bokeh.plotting import figure, hplot, show, output_file | |
from bokeh.models import HoverTool, CustomJS, ColumnDataSource | |
N = 20 | |
x = np.random.random(size=N) | |
y = np.random.random(size=N) | |
p = figure(tools=["hover"], toolbar_location=None) |
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 bokeh.core.properties import String, Instance | |
from bokeh.models import LayoutDOM, Slider | |
CODE =""" | |
import {div, empty} from "core/dom" | |
import * as p from "core/properties" | |
import {LayoutDOM, LayoutDOMView} from "models/layouts/layout_dom" | |
export class CustomView extends LayoutDOMView { |
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 bokeh.io import save | |
from bokeh.plotting import figure | |
from bokeh.layouts import column | |
from bokeh.models import CustomJS | |
from bokeh.models.widgets import Button, Tabs, Panel | |
def make_tab(color): | |
p = figure() | |
p.scatter([0], [0], color=color, radius=1) | |
return Panel(title="Tab: %s" % color.capitalize(), child=p) |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Categorical Axes</title> | |
<link rel="stylesheet" href="bokehjs/build/css/bokeh.css" type="text/css" /> | |
<link rel="stylesheet" href="bokehjs/build/css/bokeh-widgets.css" type="text/css" /> | |
<script type="text/javascript" src="bokehjs/build/js/bokeh.js"></script> | |
<script type="text/javascript" src="bokehjs/build/js/bokeh-api.js"></script> | |
<script type="text/javascript" src="bokehjs/build/js/bokeh-widgets.js"></script> |