Cody

Solution 1681924

Submitted on 28 Nov 2018 by Martin C.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
x0y0 = [-2 5]; P = [0.5 3 -5]; y_correct = 4.3093988461280149175163000679048; tol = 5e-13; assert(abs(distance2polynomial(P,x0y0)-y_correct) < tol)

p1 = 1 2 t1 = 1 4 4 p2 = 0.5000 3.0000 -5.0000 p2 = 0.5000 3.0000 -10.0000 t2 = 0.2500 3.0000 -1.0000 -60.0000 100.0000 mi = 0.2500 3.0000 0 -56.0000 104.0000 r = -8.1587 -3.0741 2.2328 r = -8.1587 -3.0741 2.2328 D = 4.3094

2   Pass
x0y0 = [pi, pi]; P = [10]; y_correct = 6.8584073464102067615373566167205; tol = 7e-13; assert(abs(distance2polynomial(P,x0y0)-y_correct) < tol)

p1 = 1.0000 -3.1416 t1 = 1.0000 -6.2832 9.8696 p2 = 10 p2 = 6.8584 t2 = 47.0378 mi = 1.0000 -6.2832 56.9074 r = 3.1416 r = 3.1416 D = 6.8584

3   Pass
x0y0 = [0.25,50]; P = [1 2 3 4 5]; y_correct = 1.6470039192886012020234097061626; tol = 5e-13; assert(abs(distance2polynomial(P,x0y0)-y_correct) < tol)

p1 = 1.0000 -0.2500 t1 = 1.0000 -0.5000 0.0625 p2 = 1 2 3 4 5 p2 = 1 2 3 4 -45 t2 = 1 4 10 20 -65 -156 -254 -360 2025 mi = 1.0e+03 * 0.0010 0.0040 0.0100 0.0200 -0.0650 -0.1560 -0.2530 -0.3605 2.0251 r = -3.0424 + 0.0000i -0.4273 + 2.7595i -0.4273 - 2.7595i 1.8968 + 0.0000i -1.0044 + 0.0000i -0.2477 + 0.9673i -0.2477 - 0.9673i r = -3.0424 1.8968 -1.0044 D = 1.6470

4   Pass
x0y0 = [-3 -3]; P = [-2 1]; y_correct = 4.4721359549995793928183473374626; tol = 5e-13; assert(abs(distance2polynomial(P,x0y0)-y_correct) < tol)

p1 = 1 3 t1 = 1 6 9 p2 = -2 1 p2 = -2 4 t2 = 4 -16 16 mi = 5 -10 25 r = 1 r = 1 D = 4.4721

5   Pass
x0y0 = [0 5]; P = [1 0 1]; y_correct = 1.9364916731037084425896326998912; tol = 2e-13; assert(abs(distance2polynomial(P,x0y0)-y_correct) < tol)

p1 = 1 0 t1 = 1 0 0 p2 = 1 0 1 p2 = 1 0 -4 t2 = 1 0 -8 0 16 mi = 1 0 -7 0 16 r = 0 1.8708 -1.8708 r = 0 1.8708 -1.8708 D = 1.9365

6   Pass
x0y0 = [-2 -5]; P = [0.5 3 -5]; y_correct = 1.8901381949770695260066523338279; tol = 2e-13; (abs(distance2polynomial(P,x0y0)-y_correct) < tol)

p1 = 1 2 t1 = 1 4 4 p2 = 0.5000 3.0000 -5.0000 p2 = 0.5000 3.0000 0 t2 = 0.2500 3.0000 9.0000 0 0 mi = 0.2500 3.0000 10.0000 4.0000 4.0000 r = -5.4893 -3.2892 -0.2215 r = -5.4893 -3.2892 -0.2215 D = 1.8901 ans = logical 1