Ask Your Question
0

solve equation with double sum

asked 2015-04-08 14:59:34 +0200

this post is marked as community wiki

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

Hi!

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:

x=var('x')
find_root(f(x)==h(x),x,x_min,x_max)

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


Update:

If I run the next code:

import sympy.mpmath

N=20
A=0.7 
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

Comments

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 19:23:11 +0200 )edit

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

mresimulator gravatar imagemresimulator ( 2015-04-10 02:04:54 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-04-10 14:30:30 +0200

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.

var('x')

N=20
A=0.7
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

Comments

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 13:57:53 +0200 )edit

Try:

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 15:42:51 +0200 )edit

Thanks you very much calc314!! Best regards

mresimulator gravatar imagemresimulator ( 2015-04-11 20:57:12 +0200 )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

Stats

Asked: 2015-04-08 14:59:34 +0200

Seen: 1,174 times

Last updated: Apr 10 '15