Ask Your Question

solve equation with double sum

asked 2015-04-08 07:59:34 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.


Please help me with my porblem. I have two no-linear equations:

1) f(x)==h(x)

2) g(x)+S_{i,j,k}(x) == 0

I know I can solve (numerically) eq.(1) doing:


In eq.(2) S_{i,j,k}(x) is a triple sum function of 'x' and i,j and k are the index of the sum.

How can I solve (numerically) eq.(2)?

Waiting for your answers. Thanks a lot! Best regards


If I run the next code:

import sympy.mpmath

G_0 = 37.7
B = 0.36

x = sympy.symbols('x')

def S(x_): 
     return sympy.mpmath.nsum(lambda i, j, k: (12*A**4*x_**6*i**4-30*A**2*x_**3*i**2*(j**2+k**2)+3*(j**2+k**2)**2)/(2*(A**2*x_**3*i**2+j**2+k**2)**(7/2)),[1,N],[1,N],[1,N])

def F(x_):
     return G_0 * (x_ - 1/(x_**2))

print(sympy.mpmath.findroot(F(x) + B*A*sqrt(x)*S(x), [0.85,1]) )

I get the next error:

TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and '<class 'sympy.mpmath.ctx_mp_python.mpf'>'

What am I doing wrong?

Best regards!

edit retag flag offensive close merge delete


Can you post more details on the sum? We will need more details to be able to give much help.

calc314 gravatar imagecalc314 ( 2015-04-08 12:23:11 -0600 )edit

I edit my post. Waiting for your answer. Thanks!

mresimulator gravatar imagemresimulator ( 2015-04-09 19:04:54 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-04-10 07:30:30 -0600

calc314 gravatar image

The following code running with Sage rather than mpmath runs for me, but it says there are no zeros on the interval.


G_0 = 37.7
B = 0.36

def S(x_):
     return add([(12*A**4*x_**6*i**4-30*A**2*x_**3*i**2*(j**2+k**2)+3*(j**2+k**2)**2)/(2*(A**2*x_**3*i**2+j**2+k**2)**(7/2)) for i in range(1,N+1) for j in range(1,N+1) for k in range(1,N+1)])

def F(x_):
     return G_0 * (x_ - 1/(x_**2))

print(find_root(F(x) + B*A*sqrt(x)*S(x), 0.85,1) )
edit flag offensive delete link more


Thanks!! I fix it defining the function G(x)=F(x) + B*A*sqrt(x)*S(x) becausesympy.mpmath.findroot need that. One more question about the summation: I wanna use the limits -N to N but i want to exclude the point (i,j,k)=(0,0,0) (this is the tree index zero simultaneously) . How can I do that? Best regards. Thanks again

mresimulator gravatar imagemresimulator ( 2015-04-11 06:57:53 -0600 )edit


add([(12*A**4*x_**6*i**4-30*A**2*x_**3*i**2*(j**2+k**2)+3*(j**2+k**2)**2)/(2*(A**2*x_**3*i**2+j**2+k**2)**(7/2)) for i in range(-N,N+1) for j in range(-N,N+1) for k in range(-N,N+1) if (i!=0 or j!=0 or k!=0) ] )

calc314 gravatar imagecalc314 ( 2015-04-11 08:42:51 -0600 )edit

Thanks you very much calc314!! Best regards

mresimulator gravatar imagemresimulator ( 2015-04-11 13:57:12 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-04-08 07:59:34 -0600

Seen: 467 times

Last updated: Apr 10 '15