Problem 282. Circle and Quadratic
the visualisation has an error, it should be
C = @(x) real(-sqrt(R^2-(x-T(1)).^2) + T(2)); % Lower half circle
Thanks Gunther. The function does produce the correct graphic, but only when T(1)=0 as in my example.
The third test is a pain. Why such a small circle for high precision? It's already a single-point tangent circle. It is no fun to look for the specific method the author had in mind when we already have the answer. IMHO, problems should be open; they accept all kinds of solutions (leaving people to explore clever ideas). Or they should be closed, and a specific method is requested (so people don't wander to dead ends). Precision should be a requirement only for closed ones.
r*(x>a) is a slick way to solve the problem for the third test. :)
@Rafael Thanks. :)
Actually, the test suite is correct --- try plotting the quadratic curve and the circle from the test suite to see this.
I also believe the test suite is incorrect. Using the function roots (after manually calculating the intersection formula), the difference that I got from -4.59997651648516 was 1e-12, which is still greater than the requested 2e-14. William seems to have the right idea (the circle he has found is correct but on the convex side of the parabola).
Is there any special in Test 3?
x(1) = -b/(2a)
x(2) = (aR^2) - (3/4)*a - (1/4)(b^2/a) + c
why is this not right? it's close
I had to make a special test only for the 3rd test because it's a single-point tangent circle. A pebble so small it seems to be resting on a nearly flat surface.
don't know why the assertions fail.
The solution is correct.
If you look at the example posted in the problem description, you will see that the return argument should be a two element row vector.
Problem Recent Solvers14
Find relatively common elements in matrix rows
Project Euler: Problem 16, Sums of Digits of Powers of Two
Magic is simple (for beginners)
More from this Author6
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!