Re: [sympy] Re: lambdify function with array of parameters

2018-03-19 Thread Leonid Kovalev
to call it straight away > though. Also, I'm reading [1] that `DeferredVector` were once scheduled for > removal? Probably outdated. > > [1] https://github.com/sympy/sympy/issues/6788 > > > > On Monday, March 19, 2018 at 11:24:59 PM UTC+1, Leonid Kovalev wrote: >> >>

[sympy] Re: lambdify function with array of parameters

2018-03-19 Thread Leonid Kovalev
Also, the conversion to dict was unnecessary, subs can take an iterator of tuples. P_a = P.subs(zip(a, val_a)) -- 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] Re: lambdify function with array of parameters

2018-03-19 Thread Leonid Kovalev
P_a = P.subs(dict(zip(a, val_a))) returns (0.450033195586719*x + 0.829322314411828)/(x**3*b[2, 0] + x**2*b[1, 0] + x*b [0, 0] + 1) You need to substitute individual MatrixElement objects like a[0], not the MatrixSymbol itself (which isn't even present in the expression P). -- You

[sympy] Re: Problem with SYMPY

2018-03-15 Thread Leonid Kovalev
I ran your code exactly as it's posted here and got [{s: 1.51, q: 0.0, z: 0.0, p: 0.0}, {s: 1.51, q: 0.0 , z: 0.0, p: 0.980392156862745}] I'm using SymPy 1.1.1. Perhaps your version of SymPy is old? By the way, it's better to use the assumption sm.symbols('p, q, z,

Re: [sympy] Re: Solving for a matrix?

2018-03-14 Thread Leonid Kovalev
)) > >>> _[0].inv() > Matrix([ > [ 2, -2, 1, 1], > [-3, 3, -2, -1], > [ 0, 0, 1, 0], > [ 1, 0, 0, 0]]) > > This still involves the extra step of inverting the result. > > Is this already the best way to get this result with SymPy?

[sympy] Re: Quotient rings of polynomial rings over finite fields

2018-03-13 Thread Leonid Kovalev
But it's better to avoid using variable name S, as S is heavily used in SymPy, in two ways: https://stackoverflow.com/a/41867990 -- 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

[sympy] Re: Quotient rings of polynomial rings over finite fields

2018-03-13 Thread Leonid Kovalev
I think QuotientRingElement is not meant to be instantiated directly like that. The docstring of QuotientRing discourages that, and I suppose the same applies to QuotientRingElement. Using S.from_sympy(x) works better. Example: >>> S = FF(2).old_poly_ring(x, y)/[x**2, x*y, y**2] >>> S

[sympy] Re: Solving for a matrix?

2018-03-13 Thread Leonid Kovalev
You have 4 equations with 16 unknowns, so there are going to be a lot of solutions. Many SymPy functions struggle with M[i, j] construction which creates MatrixElement instead of an ordinary Symbol. I would use a Matrix filled with Symbols: M = sp.Matrix(sp.symarray('M', (4, 4))) sp.solve(a

[sympy] Re: Summation of functions over integers

2018-03-12 Thread Leonid Kovalev
I'm not familiar with the algorithm, but it looks like a good addition to eval_sum_symbolic method. Currently, if the sequence term is a sum it splits it in two and calls itself for each part. If the input was a

[sympy] Re: Sympy Polynomail Issues

2018-02-26 Thread Leonid Kovalev
Let's start with the expression expr = -2.61468835142518e-12*I*x**3 - 1.77367468147515e-13*x**2 + 2.01551297295763e-14*I*x + 6.13636683162216e-92*1/x**2 - 1.320867768074e-41* I*1/x + 7.79634921616583e-16 It is not a polynomial in x, because it contains negative powers of x. If you force it to

Re: [sympy] Re: Order of terms in polynomial with symbolic coefficients?

2018-02-25 Thread Leonid Kovalev
The LaTeX printing of Poly was indeed buggy. Corrected in the current development version of SymPy: >>> latex(Poly([a3, a2, a1, a0], t)) '\\operatorname{Poly}{\\left( a_{3} t^{3} + a_{2} t^{2} + a_{1} t + a_{0}, t, domain=\\mathbb{Z}\\left[a_{0}, a_{1}, a_{2}, a_{3}\\right] \\right)}' > --

[sympy] Re: Order of terms in polynomial with symbolic coefficients?

2018-02-22 Thread Leonid Kovalev
In SymPy, polynomials have extra structure that distinguishes them from generic expressions. a3 * t**3 + a2 * t**2 + a1 * t + a0 is an expression. If you create a polynomial in t, it will print with the order of terms being from highest to lowest. >>> p = sp.Poly([a3, a2, a1, a0], t) >>>

[sympy] Re: plot of Piecewise function not working

2018-02-22 Thread Leonid Kovalev
The code in the original message works as is in the current development version of SymPy (which can be obtained by cloning from GitHub.) The issue was fixed by https://github.com/sympy/sympy/pull/13826 On Friday, March 17, 2017 at 4:20:07 PM UTC-4, bonc...@udel.edu wrote: > > Plotting a

[sympy] Re: Can someone help me with this command?

2018-02-17 Thread Leonid Kovalev
wonder why this is not implemented > for series.Perhaps that is > part of the work that can yet be done on series: using input type to > tailor that method used > to give the output. > > BTW, this runs for Anane's expression without timing out on live.sympy.org > . > > /c &g

[sympy] Re: Can someone help me with this command?

2018-02-16 Thread Leonid Kovalev
There are much more efficient tools in sympy/polys/ring_series.py that could in principle replace series but are more limited in the expressions they support. For example, this function is the reciprocal of a polynomial. Introducing this polynomial (called g) and calling rs_series_inversion

[sympy] Re: Help with chain rule

2018-02-14 Thread Leonid Kovalev
loglikelihood does not involve W anywhere, so the derivative is zero. The reason is that the object Zl and Sl that you introduced have nothing to do with Zk and Sk that were computed earlier, they share the name but are of a different class. Other issues: Since you are using passive forms

Re: [sympy] does this Piecewise integration look right?

2018-02-02 Thread Leonid Kovalev
By definition (e.g., https://en.wikipedia.org/wiki/Dirac_delta_function#As_a_measure), DiracDelta would have integral one over any set that contains 0, even if that set has only one point. So one has to ask, when we integrate over (x, a, b), do we mean closed interval [a, b], open (a, b), or

[sympy] Re: Brief Intro and Poisson sampling

2018-01-31 Thread Leonid Kovalev
The recursion issue was caused by the evaluation of incomplete gamma functions being recursive. That was changed in PR #14021 which was merged two days ago. Try to update the branch you are working with (the PR changes another module, so there should

Re: [sympy] Sympifyin string with superscripts

2018-01-25 Thread Leonid Kovalev
To avoid duplication of effort, it should be mentioned that this was also posted on Stack Overflow: https://stackoverflow.com/questions/48454848/sympy-sympifying-strings-containing-expressions-with-superscripts -- You received this message because you are subscribed to the Google Groups "sympy"

[sympy] Re: factor giving wrong result

2018-01-25 Thread Leonid Kovalev
The bug is present in 1.1.1 but not in the current master branch on GitHub , so it was fixed already. You can clone SymPy from GitHub to use the current version, or avoid the bug by making the coefficients rational as mentioned earlier (which avoids other

[sympy] Re: factor giving wrong result

2018-01-25 Thread Leonid Kovalev
This is clearly a bug, hopefully one that will be fixed soon. Aside: symbolic manipulations are more robust when expressions involve rational numbers instead of floating point numbers. For example: y = a + Rational(1, 4)*b**2 + 1*b*c*x + 1*c**2*x**2 or y = a + Rational('0.25')*b**2 +

Re: [sympy] Re: GSoC 2018

2018-01-23 Thread Leonid Kovalev
e id? > > With Regards, > Shilpa. > > P.S.: I didn't get a notification of your reply to my e-mail. Is there any > settings that I need to do? > > On Tuesday, January 23, 2018 at 12:04:50 AM UTC+5:30, Leonid Kovalev wrote: >> >> Thanks for your interest. An issue that

[sympy] Re: GSoC 2018

2018-01-22 Thread Leonid Kovalev
Thanks for your interest. An issue that recently came up in the Probability module is sampling from a Poisson distribution . It used to not work at all, and now it does but the algorithm is not efficient when the parameter lamda is large. For

[sympy] Re: How to get a start for the upcoming gsoc 2018

2018-01-15 Thread Leonid Kovalev
If you are interested in contributing to series, study the logic of the ring series module which is documented here . It has a bunch of helper functions like

[sympy] Re: Sympy codegen optimisation by temporary variables

2018-01-15 Thread Leonid Kovalev
The more aggressive (and slower) form is cs = sp.cse(dQ_dR, optimizations='basic') which results in x0 = X_A - X_B x1 = Y_A - Y_B x2 = Z_A - Z_B x3 = 1/sqrt(x0**2 + x1**2 + x2**2) x4 = x0*x3 x5 = x1*x3 x6 = x2*x3 J(1, 1) = x4 J(1, 2) = x5 J(1, 3) = x6 J(1, 4) = -x4 J(1, 5) = -x5 J(1, 6) =

[sympy] Re: Sympy codegen optimisation by temporary variables

2018-01-15 Thread Leonid Kovalev
I would indeed expect the detection of common subexpressions to be compiler's job. SymPy should not do this by default. But it can do it if you explicitly ask: cs = sp.cse(dQ_dR) print "\n".join(sp.fcode(sub[1], sub[0]) for sub in cs[0]) + "\n" + sp.fcode (cs[1][0], J) prints x0 = X_A - X_B

[sympy] Introduction

2017-12-30 Thread Leonid Kovalev
A slightly belated introductory post... - Level of familiarity with Python: low. Can write if-statements and loops; cannot be trusted with subclassing. - Mathematical education level: PhD. My research is in real/complex analysis, pretty far from anything CAS-related, but I am

[sympy] Re: solve system ode --> TypeError: cannot determine truth value of Relational

2017-12-28 Thread Leonid Kovalev
The problem is that the solver needs to know the sign of a certain expression in terms of the coefficients (the discriminant of a polynomial), and it cannot determine the sign based on the information given, as the discriminant ends up being `D = (1/(c2*r2) - 1/(c1*r1))**2`. Symbols are not

[sympy] Re: Planck units in symbolics expressions

2017-12-27 Thread Leonid Kovalev
Actually, hbar also works if you import it (and this makes more sense than importing the class): from sympy.physics.quantum.constants import hbar and then ...subs(hbar, 1). HBar is a class name, but the module also creates an instance of that class, called hbar. On Tuesday, December 26,

[sympy] Re: Planck units in symbolics expressions

2017-12-27 Thread Leonid Kovalev
hbar is a special constant; you refer to it as HBar(), not as hbar, and it needs to be imported first. This is how you can replace it in an expression: from sympy import * from sympy.physics.qho_1d import psi_n from sympy.physics.quantum.constants import HBar n, x, m, omega = symbols("n x m