Question: These formulae can be expressed as functions. import numpy as np def a( d1, d2, x1, y1, x2, y2 ): numerator=d1**2-d2**2 - ((x1**2+y1**2)-(x2**2+y2**2)) denominator=2*(y2-y1) return

 These formulae can be expressed as functions. import numpy as np

These formulae can be expressed as functions.

import numpy as np def a( d1, d2, x1, y1, x2, y2 ): numerator=d1**2-d2**2 - ((x1**2+y1**2)-(x2**2+y2**2)) denominator=2*(y2-y1) return numerator/denominator def b( x1, y1, x2, y2 ): return -(x2-x1)/(y2-y1) def solve_xy( x1, y1, x2, y2, d1, d2 ): bb=b(x1,y1,x2,y2) aa=a(d1,d2,x1,y1,x2,y2) rad=4*(bb*(aa-y1)-x1)**2 - 4*(1+bb**2)*(x1**2-d1**2+(y1-aa)**2) pre=2*(x1-bb*(aa-y1)) den=2*(1+bb**2) xp=(pre+np.sqrt(rad))/den xm=(pre-np.sqrt(rad))/den yp=aa+xp*bb ym=aa+xm*bb return xm,ym,xp,yp

def a( d1, d2, x1, y1, x2, y2 ): numerator=d1**2-d2**2 - ((x1**2+y1**2)-(x2**2+y2**2))PYTHON: output to my code that gets error

Test feedback: "triangulate(-5.546, -0.82919, 1.331, 0.1001, 4.0, 1.0) incorrectly returned-5.546-0.82919"denominator=2*(y2-y1) return numerator/denominator def b( x1, y1, x2, y2 ): return -(x2-x1)/(y2-y1)my code

def pythagoras (xa,ya,xb,yb): dd=(xa-xb)**2+(ya-yb)**2 return abs(np.sqrt(dd))

def triangulate(xp,yp,xm,ym,d1,d2): a = pythagoras(xp,yp,d1,d2) b = pythagoras(xm,ym,d1,d2) if a > b: return xp,yp else: return xm,ym [x1,y1,x2,y2,d1,d2]=[-2.4,1.8,-1.9,-1.9,4.1,3.8] [xm,ym,xp,yp]=solve_xy(x1,y1,x2,y2,d1,d2) if pythagoras(x1,y1,xm,ym) == d1 and pythagoras(x1,y1,xp,yp) == d1 and pythagoras(x1,y1,xm,ym) == d2 and pythagoras(x1,y1,xp,yp) == d2: print('Equivalent')

print('Point closer to ', triangulate(xp,yp,xm,ym,x1,y1))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!