On Jan 7, 2008 7:13 PM, Zoho <[EMAIL PROTECTED]> wrote:
>
> Hello:
>
> I am brand new to python/sympy  scripting and I have a project I have
> written in Maxima but would like to port it to sympy (as it is far
> more readable than the specific Maxima language) but I am not sure if
> sympy yet has the funcialanity that I require.
>
> What I would like to do is create an array with symbolic coefficients
> and then use the array coeffiecents to create expressions. The
> coeffiecents are solved for later. To give you and idea of what I mean
> here is a small snippet of the Maxima code:
>
> /* A Maxima program to solve
>                         psi'' + lambda *sin(psi) = 0 , psi'(0)=psi'(1)=0,
>                                         int(sin(psi(s),s=0..1) = 0.
> where   psi = b*cos(n*pi*s) + b^3*cos^3(n*pi*s) + ...
>                                 lambda=1+k*b^2+k*b^4 + ... */
>
> /* Setup the expressions for psi, lambda, x, y and solve for
> the parameters */
> setup(terms):=block([],
>         kill(k,a,b,d),
>         n:terms,
>         ratweight (b,1,c,1),
>         ratwtlvl: 2*(2*n+1),
>         /* Calculate expansion for psi and lambda */
>         C[0]:c,
>         Cpp[0]:-c,
>         k[0]:1,
>         for i thru n do (
>                 C[i]:sum(a[i,j]*c^(2*j+1),j,1,i),
>                 
> Cpp[i]:sum(a[i,j]*(-(2*j+1)^2*c^(2*j+1)+(2*j+1)*(2*j)*c^(2*j-1)),j,
> 1,i) ),
>         psi:sum(b^(2*i+1)*C[i], i,0,n),
>         lam:sum(b^(2*i)*k[i], i,0,n),
>
> ....
>
> in the Maxima code you do not need to declare the array before. Here
> 'a'  is an array and the expressions 'psi' and 'lam' are later solved
> for the coefficients.
>
> So is there a way to do this using sympy?

Hi Zoho,

thanks for your interest. I think you can do that in SymPy.

But I have problems understanding the Maxima code, could you please
write in python terms what it's doing? :)

For example:

>         for i thru n do (
>                 C[i]:sum(a[i,j]*c^(2*j+1),j,1,i),
>                 
> Cpp[i]:sum(a[i,j]*(-(2*j+1)^2*c^(2*j+1)+(2*j+1)*(2*j)*c^(2*j-1)),j,
> 1,i) ),

This assignes some expressions into arrays C and Cpp, right?

>         psi:sum(b^(2*i+1)*C[i], i,0,n),
>         lam:sum(b^(2*i)*k[i], i,0,n),

This uses C to construct psi. Where is Cpp used? Isn't k[i]
uninitialized, except k[0]? What is in a[i,j],
if you didn't assign to it? But if you are just using arrays, symbolic
expressions, sums, substitution,
all of that work nice in sympy.

Ask here if you have any problems rewriting your code and please
report all bugs that you may find,
we'll try to fix them promptly.

Ondrej

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to