# Solving a system of equations using mpmath.findroot This post is a wiki. Anyone with karma >750 is welcome to improve it.

Hi All,

A few weeks ago, the code below, which was designed to compute some points was working perfectly. After compiling it a few days ago, I got : ValueError: Could not find root within given tolerance. (7235.55 > 2.1684e-19) Try another starting point or tweak arguments.

Please I will be very pleased if someone could help me solve this problem. Thanks for your understanding

 import mpmath
theta=pi/12

p1=vector([0,0,0])
p2=vector([-12,0,0])
p3=vector([1/24,-17/24*sqrt(287),0])

#Calcul du point p4

x4,r4=var('x4,r4')
T4=solve([(p1-x4)^2+(p1-r4*cos(theta))^2+(p1-r4*sin(theta))^2==25,(p2-x4)^2+(p2-r4*cos(theta))^2+(p2-r4*sin(theta))^2==100],x4,r4,solution_dict=True)

a=T4.values()
b=T4.values()
p4=vector([a,0,0])
if b<0:
p4=a*cos(theta)
p4=a*sin(theta)
else:
p4=b*cos(theta)
p4=b*sin(theta)

var(" x5 y5 z5 x6 y6 z6 x7 y7 z7")

eq25 = (p2-x5)^2+(p2-y5)^2+(p2-z5)^2-100 == 0
eq46 = (p4-x6)^2+(p4-y6)^2+(p4-z6)^2-144 == 0
eq45 = (p4-x5)^2+(p4-y5)^2+(p4-z5)^2-121 == 0
eq16 = (p1-x6)^2+(p1-y6)^2+(p1-z6)^2-100 == 0
eq27 = (p2-x7)^2+(p2-y7)^2+(p2-z7)^2-144 == 0
eq37 = (p3-x7)^2+(p3-y7)^2+(p3-z7)^2-144 == 0
eq56 = (x6-x5)^2+(y6-y5)^2+(z6-z5)^2-144 == 0
eq67 = (x6-x7)^2+(y6-y7)^2+(z6-z7)^2-100 == 0
eq57 = (x7-x5)^2+(y7-y5)^2+(z7-z5)^2-25 == 0

# Calcul des points p5, p6, et p7

f= [lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq25.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq46.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq45.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq16.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq27.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR ...
edit retag close merge delete