1. Out of intense complexities,
intense simplicities emerge;
Linear Formulation of Square Peg Problem Test
Function
Sing Kuang Tan
singkuangtan@gmail.com
29 May 2022
2. Recap
• Square Peg Problem (Inscribed Square Problem) Definition
• Does every plane simple closed curve contain all four vertices of some
square?
• An example of a closed curve with 3 squares are shown bottom
3. Test function
p1
p2
p3
p4
A test function f() maps to a 1 if 4 points form a square
Specifically
𝑓 𝑝1, 𝑝2, 𝑝3, 𝑝4 =
1 𝑖𝑓 4 𝑝𝑜𝑖𝑛𝑡𝑠 𝑓𝑜𝑟𝑚 𝑎 𝑠𝑞𝑢𝑎𝑟𝑒
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
4. p1
p2
p3
p4
A test function f() maps to a 1 if 4 points form a square
Specifically
𝑓 𝑝1, 𝑝2, 𝑝3, 𝑝4 =
1 𝑖𝑓 4 𝑝𝑜𝑖𝑛𝑡𝑠 𝑓𝑜𝑟𝑚 𝑎 𝑠𝑞𝑢𝑎𝑟𝑒
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
f(p1,p2,p3,p4)=1 if
𝑝1 − 𝑝2 = 𝑝2 − 𝑝4 = 𝑝3 − 𝑝4 = 𝑝1 − 𝑝3
And 𝑝1 − 𝑝4 = 𝑝2 − 𝑝3
5. p1
p2
p3
p4
A test function f() maps to a 1 if 4 points form a square
Specifically
𝑓 𝑝1, 𝑝2, 𝑝3, 𝑝4 =
1 𝑖𝑓 4 𝑝𝑜𝑖𝑛𝑡𝑠 𝑓𝑜𝑟𝑚 𝑎 𝑠𝑞𝑢𝑎𝑟𝑒
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
f(p1,p2,p3,p4)=1 if
𝑝1 − 𝑝2 = 𝑝2 − 𝑝4 = 𝑝3 − 𝑝4 = 𝑝1 − 𝑝3
And 𝑝1 − 𝑝4 = 𝑝2 − 𝑝3
The lengths of the sides of the square are the same
6. p1
p2
p3
p4
A test function f() maps to a 1 if 4 points form a square
Specifically
𝑓 𝑝1, 𝑝2, 𝑝3, 𝑝4 =
1 𝑖𝑓 4 𝑝𝑜𝑖𝑛𝑡𝑠 𝑓𝑜𝑟𝑚 𝑎 𝑠𝑞𝑢𝑎𝑟𝑒
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
f(p1,p2,p3,p4)=1 if
𝑝1 − 𝑝2 = 𝑝2 − 𝑝4 = 𝑝3 − 𝑝4 = 𝑝1 − 𝑝3
And 𝑝1 − 𝑝4 = 𝑝2 − 𝑝3
The lengths of the diagonals of the square are the same
7. p1
p2
p3
p4
A test function f() maps to a 1 if 4 points form a square
Specifically
𝑓 𝑝1, 𝑝2, 𝑝3, 𝑝4 =
1 𝑖𝑓 4 𝑝𝑜𝑖𝑛𝑡𝑠 𝑓𝑜𝑟𝑚 𝑎 𝑠𝑞𝑢𝑎𝑟𝑒
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
f(p1,p2,p3,p4)=1 if
𝑝1 − 𝑝2 = 𝑝2 − 𝑝4 = 𝑝3 − 𝑝4 = 𝑝1 − 𝑝3
And 𝑝1 − 𝑝4 = 𝑝2 − 𝑝3
This existing test function is complex with too many quadratic operations
8. My Test Function using Linear Operations
p1=(x1,y1)
p2=(x2,y2)
p3=(x3,y3)
p4=(x4,y4)
A test function f() maps to a 1 if 4 points form a square
Specifically
𝑓 𝑝1, 𝑝2, 𝑝3, 𝑝4 =
1 𝑖𝑓 4 𝑝𝑜𝑖𝑛𝑡𝑠 𝑓𝑜𝑟𝑚 𝑎 𝑠𝑞𝑢𝑎𝑟𝑒
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
f(p1,p2,p3,p4)=1 if
x2-x1=x4-x3
y2-y1=y4-y3
x4-x1=y2-y3
y4-y1=x3-x2
This test function is much simpler with only linear operations
9. My Test Function using Linear Operations
p1=(x1,y1)
p2=(x2,y2)
p3=(x3,y3)
p4=(x4,y4)
A test function f() maps to a 1 if 4 points form a square
Specifically
𝑓 𝑝1, 𝑝2, 𝑝3, 𝑝4 =
1 𝑖𝑓 4 𝑝𝑜𝑖𝑛𝑡𝑠 𝑓𝑜𝑟𝑚 𝑎 𝑠𝑞𝑢𝑎𝑟𝑒
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
f(p1,p2,p3,p4)=1 if
x2-x1=x4-x3
y2-y1=y4-y3
x4-x1=y2-y3
y4-y1=x3-x2
This test function is much simpler with only linear operations
The gradient of the top and bottom sides are the same
10. My Test Function using Linear Operations
p1=(x1,y1)
p2=(x2,y2)
p3=(x3,y3)
p4=(x4,y4)
A test function f() maps to a 1 if 4 points form a square
Specifically
𝑓 𝑝1, 𝑝2, 𝑝3, 𝑝4 =
1 𝑖𝑓 4 𝑝𝑜𝑖𝑛𝑡𝑠 𝑓𝑜𝑟𝑚 𝑎 𝑠𝑞𝑢𝑎𝑟𝑒
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
f(p1,p2,p3,p4)=1 if
x2-x1=x4-x3
y2-y1=y4-y3
x4-x1=y2-y3
y4-y1=x3-x2
This test function is much simpler with only linear operations
The vectors of the diagonals are rotated by right angle
11. Example
• Parametric equation of shape
• x=cos(t)
• y=2sin(t)
• Find the inscribed square in the shape
• Hint: let cos(t)=2sin(t)
13. • t2=0.46364
• t3=3.60523
• t1=2.67795
• t4=-0.46364
• Put t1,t2,t3,t4 back into the linear equations
• x2-x1=x4-x3
• y2-y1=y4-y3
• x4-x1=y2-y3
• y4-y1=x3-x2
14. • Put t1,t2,t3,t4 back into the linear equations
• x2-x1=x4-x3
• y2-y1=y4-y3
• x4-x1=y2-y3
• y4-y1=x3-x2
• becomes
• cos(t2)-cos(t1)=cos(t4)-cos(t3)
• 2sin(t2)-2sin(t1)=2sin(t4)-2sin(t3)
• cos(t4)-cos(t1)=2sin(t2)-2sin(t3)
• 2sin(t4)-2sin(t1)=cos(t3)-cos(t2)
15. • The equations
• cos(t2)-cos(t1)=cos(t4)-cos(t3)
• 2sin(t2)-2sin(t1)=2sin(t4)-2sin(t3)
• cos(t4)-cos(t1)=2sin(t2)-2sin(t3)
• 2sin(t4)-2sin(t1)=cos(t3)-cos(t2)
• are all satisfied
• Therefore these t1,t2,t3,t4 are points of inscribed square
t1 t2
t3 t4
16. Why I study test function for square peg
problem?
• Study pure mathematics to invent new algorithms
• Most physical objects are moving along curves that are sum of
sinusoidal waves
• Can be represented by curve and constraints in Square Peg Problem
17. I’ll be back
• I will come back and explain how to find the inscribed
squares of curves of more complex parametric equations
and complex Fourier series
• Examples of curves
18. Links to my papers
● https://vixra.org/author/sing_kuang_tan
● Link to my NP vs P paper
● Discrete Markov Random Field relaxation paper
● Linear Formulation of Square Peg Problem Test Function
19. About Me
●My job uses Machine Learning to solve problems
○Like my posts or slides in LinkedIn, Twitter or Slideshare
○Follow me on LinkedIn
■ https://www.linkedin.com/in/sing-kuang-tan-b189279/
○Follow me on Twitter
■ https://twitter.com/Tan_Sing_Kuang
○Send me comments through these links
20. ●Look at my Slideshare slides
○https://www.slideshare.net/SingKuangTan
○https://slideplayer.com/user/21705658/
■ Don’t Be a Square Man; Visual Proof for Square Peg Problem with Convex Shapes
■ Visual Proofs for Topology
■ Implement Data Structure Fast with Python
■ Discrete Markov Random Field Relaxation
■ NP vs P Proof using Discrete Finite Automata
■ Use Inductive or Deductive Logic to solve NP vs P?
■ Kung Fu Computer Science, Clique Problem: Step by Step
■ Beyond Shannon, Sipser and Razborov; Solve Clique Problem like an Electronic Engineer
■ A weird Soviet method to partially solve the Perebor Problems
■ 8 trends in Hang Seng Index
■ 4 types of Mathematical Proofs
■ How I prove NP vs P
○Follow me on Slideshare
21. Share my links
● I am a Small Person with Big Dreams
○ Please help me to repost my links to other platforms so that I can spread my ideas to the rest of the world
● 我人小,但因梦想而伟大。
○ 请帮我的文件链接传发到其他平台,让我的思想能传遍天下。
● Comments? Send to singkuangtan@gmail.com
● Link to my paper NP vs P paper
○ https://www.slideshare.net/SingKuangTan/brief-np-vspexplain-249524831
○ Prove Np not equal P using Markov Random Field and Boolean Algebra Simplification
○ https://vixra.org/abs/2105.0181
○ Other link
■ https://www.slideshare.net/SingKuangTan