Hello. I need to create a function:
Pplus(i,t) = t**i * summation((-1)**(i+j)*binomCoeff(i,j)*Pval(j),(j,0,i))
After which I need to define a function:
P(t)=summation(Pplus(i,t),(i,0,n))
After which I'll need to do:
sqareaP=integrate(P(t)**2,(t,0,1))
I am wondering whether for this I should d
lambdify and implemented_function are best if you intend to evaluate
these numerically. Otherwise, just use a regular Python function.
Alternately, just use the symbolic expression and use subs to
substitute in exact values.
Aaron Meurer
On Thu, Nov 29, 2012 at 9:19 PM, Shriramana Sharma wrote:
On Fri, Nov 30, 2012 at 10:06 AM, Aaron Meurer wrote:
> lambdify and implemented_function are best if you intend to evaluate
> these numerically. Otherwise, just use a regular Python function.
Hi thanks. Please also clarify how I can make a function which accepts
a symbolic argument but does not
Oh, for that, you want to subclass Function and define the eval
method. implemented_function might do this as well (I don't remember
the details and I'm not at my computer right now).
Aaron Meurer
On Nov 30, 2012, at 8:04 AM, Shriramana Sharma wrote:
> On Fri, Nov 30, 2012 at 10:06 AM, Aaron Me
A python function will just return whatever you tell it to return. If
you give it symbolic input, it will plug that in and return it.
A subclass of Function will work like
In [20]: class MyFunc(Function):
: @classmethod
: def eval(cls, arg):
: if arg == 1:
Hello. I have the function binomCoeff defined (from Wikipedia) as:
def binomCoeff ( n, k ) :
if k < 0 or k > n : return 0
if k > n - k : k = n - k # take advantage of symmetry
c = 1
for i in range ( 1, k + 1 ) : # 1 to k
c = c * ( n - ( k - i ) )
>
>
> I would most appreciate it if anyone could advise me on what to do. Thanks!
>
>
Use SymPy ! :-)
>>> binomial(i,j)
binomial(i, j)
>>> _.subs(i,5)
binomial(5, j)
>>> _.subs(j,2)
10
So your expression is written as
>>> var('lamb mu')
(lamb, mu)
>>> l, i = symbols('l i',integer=True)
>>> f=sym
On Sun, Nov 18, 2012 at 1:29 PM, Chris Smith wrote:
>
def f(l, i):
> ... return lamb * ( 1 + (-mu)**(l+i) ) * binomial(l+i,i)
> ...
This is what I ended up figuring out myself! Anyhow, thanks for the
detailed explanation. I'll be back with more queries later. :-)
--
Shriramana Sharma
On Sun, Nov 18, 2012 at 3:03 PM, Shriramana Sharma wrote:
> I'll be back with more queries later. :-)
OK so here's my next query on the same thread:
In [1]: from sympy import *
...: i,j=symbols('i j',integer=True)
...: lamb=list(symbols('lamb:4'))
...: n=3
...: summation(lamb[i]*(-1)
On Sun, Nov 18, 2012 at 8:16 PM, Shriramana Sharma wrote:
>
>...: summation(lamb[i]*(-1)**(n-j)*binomial(i,n-j),(i,n-j,n))
One logical error I found in the above line is that j doesn't have a
definite (integer) value, so how can summation run i from n-j to n,
but even when I added at the head
On Sun, Nov 18, 2012 at 9:02 PM, Shriramana Sharma wrote:
> On Sun, Nov 18, 2012 at 8:16 PM, Shriramana Sharma
> wrote:
> >
> >...: summation(lamb[i]*(-1)**(n-j)*binomial(i,n-j),(i,n-j,n))
>
>
Something like this?
>>> var('i j n')
(i, j, n)
>>> lamb = Function('lamb')
>>> Sum(lamb(i)*(-1)**(
On Sun, Nov 18, 2012 at 8:54 PM, Chris Smith wrote:
lamb = Function('lamb')
Hey very nice, but I actually want to later on substitute values for
lamb0..3, and if lamb is an undefined function as the above, how do I
do that?
BTW as and when I use SymPy I am slowly coming to think that
succes
On Sun, Nov 18, 2012 at 9:27 PM, Shriramana Sharma wrote:
> On Sun, Nov 18, 2012 at 8:54 PM, Chris Smith wrote:
> lamb = Function('lamb')
>
> Hey very nice, but I actually want to later on substitute values for
> lamb0..3, and if lamb is an undefined function as the above, how do I
> do that
On Sun, Nov 18, 2012 at 10:03 PM, Chris Smith wrote:
_.replace(f, lambda x: x**2)
No I mean: I have individual values for lamb0, lamb1, lamb2, lamb3. So
what I did was:
from sympy import *
var('i j n')
lamb=Function('lamb')
f=Sum(lamb(i)*(-1)**(n-j)*binomial(i,n-j),(i,n-j,n))
mylamb=list(va
>
> No I mean: I have individual values for lamb0, lamb1, lamb2, lamb3. So
> what I did was:
>
> from sympy import *
> var('i j n')
> lamb=Function('lamb')
> f=Sum(lamb(i)*(-1)**(n-j)*binomial(i,n-j),(i,n-j,n))
> mylamb=list(var('lamb:4'))
> nval=3
> for jval in range(nval+1):
> print(f.sub
Le 18/11/2012 18:09, Shriramana Sharma a écrit :
On Sun, Nov 18, 2012 at 10:03 PM, Chris Smith wrote:
_.replace(f, lambda x: x**2)
No I mean: I have individual values for lamb0, lamb1, lamb2, lamb3. So
what I did was:
from sympy import *
var('i j n')
lamb=Function('lamb')
f=Sum(lamb(i)*(-1)*
On Sun, Nov 18, 2012 at 10:03 PM, Chris Smith wrote:
>> Hey very nice, but I actually want to later on substitute values for
>> lamb0..3, and if lamb is an undefined function as the above, how do I
>> do that?
>>
>
f=Function('f')
f(1)+f(2)
> f(1) + f(2)
_.replace(f, lambda x: x**2)
>>> eqs=Tuple(*[A(0) + 5*A(1) - 2, -3*A(0) + 6*A(1) - 15])
>>> solve(eqs, eqs.atoms(Function))
{A(0): -3, A(1): 1}
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this gro
On Sat, Dec 1, 2012 at 5:07 PM, Chris Smith wrote:
eqs=Tuple(*[A(0) + 5*A(1) - 2, -3*A(0) + 6*A(1) - 15])
solve(eqs, eqs.atoms(Function))
> {A(0): -3, A(1): 1}
Hi thanks for this! So does this mean that there is no need for
separate support for subscripted symbolic variables in SymPy?
>
> Hi thanks for this! So does this mean that there is no need for
> separate support for subscripted symbolic variables in SymPy?
>
>
If the functions work, then no. But functions don't carry assumptions.
Having you raise questions like this helps to flesh out situations where
existing or new str
On Sat, Dec 1, 2012 at 5:32 PM, Chris Smith wrote:
> If the functions work, then no. But functions don't carry assumptions.
Can you clarify what you mean by "assumptions"?
And even though it seems (I haven't yet implemented that part of my
program yet) that it would be sufficient to use Function
On Sat, Dec 1, 2012 at 6:42 PM, Shriramana Sharma wrote:
> On Sat, Dec 1, 2012 at 5:32 PM, Chris Smith wrote:
> > If the functions work, then no. But functions don't carry assumptions.
>
> Can you clarify what you mean by "assumptions"?
>
> And even though it seems (I haven't yet implemented tha
On Sat, Dec 1, 2012 at 6:46 PM, Chris Smith wrote:
>
> that's what symbols does for you; just store the result in an array if you
> want:
>
a=symbols('a:11')
a[1]
> a1
a
> (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
But I already said that I can't use a Python list because I can'
I ran into this problem in MatrixExprs. We don't currently have a
subscripted symbol. It would be nice though.
In the following example
In [1]: X = MatrixSymbol('X', n, n)
In [2]: X[1, 2]
Out[2]: X₁₂
Ideally X[1, 2] is a Symbol that contains separate information for its
origin X and its indice
Hi,
I tried python lists and every thing seems fine to me-
>>> ls=symbols('a:10')
>>> ls
(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9)
Now I call a function Sum (it sums up a series in particular, infinite
series)-
>>> for i in range(10):
... Sum(1/(ls[i]**ls[i]),(ls[i],1,oo)).evalf()
...
1.2912859
On Sat, Dec 1, 2012 at 8:22 PM, Rishabh Dixit wrote:
for i in range(10):
> ... Sum(1/(ls[i]**ls[i]),(ls[i],1,oo)).evalf()
> ...
>
solve([ls[0]+5*ls[1]-2,-3*ls[0]+6*ls[1]-15])
> {a0: -3, a1: 1}
Rishabh, basically the difference between what you are saying and I am
saying is, in the firs
On Dec 1, 2012, at 6:31 AM, Shriramana Sharma wrote:
On Sat, Dec 1, 2012 at 6:46 PM, Chris Smith wrote:
that's what symbols does for you; just store the result in an array if you
want:
a=symbols('a:11')
a[1]
a1
a
(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
But I already said that I
If you work with the current master you won't get the Indexed error:
>>> from sympy import IndexedBase
>>> A=IndexedBase('A')
>>> solve([A[0] + 5*A[1] - 2, -3*A[0]+ 6*A[1] - 15])
[]
But no solution...so let's try the Tuple-atoms trick:
>>> eqs=Tuple(*([A[0] + 5*A[1] - 2, -3*A[0]+ 6*A[1] - 15]))
On Sun, Dec 2, 2012 at 6:59 AM, Chris Smith wrote:
> If you work with the current master you won't get the Indexed error:
>
from sympy import IndexedBase
A=IndexedBase('A')
solve([A[0] + 5*A[1] - 2, -3*A[0]+ 6*A[1] - 15])
> []
>
> But no solution...so let's try the Tuple-atoms trick
On Sat, Dec 1, 2012 at 7:13 PM, Matthew Rocklin wrote:
> In the following example
> In [1]: X = MatrixSymbol('X', n, n)
>
> In [2]: X[1, 2]
> Out[2]: X₁₂
>
> Ideally X[1, 2] is a Symbol that contains separate information for its
> origin X and its indices, 1, and 2. Alas, all it knows is the comb
On Sun, Dec 2, 2012 at 7:58 AM, Shriramana Sharma wrote:
> On Sun, Dec 2, 2012 at 6:59 AM, Chris Smith wrote:
> > If you work with the current master you won't get the Indexed error:
> >
> from sympy import IndexedBase
> A=IndexedBase('A')
> solve([A[0] + 5*A[1] - 2, -3*A[0]+ 6*A[
What about this?
class Syms(object):
"""Return an Indexed object with name given at instantiation.
Indexing can be done using matrix or function notation.
Examples
>> from sympy.future import Syms
>> a=Syms('a')
>> a[1]
a[1]
>> a(1)
a[1]
>> a(
On Sun, Dec 2, 2012 at 9:46 AM, Chris Smith wrote:
> I don't follow you...if the function or Indexed has a different name then
> it's different from others, and if the argument(s) of any function or
> Indexed are different they represent different objects.
>
eqs=Tuple(f(1,2)+f(i)-3,f(1,2)-f(i
On Sat, Dec 1, 2012 at 5:07 PM, Chris Smith wrote:
eqs=Tuple(*[A(0) + 5*A(1) - 2, -3*A(0) + 6*A(1) - 15])
solve(eqs, eqs.atoms(Function))
> {A(0): -3, A(1): 1}
On Sun, Dec 2, 2012 at 6:59 AM, Chris Smith wrote:
eqs=Tuple(*([A[0] + 5*A[1] - 2, -3*A[0]+ 6*A[1] - 15]))
Hi can you cl
Sorry for the extra mail!
On Sun, Dec 2, 2012 at 10:04 PM, Shriramana Sharma wrote:
> Hi can you clarify why you have used a * inside the Tuple constructor
> in both the above cases and why the additional () around the []
> containing the list in the second case? The Tuple documentation
> doesn't
Of you have a tuple literal, it's redundant. Tuple(*(1,2)) is the same
as Tuple(1,2). But if you have a variable, you have to use Tuple(*a).
Aaron Meurer
On Dec 2, 2012, at 9:34 AM, Shriramana Sharma wrote:
> On Sat, Dec 1, 2012 at 5:07 PM, Chris Smith wrote:
> eqs=Tuple(*[A(0) + 5*A(1) -
>
>
> I found out from the Python documentation that * unpacks lists, but my
> question about the extra () in the second example still stands...
>
>
It unpacks tuples, too.
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send ema
OK, in the current master the Indexed quantities will be detected
automatically.
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to
sympy+unsubscr.
38 matches
Mail list logo