Piecewise Functions for sympy Reformulated #24065
abrombo
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have written two modules for sympy that are demonstrated in the following zipped html file of a Jupyter Notebook (since I can't directly attach an html file) -
piecewise.zip
The modules are gprinter and piecewise. gprinter is a convenience module for printing LaTeX output in python and in Jupyter. What it does should be obvious in the attached notebook image. piecewise is a module for piecewise functions defined on an ordered numerical grid. The operators add, sub, mul, and neg are defined. The arguments of the operators do not have to have the same grid. A grid appropriate to the result is calculated. Additionally the operator and (&) is defined as the convolution product of piecewise functions. This is demonstrated in the attached file. My motivation for writing this was to determine the exact convolution power products of a gate function. The gate function is 1 for -1/2 < x <= 1/2 and 0 otherwise, it's Fourier transform is sin(w/2)/(w/2). The Fourier transforms of convolution powers of the gate function are powers of the Fourier transform of the gate function. In addition to the calculating functions the member function asy of PieceWiseFunction writes the Asymptote graphics language code and plots the piecewise functions. Here is a link to Asymptote -
https://asymptote.sourceforge.io/
Take a look at the galleries. I only used the 2D plotting capabilities.
Beta Was this translation helpful? Give feedback.
All reactions