How to Determine a Sinus Function from Samples

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite
1












I keep failing ungracefully at a seemingly simple task of determing a function to describe the coherence between two measured variables (a, b) and and a resulting value. Here's a complete round of example measurements and their respective result:



x: -0.08 y: -0.28 result: 1.850
x: -0.16 y: -0.25 result: 2.129
x: -0.23 y: -0.19 result: 2.446
x: -0.26 y: -0.11 result: 2.744
x: -0.27 y: -0.03 result: 3.047
x: -0.25 y: +0.06 result: 3.363
x: -0.20 y: +0.13 result: 3.730
x: -0.14 y: +0.20 result: 4.121
x: -0.05 y: +0.22 result: 4.498
x: +0.03 y: +0.22 result: 4.844
x: +0.11 y: +0.19 result: 5.240
x: +0.19 y: +0.14 result: 5.652
x: +0.22 y: +0.08 result: 5.956
x: +0.26 y: -0.01 result: 6.330
x: +0.25 y: -0.10 result: 6.645
x: +0.21 y: -0.18 result: 6.996
x: +0.18 y: -0.24 result: 7.229
x: +0.09 y: -0.29 result: 7.553
x: +0.00 y: -0.29 result: 7.844
x: -0.07 y: -0.28 result: 1.829


I've figured so far that $result = (something + 0.5) times pi $, but I can't figure out the $something$ part. x seems to move between -0.27 and +0.27, while y between -0.30 and 0.22. I've tried to visualize their behaviour in circles, for hopefully it brings help rather than further confusion:



Visualization



I seem to have forgotten how to go about solving such a task and been fiddling with Wolfram Alpha for some time now, but can't seem to get behind the concept. Please help!



To sum it all up, the question is: find a function to calculate result from x and y.







share|cite|improve this question






















  • Your question is quite unclear.
    – Taroccoesbrocco
    Aug 14 at 6:26










  • Do you want result as a function of both $x$ and $y$, or two separate functions that relate result to $x$ and then to $y$?
    – Bill Wallis
    Aug 14 at 9:13











  • @BillWallis I figured it must be one function to both $x$ and $y$, because for $y=0$ the result can be either $pi$ or $2pi$.
    – draconigen
    Aug 14 at 10:09















up vote
1
down vote

favorite
1












I keep failing ungracefully at a seemingly simple task of determing a function to describe the coherence between two measured variables (a, b) and and a resulting value. Here's a complete round of example measurements and their respective result:



x: -0.08 y: -0.28 result: 1.850
x: -0.16 y: -0.25 result: 2.129
x: -0.23 y: -0.19 result: 2.446
x: -0.26 y: -0.11 result: 2.744
x: -0.27 y: -0.03 result: 3.047
x: -0.25 y: +0.06 result: 3.363
x: -0.20 y: +0.13 result: 3.730
x: -0.14 y: +0.20 result: 4.121
x: -0.05 y: +0.22 result: 4.498
x: +0.03 y: +0.22 result: 4.844
x: +0.11 y: +0.19 result: 5.240
x: +0.19 y: +0.14 result: 5.652
x: +0.22 y: +0.08 result: 5.956
x: +0.26 y: -0.01 result: 6.330
x: +0.25 y: -0.10 result: 6.645
x: +0.21 y: -0.18 result: 6.996
x: +0.18 y: -0.24 result: 7.229
x: +0.09 y: -0.29 result: 7.553
x: +0.00 y: -0.29 result: 7.844
x: -0.07 y: -0.28 result: 1.829


I've figured so far that $result = (something + 0.5) times pi $, but I can't figure out the $something$ part. x seems to move between -0.27 and +0.27, while y between -0.30 and 0.22. I've tried to visualize their behaviour in circles, for hopefully it brings help rather than further confusion:



Visualization



I seem to have forgotten how to go about solving such a task and been fiddling with Wolfram Alpha for some time now, but can't seem to get behind the concept. Please help!



To sum it all up, the question is: find a function to calculate result from x and y.







share|cite|improve this question






















  • Your question is quite unclear.
    – Taroccoesbrocco
    Aug 14 at 6:26










  • Do you want result as a function of both $x$ and $y$, or two separate functions that relate result to $x$ and then to $y$?
    – Bill Wallis
    Aug 14 at 9:13











  • @BillWallis I figured it must be one function to both $x$ and $y$, because for $y=0$ the result can be either $pi$ or $2pi$.
    – draconigen
    Aug 14 at 10:09













up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





I keep failing ungracefully at a seemingly simple task of determing a function to describe the coherence between two measured variables (a, b) and and a resulting value. Here's a complete round of example measurements and their respective result:



x: -0.08 y: -0.28 result: 1.850
x: -0.16 y: -0.25 result: 2.129
x: -0.23 y: -0.19 result: 2.446
x: -0.26 y: -0.11 result: 2.744
x: -0.27 y: -0.03 result: 3.047
x: -0.25 y: +0.06 result: 3.363
x: -0.20 y: +0.13 result: 3.730
x: -0.14 y: +0.20 result: 4.121
x: -0.05 y: +0.22 result: 4.498
x: +0.03 y: +0.22 result: 4.844
x: +0.11 y: +0.19 result: 5.240
x: +0.19 y: +0.14 result: 5.652
x: +0.22 y: +0.08 result: 5.956
x: +0.26 y: -0.01 result: 6.330
x: +0.25 y: -0.10 result: 6.645
x: +0.21 y: -0.18 result: 6.996
x: +0.18 y: -0.24 result: 7.229
x: +0.09 y: -0.29 result: 7.553
x: +0.00 y: -0.29 result: 7.844
x: -0.07 y: -0.28 result: 1.829


I've figured so far that $result = (something + 0.5) times pi $, but I can't figure out the $something$ part. x seems to move between -0.27 and +0.27, while y between -0.30 and 0.22. I've tried to visualize their behaviour in circles, for hopefully it brings help rather than further confusion:



Visualization



I seem to have forgotten how to go about solving such a task and been fiddling with Wolfram Alpha for some time now, but can't seem to get behind the concept. Please help!



To sum it all up, the question is: find a function to calculate result from x and y.







share|cite|improve this question














I keep failing ungracefully at a seemingly simple task of determing a function to describe the coherence between two measured variables (a, b) and and a resulting value. Here's a complete round of example measurements and their respective result:



x: -0.08 y: -0.28 result: 1.850
x: -0.16 y: -0.25 result: 2.129
x: -0.23 y: -0.19 result: 2.446
x: -0.26 y: -0.11 result: 2.744
x: -0.27 y: -0.03 result: 3.047
x: -0.25 y: +0.06 result: 3.363
x: -0.20 y: +0.13 result: 3.730
x: -0.14 y: +0.20 result: 4.121
x: -0.05 y: +0.22 result: 4.498
x: +0.03 y: +0.22 result: 4.844
x: +0.11 y: +0.19 result: 5.240
x: +0.19 y: +0.14 result: 5.652
x: +0.22 y: +0.08 result: 5.956
x: +0.26 y: -0.01 result: 6.330
x: +0.25 y: -0.10 result: 6.645
x: +0.21 y: -0.18 result: 6.996
x: +0.18 y: -0.24 result: 7.229
x: +0.09 y: -0.29 result: 7.553
x: +0.00 y: -0.29 result: 7.844
x: -0.07 y: -0.28 result: 1.829


I've figured so far that $result = (something + 0.5) times pi $, but I can't figure out the $something$ part. x seems to move between -0.27 and +0.27, while y between -0.30 and 0.22. I've tried to visualize their behaviour in circles, for hopefully it brings help rather than further confusion:



Visualization



I seem to have forgotten how to go about solving such a task and been fiddling with Wolfram Alpha for some time now, but can't seem to get behind the concept. Please help!



To sum it all up, the question is: find a function to calculate result from x and y.









share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Aug 14 at 6:30

























asked Aug 14 at 5:57









draconigen

84




84











  • Your question is quite unclear.
    – Taroccoesbrocco
    Aug 14 at 6:26










  • Do you want result as a function of both $x$ and $y$, or two separate functions that relate result to $x$ and then to $y$?
    – Bill Wallis
    Aug 14 at 9:13











  • @BillWallis I figured it must be one function to both $x$ and $y$, because for $y=0$ the result can be either $pi$ or $2pi$.
    – draconigen
    Aug 14 at 10:09

















  • Your question is quite unclear.
    – Taroccoesbrocco
    Aug 14 at 6:26










  • Do you want result as a function of both $x$ and $y$, or two separate functions that relate result to $x$ and then to $y$?
    – Bill Wallis
    Aug 14 at 9:13











  • @BillWallis I figured it must be one function to both $x$ and $y$, because for $y=0$ the result can be either $pi$ or $2pi$.
    – draconigen
    Aug 14 at 10:09
















Your question is quite unclear.
– Taroccoesbrocco
Aug 14 at 6:26




Your question is quite unclear.
– Taroccoesbrocco
Aug 14 at 6:26












Do you want result as a function of both $x$ and $y$, or two separate functions that relate result to $x$ and then to $y$?
– Bill Wallis
Aug 14 at 9:13





Do you want result as a function of both $x$ and $y$, or two separate functions that relate result to $x$ and then to $y$?
– Bill Wallis
Aug 14 at 9:13













@BillWallis I figured it must be one function to both $x$ and $y$, because for $y=0$ the result can be either $pi$ or $2pi$.
– draconigen
Aug 14 at 10:09





@BillWallis I figured it must be one function to both $x$ and $y$, because for $y=0$ the result can be either $pi$ or $2pi$.
– draconigen
Aug 14 at 10:09











1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










Relating $x$ and $y$



You're right that $x$ and $y$ are related by circles. In fact, by plotting $y$ against $x$, we have the following graph.



enter image description here



This looks pretty close to a circle. The radius of a circle is given by
$$
r = sqrtx^2 + y^2,
$$
so by taking the average of each $sqrtx^2 + y^2$ for your data we find that the radius is approximately $r approx 0.2653$ (to $4$ significant figures). We also find that the average of the $x$ values is $barx = -0.0085$, and the average of the $y$ values is $bary = -0.0505$. These give an estimate for the center of the circle.



The next graph shows the circle of radius $r = 0.2653$ and midpoint $(-0.0085, -0.0505)$ (orange) compared to the plot of your data (blue).



enter image description here



It seems to fit fairly well.



Introducing $theta$



Assuming that this is 'good enough', we can parametrise your $(x, y)$ coordinates by replacing the $2$-tuple $(x, y)$ with $theta$, namely the angle that the point $(x, y)$ makes with the positive $x$-axis. The formula for $theta$ has a few different formulations depending on what range you want $theta$ in, but by playing around with the trigonometric identities you can determine which one you want. The formula that I used is
$$
theta = begincases
arctan(y/x),& textif $x > 0$,\
pi + arctan(y/x),& textif $x < 0$,\
mathrmsgn(y)pi/2,& textif $x = 0$.\
endcases
$$
Note that $mathrmsgn(y)$ is the function that returns the sign of $y$, so
$$
mathrmsgn(y) = begincases
+1,& textif $y > 0$,\
-1,& textif $y < 0$,\
0,& textif $y = 0$.\
endcases
$$
Plotting $theta$ against result, we have the following graph.



enter image description here



Performing simple linear regression on this gives the formula
$$
textresult = 6.2865 - theta.tag$ast$
$$
The values have been rounded to $4$ decimal places. Note that
$$
6.2865 approx 6.283185307 approx 2pi.
$$
The following graph shows how close the fit is.



enter image description here



The blue dots are the original data, and the orange dots are defined by the line $(ast)$



Defining the function



Now that we know the relationship, we can write up an estimate for your function. We will suppose that the constant in $(ast)$ is indeed $2pi$. If
$$
textresult = 2pi - theta
$$
and
$$
theta = begincases
arctan(y/x),& textif $x > 0$,\
pi + arctan(y/x),& textif $x < 0$,\
mathrmsgn(y)pi/2,& textif $x = 0$,\
endcases
$$
then it is easy to see that
$$
textresult = begincases
2pi - arctan(y/x),& textif $x > 0$,\
pi - arctan(y/x),& textif $x < 0$,\
2pi - mathrmsgn(y)pi/2,& textif $x = 0$.\
endcases
$$
The following tables shows how close the values are using this function. The real results are in the 'result' column, and the values using the function are in the 'forecast' column.
$$
beginarrayc
x & y & textresult & theta & textforecast\hline
-0.08 & -0.28 & colorred1.849 & 4.434 & colorgreen1.85 \
-0.16 & -0.25 & colorred2.14 & 4.143 & colorgreen2.129 \
-0.23 & -0.19 & colorred2.451 & 3.832 & colorgreen2.446 \
-0.26 & -0.11 & colorred2.741 & 3.542 & colorgreen2.744 \
-0.27 & -0.03 & colorred3.031 & 3.252 & colorgreen3.047 \
-0.25 & 0.06 & colorred3.377 & 2.906 & colorgreen3.363 \
-0.2 & 0.13 & colorred3.718 & 2.565 & colorgreen3.73 \
-0.14 & 0.2 & colorred4.102 & 2.182 & colorgreen4.121 \
-0.05 & 0.22 & colorred4.489 & 1.794 & colorgreen4.498 \
0.03 & 0.22 & colorred4.848 & 1.435 & colorgreen4.844 \
0.11 & 0.19 & colorred5.237 & 1.046 & colorgreen5.24 \
0.19 & 0.14 & colorred5.648 & 0.635 & colorgreen5.652 \
0.22 & 0.08 & colorred5.934 & 0.349 & colorgreen5.956 \
0.26 & -0.01 & colorred6.322 & -0.038 & colorgreen6.33 \
0.25 & -0.1 & colorred6.664 & -0.381 & colorgreen6.645 \
0.21 & -0.18 & colorred6.992 & -0.709 & colorgreen6.996 \
0.18 & -0.24 & colorred7.21 & -0.927 & colorgreen7.229 \
0.09 & -0.29 & colorred7.553 & -1.27 & colorgreen7.553 \
0 & -0.29 & colorred7.854 & -1.571 & colorgreen7.844 \
-0.07 & -0.28 & colorred1.816 & 4.467 & colorgreen1.829 \
endarray
$$
All values are rounded to $3$ decimal places.






share|cite|improve this answer




















  • This is it! You've put an impressive amount of work into explaining your derivation in a way that even I would understand, and for that I am especially grateful. Thank you!
    – draconigen
    Aug 14 at 11:48










  • @draconigen You're welcome, it was a fun problem!
    – Bill Wallis
    Aug 14 at 11:49










Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "69"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2882112%2fhow-to-determine-a-sinus-function-from-samples%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










Relating $x$ and $y$



You're right that $x$ and $y$ are related by circles. In fact, by plotting $y$ against $x$, we have the following graph.



enter image description here



This looks pretty close to a circle. The radius of a circle is given by
$$
r = sqrtx^2 + y^2,
$$
so by taking the average of each $sqrtx^2 + y^2$ for your data we find that the radius is approximately $r approx 0.2653$ (to $4$ significant figures). We also find that the average of the $x$ values is $barx = -0.0085$, and the average of the $y$ values is $bary = -0.0505$. These give an estimate for the center of the circle.



The next graph shows the circle of radius $r = 0.2653$ and midpoint $(-0.0085, -0.0505)$ (orange) compared to the plot of your data (blue).



enter image description here



It seems to fit fairly well.



Introducing $theta$



Assuming that this is 'good enough', we can parametrise your $(x, y)$ coordinates by replacing the $2$-tuple $(x, y)$ with $theta$, namely the angle that the point $(x, y)$ makes with the positive $x$-axis. The formula for $theta$ has a few different formulations depending on what range you want $theta$ in, but by playing around with the trigonometric identities you can determine which one you want. The formula that I used is
$$
theta = begincases
arctan(y/x),& textif $x > 0$,\
pi + arctan(y/x),& textif $x < 0$,\
mathrmsgn(y)pi/2,& textif $x = 0$.\
endcases
$$
Note that $mathrmsgn(y)$ is the function that returns the sign of $y$, so
$$
mathrmsgn(y) = begincases
+1,& textif $y > 0$,\
-1,& textif $y < 0$,\
0,& textif $y = 0$.\
endcases
$$
Plotting $theta$ against result, we have the following graph.



enter image description here



Performing simple linear regression on this gives the formula
$$
textresult = 6.2865 - theta.tag$ast$
$$
The values have been rounded to $4$ decimal places. Note that
$$
6.2865 approx 6.283185307 approx 2pi.
$$
The following graph shows how close the fit is.



enter image description here



The blue dots are the original data, and the orange dots are defined by the line $(ast)$



Defining the function



Now that we know the relationship, we can write up an estimate for your function. We will suppose that the constant in $(ast)$ is indeed $2pi$. If
$$
textresult = 2pi - theta
$$
and
$$
theta = begincases
arctan(y/x),& textif $x > 0$,\
pi + arctan(y/x),& textif $x < 0$,\
mathrmsgn(y)pi/2,& textif $x = 0$,\
endcases
$$
then it is easy to see that
$$
textresult = begincases
2pi - arctan(y/x),& textif $x > 0$,\
pi - arctan(y/x),& textif $x < 0$,\
2pi - mathrmsgn(y)pi/2,& textif $x = 0$.\
endcases
$$
The following tables shows how close the values are using this function. The real results are in the 'result' column, and the values using the function are in the 'forecast' column.
$$
beginarrayc
x & y & textresult & theta & textforecast\hline
-0.08 & -0.28 & colorred1.849 & 4.434 & colorgreen1.85 \
-0.16 & -0.25 & colorred2.14 & 4.143 & colorgreen2.129 \
-0.23 & -0.19 & colorred2.451 & 3.832 & colorgreen2.446 \
-0.26 & -0.11 & colorred2.741 & 3.542 & colorgreen2.744 \
-0.27 & -0.03 & colorred3.031 & 3.252 & colorgreen3.047 \
-0.25 & 0.06 & colorred3.377 & 2.906 & colorgreen3.363 \
-0.2 & 0.13 & colorred3.718 & 2.565 & colorgreen3.73 \
-0.14 & 0.2 & colorred4.102 & 2.182 & colorgreen4.121 \
-0.05 & 0.22 & colorred4.489 & 1.794 & colorgreen4.498 \
0.03 & 0.22 & colorred4.848 & 1.435 & colorgreen4.844 \
0.11 & 0.19 & colorred5.237 & 1.046 & colorgreen5.24 \
0.19 & 0.14 & colorred5.648 & 0.635 & colorgreen5.652 \
0.22 & 0.08 & colorred5.934 & 0.349 & colorgreen5.956 \
0.26 & -0.01 & colorred6.322 & -0.038 & colorgreen6.33 \
0.25 & -0.1 & colorred6.664 & -0.381 & colorgreen6.645 \
0.21 & -0.18 & colorred6.992 & -0.709 & colorgreen6.996 \
0.18 & -0.24 & colorred7.21 & -0.927 & colorgreen7.229 \
0.09 & -0.29 & colorred7.553 & -1.27 & colorgreen7.553 \
0 & -0.29 & colorred7.854 & -1.571 & colorgreen7.844 \
-0.07 & -0.28 & colorred1.816 & 4.467 & colorgreen1.829 \
endarray
$$
All values are rounded to $3$ decimal places.






share|cite|improve this answer




















  • This is it! You've put an impressive amount of work into explaining your derivation in a way that even I would understand, and for that I am especially grateful. Thank you!
    – draconigen
    Aug 14 at 11:48










  • @draconigen You're welcome, it was a fun problem!
    – Bill Wallis
    Aug 14 at 11:49














up vote
1
down vote



accepted










Relating $x$ and $y$



You're right that $x$ and $y$ are related by circles. In fact, by plotting $y$ against $x$, we have the following graph.



enter image description here



This looks pretty close to a circle. The radius of a circle is given by
$$
r = sqrtx^2 + y^2,
$$
so by taking the average of each $sqrtx^2 + y^2$ for your data we find that the radius is approximately $r approx 0.2653$ (to $4$ significant figures). We also find that the average of the $x$ values is $barx = -0.0085$, and the average of the $y$ values is $bary = -0.0505$. These give an estimate for the center of the circle.



The next graph shows the circle of radius $r = 0.2653$ and midpoint $(-0.0085, -0.0505)$ (orange) compared to the plot of your data (blue).



enter image description here



It seems to fit fairly well.



Introducing $theta$



Assuming that this is 'good enough', we can parametrise your $(x, y)$ coordinates by replacing the $2$-tuple $(x, y)$ with $theta$, namely the angle that the point $(x, y)$ makes with the positive $x$-axis. The formula for $theta$ has a few different formulations depending on what range you want $theta$ in, but by playing around with the trigonometric identities you can determine which one you want. The formula that I used is
$$
theta = begincases
arctan(y/x),& textif $x > 0$,\
pi + arctan(y/x),& textif $x < 0$,\
mathrmsgn(y)pi/2,& textif $x = 0$.\
endcases
$$
Note that $mathrmsgn(y)$ is the function that returns the sign of $y$, so
$$
mathrmsgn(y) = begincases
+1,& textif $y > 0$,\
-1,& textif $y < 0$,\
0,& textif $y = 0$.\
endcases
$$
Plotting $theta$ against result, we have the following graph.



enter image description here



Performing simple linear regression on this gives the formula
$$
textresult = 6.2865 - theta.tag$ast$
$$
The values have been rounded to $4$ decimal places. Note that
$$
6.2865 approx 6.283185307 approx 2pi.
$$
The following graph shows how close the fit is.



enter image description here



The blue dots are the original data, and the orange dots are defined by the line $(ast)$



Defining the function



Now that we know the relationship, we can write up an estimate for your function. We will suppose that the constant in $(ast)$ is indeed $2pi$. If
$$
textresult = 2pi - theta
$$
and
$$
theta = begincases
arctan(y/x),& textif $x > 0$,\
pi + arctan(y/x),& textif $x < 0$,\
mathrmsgn(y)pi/2,& textif $x = 0$,\
endcases
$$
then it is easy to see that
$$
textresult = begincases
2pi - arctan(y/x),& textif $x > 0$,\
pi - arctan(y/x),& textif $x < 0$,\
2pi - mathrmsgn(y)pi/2,& textif $x = 0$.\
endcases
$$
The following tables shows how close the values are using this function. The real results are in the 'result' column, and the values using the function are in the 'forecast' column.
$$
beginarrayc
x & y & textresult & theta & textforecast\hline
-0.08 & -0.28 & colorred1.849 & 4.434 & colorgreen1.85 \
-0.16 & -0.25 & colorred2.14 & 4.143 & colorgreen2.129 \
-0.23 & -0.19 & colorred2.451 & 3.832 & colorgreen2.446 \
-0.26 & -0.11 & colorred2.741 & 3.542 & colorgreen2.744 \
-0.27 & -0.03 & colorred3.031 & 3.252 & colorgreen3.047 \
-0.25 & 0.06 & colorred3.377 & 2.906 & colorgreen3.363 \
-0.2 & 0.13 & colorred3.718 & 2.565 & colorgreen3.73 \
-0.14 & 0.2 & colorred4.102 & 2.182 & colorgreen4.121 \
-0.05 & 0.22 & colorred4.489 & 1.794 & colorgreen4.498 \
0.03 & 0.22 & colorred4.848 & 1.435 & colorgreen4.844 \
0.11 & 0.19 & colorred5.237 & 1.046 & colorgreen5.24 \
0.19 & 0.14 & colorred5.648 & 0.635 & colorgreen5.652 \
0.22 & 0.08 & colorred5.934 & 0.349 & colorgreen5.956 \
0.26 & -0.01 & colorred6.322 & -0.038 & colorgreen6.33 \
0.25 & -0.1 & colorred6.664 & -0.381 & colorgreen6.645 \
0.21 & -0.18 & colorred6.992 & -0.709 & colorgreen6.996 \
0.18 & -0.24 & colorred7.21 & -0.927 & colorgreen7.229 \
0.09 & -0.29 & colorred7.553 & -1.27 & colorgreen7.553 \
0 & -0.29 & colorred7.854 & -1.571 & colorgreen7.844 \
-0.07 & -0.28 & colorred1.816 & 4.467 & colorgreen1.829 \
endarray
$$
All values are rounded to $3$ decimal places.






share|cite|improve this answer




















  • This is it! You've put an impressive amount of work into explaining your derivation in a way that even I would understand, and for that I am especially grateful. Thank you!
    – draconigen
    Aug 14 at 11:48










  • @draconigen You're welcome, it was a fun problem!
    – Bill Wallis
    Aug 14 at 11:49












up vote
1
down vote



accepted







up vote
1
down vote



accepted






Relating $x$ and $y$



You're right that $x$ and $y$ are related by circles. In fact, by plotting $y$ against $x$, we have the following graph.



enter image description here



This looks pretty close to a circle. The radius of a circle is given by
$$
r = sqrtx^2 + y^2,
$$
so by taking the average of each $sqrtx^2 + y^2$ for your data we find that the radius is approximately $r approx 0.2653$ (to $4$ significant figures). We also find that the average of the $x$ values is $barx = -0.0085$, and the average of the $y$ values is $bary = -0.0505$. These give an estimate for the center of the circle.



The next graph shows the circle of radius $r = 0.2653$ and midpoint $(-0.0085, -0.0505)$ (orange) compared to the plot of your data (blue).



enter image description here



It seems to fit fairly well.



Introducing $theta$



Assuming that this is 'good enough', we can parametrise your $(x, y)$ coordinates by replacing the $2$-tuple $(x, y)$ with $theta$, namely the angle that the point $(x, y)$ makes with the positive $x$-axis. The formula for $theta$ has a few different formulations depending on what range you want $theta$ in, but by playing around with the trigonometric identities you can determine which one you want. The formula that I used is
$$
theta = begincases
arctan(y/x),& textif $x > 0$,\
pi + arctan(y/x),& textif $x < 0$,\
mathrmsgn(y)pi/2,& textif $x = 0$.\
endcases
$$
Note that $mathrmsgn(y)$ is the function that returns the sign of $y$, so
$$
mathrmsgn(y) = begincases
+1,& textif $y > 0$,\
-1,& textif $y < 0$,\
0,& textif $y = 0$.\
endcases
$$
Plotting $theta$ against result, we have the following graph.



enter image description here



Performing simple linear regression on this gives the formula
$$
textresult = 6.2865 - theta.tag$ast$
$$
The values have been rounded to $4$ decimal places. Note that
$$
6.2865 approx 6.283185307 approx 2pi.
$$
The following graph shows how close the fit is.



enter image description here



The blue dots are the original data, and the orange dots are defined by the line $(ast)$



Defining the function



Now that we know the relationship, we can write up an estimate for your function. We will suppose that the constant in $(ast)$ is indeed $2pi$. If
$$
textresult = 2pi - theta
$$
and
$$
theta = begincases
arctan(y/x),& textif $x > 0$,\
pi + arctan(y/x),& textif $x < 0$,\
mathrmsgn(y)pi/2,& textif $x = 0$,\
endcases
$$
then it is easy to see that
$$
textresult = begincases
2pi - arctan(y/x),& textif $x > 0$,\
pi - arctan(y/x),& textif $x < 0$,\
2pi - mathrmsgn(y)pi/2,& textif $x = 0$.\
endcases
$$
The following tables shows how close the values are using this function. The real results are in the 'result' column, and the values using the function are in the 'forecast' column.
$$
beginarrayc
x & y & textresult & theta & textforecast\hline
-0.08 & -0.28 & colorred1.849 & 4.434 & colorgreen1.85 \
-0.16 & -0.25 & colorred2.14 & 4.143 & colorgreen2.129 \
-0.23 & -0.19 & colorred2.451 & 3.832 & colorgreen2.446 \
-0.26 & -0.11 & colorred2.741 & 3.542 & colorgreen2.744 \
-0.27 & -0.03 & colorred3.031 & 3.252 & colorgreen3.047 \
-0.25 & 0.06 & colorred3.377 & 2.906 & colorgreen3.363 \
-0.2 & 0.13 & colorred3.718 & 2.565 & colorgreen3.73 \
-0.14 & 0.2 & colorred4.102 & 2.182 & colorgreen4.121 \
-0.05 & 0.22 & colorred4.489 & 1.794 & colorgreen4.498 \
0.03 & 0.22 & colorred4.848 & 1.435 & colorgreen4.844 \
0.11 & 0.19 & colorred5.237 & 1.046 & colorgreen5.24 \
0.19 & 0.14 & colorred5.648 & 0.635 & colorgreen5.652 \
0.22 & 0.08 & colorred5.934 & 0.349 & colorgreen5.956 \
0.26 & -0.01 & colorred6.322 & -0.038 & colorgreen6.33 \
0.25 & -0.1 & colorred6.664 & -0.381 & colorgreen6.645 \
0.21 & -0.18 & colorred6.992 & -0.709 & colorgreen6.996 \
0.18 & -0.24 & colorred7.21 & -0.927 & colorgreen7.229 \
0.09 & -0.29 & colorred7.553 & -1.27 & colorgreen7.553 \
0 & -0.29 & colorred7.854 & -1.571 & colorgreen7.844 \
-0.07 & -0.28 & colorred1.816 & 4.467 & colorgreen1.829 \
endarray
$$
All values are rounded to $3$ decimal places.






share|cite|improve this answer












Relating $x$ and $y$



You're right that $x$ and $y$ are related by circles. In fact, by plotting $y$ against $x$, we have the following graph.



enter image description here



This looks pretty close to a circle. The radius of a circle is given by
$$
r = sqrtx^2 + y^2,
$$
so by taking the average of each $sqrtx^2 + y^2$ for your data we find that the radius is approximately $r approx 0.2653$ (to $4$ significant figures). We also find that the average of the $x$ values is $barx = -0.0085$, and the average of the $y$ values is $bary = -0.0505$. These give an estimate for the center of the circle.



The next graph shows the circle of radius $r = 0.2653$ and midpoint $(-0.0085, -0.0505)$ (orange) compared to the plot of your data (blue).



enter image description here



It seems to fit fairly well.



Introducing $theta$



Assuming that this is 'good enough', we can parametrise your $(x, y)$ coordinates by replacing the $2$-tuple $(x, y)$ with $theta$, namely the angle that the point $(x, y)$ makes with the positive $x$-axis. The formula for $theta$ has a few different formulations depending on what range you want $theta$ in, but by playing around with the trigonometric identities you can determine which one you want. The formula that I used is
$$
theta = begincases
arctan(y/x),& textif $x > 0$,\
pi + arctan(y/x),& textif $x < 0$,\
mathrmsgn(y)pi/2,& textif $x = 0$.\
endcases
$$
Note that $mathrmsgn(y)$ is the function that returns the sign of $y$, so
$$
mathrmsgn(y) = begincases
+1,& textif $y > 0$,\
-1,& textif $y < 0$,\
0,& textif $y = 0$.\
endcases
$$
Plotting $theta$ against result, we have the following graph.



enter image description here



Performing simple linear regression on this gives the formula
$$
textresult = 6.2865 - theta.tag$ast$
$$
The values have been rounded to $4$ decimal places. Note that
$$
6.2865 approx 6.283185307 approx 2pi.
$$
The following graph shows how close the fit is.



enter image description here



The blue dots are the original data, and the orange dots are defined by the line $(ast)$



Defining the function



Now that we know the relationship, we can write up an estimate for your function. We will suppose that the constant in $(ast)$ is indeed $2pi$. If
$$
textresult = 2pi - theta
$$
and
$$
theta = begincases
arctan(y/x),& textif $x > 0$,\
pi + arctan(y/x),& textif $x < 0$,\
mathrmsgn(y)pi/2,& textif $x = 0$,\
endcases
$$
then it is easy to see that
$$
textresult = begincases
2pi - arctan(y/x),& textif $x > 0$,\
pi - arctan(y/x),& textif $x < 0$,\
2pi - mathrmsgn(y)pi/2,& textif $x = 0$.\
endcases
$$
The following tables shows how close the values are using this function. The real results are in the 'result' column, and the values using the function are in the 'forecast' column.
$$
beginarrayc
x & y & textresult & theta & textforecast\hline
-0.08 & -0.28 & colorred1.849 & 4.434 & colorgreen1.85 \
-0.16 & -0.25 & colorred2.14 & 4.143 & colorgreen2.129 \
-0.23 & -0.19 & colorred2.451 & 3.832 & colorgreen2.446 \
-0.26 & -0.11 & colorred2.741 & 3.542 & colorgreen2.744 \
-0.27 & -0.03 & colorred3.031 & 3.252 & colorgreen3.047 \
-0.25 & 0.06 & colorred3.377 & 2.906 & colorgreen3.363 \
-0.2 & 0.13 & colorred3.718 & 2.565 & colorgreen3.73 \
-0.14 & 0.2 & colorred4.102 & 2.182 & colorgreen4.121 \
-0.05 & 0.22 & colorred4.489 & 1.794 & colorgreen4.498 \
0.03 & 0.22 & colorred4.848 & 1.435 & colorgreen4.844 \
0.11 & 0.19 & colorred5.237 & 1.046 & colorgreen5.24 \
0.19 & 0.14 & colorred5.648 & 0.635 & colorgreen5.652 \
0.22 & 0.08 & colorred5.934 & 0.349 & colorgreen5.956 \
0.26 & -0.01 & colorred6.322 & -0.038 & colorgreen6.33 \
0.25 & -0.1 & colorred6.664 & -0.381 & colorgreen6.645 \
0.21 & -0.18 & colorred6.992 & -0.709 & colorgreen6.996 \
0.18 & -0.24 & colorred7.21 & -0.927 & colorgreen7.229 \
0.09 & -0.29 & colorred7.553 & -1.27 & colorgreen7.553 \
0 & -0.29 & colorred7.854 & -1.571 & colorgreen7.844 \
-0.07 & -0.28 & colorred1.816 & 4.467 & colorgreen1.829 \
endarray
$$
All values are rounded to $3$ decimal places.







share|cite|improve this answer












share|cite|improve this answer



share|cite|improve this answer










answered Aug 14 at 11:04









Bill Wallis

2,2431826




2,2431826











  • This is it! You've put an impressive amount of work into explaining your derivation in a way that even I would understand, and for that I am especially grateful. Thank you!
    – draconigen
    Aug 14 at 11:48










  • @draconigen You're welcome, it was a fun problem!
    – Bill Wallis
    Aug 14 at 11:49
















  • This is it! You've put an impressive amount of work into explaining your derivation in a way that even I would understand, and for that I am especially grateful. Thank you!
    – draconigen
    Aug 14 at 11:48










  • @draconigen You're welcome, it was a fun problem!
    – Bill Wallis
    Aug 14 at 11:49















This is it! You've put an impressive amount of work into explaining your derivation in a way that even I would understand, and for that I am especially grateful. Thank you!
– draconigen
Aug 14 at 11:48




This is it! You've put an impressive amount of work into explaining your derivation in a way that even I would understand, and for that I am especially grateful. Thank you!
– draconigen
Aug 14 at 11:48












@draconigen You're welcome, it was a fun problem!
– Bill Wallis
Aug 14 at 11:49




@draconigen You're welcome, it was a fun problem!
– Bill Wallis
Aug 14 at 11:49












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2882112%2fhow-to-determine-a-sinus-function-from-samples%23new-answer', 'question_page');

);

Post as a guest













































































這個網誌中的熱門文章

tkz-euclide: tkzDrawCircle[R] not working

How to combine Bézier curves to a surface?

1st Magritte Awards