Re: [sympy] Re: C Code Generator

2023-03-19 Thread brombo
First I think there is a problem with ccode doing what it is supposed to 
do.  Consider the following code -
(x,y,th) = symbols(r"x' y' \theta")

then
x' = ccode(x)
y' = ccode(y)
\theta = ccode(th)

I don't think x', y', and \theta are legal program variables in c.

Also I have looking at codegen examples and wish to know if the following 
conclusion is correct. If I have a python function (example) -
def W(x):
s = 1
for i in range(10): 
s += x**i
   return s 

there is no simple way (if any) to convert it to -
double W(double x) 
{ 
  double s = 1; 
  int i; 
  for (i=0;i<10;++i)
  { 
s = s+pow(x,i); 
  }
  return s; 
} 
On Saturday, March 18, 2023 at 11:14:20 AM UTC-4 moore...@gmail.com wrote:

> You can make custom printers for any SymPy function to return what you 
> desire. Subclass the C printer and overwrite/create methods for your 
> functions. The current c code printer does not target any specialized C 
> libraries (but that would be a nice addition!).
>
> Jason
> moorepants.info
> +01 530-601-9791 <(530)%20601-9791>
>
>
> On Sat, Mar 18, 2023 at 3:18 PM brombo  wrote:
>
>> I have looked further and while ccode(expr) can export functions like 
>> sin, cox, exp it cannot export special functions such as bessel, elliptic, 
>> etc.. Is there a way to export special functions into c-code?
>>
>> On Saturday, March 18, 2023 at 9:52:48 AM UTC-4 brombo wrote:
>>
>>> Does the C code generator generate special function calls with the same 
>>> syntax that is used in the gsl (GNU Scientific Library).  For example is 
>>> the sympy call besselj(nu,z) translated to J(nu,z) etc.?
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "sympy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to sympy+un...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sympy/73a99292-df6c-420a-804a-b2a52dfae437n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/sympy/73a99292-df6c-420a-804a-b2a52dfae437n%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/8dd42cf4-470d-4d78-9b99-71a617b0ff25n%40googlegroups.com.


[sympy] Re: C Code Generator

2023-03-18 Thread brombo
I have looked further and while ccode(expr) can export functions like sin, 
cox, exp it cannot export special functions such as bessel, elliptic, etc.. 
Is there a way to export special functions into c-code?

On Saturday, March 18, 2023 at 9:52:48 AM UTC-4 brombo wrote:

> Does the C code generator generate special function calls with the same 
> syntax that is used in the gsl (GNU Scientific Library).  For example is 
> the sympy call besselj(nu,z) translated to J(nu,z) etc.?
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/73a99292-df6c-420a-804a-b2a52dfae437n%40googlegroups.com.


[sympy] C Code Generator

2023-03-18 Thread brombo
Does the C code generator generate special function calls with the same 
syntax that is used in the gsl (GNU Scientific Library).  For example is 
the sympy call besselj(nu,z) translated to J(nu,z) etc.?

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/d37acec9-a82f-4cf8-9815-b2ae71f9ae21n%40googlegroups.com.


[sympy] Question about printing from my classes?

2023-03-15 Thread brombo
Is the following correct?  As long as the classes I write have _sympystr 
and _latex members the printing using sympy and my objects is transparent.

One more question.  I am running Ubuntu 22.04 and have not been able to set 
a PYTHONPATH to include the directories with my code in them.  Has 
something changed in Ubuntu 22.04.  What do you do to put the sympy code in 
the path?

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/9b0a27b4-349d-41c1-93ef-208088a1fc02n%40googlegroups.com.


[sympy] Grouping Terms

2023-01-16 Thread brombo
I have a sum of terms some of which are multiplied by cos(th).  I want to 
group these terms together (in parenthesis) and have the terms not 
multiplied by cos(th).  A complicating issue is that the sum is a numerator 
in a fraction.  Consider the following expression:

(A*cos(th)+B*cos(th)+C)/D

what I want is:

((A+B)*cos(th)+C)/D

or:

(A+B)*cos(th)/D +C/D

Any suggestions would be welcome.  Note that if I expand the first 
expression it prints out the same and not as:

A*cos(th)/D+B*cos(th)/D+C/D

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/2b10c43b-0bd7-4891-a33b-33678b34ea97n%40googlegroups.com.


[sympy] Custom Printing

2022-12-08 Thread brombo
I understand how to create a custom latex printer for my classes using 
_latex().  My question is there an acceptable way for me to create a custom 
latex printer for sympy class objects?  For example a custom latex printer 
for sympy functions or derivatives that would override the sympy printer 
functions when printing my objects? 

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/ff57da55-7311-4375-adfe-d61434fc5393n%40googlegroups.com.


[sympy] An Improved Interface (API) for differentiation

2022-09-27 Thread brombo
I am developing an improved API for differentiation in sympy which is a 
class for scalar differential operators (a linear combination of sympy 
expressions and partial derivatives).  The code (test_dop.py attached) 
produces the following output -
[image: test_dop-1.jpg]
To run this code also requires the gprinter.py and dop.py modules (also 
attached).  Note that the scalar differential operator API could be 
extended to vector operators or differential forms.  It only depends on how 
you define the coefficients of the partial derivative operators.  You could 
also define partial derivative operators that operate on the left argument 
instead of on the right argument of *.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/d94763b0-0ff2-4dfd-8947-2825211655a5n%40googlegroups.com.
#gprinter.py

import sys,shutil,os

from sympy import init_printing, latex

try:
from IPython.display import display, Latex, Math, display_latex
except ImportError:
pass
try:
from sympy.interactive import printing
except ImportError:
pass

from sympy import *

def isinteractive():  #Is ipython running
'''
We will assume that if ipython is running then jupyter notebook is
running.
'''
try:
__IPYTHON__
return True
except NameError:
return False

class gprinter:

'''
The gprinter class implements the functions needed to print sympy
objects in a function, gprint, that mimics the syntax
of the python 3 print function.  Additionally, it also impliments latex
printing from Jupyter Notebook/Lab and from python scripts.  For latex
printing from linux and windows the following programs are required:

Jupyter Notebook/Lab is sufficient for printing latex in both linux and
windows since in both cases it now includes Mathjax.

To print latex from a python script in linux a tex distribution is
required.  It is suggested that the texlive-full distribution which
includes pdfcrop be installed with the command:

sudo apt-get install texlive-full

To print latex from a python script in windows 10 the full texlive
installation is also suggested. Use the following link to download
the windows texlive installation program:

http://mirror.ctan.org/systems/texlive/tlnet/install-tl-windows.exe

In order to use the pdfcrop program in texlive a perl distribution must
be installed.  Here is a suggested installation link:

http://strawberryperl.com/
'''

line_sep = \
"""

"""
latex_preamble = \
"""
\\pagestyle{empty}
\\usepackage[latin1]{inputenc}
\\usepackage{amsmath}
\\usepackage{amsfonts}
\\usepackage{amssymb}
\\usepackage{amsbsy}
\\usepackage{tensor}
\\usepackage{listings}
\\usepackage{color}
\\usepackage{xcolor}
\\usepackage{bm}
\\usepackage{breqn}
\\definecolor{gray}{rgb}{0.95,0.95,0.95}
\\setlength{\\parindent}{0pt}
\\DeclareMathOperator{\\Tr}{Tr}
\\DeclareMathOperator{\\Adj}{Adj}
\\newcommand{\\bfrac}[2]{\\displaystyle\\frac{#1}{#2}}
\\newcommand{\\bc}{\\begin{center}}
\\newcommand{\\ec}{\\end{center}}
\\newcommand{\\lp}{\\left (}
\\newcommand{\\rp}{\\right )}
\\newcommand{\\paren}[1]{\\lp {#1} \\rp}
\\newcommand{\\half}{\\frac{1}{2}}
\\newcommand{\\llt}{\\left <}
\\newcommand{\\rgt}{\\right >}
\\newcommand{\\abs}[1]{\\left |{#1}\\right | }
\\newcommand{\\pdiff}[2]{\\bfrac{\\partial {#1}}{\\partial {#2}}}
\\newcommand{\\lbrc}{\\left \\{}
\\newcommand{\\rbrc}{\\right \\}}
\\newcommand{\\W}{\\wedge}
\\newcommand{\\prm}[1]{{#1}'}
\\newcommand{\\ddt}[1]{\\bfrac{d{#1}}{dt}}
\\newcommand{\\R}{\\dagger}
\\newcommand{\\deriv}[3]{\\bfrac{d^{#3}#1}{d{#2}^{#3}}}
\\newcommand{\\grade}[2]{\\left < {#1} \\right >_{#2}}
\\newcommand{\\f}[2]{{#1}\\lp{#2}\\rp}
\\newcommand{\\eval}[2]{\\left . {#1} \\right |_{#2}}
\\newcommand{\\Nabla}{\\boldsymbol{\\nabla}}
\\newcommand{\\eb}{\\boldsymbol{e}}
\\newcommand{\\bs}[1]{\\boldsymbol{#1}}
\\newcommand{\\grad}{\\bs{\\nabla}}
\\usepackage{float}
\\floatstyle{plain}
\\newfloat{Code}{H}{myc}
\\lstloadlanguages{Python}
"""

ip_cmds = \
[r'$$\DeclareMathOperator{\Tr}{Tr}$$',\
 r'$$\DeclareMathOperator{\Adj}{Adj}$$',\
 r'$$\DeclareMathOperator{\sinc}{sinc}$$',\
 r'$$\newcommand{\bfrac}[2]{\displaystyle\frac{#1}{#2}}$$',\
 r'$$\newcommand{\lp}{\left (}$$',\
 r'$$\newcommand{\rp}{\right )}$$',\
 r'$$\newcommand{\paren}[1]{\lp {#1} \rp}$$',\
 r'$$\newcommand{\half}{\frac{1}{2}}$$',\
 r'$$\newcommand{\llt}{\left <}$$',\
 r'$$\newcommand{\rgt}{\right >}$$',\
 r'$$\newcommand{\abs}[1]{\left |{#1}\right | }$$',\
 r'$$\newcommand{\pdiff}[2]{\bfrac{\partial {#1}}{\partial {#2}}}$$',\
 

[sympy] Printing and str()

2022-09-25 Thread brombo
In my class I have _latex and _sympystr.  Your latex() function uses my 
_latex but str() does not use _sympystr I have to define __str__() in my 
class to print correctly.  How should I use _sympystr to return the correct 
string. 

def _sympystr(self,printer):
if self.order == 0:
return 'D{}'
s = 'D'
for x in self.pdiffs:
s += '{' + printer._print(x) + '}'
n = self.pdiffs[x]
if n > 1:
s += '^' + printer._print(n)
return s

 def _latex(self,printer):
if self.order == 0:
return ''
s = r'\frac{\partial'
if self.order > 1:
s += '^{' + printer._print(self.order) + '}'
s += '}{'
keys = list(self.pdiffs.keys())
keys.sort(key=lambda x: x.sort_key())
for key in keys:
i = self.pdiffs[key]
s += r'\partial ' + printer._print(key)
if i > 1:
s += '^{' + printer._print(i) + '}'
s += '}'
return s

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/3681a732-62ca-4169-84ea-291b92dccef4n%40googlegroups.com.


[sympy] sympy printer for custom class

2022-09-09 Thread brombo
I have written the custom class PieceWiseFunction.  One of the class 
members is:

def _latex(self):
s = r'\left \{\begin{array}{c}'+'\n'
s += r'x < '+latex(self.x[0])+': '+latex(self.f[0])+r' \\ '+'\n'
for i in range(1,len(self.x)):
xlo = latex(self.x[i-1])
xhi = latex(self.x[i])
f   = latex(self.f[i])
s += xlo+r' \le x < '+xhi+r': '+f+r' \\ '+'\n'
s += r' x \ge '+latex(self.x[-1])+': '+latex(self.f[-1])+'\n'
s += r' \end{array}\right \}'
return s

I am trying to use the sympy "latex" function to access my _latex and get 
the following error message:

File 
"/home/brombo/.local/lib/python3.8/site-packages/sympy/printing/printer.py", 
line 309, in _print
return getattr(expr, self.printmethod)(self, **kwargs)
TypeError: _latex() takes 1 positional argument but 2 were given

What am I doing wrong in my definition of _latex?

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/c0821032-a469-4506-afc9-880d0ea0d952n%40googlegroups.com.


[sympy] Evaluation of symbolic integrals

2022-09-07 Thread brombo
I calculated an integral g when printed grives:

Piecewise((sin(w/2)/w - 2*cos(w/2)/w**2 + 4*sin(w/2)/w**3, Ne(w, 0)), (2/3, 
True)) + 2*Piecewise((-sin(w/2)/(2*w) + cos(w/2)/w**2 + sin(w/2)/w**3 - 
sin(3*w/2)/w**3, Ne(w, 0)), (1/6, True))

First, how can I extract from g (without cutting and pasting the output) 
what I really want which is:

(sin(w/2)/w - 2*cos(w/2)/w**2 + 4*sin(w/2)/w**3)+2*(-sin(w/2)/(2*w) + 
cos(w/2)/w**2 + sin(w/2)/w**3 - sin(3*w/2)/w**3)

Secondly,  I can substitute y = w/2.  In the resulting expression force 
expansion of sin(3*y). trigsimp doesn't do that.  I know the answer is 
supposed to be of the form (sin(y)/y)**3.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/498806a0-bc5d-490f-acba-c7bb265acbcbn%40googlegroups.com.


[sympy] Re: Piecewise functions and Convolution

2022-09-06 Thread brombo
Attached is the output of the latest piecewise.py (I got convolution, latex 
printing, and Asymptote ploting working)

On Monday, September 5, 2022 at 11:42:49 AM UTC-4 brombo wrote:

> Would this be of any interest to anyone (see and run attached).  I have 
> written a piecewise function class (not like the one already in sympy) 
> where the piecewise function is defined on an ordered numerical grid (see 
> attached).  The class in not finished but I can calculate the convolved 
> powers of gate functions and will extend the class to calculate the 
> convolution of two piecewise functions if sympy can integrate the member 
> functions of the piecewise function.  My interest comes from knowing the 
> Fourier transform of a gate function is a sinc function.  Thus the Fourier 
> transform of a gate repeatedly convolved with itself is the power of a sinc 
> function.  This is relevant to finding rf modulation envelopes that 
> minimize  sidebands.  Please run the code an see if it of general interest 
> and I will complete the class and documentation and submit it as an 
> addition to sympy.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/f71333b3-fb32-40c4-90b0-5b419dd31cefn%40googlegroups.com.


convolutions.pdf
Description: Adobe PDF document


piecewise.pdf
Description: Adobe PDF document


[sympy] Piecewise functions and Convolution

2022-09-05 Thread brombo
Would this be of any interest to anyone (see and run attached).  I have 
written a piecewise function class (not like the one already in sympy) 
where the piecewise function is defined on an ordered numerical grid (see 
attached).  The class in not finished but I can calculate the convolved 
powers of gate functions and will extend the class to calculate the 
convolution of two piecewise functions if sympy can integrate the member 
functions of the piecewise function.  My interest comes from knowing the 
Fourier transform of a gate function is a sinc function.  Thus the Fourier 
transform of a gate repeatedly convolved with itself is the power of a sinc 
function.  This is relevant to finding rf modulation envelopes that 
minimize  sidebands.  Please run the code an see if it of general interest 
and I will complete the class and documentation and submit it as an 
addition to sympy.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/c9634965-089a-4456-b27b-ff3f0211a042n%40googlegroups.com.
from sympy import *
import bisect,copy
#init_printing( use_latex='mathjax' )

def sympy_fct(f,x,t):
return f.subs(x,t)

def union(a,b):
"""
If a and b are ordered lists return an ordered list containing all
of the elements of a and b with no duplicates
"""
return sorted(list(set(a)|set(b)))

def interval(x,x0):
"""
If x is a sorted list of lenght n then
x0 < x[0] -> 0
x[i] < x0 <= x[i+1] -> i+1
x0 >= x[-1] -> n
"""
if x0 < x[0]:
return 0
if x0 >= x[-1]:
return len(x)
return bisect.bisect_left(x,x0)

def Integrate(f,xlo,xhi):
x = Symbol('x',real=True)
#print('Integrate: ',f,xlo,xhi)
if f == 0 or f == S(0):
return 0
return integrate(f,(x,xlo,xhi))

def Subs(f,x,xp):
"""
Takes care of the case where f is a python constant and not a sympy
expression.
"""
#print('Subs: ',f,x,xp)
if isinstance(f,Expr):
return f.subs(x,xp)
return f

class PieceWiseFunction:
"""
A piecewise function is defined by a ordered list of numbers self.x
and a list of sympy expressions (functions) self.f of the symbol x.
If the length of self.x is n then the length of self.f is n+1. Then
the fuction is given by:

x <  self.x[0]  -> self.f0[0]
x <  self.x[i] and x >= self.x[i+1] -> self.f[i+1]
x >= self.x[-1] -> self.f[-1]

The init options are to input self.f and self.x separately or to
input one list [self.f[0],self.x[0],self.f[1],...,self.x[-1],self.f[-1]]

x = Symbol('x',real=True)
pwf1 = PieceWiseFunction([exp(x),-1,x**2,1,exp(-x)])
pwf2 = PieceWiseFunction([exp(x),x**2,exp(-x)],[-1,1])

pwf1 and pwf2 define the same piewcewise fuction:

exp(x): x < -1
x**2: -1 <= x < 1
exp(-x): x >= 1

"""

def __init__(self,pf,x=[]):
self.x = []
self.f = []
if len(pf) > 0 and len(x) == 0:
for i in range(len(pf)):
if i % 2 == 0:
if isinstance(pf[i],Expr):
self.f.append(pf[i])
else:
self.f.append(pf[i]*S(1))
else:
self.x.append(pf[i])
elif len(x) > 0:
self.x = x
self.f = pf

def fct(self,t):
"""
Return the value of the PieceWiseFunction for value t where t is
a number not a symbol.
"""
if self.x == []:
return(S(0))
if  t < self.x[0]:
if isinstance(self.f[0],Expr):
return self.f[0].subs(x,t)
else:
return self.f[0]
elif t > self.x[-1]:
if isinstance(self.f[-1],Expr):
return self.f[-1].subs(x,t)
else:
return self.f[-1]
else:
i = bisect.bisect_left(self.x,t)-1
if isinstance(self.f[i+1],Expr):
return self.f[i+1].subs(x,t)
else:
return self.f[i+1]

def fct_expr(self,t):
"""
Return the expression of the PieceWiseFunction for the interval
that t is on where t is a number not a symbol.
"""
if self.x == []:
return(S(0))
if  t < self.x[0]:
return self.f[0]
elif t > self.x[-1]:
return self.f[-1]
else:
i = bisect.bisect_left(self.x,t)-1
return self.f[i+1]

def RemoveDuplcates(self):
"""
Simplify a PieceWiseFunction that has the same expression defined
on adjacent intervals.
"""
i = 0
while i < len(self.x):
if self.f[i] == self.f[i+1]:
self.x.pop(i)

[sympy] Optimum factoring of multinomial expression

2022-02-16 Thread brombo
Does sympy have the capability to optimally factor (minimum number of 
numerical operations) a polynomial or better yet a multinomial for 
numerical evaluation.  The simple example for a polynomial would be 
consider the polynomial -

y = a*x**3+b*x**2+c*x+d

then the  optimal factorization (minimizes number of numerical operations) 
would be -

y  = ((a*x+b)*x+c)*x+d

What are sympy's the current capabilities?

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/7f6b4493-e595-4d89-b5bc-747b47f5d4d2n%40googlegroups.com.


[sympy] Plotting

2021-11-10 Thread brombo
This is a subject that is more general than sympy but is relevant to sympy 
and I don't know where else to ask this question.  For plotting in sympy 
and python for that matter we pretty much make do with mathplotlib.  The 
software package Asymptote

https://asymptote.sourceforge.io/

is much better (it has a 3d vector syntax for plotting) and can generate 
report quality graphics (especially in 3d and even interactive 3d as show 
in the galleries in the link).  The problem is that it was originally 
written in 2004 before the staying power of python was know so that it has 
it's own programming language.  What it needs is a complete python wrapper 
for the graphics related types (it uses a strongly typed interpreted 
programming language with the flavor of C or C++) and plotting commands.  
This is beyond my programming abilities.  Where in the python community 
should I propose this as a task that should be worked on?  Note that some 
people who know more about programming than I do looked at the source code 
and said that it uses a virtual machine which would make writing a python 
api simpler.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/4b0de05d-bf6a-45dd-98f7-76a40e83n%40googlegroups.com.


[sympy] Reintegration of geometric algebra into sympy and documentation requirements

2019-04-02 Thread brombo


After GSOC is over I have someone to help me reintegrate geometric 
algebra/calculus 
into sympy.  The biggest problem is documentation (all of it is in 
LaTeX).  I know that sympy uses sphinx.  Can one use nbsphinx so they 
can launch tutorial notebooks directly from the documentation or is the 
problem that sympy does not automatically install notebook so jupyter 
notebook must be installed separately?

PS: Where are the instructions for adding a package to sympy?  It has been a 
long time since I did it. 

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/6e0118a4-df48-4911-a8ad-1cfd738e8073%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Is there a simple way to use sympy in google colab?

2019-03-13 Thread brombo
Is there a simple way to use sympy in google colab?

https://colab.research.google.com/notebooks/welcome.ipynb

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/b8db2e97-f35e-4de5-95b8-de9962c96138%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] sympy docs

2019-02-14 Thread brombo
Where are the instructions on how to document sympy code with sphinx?

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/ac90b40f-8f4b-4701-ba51-abd880ad2d59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] nbsphinx

2019-02-13 Thread brombo
Does the installed version of sympy use nbsphinx for documentation -

https://nbsphinx.readthedocs.io/en/0.4.2/

so that the documentation (sphinx) can launch a jupyter notebook?  In 
documenting my code I would like to use notebook as part of the 
documentation.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/1f42b4cd-b20b-485d-a0ac-b7c9b397fcf4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Between 1.2 and 1.4 simplify stopped working for me for some cases

2018-11-08 Thread brombo
To start with I cannot give a simple example using only sympy.  I have only 
been able to generate this failure using my modules.  Below is code and 
output showing as simple an example as I can generate with some 
diagnostics.  If you could suggest any other diagnostics I would appreciate 
it.

The problem is that an expressing that should evaluation to zero does not 
even thought by inspecting the output it should.

Demonstration code:

from sympy import symbols, sin, cos, simplify, srepr
from ga import Ga
from mv import Mv
from metric import linear_expand
from printer import Format
xy = symbols('x y',real=True)
x = symbols('x',real=True)
o2d = Ga('e_x e_y',g=[1,1],coords=xy)
o1d = Ga('e',g=[1],coords=[x])
grad2d = o2d.grad
grad1d = o1d.grad
A = o1d.mv('A','mv',f=True)
B = o1d.mv('B','mv',f=True)
print(r'\bs{A}=',A)
print(r'\bs{B}=',B)
print(r'\bs{AB}=',A*B)
diff = grad1d*(A*B) - (grad1d*A)*B -(grad1d.odot()*A)*B.odot()
print(diff)
E = linear_expand(diff.obj)
scalar =E[0][0]
vector =E[0][1]
print('scalar =',simplify(E[0][0]))
print('vector =',simplify(E[0][1]))
print('srepr =',srepr(scalar))
args = scalar.args
print('args =',args)
print(simplify(args[1]+args[3]))
print(type(args[1]))
print(type(args[3]))
print(args[1].args)
print(args[3].args)

Both scalar and vector should be zero.  Note that if I use sympy 1.2 zero 
is output.  Output follows:

\bs{A}= A+A__x*e_x
\bs{B}= B+B__x*e_x
\bs{AB}= A*B + A__x*B__x+(A*B__x + A__x*B)*e_x
-A*Derivative(B__x, x) + A*Derivative(B__x, x) + A__x*Derivative(B, x) - 
A__x*Derivative(B, x)+(A*Derivative(B, x) - A*Derivative(B, x) - 
A__x*Derivative(B__x, x) + A__x*Derivative(B__x, x))*e_x
scalar = -A*Derivative(B__x, x) + A*Derivative(B__x, x) + 
A__x*Derivative(B, x) - A__x*Derivative(B, x)
vector = A*Derivative(B, x) - A*Derivative(B, x) - A__x*Derivative(B__x, x) 
+ A__x*Derivative(B__x, x)
srepr = Add(Mul(Integer(-1), Function('A')(Symbol('x', real=True)), 
Derivative(Function('B__x')(Symbol('x', real=True)), Tuple(Symbol('x', 
real=True), Integer(1, Mul(Function('A')(Symbol('x', real=True)), 
Derivative(Function('B__x')(Symbol('x', real=True)), Tuple(Symbol('x', 
real=True), Integer(1, Mul(Function('A__x')(Symbol('x', real=True)), 
Derivative(Function('B')(Symbol('x', real=True)), Tuple(Symbol('x', 
real=True), Integer(1, Mul(Integer(-1), Function('A__x')(Symbol('x', 
real=True)), Derivative(Function('B')(Symbol('x', real=True)), 
Tuple(Symbol('x', real=True), Integer(1)
args = (A__x(x)*Derivative(B(x), x), A(x)*Derivative(B__x(x), x), 
-A__x(x)*Derivative(B(x), x), -A(x)*Derivative(B__x(x), x))
(-Derivative(B__x, x) + Derivative(B__x, x))*A


(Derivative(B__x(x), x), A(x))
(-1, Derivative(B__x(x), x), A(x))

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/b61e03d3-9765-4687-98c4-3851791951df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Testing for Types

2018-11-02 Thread brombo
If you want to test a sympy expression to see if it is a real scalar 
(combination real of numbers, functions, symbols, etc.) how would you do it?

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/8941ce89-df1d-4425-87cd-6ebf013e1572%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [sympy] Re: Real Functions

2015-09-19 Thread brombo
Could you elucidate further or give me a link.  I  don't have a clue to 
implement what you suggested.

On Saturday, September 19, 2015 at 6:00:11 PM UTC-4, Aaron Meurer wrote:
>
> The only way to do it presently is to subclass Function manually: 
>
> class f(Function): 
> is_real = True 
>
> Aaron Meurer 
>
> On Sat, Sep 19, 2015 at 2:47 PM, brombo <abrom...@gmail.com > 
> wrote: 
> > Your method works for a function, but not the derivative of a function - 
> > 
> > x = Symbol('x',real=True) 
> > 
> > f = RealFunction('f')(x) 
> > 
> > print re(f) 
> > f 
> > print im(f) 
> > 0 
> > 
> > df = f.diff(x) 
> > print re(df) 
> > re(df) 
> > print im(df) 
> > im(df) 
> > 
> > What should happen is that re(df) = df and im(df) = 0, but is doesn't 
> > happen.  Any suggestions? 
> > 
> > 
> > 
> > 
> > On Saturday, September 19, 2015 at 12:58:53 PM UTC-4, brombo wrote: 
> >> 
> >> How do I define a real function of a real variable? 
> >> 
> >> X = symbols('x y z',real=True) 
> >> 
> >> f = Function('f',real=True)(*X) 
> >> 
> >> "real=True" in Function doesn't do anything. 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "sympy" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to sympy+un...@googlegroups.com . 
> > To post to this group, send email to sy...@googlegroups.com 
> . 
> > Visit this group at http://groups.google.com/group/sympy. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/sympy/6a732f8b-c09a-440e-b524-145343e1a499%40googlegroups.com.
>  
>
> > 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/0c906880-41fe-41bb-82ea-ae6ddcb3848f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Re: Real Functions

2015-09-19 Thread brombo
Your method works for a function, but not the derivative of a function -

x = Symbol('x',real=True)

f = RealFunction('f')(x)

print re(f)
f
print im(f)
0

df = f.diff(x)
print re(df)
re(df)
print im(df)
im(df)

What should happen is that re(df) = df and im(df) = 0, but is doesn't 
happen.  Any suggestions?




On Saturday, September 19, 2015 at 12:58:53 PM UTC-4, brombo wrote:
>
> How do I define a real function of a real variable?
>
> X = symbols('x y z',real=True)
>
> f = Function('f',real=True)(*X)
>
> "real=True" in Function doesn't do anything.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/6a732f8b-c09a-440e-b524-145343e1a499%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Real Functions

2015-09-19 Thread brombo
How do I define a real function of a real variable?

X = symbols('x y z',real=True)

f = Function('f',real=True)(*X)

"real=True" in Function doesn't do anything.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/6c98624e-2a2b-4562-97bb-491cf5d4f097%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] sympy will be used at AGACSE 2015 (Applied Geometric Algebra in Computer Science and Engineering 2015) at Barcelona

2015-07-10 Thread brombo
Sypmy will be used in courses at AGACSE 2015 in Barcelona during July and 
August (http://www-ma2.upc.edu/agacse2015/) with galgebra 
(https://github.com/brombo/galgebra) during a course and laboratory session 
given by Alan Macdonald 
(http://www-ma2.upc.edu/agacse2015/summer-school.html).  See links for more 
details.

-- 
You received this message because you are subscribed to the Google Groups 
sympy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/590e984b-f1e2-42c3-98c8-29d90268c13f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Absolute value removal

2015-07-09 Thread brombo
Is there a simple way of removing all absolute values from an expression.  
For example if the expression is (Abs(sin(w))/cos(w)) + Abs(w) return 
(sin(w)/cos(w)) + w. 

-- 
You received this message because you are subscribed to the Google Groups 
sympy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/0da1faa3-6d6d-4a83-8e08-54ed0da8b7e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Strange behavior from custom matrix printer

2015-07-02 Thread brombo
I have implemented a custom matrix printer with _print_MatrixBase(self, 
expr).  I am running jupyter notebook with the output of  
_print_MatrixBase(self, expr) being given by -

def _print_MatrixBase(self, expr):
rows = expr.rows
cols = expr.cols

out_str = ' \\left [ \\begin{array}{' + (cols * 'c') + '} '
for row in range(rows):
for col in range(cols):
out_str += latex(expr[row,col]) + '  '
out_str = out_str[:-2] + '  '
out_str = out_str[:-4] + ' \\end{array}\\right ] '

if isinteractive():
return display(Math(out_str))
else:
return out_str

for jupyter notebook the output is return display(Math(out_str)) where 
the out_str ins the tex output for the matrix.  The notebook output is -

See attached file

Where  sp3.g is a sympy Matrix.  Why is None  output along with the 
correct matrix output?

-- 
You received this message because you are subscribed to the Google Groups 
sympy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/2d60f6fc-a7bc-41e7-a82a-86cad4b7d096%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Print latex formatted matrix from ipython notebook

2015-06-17 Thread brombo
Is there anyway to print a nicely latex formatted matrix in ipython 
notebook?  When I try I just get the test version printed out while the 
latex formatting for the other objects I am printing works fine.

-- 
You received this message because you are subscribed to the Google Groups 
sympy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/c49e47fb-8a4f-4196-9d0c-2cfff60a7691%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Functional dependence

2015-06-06 Thread brombo
If I have a sympy expression, g, that is a function of sympy symbols (say 
x, y, z, and t) how can I determine that g is not dependent on any other 
symbols.  The context for this is that I wish to determine if I have a 
metric tensor that tensor is a function only of x, y, z, and t and not a 
fuction of any other symbols (for example spherical coordinates) so that I 
can know that if I substitute numerical values for x, y, z, and t all 
components of the metric tensor will be numbers that depend on no 
parameters. 

-- 
You received this message because you are subscribed to the Google Groups 
sympy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/08765f44-6552-4ffc-b485-c30a76564790%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.