MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply TodayImagine the quadratic curve with equation

y=y(x)=ax^2+bx+c

On the concave side of this curve there is a circle of radius R. The circle is as close the the extremum of the quadratic as possible without resulting in the curves crossing each other. Write a function which takes as inputs a,b,c, and R and returns the coordinates of the center of the circle.

For example, if

a=1; b=0; c=10; R=pi;

then the function returns

T = circ_puzz(a,b,c,R) T = 0 20.1196044010894

This can be visualized as follows:

P = @(x) a*x.^2 + b*x + c; % Quadratic C = @(x) real(-sqrt(R^2-(x-T(1)).^2) + T(2)); % Lower half circle x = linspace(-R,R,10000); % Range of plotted data. plot(x,C(x),'r',x,-C(x)+2*T(2),'r',x,P(x),T(1),T(2),'*k') ylim([0,30]) axis equal

21 correct solutions
45 incorrect solutions

Last solution submitted on Aug 20, 2013

1 player likes this problem

1 Comment

Trung Duong
on 9 Feb 2012

Is there any special in Test 3?

2 Comments

Trung Duong
on 9 Feb 2012

don't know why the assertions fail.
The solution is correct.

Matt Fig
on 9 Feb 2012

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.

2 Comments