Cody

# Problem 636. Spherical radius given four points

Solution 1955792

Submitted on 2 Oct 2019
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   Fail
pts=[0 3 2;1 -1 1;2 1 0;5 1 3]; % c(2 1 3) r=3 y_correct = 3; assert(isequal(Sphere_radius(pts),y_correct))

D = -1 4 1 -2 2 2 -5 2 -1 Di = 10 8 -22 Dx = 10 4 1 8 2 2 -22 2 -1 R = 4 Dx = -1 10 1 -2 8 2 -5 -22 -1 R = 4.0000 2.0000 Dx = -1 4 10 -2 2 8 -5 2 -22 R = 4.0000 2.0000 6.0000 r = 5.7446

Assertion failed.

2   Pass
pts=[1 0 0;0 1 0;0 0 1;-1 0 0]; % c(0 0 0) r=1 y_correct = 1; assert(isequal(Sphere_radius(pts),y_correct))

D = 1 -1 0 1 0 -1 2 0 0 Di = 0 0 0 Dx = 0 -1 0 0 0 -1 0 0 0 R = 0 Dx = 1 0 0 1 0 -1 2 0 0 R = 0 0 Dx = 1 -1 0 1 0 0 2 0 0 R = 0 0 0 r = 1

3   Fail
pts=[1 0 -1;0 1 -1;0 0 0;-1 0 -1]; % c(0 0 -1) r=1 y_correct = 1; assert(isequal(Sphere_radius(pts),y_correct))

D = 1 -1 0 1 0 -1 2 0 0 Di = 0 2 0 Dx = 0 -1 0 2 0 -1 0 0 0 R = 0 Dx = 1 0 0 1 2 -1 2 0 0 R = 0 0 Dx = 1 -1 0 1 0 2 2 0 0 R = 0 0 -2 r = 1.4142

Assertion failed.

4   Fail
pts=[2 0 -2;0 2 -2;0 0 0;-2 0 -2]; % c(0 0 -2) r=2 y_correct = 2; assert(isequal(Sphere_radius(pts),y_correct))

D = 2 -2 0 2 0 -2 4 0 0 Di = 0 8 0 Dx = 0 -2 0 8 0 -2 0 0 0 R = 0 Dx = 2 0 0 2 8 -2 4 0 0 R = 0 0 Dx = 2 -2 0 2 0 8 4 0 0 R = 0 0 -4 r = 2.8284

Assertion failed.

5   Fail
pts=[-5 -1 -3;1 -1 -3;-2 -4 -3;-2 -1 0]; % c(-2 -1 -3) r=3 y_correct = 3; assert(isequal(Sphere_radius(pts),y_correct))

D = -6 0 0 -3 3 0 -3 0 -3 Di = 24 6 30 Dx = 24 0 0 6 3 0 30 0 -3 R = -4.0000 Dx = -6 24 0 -3 6 0 -3 30 -3 R = -4.0000 -2.0000 Dx = -6 0 24 -3 3 6 -3 0 30 R = -4.0000 -2.0000 -6.0000 r = 3.3166

Assertion failed.