This is an optimization problem.
It is based on OLD Homework 0510-9 at
http://www.math.umn.edu/~adams/MATH1271/hmwrkMATH1271.html.
L
be the line ax+by=c
.
Find the point on L
that is closest to
(x0,y0)
.p
/ lincoeff ,
q
/ lincoeff ) ",p
and q
are integers.
( -constcoeff / lincoeff ,
t*lincoeff+s*b*constcoeff / lincoeff )
Solving ax+by=c
for y
,
we get y=t-s*bx
.
Let f(x)
be the square of the distance from
(x,y)
to (x0,y0)
,
with y=t-s*bx
.
Then f(x)
is the square of the distance from
(x,t-s*bx
) to (x0,y0)
.
Then f(x)=[x-x0]^2+[t-b*sx-y0]^2
.
Then f'(x)=2[x-x0]+
2[t-b*sx-y0][-b*s]
.
Expanding, collecting terms, and factoring out 2
,
f'(x)=2(lincoeffx+constcoeff)
.
Expanding, collecting terms, and factoring out 2
,
f'(x)=2(lincoeffx--constcoeff)
.
Then f'(x)=0
if and only if x = -constcoeff/lincoeff
.
Also, f'(x)
is negative on x < -constcoeff/lincoeff
and positive on x > -constcoeff/lincoeff
.
Then f(x)
is decreasing on x < -constcoeff/lincoeff
and increasing on x > -constcoeff/lincoeff
.
Then f(x)
attains its minimum at x = -constcoeff/lincoeff
.
Since y=t-s*bx
it follows that,
when x = -constcoeff/lincoeff
,
we get y=t*lincoeff+s*b*constcoeff/lincoeff
.
In the "Answer" box, fill in -constcoeff
and t*lincoeff+s*b*constcoeff
,
so that it reads:
(-constcoeff/lincoeff,
t*lincoeff+s*b*constcoeff/lincoeff)