Zeel commited on
Commit
01504eb
1 Parent(s): 7da8033

update the method

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -63,10 +63,22 @@ x = jnp.linspace(0, 1, 100)
63
 
64
  st.title("Radius of the Circle: Optimization Playground")
65
  st.markdown(
66
- """
67
  Inspired from: https://twitter.com/iwontoffendyou/status/1704935240907518367
68
 
69
  Optimize the radius of the circle such that it is tangent to the parabola, unit circle and the x=0 line
 
 
 
 
 
 
 
 
 
 
 
 
70
  """
71
  )
72
 
 
63
 
64
  st.title("Radius of the Circle: Optimization Playground")
65
  st.markdown(
66
+ r"""
67
  Inspired from: https://twitter.com/iwontoffendyou/status/1704935240907518367
68
 
69
  Optimize the radius of the circle such that it is tangent to the parabola, unit circle and the x=0 line
70
+
71
+ Method:
72
+ - The inner circle is tangent to the parabola at $x=x_1$ and tangent to the unit circle at $x=x_2$.
73
+ - Let's call the center of the inner circle as $(x^*, y^*)$.
74
+ - We know that ditances between $(x^*, y^*)$ and the parabola, unit circle and the x=0 line should be equal to each other.
75
+ - First, we can find analytical forms of perpendicular lines shown in the figure. They have the form of $y = m * x + c$ where $m = -\frac{1}{f'(x)}$ and $c = f(x) - m * x$.
76
+ - Perpendicular line to the parabola: $y = m_1 * x + c_1$
77
+ - Perpendicular line to the unit circle: $y = m_2 * x + c_2$
78
+ - The intersection of the two lines is $(x^*, y^*)$. $x^* = \frac{c_2 - c_1}{m_1 -m_2}$ and $y^* = m_1 * x^* + c_1$ or $y^* = m_2 * x^* + c_2$.
79
+ - We define three distances: $d_1 = (x^* - x_1)^2 + (y^* - f(x_1))^2$, $d_2 = (x^* - x_2)^2 + (y^* - f(x_2))^2$ and $d_3 = {x^*}^2$.
80
+ - Our loss function is $L = (d_1 - d_2)^2 + (d_1 - d_3)^2 + (d_2 - d_3)^2$.
81
+
82
  """
83
  )
84