Given the lengths of the 3 sides of a triangle, output the radius of the circumscribed circle.
[3 4 5] -> 2.5
Either I am going mad or Test 1 is broken... (It's quite possibly the former!) Can anyone help?
It's probably a roundoff error in the calculation of the angle (in degrees) by acosd, which causes the end-result to have a slight offset (in the 7th or 8th decimal, which is not printed on-screen but which is there) from the exact correct answer. So instead, use the identity "(sin(x))^2 + (cos(x))^2 = 1" in order to eliminate the use of sin and cos in your calculation.
Lucinda King, you make a fair point: preferably the Test Suite should have allowed for these "slight offsets" that are created when working with floating-point numbers. Especially when the "correct" answers are not integers. [See e.g. Problem 44690.]
Why is 2.5000 not considered equal to 2.5?
How to find the position of an element in a vector without using the find function
Back to basics 9 - Indexed References
Make an awesome ramp for a tiny motorcycle stuntman
Rotate a Matrix by 90 degrees
Matlab Basics - Rounding III
Back to basics 20 - singleton dimensions
Back to basics 25 - Valid variable names
Back to basics 15 - Benchmark
Valid Chess Moves
Back to basics 1 - Saving
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office