Skip to main content
deleted 1089 characters in body
Source Link
smichr
  • 465
  • 2
  • 10

I would continue by replacing $x_P$ and $y_P$ with $2\cos(\theta)$ and $2\sin(\theta)$, respectively. This will give a function $f(\theta)$. Graphing, the minimum is seen at about $82^\circ$, corresponding to a value of approximately $4.086$ for the objective function. If you write the equation in terms of $x=\tan(\theta/2)$ you can take the derivative wrt x and find the minimum. The derivative will have radicals which can be removed and the resulting polynomial does not have a closed form solution (though can easily be solved numerically). Testing the real possibilities to see which minimizes the function confirms the graphical solution.

It is so tempting to think of minimizing $a + b$ as the same as minimizing $a^2 + b^2$ when faced with the square roots of expressions for $a$ and $b$. And the reward, for this problem, is a tractable solution...which is close (at $\theta=-2\tan^{-1}(1/20 - \sqrt{401}/20)\approx 87^\circ$) but is about $5^\circ$ from the correct answer.

If I re-derive the objective function according to the description you gave, I get something else. Here is thea derivation using the CAS SymPy, a CAS in Python:

So the minimum is $\sqrt{41}$ at a value of $t =2\tan^{-1}(8/5 + \sqrt{139}/5)$$\tan(t/2) =(8/5 + \sqrt{139}/5)$. This agrees with the graphical minimum of the objective function.

I would continue by replacing $x_P$ and $y_P$ with $2\cos(\theta)$ and $2\sin(\theta)$, respectively. This will give a function $f(\theta)$. Graphing, the minimum is seen at about $82^\circ$, corresponding to a value of approximately $4.086$ for the objective function. If you write the equation in terms of $x=\tan(\theta/2)$ you can take the derivative wrt x and find the minimum. The derivative will have radicals which can be removed and the resulting polynomial does not have a closed form solution (though can easily be solved numerically). Testing the real possibilities to see which minimizes the function confirms the graphical solution.

It is so tempting to think of minimizing $a + b$ as the same as minimizing $a^2 + b^2$ when faced with the square roots of expressions for $a$ and $b$. And the reward, for this problem, is a tractable solution...which is close (at $\theta=-2\tan^{-1}(1/20 - \sqrt{401}/20)\approx 87^\circ$) but is about $5^\circ$ from the correct answer.

If I re-derive the objective function according to the description you gave, I get something else. Here is the derivation using the CAS SymPy:

So the minimum is $\sqrt{41}$ at a value of $t =2\tan^{-1}(8/5 + \sqrt{139}/5)$. This agrees with the graphical minimum of the objective function.

Here is a derivation using SymPy, a CAS in Python:

So the minimum is $\sqrt{41}$ at a value of $\tan(t/2) =(8/5 + \sqrt{139}/5)$. This agrees with the graphical minimum of the objective function.

updated for correct objective
Source Link
smichr
  • 465
  • 2
  • 10
# define objects

>>> from sympy.abc import *
>>> from sympy import *
>>> P=Circle((5,0),2).arbitrary_point(t)
>>> C=Point(0,5)
>>> A=Point(1,0)

# define objective

>>> objective=Segment(P,C).length + Segment(AP,CA).length/2; o2
sqrt((2*sin(t) - 5)**2 + (2*cos(t) + 5)**2) + sqrt(26(2*cos(t) + 4)**2 + 4*sin(t)**2)/2

# we desire the minimum wrt t (which controls where we are on the circle)

>>> objective.diff(t)
(2*(2*sin(t) - 5)*cos(t) - 2*(2*cos(t) + 5)*sin(t))/sqrt((2*sin(t) - 5)**2 + (2*cos(t) + 5)**2) + (-2*(2*cos(t) + 4)*sin(t) + 4*sin(t)*cos(t))/(2*sqrt((2*cos(t) + 4)**2 + 4*sin(t)**2))

# rewrite sin and cos in terms of tan and let tan(t/2) be x, keep only
# the numerator

>>> _.rewrite(tan).subs(tan(t/2),x).as_numer_denom()[0].factor
(x**2 + 1)**2*(8*x*(1 - x**2)
10* - 8*x*(x**2 + 3))*sqrt((4*x/(x**2 + 1) - 5)**2 + (2*(1 - x**2)/(x**2 + 1) + 5)**2) + (x**2 + 1)**2*(-8*x*(3*x**2 + 7) + 4*(1 - x**2)*(-5*x**2 + 4*x - 5))*sqrt(16*x**2/(x**2 + 1)**2 + (2*(1 - 2*xx**2)/(x**2 + 1) + 4)**2)

# remove radicals

>>> unrad(_)
(25*x**22 - 100*x**21 + 339*x**20 - 1440*x**19 + 1991*x**18 - 7020*x**17 + 6949*x**16 - 16320*x**15 + 16346*x**14 - 17640*x**13 + 27454*x**12 + 33614*x**10 + 24360*x**9 + 29866*x**8 + 31680*x**7 + 18749*x**6 + 19980*x**5 + 7871*x**4 + 6560*x**3 + 1979*x**2 + 900*x + 225, [])

# factor

>>> factor(_[0])
(x**2 + 1)**8*(5*x**2 - 16*x - 15)*(5*x**4 - 4*x**3 + 30*x**2 - 44*x - 15)

# get solutions for x

>>> [i for i in solve(_) if i.is_real]
[[8/5 -I sqrt(139)/5, I8/5 + sqrt(139)/5, 1/5 -+ sqrt(2-96/25 - 88/(75*(196/25 + 4*sqrt(4877997),/1125)**(1/3)) + 2*(196/25 + 4*sqrt(4877997)/1125)**(1/3))/2 + sqrt(-192/25 - 2*(196/25 + 4*sqrt(4877997)/1125)**(1/3) + 88/(75*(196/25 + 4*sqrt(4877997)/1125)**(1/3)) + 1616/(125*sqrt(-96/25 - 88/(75*(196/25 + 4*sqrt(4877997)/1125)**(1/3)) + 2*(196/25 + 4*sqrt(4877997)/1125)**(1/3))))/2, -sqrt(-192/25 - 2*(196/25 + 4*sqrt(4877997)]

#/1125)**(1/3) keep+ real88/(75*(196/25 solutions+ and4*sqrt(4877997)/1125)**(1/3)) map+ back1616/(125*sqrt(-96/25 to- t88/(75*(196/25 + 4*sqrt(4877997)/1125)**(1/3)) + 2*(196/25 + 4*sqrt(4877997)/1125)**(1/3))))/2 + 1/5 + sqrt(-96/25 - 88/(75*(196/25 + 4*sqrt(4877997)/1125)**(1/3)) + 2*(196/25 + 4*sqrt(4877997)/1125)**(1/3))/2]

>>> ans = flatten([solve(tan(t/2)-i) for i in _[-2:]]_])
[-pi/4, 3*pi/4]

# check value of objective at those values of t

>>> [objective.subs(t,i).simplifyn() for i in _]ans]
[2[11.3350373276846, 6.40312423743285, 7.11408182438962, 11.9279919892822]

# value of objective at ans[1]

>>> m=objective.subs(t,ans[1]);m
sqrt(4*sin(2*atan(8/5 + sqrt(26139)/25))**2 + 5*sqrt(22*cos(2*atan(8/5 + sqrt(139),/5)) -+ 4)**2)/2 + sqrt(26)(2*cos(2*atan(8/25 + 5*sqrtsqrt(2139)]
>>>/5)) [i.n+ 5)**2 + (-5 + 2*sin(2*atan(8/5 + sqrt(139)/5)))**2)

# forlooks iworse inthat _]it is - this is equivalent to sqrt(41)
[11.6205775686619,
>>> 7nsimplify(m)
sqrt(41)
>>> m.62057756866187]equals(_)
True

So the minimum is $-2 + \sqrt{26}/2 + 5\sqrt2 \approx 7.6$ and$\sqrt{41}$ at a value of $t =3\pi/4$$t =2\tan^{-1}(8/5 + \sqrt{139}/5)$. This agrees with the graphical minimum of the objective function.

# define objects

>>> from sympy.abc import *
>>> from sympy import *
>>> P=Circle((5,0),2).arbitrary_point(t)
>>> C=Point(0,5)
>>> A=Point(1,0)

# define objective

>>> objective=Segment(P,C).length + Segment(A,C).length/2; o
sqrt((2*sin(t) - 5)**2 + (2*cos(t) + 5)**2) + sqrt(26)/2

# we desire the minimum wrt t (which controls where we are on the circle)

>>> objective.diff(t)
(2*(2*sin(t) - 5)*cos(t) - 2*(2*cos(t) + 5)*sin(t))/sqrt((2*sin(t) - 5)**2 + (2*cos(t) + 5)**2)

# rewrite sin and cos in terms of tan and let tan(t/2) be x

>>> _.rewrite(tan).subs(tan(t/2),x).as_numer_denom()[0].factor()
10*(x**2 + 1)*(x**2 - 2*x - 1)

# get solutions for x

>>> solve(_)
[-I, I, 1 - sqrt(2), 1 + sqrt(2)]

# keep real solutions and map back to t

>>> flatten([solve(tan(t/2)-i) for i in _[-2:]])
[-pi/4, 3*pi/4]

# check value of objective at those values of t

>>> [objective.subs(t,i).simplify() for i in _]
[2 + sqrt(26)/2 + 5*sqrt(2), -2 + sqrt(26)/2 + 5*sqrt(2)]
>>> [i.n() for i in _]
[11.6205775686619, 7.62057756866187]

So the minimum is $-2 + \sqrt{26}/2 + 5\sqrt2 \approx 7.6$ and a value of $t =3\pi/4$. This agrees with the graphical minimum of the objective function.

# define objects

>>> from sympy.abc import *
>>> from sympy import *
>>> P=Circle((5,0),2).arbitrary_point(t)
>>> C=Point(0,5)
>>> A=Point(1,0)

# define objective

>>> objective=Segment(P,C).length + Segment(P,A).length/2
sqrt((2*sin(t) - 5)**2 + (2*cos(t) + 5)**2) + sqrt((2*cos(t) + 4)**2 + 4*sin(t)**2)/2

# we desire the minimum wrt t (which controls where we are on the circle)

>>> objective.diff(t)
(2*(2*sin(t) - 5)*cos(t) - 2*(2*cos(t) + 5)*sin(t))/sqrt((2*sin(t) - 5)**2 + (2*cos(t) + 5)**2) + (-2*(2*cos(t) + 4)*sin(t) + 4*sin(t)*cos(t))/(2*sqrt((2*cos(t) + 4)**2 + 4*sin(t)**2))

# rewrite sin and cos in terms of tan and let tan(t/2) be x, keep only
# the numerator

>>> _.rewrite(tan).subs(tan(t/2),x).as_numer_denom()[0]
(x**2 + 1)**2*(8*x*(1 - x**2) - 8*x*(x**2 + 3))*sqrt((4*x/(x**2 + 1) - 5)**2 + (2*(1 - x**2)/(x**2 + 1) + 5)**2) + (x**2 + 1)**2*(-8*x*(3*x**2 + 7) + 4*(1 - x**2)*(-5*x**2 + 4*x - 5))*sqrt(16*x**2/(x**2 + 1)**2 + (2*(1 - x**2)/(x**2 + 1) + 4)**2)

# remove radicals

>>> unrad(_)
(25*x**22 - 100*x**21 + 339*x**20 - 1440*x**19 + 1991*x**18 - 7020*x**17 + 6949*x**16 - 16320*x**15 + 16346*x**14 - 17640*x**13 + 27454*x**12 + 33614*x**10 + 24360*x**9 + 29866*x**8 + 31680*x**7 + 18749*x**6 + 19980*x**5 + 7871*x**4 + 6560*x**3 + 1979*x**2 + 900*x + 225, [])

# factor

>>> factor(_[0])
(x**2 + 1)**8*(5*x**2 - 16*x - 15)*(5*x**4 - 4*x**3 + 30*x**2 - 44*x - 15)

# get solutions for x

>>> [i for i in solve(_) if i.is_real]
[8/5 - sqrt(139)/5, 8/5 + sqrt(139)/5, 1/5 + sqrt(-96/25 - 88/(75*(196/25 + 4*sqrt(4877997)/1125)**(1/3)) + 2*(196/25 + 4*sqrt(4877997)/1125)**(1/3))/2 + sqrt(-192/25 - 2*(196/25 + 4*sqrt(4877997)/1125)**(1/3) + 88/(75*(196/25 + 4*sqrt(4877997)/1125)**(1/3)) + 1616/(125*sqrt(-96/25 - 88/(75*(196/25 + 4*sqrt(4877997)/1125)**(1/3)) + 2*(196/25 + 4*sqrt(4877997)/1125)**(1/3))))/2, -sqrt(-192/25 - 2*(196/25 + 4*sqrt(4877997)/1125)**(1/3) + 88/(75*(196/25 + 4*sqrt(4877997)/1125)**(1/3)) + 1616/(125*sqrt(-96/25 - 88/(75*(196/25 + 4*sqrt(4877997)/1125)**(1/3)) + 2*(196/25 + 4*sqrt(4877997)/1125)**(1/3))))/2 + 1/5 + sqrt(-96/25 - 88/(75*(196/25 + 4*sqrt(4877997)/1125)**(1/3)) + 2*(196/25 + 4*sqrt(4877997)/1125)**(1/3))/2]

>>> ans = flatten([solve(tan(t/2)-i) for i in _])

# check value of objective at those values of t

>>> [objective.subs(t,i).n() for i in ans]
[11.3350373276846, 6.40312423743285, 7.11408182438962, 11.9279919892822]

# value of objective at ans[1]

>>> m=objective.subs(t,ans[1]);m
sqrt(4*sin(2*atan(8/5 + sqrt(139)/5))**2 + (2*cos(2*atan(8/5 + sqrt(139)/5)) + 4)**2)/2 + sqrt((2*cos(2*atan(8/5 + sqrt(139)/5)) + 5)**2 + (-5 + 2*sin(2*atan(8/5 + sqrt(139)/5)))**2)

# looks worse that it is - this is equivalent to sqrt(41)

>>> nsimplify(m)
sqrt(41)
>>> m.equals(_)
True

So the minimum is $\sqrt{41}$ at a value of $t =2\tan^{-1}(8/5 + \sqrt{139}/5)$. This agrees with the graphical minimum of the objective function.

added 1387 characters in body
Source Link
smichr
  • 465
  • 2
  • 10

If I re-derive the objective function according to the description you gave, I get something else. Here is the derivation using the CAS SymPy:

# define objects

>>> from sympy.abc import *
>>> from sympy import *
>>> P=Circle((5,0),2).arbitrary_point(t)
>>> C=Point(0,5)
>>> A=Point(1,0)

# define objective

>>> objective=Segment(P,C).length + Segment(A,C).length/2; o
sqrt((2*sin(t) - 5)**2 + (2*cos(t) + 5)**2) + sqrt(26)/2

# we desire the minimum wrt t (which controls where we are on the circle)

>>> objective.diff(t)
(2*(2*sin(t) - 5)*cos(t) - 2*(2*cos(t) + 5)*sin(t))/sqrt((2*sin(t) - 5)**2 + (2*cos(t) + 5)**2)

# rewrite sin and cos in terms of tan and let tan(t/2) be x

>>> _.rewrite(tan).subs(tan(t/2),x).as_numer_denom()[0].factor()
10*(x**2 + 1)*(x**2 - 2*x - 1)

# get solutions for x

>>> solve(_)
[-I, I, 1 - sqrt(2), 1 + sqrt(2)]

# keep real solutions and map back to t

>>> flatten([solve(tan(t/2)-i) for i in _[-2:]])
[-pi/4, 3*pi/4]

# check value of objective at those values of t

>>> [objective.subs(t,i).simplify() for i in _]
[2 + sqrt(26)/2 + 5*sqrt(2), -2 + sqrt(26)/2 + 5*sqrt(2)]
>>> [i.n() for i in _]
[11.6205775686619, 7.62057756866187]

So the minimum is $-2 + \sqrt{26}/2 + 5\sqrt2 \approx 7.6$ and a value of $t =3\pi/4$. This agrees with the graphical minimum of the objective function.

If I re-derive the objective function according to the description you gave, I get something else. Here is the derivation using the CAS SymPy:

# define objects

>>> from sympy.abc import *
>>> from sympy import *
>>> P=Circle((5,0),2).arbitrary_point(t)
>>> C=Point(0,5)
>>> A=Point(1,0)

# define objective

>>> objective=Segment(P,C).length + Segment(A,C).length/2; o
sqrt((2*sin(t) - 5)**2 + (2*cos(t) + 5)**2) + sqrt(26)/2

# we desire the minimum wrt t (which controls where we are on the circle)

>>> objective.diff(t)
(2*(2*sin(t) - 5)*cos(t) - 2*(2*cos(t) + 5)*sin(t))/sqrt((2*sin(t) - 5)**2 + (2*cos(t) + 5)**2)

# rewrite sin and cos in terms of tan and let tan(t/2) be x

>>> _.rewrite(tan).subs(tan(t/2),x).as_numer_denom()[0].factor()
10*(x**2 + 1)*(x**2 - 2*x - 1)

# get solutions for x

>>> solve(_)
[-I, I, 1 - sqrt(2), 1 + sqrt(2)]

# keep real solutions and map back to t

>>> flatten([solve(tan(t/2)-i) for i in _[-2:]])
[-pi/4, 3*pi/4]

# check value of objective at those values of t

>>> [objective.subs(t,i).simplify() for i in _]
[2 + sqrt(26)/2 + 5*sqrt(2), -2 + sqrt(26)/2 + 5*sqrt(2)]
>>> [i.n() for i in _]
[11.6205775686619, 7.62057756866187]

So the minimum is $-2 + \sqrt{26}/2 + 5\sqrt2 \approx 7.6$ and a value of $t =3\pi/4$. This agrees with the graphical minimum of the objective function.

added 342 characters in body
Source Link
smichr
  • 465
  • 2
  • 10
Loading
added 354 characters in body
Source Link
smichr
  • 465
  • 2
  • 10
Loading
Source Link
smichr
  • 465
  • 2
  • 10
Loading