Ceiling and Floor function












3












$begingroup$


I believe that I have found a trigonometric expression for both the ceiling and floor function, and I seek confirmation that it is, indeed, correct.



Update



enter image description here










share|cite|improve this question











$endgroup$












  • $begingroup$
    your function is not defined for integer
    $endgroup$
    – stity
    Nov 24 '15 at 22:02






  • 2




    $begingroup$
    Because $tan$ of integer multiples of $pi$ is $0$ so $cot$ is undefined at these points.
    $endgroup$
    – Sam Weatherhog
    Nov 24 '15 at 22:05






  • 1




    $begingroup$
    Just define $f(x)=arctan(cot(pi x))/pi$ for $xnotinmathbb Z$ and $f(x)=1/2$ for $xinmathbb Z$ and then use that $f$ in your formula for floor.
    $endgroup$
    – Gregory Grant
    Nov 24 '15 at 22:09






  • 2




    $begingroup$
    @Taylor yes $lim_{xto infty}arctan(x)=frac{pi}{2}$. Gregory is saying that you make your function $x-frac{1}{2}+f(x)$ where $f$ is defined as in his comment
    $endgroup$
    – Sam Weatherhog
    Nov 24 '15 at 22:12








  • 1




    $begingroup$
    @Taylor I mean define $f(x)=left{begin{array}{ll} arctan(cot(pi x))/pi, & xnotinmathbb Z\ 1/2, & xinmathbb Zend{array}right.$. Then $lfloor{x}rfloor = x - frac{1}{2} + f(x)$ $forall x$.
    $endgroup$
    – Gregory Grant
    Nov 24 '15 at 22:19


















3












$begingroup$


I believe that I have found a trigonometric expression for both the ceiling and floor function, and I seek confirmation that it is, indeed, correct.



Update



enter image description here










share|cite|improve this question











$endgroup$












  • $begingroup$
    your function is not defined for integer
    $endgroup$
    – stity
    Nov 24 '15 at 22:02






  • 2




    $begingroup$
    Because $tan$ of integer multiples of $pi$ is $0$ so $cot$ is undefined at these points.
    $endgroup$
    – Sam Weatherhog
    Nov 24 '15 at 22:05






  • 1




    $begingroup$
    Just define $f(x)=arctan(cot(pi x))/pi$ for $xnotinmathbb Z$ and $f(x)=1/2$ for $xinmathbb Z$ and then use that $f$ in your formula for floor.
    $endgroup$
    – Gregory Grant
    Nov 24 '15 at 22:09






  • 2




    $begingroup$
    @Taylor yes $lim_{xto infty}arctan(x)=frac{pi}{2}$. Gregory is saying that you make your function $x-frac{1}{2}+f(x)$ where $f$ is defined as in his comment
    $endgroup$
    – Sam Weatherhog
    Nov 24 '15 at 22:12








  • 1




    $begingroup$
    @Taylor I mean define $f(x)=left{begin{array}{ll} arctan(cot(pi x))/pi, & xnotinmathbb Z\ 1/2, & xinmathbb Zend{array}right.$. Then $lfloor{x}rfloor = x - frac{1}{2} + f(x)$ $forall x$.
    $endgroup$
    – Gregory Grant
    Nov 24 '15 at 22:19
















3












3








3


3



$begingroup$


I believe that I have found a trigonometric expression for both the ceiling and floor function, and I seek confirmation that it is, indeed, correct.



Update



enter image description here










share|cite|improve this question











$endgroup$




I believe that I have found a trigonometric expression for both the ceiling and floor function, and I seek confirmation that it is, indeed, correct.



Update



enter image description here







trigonometry pi floor-function ceiling-function






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Nov 25 '15 at 12:10







Taylor

















asked Nov 24 '15 at 21:55









TaylorTaylor

333617




333617












  • $begingroup$
    your function is not defined for integer
    $endgroup$
    – stity
    Nov 24 '15 at 22:02






  • 2




    $begingroup$
    Because $tan$ of integer multiples of $pi$ is $0$ so $cot$ is undefined at these points.
    $endgroup$
    – Sam Weatherhog
    Nov 24 '15 at 22:05






  • 1




    $begingroup$
    Just define $f(x)=arctan(cot(pi x))/pi$ for $xnotinmathbb Z$ and $f(x)=1/2$ for $xinmathbb Z$ and then use that $f$ in your formula for floor.
    $endgroup$
    – Gregory Grant
    Nov 24 '15 at 22:09






  • 2




    $begingroup$
    @Taylor yes $lim_{xto infty}arctan(x)=frac{pi}{2}$. Gregory is saying that you make your function $x-frac{1}{2}+f(x)$ where $f$ is defined as in his comment
    $endgroup$
    – Sam Weatherhog
    Nov 24 '15 at 22:12








  • 1




    $begingroup$
    @Taylor I mean define $f(x)=left{begin{array}{ll} arctan(cot(pi x))/pi, & xnotinmathbb Z\ 1/2, & xinmathbb Zend{array}right.$. Then $lfloor{x}rfloor = x - frac{1}{2} + f(x)$ $forall x$.
    $endgroup$
    – Gregory Grant
    Nov 24 '15 at 22:19




















  • $begingroup$
    your function is not defined for integer
    $endgroup$
    – stity
    Nov 24 '15 at 22:02






  • 2




    $begingroup$
    Because $tan$ of integer multiples of $pi$ is $0$ so $cot$ is undefined at these points.
    $endgroup$
    – Sam Weatherhog
    Nov 24 '15 at 22:05






  • 1




    $begingroup$
    Just define $f(x)=arctan(cot(pi x))/pi$ for $xnotinmathbb Z$ and $f(x)=1/2$ for $xinmathbb Z$ and then use that $f$ in your formula for floor.
    $endgroup$
    – Gregory Grant
    Nov 24 '15 at 22:09






  • 2




    $begingroup$
    @Taylor yes $lim_{xto infty}arctan(x)=frac{pi}{2}$. Gregory is saying that you make your function $x-frac{1}{2}+f(x)$ where $f$ is defined as in his comment
    $endgroup$
    – Sam Weatherhog
    Nov 24 '15 at 22:12








  • 1




    $begingroup$
    @Taylor I mean define $f(x)=left{begin{array}{ll} arctan(cot(pi x))/pi, & xnotinmathbb Z\ 1/2, & xinmathbb Zend{array}right.$. Then $lfloor{x}rfloor = x - frac{1}{2} + f(x)$ $forall x$.
    $endgroup$
    – Gregory Grant
    Nov 24 '15 at 22:19


















$begingroup$
your function is not defined for integer
$endgroup$
– stity
Nov 24 '15 at 22:02




$begingroup$
your function is not defined for integer
$endgroup$
– stity
Nov 24 '15 at 22:02




2




2




$begingroup$
Because $tan$ of integer multiples of $pi$ is $0$ so $cot$ is undefined at these points.
$endgroup$
– Sam Weatherhog
Nov 24 '15 at 22:05




$begingroup$
Because $tan$ of integer multiples of $pi$ is $0$ so $cot$ is undefined at these points.
$endgroup$
– Sam Weatherhog
Nov 24 '15 at 22:05




1




1




$begingroup$
Just define $f(x)=arctan(cot(pi x))/pi$ for $xnotinmathbb Z$ and $f(x)=1/2$ for $xinmathbb Z$ and then use that $f$ in your formula for floor.
$endgroup$
– Gregory Grant
Nov 24 '15 at 22:09




$begingroup$
Just define $f(x)=arctan(cot(pi x))/pi$ for $xnotinmathbb Z$ and $f(x)=1/2$ for $xinmathbb Z$ and then use that $f$ in your formula for floor.
$endgroup$
– Gregory Grant
Nov 24 '15 at 22:09




2




2




$begingroup$
@Taylor yes $lim_{xto infty}arctan(x)=frac{pi}{2}$. Gregory is saying that you make your function $x-frac{1}{2}+f(x)$ where $f$ is defined as in his comment
$endgroup$
– Sam Weatherhog
Nov 24 '15 at 22:12






$begingroup$
@Taylor yes $lim_{xto infty}arctan(x)=frac{pi}{2}$. Gregory is saying that you make your function $x-frac{1}{2}+f(x)$ where $f$ is defined as in his comment
$endgroup$
– Sam Weatherhog
Nov 24 '15 at 22:12






1




1




$begingroup$
@Taylor I mean define $f(x)=left{begin{array}{ll} arctan(cot(pi x))/pi, & xnotinmathbb Z\ 1/2, & xinmathbb Zend{array}right.$. Then $lfloor{x}rfloor = x - frac{1}{2} + f(x)$ $forall x$.
$endgroup$
– Gregory Grant
Nov 24 '15 at 22:19






$begingroup$
@Taylor I mean define $f(x)=left{begin{array}{ll} arctan(cot(pi x))/pi, & xnotinmathbb Z\ 1/2, & xinmathbb Zend{array}right.$. Then $lfloor{x}rfloor = x - frac{1}{2} + f(x)$ $forall x$.
$endgroup$
– Gregory Grant
Nov 24 '15 at 22:19












2 Answers
2






active

oldest

votes


















1












$begingroup$

Note that you have the identity $tanleft(frac{pi}{2}-xright)=cot(x)$. Using this, your formula for the floor function is:



$$
begin{split} lfloor x rfloor &= x-frac{1}{2}+frac{arctanleft(tanleft(frac{pi}{2}-picdot xright)right)}{pi} \ &=x-frac{1}{2}+frac{frac{pi}{2}-picdot x+npi}{pi}, text{ for }ninmathbb{Z} \ &=x-frac{1}{2}+frac{1}{2}-x+n \ &=n end{split}
$$



Then there is some $nin mathbb{Z}$ such that $n=lfloor x rfloor$. If, as usual, you insist that $-pile arctan(x) le pi$ this then forces:



$$
begin{split} && -1le frac{1}{2}-x+n le 1 \ &implies& -frac{3}{2}le n-x le frac{1}{2} \ &implies& x-frac{3}{2} le n le x+frac{1}{2} end{split}
$$



So the value for $n$ is close to $lfloor x rfloor$. I'm not sure how computers choose which value to pick for $arctan$ but it appears to always pick the right one for your formula to work. I'm not sure it would be a good idea to use this formula in your work unless you know which value of $arctan$ to pick to ensure that you get the right answer.






share|cite|improve this answer











$endgroup$













  • $begingroup$
    Does that mean that the formula is correct, then?
    $endgroup$
    – Taylor
    Nov 24 '15 at 22:32










  • $begingroup$
    It will be correct for some value of $arctan$ but $arctan$ is multiple valued so then you're just choosing the value of $arctan$ that makes the formula work. For example, if $x=1.6$ then $arctan(cot(pi*x))$ could be $-0.3142$ (which makes the formula work) or you could choose $-3.4558$ and this value will not make the formula work.
    $endgroup$
    – Sam Weatherhog
    Nov 24 '15 at 22:37



















3












$begingroup$

If you're using the single-valued $arctan$, i.e. $-frac{pi}{2} leq arctan(x) leq frac{pi}{2}$, which is what all computer languages I've seen use, this works perfectly fine.



Proof:



Let $x = s(a + b)$, where $a in mathbb{N}$, $0 leq b < 1$ and $s in {-1,1}$. We can call $a$ the absolute integer part, $b$ the absolute fractional part, and $s$ is $x$'s sign.



Then:
$$
begin{align*}
frac{arctan(cot(pi x))}{pi}
&= frac{arctan(cot(pi s(a + b)))}{pi}\[1em]
&= frac{arctan(scdotcot(pi a + pi b)))}{pi}\[1em]
&= frac{arctan(scdotcot(pi b))}{pi}\[1em]
&= frac{arctan(scdottan(frac{pi}{2} - pi b))}{pi}\[1em]
&= frac{arctan(scdottan(pi(frac{1}{2} - b)))}{pi}\[1em]
&= frac{arctan(tan(pi s(frac{1}{2} - b)))}{pi}\[1em]
&= frac{pi s(frac{1}{2} - b)}{pi}\[1em]
&= sbigg(frac{1}{2} - bbigg)\[1em]
end{align*}
$$



Note that we can assert that $arctan(tan(pi s(frac{1}{2} - b)) = pi s(frac{1}{2} - b)$ without issues only because



$$
begin{alignat*}{5}
0 && quad leq && b quad && < quad && 1 &&implies\[0.5em]
0 && quad geq && -b quad && > quad && -1 &&implies\[0.5em]
frac{1}{2} && quad geq && quad frac{1}{2} - b quad && > quad && -frac{1}{2} &&implies\[0.5em]
frac{pi}{2} && quad geq && piBigg(frac{1}{2} - bBigg) quad && > quad && -frac{pi}{2} &&\
end{alignat*}
$$



$arctan(tan(x)) = x$ only holds for $x$ in that range. For example, $arctan(tan(x)) = x - pi$ if $frac{pi}{2} < x < pi$.



With that said...
$$
begin{align*}
lfloor x rfloor &= x - frac{1}{2} + sbigg(frac{1}{2} - bbigg)\[0.5em]
&= s(a + b) - frac{1 - s}{2} - sb\[0.5em]
&= s(a + b - b) - frac{1 - s}{2}\[0.5em]
&= sa - frac{1 - s}{2}\[0.5em]
end{align*}
$$



If $s=1$, $lfloor xrfloor = a - frac{1 - 1}{2} = a$.



If $s=-1$, $lfloor xrfloor = -a - frac{1 + 1}{2} = -a - 1 = -(a + 1)$.



This works because $lfloor pm y.uwv rfloor$ is y if the number is positive, and $-(y + 1)$ if the number is negative. e.g. $lfloor 1.2rfloor = 1$ but $lfloor -1.2rfloor = -2$.



Proving that your $ceil$ function works should go about the same way.



I realize I am three years late to this but I initially was going to post my own trigonometric floor:



$$
lfloor x rfloor = x - text{frac}(x)\[1.4em]
%
text{frac}(x) = text{sgn}Big(sin(2pi x)Big)Bigg( frac{cos^{-1}(cos(2pi x))}{2pi} - frac{1}{2} Bigg) + frac{1}{2}left| text{sgn}Big(sin(2pi x)Big)right|\[1.4em]
%
text{sgn}(x) = frac{1}{2}Bigg(frac{cot^{-1}(x) - cot^{-1}(-x)}{big|cot^{-1}(x)big|}Bigg)
$$



But yours seems a bit simpler.






share|cite|improve this answer











$endgroup$













  • $begingroup$
    This is excellent and much better defined, thank you for sharing +1
    $endgroup$
    – Albert Renshaw
    Dec 4 '18 at 21:10











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',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
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%2f1545006%2fceiling-and-floor-function%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1












$begingroup$

Note that you have the identity $tanleft(frac{pi}{2}-xright)=cot(x)$. Using this, your formula for the floor function is:



$$
begin{split} lfloor x rfloor &= x-frac{1}{2}+frac{arctanleft(tanleft(frac{pi}{2}-picdot xright)right)}{pi} \ &=x-frac{1}{2}+frac{frac{pi}{2}-picdot x+npi}{pi}, text{ for }ninmathbb{Z} \ &=x-frac{1}{2}+frac{1}{2}-x+n \ &=n end{split}
$$



Then there is some $nin mathbb{Z}$ such that $n=lfloor x rfloor$. If, as usual, you insist that $-pile arctan(x) le pi$ this then forces:



$$
begin{split} && -1le frac{1}{2}-x+n le 1 \ &implies& -frac{3}{2}le n-x le frac{1}{2} \ &implies& x-frac{3}{2} le n le x+frac{1}{2} end{split}
$$



So the value for $n$ is close to $lfloor x rfloor$. I'm not sure how computers choose which value to pick for $arctan$ but it appears to always pick the right one for your formula to work. I'm not sure it would be a good idea to use this formula in your work unless you know which value of $arctan$ to pick to ensure that you get the right answer.






share|cite|improve this answer











$endgroup$













  • $begingroup$
    Does that mean that the formula is correct, then?
    $endgroup$
    – Taylor
    Nov 24 '15 at 22:32










  • $begingroup$
    It will be correct for some value of $arctan$ but $arctan$ is multiple valued so then you're just choosing the value of $arctan$ that makes the formula work. For example, if $x=1.6$ then $arctan(cot(pi*x))$ could be $-0.3142$ (which makes the formula work) or you could choose $-3.4558$ and this value will not make the formula work.
    $endgroup$
    – Sam Weatherhog
    Nov 24 '15 at 22:37
















1












$begingroup$

Note that you have the identity $tanleft(frac{pi}{2}-xright)=cot(x)$. Using this, your formula for the floor function is:



$$
begin{split} lfloor x rfloor &= x-frac{1}{2}+frac{arctanleft(tanleft(frac{pi}{2}-picdot xright)right)}{pi} \ &=x-frac{1}{2}+frac{frac{pi}{2}-picdot x+npi}{pi}, text{ for }ninmathbb{Z} \ &=x-frac{1}{2}+frac{1}{2}-x+n \ &=n end{split}
$$



Then there is some $nin mathbb{Z}$ such that $n=lfloor x rfloor$. If, as usual, you insist that $-pile arctan(x) le pi$ this then forces:



$$
begin{split} && -1le frac{1}{2}-x+n le 1 \ &implies& -frac{3}{2}le n-x le frac{1}{2} \ &implies& x-frac{3}{2} le n le x+frac{1}{2} end{split}
$$



So the value for $n$ is close to $lfloor x rfloor$. I'm not sure how computers choose which value to pick for $arctan$ but it appears to always pick the right one for your formula to work. I'm not sure it would be a good idea to use this formula in your work unless you know which value of $arctan$ to pick to ensure that you get the right answer.






share|cite|improve this answer











$endgroup$













  • $begingroup$
    Does that mean that the formula is correct, then?
    $endgroup$
    – Taylor
    Nov 24 '15 at 22:32










  • $begingroup$
    It will be correct for some value of $arctan$ but $arctan$ is multiple valued so then you're just choosing the value of $arctan$ that makes the formula work. For example, if $x=1.6$ then $arctan(cot(pi*x))$ could be $-0.3142$ (which makes the formula work) or you could choose $-3.4558$ and this value will not make the formula work.
    $endgroup$
    – Sam Weatherhog
    Nov 24 '15 at 22:37














1












1








1





$begingroup$

Note that you have the identity $tanleft(frac{pi}{2}-xright)=cot(x)$. Using this, your formula for the floor function is:



$$
begin{split} lfloor x rfloor &= x-frac{1}{2}+frac{arctanleft(tanleft(frac{pi}{2}-picdot xright)right)}{pi} \ &=x-frac{1}{2}+frac{frac{pi}{2}-picdot x+npi}{pi}, text{ for }ninmathbb{Z} \ &=x-frac{1}{2}+frac{1}{2}-x+n \ &=n end{split}
$$



Then there is some $nin mathbb{Z}$ such that $n=lfloor x rfloor$. If, as usual, you insist that $-pile arctan(x) le pi$ this then forces:



$$
begin{split} && -1le frac{1}{2}-x+n le 1 \ &implies& -frac{3}{2}le n-x le frac{1}{2} \ &implies& x-frac{3}{2} le n le x+frac{1}{2} end{split}
$$



So the value for $n$ is close to $lfloor x rfloor$. I'm not sure how computers choose which value to pick for $arctan$ but it appears to always pick the right one for your formula to work. I'm not sure it would be a good idea to use this formula in your work unless you know which value of $arctan$ to pick to ensure that you get the right answer.






share|cite|improve this answer











$endgroup$



Note that you have the identity $tanleft(frac{pi}{2}-xright)=cot(x)$. Using this, your formula for the floor function is:



$$
begin{split} lfloor x rfloor &= x-frac{1}{2}+frac{arctanleft(tanleft(frac{pi}{2}-picdot xright)right)}{pi} \ &=x-frac{1}{2}+frac{frac{pi}{2}-picdot x+npi}{pi}, text{ for }ninmathbb{Z} \ &=x-frac{1}{2}+frac{1}{2}-x+n \ &=n end{split}
$$



Then there is some $nin mathbb{Z}$ such that $n=lfloor x rfloor$. If, as usual, you insist that $-pile arctan(x) le pi$ this then forces:



$$
begin{split} && -1le frac{1}{2}-x+n le 1 \ &implies& -frac{3}{2}le n-x le frac{1}{2} \ &implies& x-frac{3}{2} le n le x+frac{1}{2} end{split}
$$



So the value for $n$ is close to $lfloor x rfloor$. I'm not sure how computers choose which value to pick for $arctan$ but it appears to always pick the right one for your formula to work. I'm not sure it would be a good idea to use this formula in your work unless you know which value of $arctan$ to pick to ensure that you get the right answer.







share|cite|improve this answer














share|cite|improve this answer



share|cite|improve this answer








edited Nov 24 '15 at 22:52

























answered Nov 24 '15 at 22:30









Sam WeatherhogSam Weatherhog

1,267515




1,267515












  • $begingroup$
    Does that mean that the formula is correct, then?
    $endgroup$
    – Taylor
    Nov 24 '15 at 22:32










  • $begingroup$
    It will be correct for some value of $arctan$ but $arctan$ is multiple valued so then you're just choosing the value of $arctan$ that makes the formula work. For example, if $x=1.6$ then $arctan(cot(pi*x))$ could be $-0.3142$ (which makes the formula work) or you could choose $-3.4558$ and this value will not make the formula work.
    $endgroup$
    – Sam Weatherhog
    Nov 24 '15 at 22:37


















  • $begingroup$
    Does that mean that the formula is correct, then?
    $endgroup$
    – Taylor
    Nov 24 '15 at 22:32










  • $begingroup$
    It will be correct for some value of $arctan$ but $arctan$ is multiple valued so then you're just choosing the value of $arctan$ that makes the formula work. For example, if $x=1.6$ then $arctan(cot(pi*x))$ could be $-0.3142$ (which makes the formula work) or you could choose $-3.4558$ and this value will not make the formula work.
    $endgroup$
    – Sam Weatherhog
    Nov 24 '15 at 22:37
















$begingroup$
Does that mean that the formula is correct, then?
$endgroup$
– Taylor
Nov 24 '15 at 22:32




$begingroup$
Does that mean that the formula is correct, then?
$endgroup$
– Taylor
Nov 24 '15 at 22:32












$begingroup$
It will be correct for some value of $arctan$ but $arctan$ is multiple valued so then you're just choosing the value of $arctan$ that makes the formula work. For example, if $x=1.6$ then $arctan(cot(pi*x))$ could be $-0.3142$ (which makes the formula work) or you could choose $-3.4558$ and this value will not make the formula work.
$endgroup$
– Sam Weatherhog
Nov 24 '15 at 22:37




$begingroup$
It will be correct for some value of $arctan$ but $arctan$ is multiple valued so then you're just choosing the value of $arctan$ that makes the formula work. For example, if $x=1.6$ then $arctan(cot(pi*x))$ could be $-0.3142$ (which makes the formula work) or you could choose $-3.4558$ and this value will not make the formula work.
$endgroup$
– Sam Weatherhog
Nov 24 '15 at 22:37











3












$begingroup$

If you're using the single-valued $arctan$, i.e. $-frac{pi}{2} leq arctan(x) leq frac{pi}{2}$, which is what all computer languages I've seen use, this works perfectly fine.



Proof:



Let $x = s(a + b)$, where $a in mathbb{N}$, $0 leq b < 1$ and $s in {-1,1}$. We can call $a$ the absolute integer part, $b$ the absolute fractional part, and $s$ is $x$'s sign.



Then:
$$
begin{align*}
frac{arctan(cot(pi x))}{pi}
&= frac{arctan(cot(pi s(a + b)))}{pi}\[1em]
&= frac{arctan(scdotcot(pi a + pi b)))}{pi}\[1em]
&= frac{arctan(scdotcot(pi b))}{pi}\[1em]
&= frac{arctan(scdottan(frac{pi}{2} - pi b))}{pi}\[1em]
&= frac{arctan(scdottan(pi(frac{1}{2} - b)))}{pi}\[1em]
&= frac{arctan(tan(pi s(frac{1}{2} - b)))}{pi}\[1em]
&= frac{pi s(frac{1}{2} - b)}{pi}\[1em]
&= sbigg(frac{1}{2} - bbigg)\[1em]
end{align*}
$$



Note that we can assert that $arctan(tan(pi s(frac{1}{2} - b)) = pi s(frac{1}{2} - b)$ without issues only because



$$
begin{alignat*}{5}
0 && quad leq && b quad && < quad && 1 &&implies\[0.5em]
0 && quad geq && -b quad && > quad && -1 &&implies\[0.5em]
frac{1}{2} && quad geq && quad frac{1}{2} - b quad && > quad && -frac{1}{2} &&implies\[0.5em]
frac{pi}{2} && quad geq && piBigg(frac{1}{2} - bBigg) quad && > quad && -frac{pi}{2} &&\
end{alignat*}
$$



$arctan(tan(x)) = x$ only holds for $x$ in that range. For example, $arctan(tan(x)) = x - pi$ if $frac{pi}{2} < x < pi$.



With that said...
$$
begin{align*}
lfloor x rfloor &= x - frac{1}{2} + sbigg(frac{1}{2} - bbigg)\[0.5em]
&= s(a + b) - frac{1 - s}{2} - sb\[0.5em]
&= s(a + b - b) - frac{1 - s}{2}\[0.5em]
&= sa - frac{1 - s}{2}\[0.5em]
end{align*}
$$



If $s=1$, $lfloor xrfloor = a - frac{1 - 1}{2} = a$.



If $s=-1$, $lfloor xrfloor = -a - frac{1 + 1}{2} = -a - 1 = -(a + 1)$.



This works because $lfloor pm y.uwv rfloor$ is y if the number is positive, and $-(y + 1)$ if the number is negative. e.g. $lfloor 1.2rfloor = 1$ but $lfloor -1.2rfloor = -2$.



Proving that your $ceil$ function works should go about the same way.



I realize I am three years late to this but I initially was going to post my own trigonometric floor:



$$
lfloor x rfloor = x - text{frac}(x)\[1.4em]
%
text{frac}(x) = text{sgn}Big(sin(2pi x)Big)Bigg( frac{cos^{-1}(cos(2pi x))}{2pi} - frac{1}{2} Bigg) + frac{1}{2}left| text{sgn}Big(sin(2pi x)Big)right|\[1.4em]
%
text{sgn}(x) = frac{1}{2}Bigg(frac{cot^{-1}(x) - cot^{-1}(-x)}{big|cot^{-1}(x)big|}Bigg)
$$



But yours seems a bit simpler.






share|cite|improve this answer











$endgroup$













  • $begingroup$
    This is excellent and much better defined, thank you for sharing +1
    $endgroup$
    – Albert Renshaw
    Dec 4 '18 at 21:10
















3












$begingroup$

If you're using the single-valued $arctan$, i.e. $-frac{pi}{2} leq arctan(x) leq frac{pi}{2}$, which is what all computer languages I've seen use, this works perfectly fine.



Proof:



Let $x = s(a + b)$, where $a in mathbb{N}$, $0 leq b < 1$ and $s in {-1,1}$. We can call $a$ the absolute integer part, $b$ the absolute fractional part, and $s$ is $x$'s sign.



Then:
$$
begin{align*}
frac{arctan(cot(pi x))}{pi}
&= frac{arctan(cot(pi s(a + b)))}{pi}\[1em]
&= frac{arctan(scdotcot(pi a + pi b)))}{pi}\[1em]
&= frac{arctan(scdotcot(pi b))}{pi}\[1em]
&= frac{arctan(scdottan(frac{pi}{2} - pi b))}{pi}\[1em]
&= frac{arctan(scdottan(pi(frac{1}{2} - b)))}{pi}\[1em]
&= frac{arctan(tan(pi s(frac{1}{2} - b)))}{pi}\[1em]
&= frac{pi s(frac{1}{2} - b)}{pi}\[1em]
&= sbigg(frac{1}{2} - bbigg)\[1em]
end{align*}
$$



Note that we can assert that $arctan(tan(pi s(frac{1}{2} - b)) = pi s(frac{1}{2} - b)$ without issues only because



$$
begin{alignat*}{5}
0 && quad leq && b quad && < quad && 1 &&implies\[0.5em]
0 && quad geq && -b quad && > quad && -1 &&implies\[0.5em]
frac{1}{2} && quad geq && quad frac{1}{2} - b quad && > quad && -frac{1}{2} &&implies\[0.5em]
frac{pi}{2} && quad geq && piBigg(frac{1}{2} - bBigg) quad && > quad && -frac{pi}{2} &&\
end{alignat*}
$$



$arctan(tan(x)) = x$ only holds for $x$ in that range. For example, $arctan(tan(x)) = x - pi$ if $frac{pi}{2} < x < pi$.



With that said...
$$
begin{align*}
lfloor x rfloor &= x - frac{1}{2} + sbigg(frac{1}{2} - bbigg)\[0.5em]
&= s(a + b) - frac{1 - s}{2} - sb\[0.5em]
&= s(a + b - b) - frac{1 - s}{2}\[0.5em]
&= sa - frac{1 - s}{2}\[0.5em]
end{align*}
$$



If $s=1$, $lfloor xrfloor = a - frac{1 - 1}{2} = a$.



If $s=-1$, $lfloor xrfloor = -a - frac{1 + 1}{2} = -a - 1 = -(a + 1)$.



This works because $lfloor pm y.uwv rfloor$ is y if the number is positive, and $-(y + 1)$ if the number is negative. e.g. $lfloor 1.2rfloor = 1$ but $lfloor -1.2rfloor = -2$.



Proving that your $ceil$ function works should go about the same way.



I realize I am three years late to this but I initially was going to post my own trigonometric floor:



$$
lfloor x rfloor = x - text{frac}(x)\[1.4em]
%
text{frac}(x) = text{sgn}Big(sin(2pi x)Big)Bigg( frac{cos^{-1}(cos(2pi x))}{2pi} - frac{1}{2} Bigg) + frac{1}{2}left| text{sgn}Big(sin(2pi x)Big)right|\[1.4em]
%
text{sgn}(x) = frac{1}{2}Bigg(frac{cot^{-1}(x) - cot^{-1}(-x)}{big|cot^{-1}(x)big|}Bigg)
$$



But yours seems a bit simpler.






share|cite|improve this answer











$endgroup$













  • $begingroup$
    This is excellent and much better defined, thank you for sharing +1
    $endgroup$
    – Albert Renshaw
    Dec 4 '18 at 21:10














3












3








3





$begingroup$

If you're using the single-valued $arctan$, i.e. $-frac{pi}{2} leq arctan(x) leq frac{pi}{2}$, which is what all computer languages I've seen use, this works perfectly fine.



Proof:



Let $x = s(a + b)$, where $a in mathbb{N}$, $0 leq b < 1$ and $s in {-1,1}$. We can call $a$ the absolute integer part, $b$ the absolute fractional part, and $s$ is $x$'s sign.



Then:
$$
begin{align*}
frac{arctan(cot(pi x))}{pi}
&= frac{arctan(cot(pi s(a + b)))}{pi}\[1em]
&= frac{arctan(scdotcot(pi a + pi b)))}{pi}\[1em]
&= frac{arctan(scdotcot(pi b))}{pi}\[1em]
&= frac{arctan(scdottan(frac{pi}{2} - pi b))}{pi}\[1em]
&= frac{arctan(scdottan(pi(frac{1}{2} - b)))}{pi}\[1em]
&= frac{arctan(tan(pi s(frac{1}{2} - b)))}{pi}\[1em]
&= frac{pi s(frac{1}{2} - b)}{pi}\[1em]
&= sbigg(frac{1}{2} - bbigg)\[1em]
end{align*}
$$



Note that we can assert that $arctan(tan(pi s(frac{1}{2} - b)) = pi s(frac{1}{2} - b)$ without issues only because



$$
begin{alignat*}{5}
0 && quad leq && b quad && < quad && 1 &&implies\[0.5em]
0 && quad geq && -b quad && > quad && -1 &&implies\[0.5em]
frac{1}{2} && quad geq && quad frac{1}{2} - b quad && > quad && -frac{1}{2} &&implies\[0.5em]
frac{pi}{2} && quad geq && piBigg(frac{1}{2} - bBigg) quad && > quad && -frac{pi}{2} &&\
end{alignat*}
$$



$arctan(tan(x)) = x$ only holds for $x$ in that range. For example, $arctan(tan(x)) = x - pi$ if $frac{pi}{2} < x < pi$.



With that said...
$$
begin{align*}
lfloor x rfloor &= x - frac{1}{2} + sbigg(frac{1}{2} - bbigg)\[0.5em]
&= s(a + b) - frac{1 - s}{2} - sb\[0.5em]
&= s(a + b - b) - frac{1 - s}{2}\[0.5em]
&= sa - frac{1 - s}{2}\[0.5em]
end{align*}
$$



If $s=1$, $lfloor xrfloor = a - frac{1 - 1}{2} = a$.



If $s=-1$, $lfloor xrfloor = -a - frac{1 + 1}{2} = -a - 1 = -(a + 1)$.



This works because $lfloor pm y.uwv rfloor$ is y if the number is positive, and $-(y + 1)$ if the number is negative. e.g. $lfloor 1.2rfloor = 1$ but $lfloor -1.2rfloor = -2$.



Proving that your $ceil$ function works should go about the same way.



I realize I am three years late to this but I initially was going to post my own trigonometric floor:



$$
lfloor x rfloor = x - text{frac}(x)\[1.4em]
%
text{frac}(x) = text{sgn}Big(sin(2pi x)Big)Bigg( frac{cos^{-1}(cos(2pi x))}{2pi} - frac{1}{2} Bigg) + frac{1}{2}left| text{sgn}Big(sin(2pi x)Big)right|\[1.4em]
%
text{sgn}(x) = frac{1}{2}Bigg(frac{cot^{-1}(x) - cot^{-1}(-x)}{big|cot^{-1}(x)big|}Bigg)
$$



But yours seems a bit simpler.






share|cite|improve this answer











$endgroup$



If you're using the single-valued $arctan$, i.e. $-frac{pi}{2} leq arctan(x) leq frac{pi}{2}$, which is what all computer languages I've seen use, this works perfectly fine.



Proof:



Let $x = s(a + b)$, where $a in mathbb{N}$, $0 leq b < 1$ and $s in {-1,1}$. We can call $a$ the absolute integer part, $b$ the absolute fractional part, and $s$ is $x$'s sign.



Then:
$$
begin{align*}
frac{arctan(cot(pi x))}{pi}
&= frac{arctan(cot(pi s(a + b)))}{pi}\[1em]
&= frac{arctan(scdotcot(pi a + pi b)))}{pi}\[1em]
&= frac{arctan(scdotcot(pi b))}{pi}\[1em]
&= frac{arctan(scdottan(frac{pi}{2} - pi b))}{pi}\[1em]
&= frac{arctan(scdottan(pi(frac{1}{2} - b)))}{pi}\[1em]
&= frac{arctan(tan(pi s(frac{1}{2} - b)))}{pi}\[1em]
&= frac{pi s(frac{1}{2} - b)}{pi}\[1em]
&= sbigg(frac{1}{2} - bbigg)\[1em]
end{align*}
$$



Note that we can assert that $arctan(tan(pi s(frac{1}{2} - b)) = pi s(frac{1}{2} - b)$ without issues only because



$$
begin{alignat*}{5}
0 && quad leq && b quad && < quad && 1 &&implies\[0.5em]
0 && quad geq && -b quad && > quad && -1 &&implies\[0.5em]
frac{1}{2} && quad geq && quad frac{1}{2} - b quad && > quad && -frac{1}{2} &&implies\[0.5em]
frac{pi}{2} && quad geq && piBigg(frac{1}{2} - bBigg) quad && > quad && -frac{pi}{2} &&\
end{alignat*}
$$



$arctan(tan(x)) = x$ only holds for $x$ in that range. For example, $arctan(tan(x)) = x - pi$ if $frac{pi}{2} < x < pi$.



With that said...
$$
begin{align*}
lfloor x rfloor &= x - frac{1}{2} + sbigg(frac{1}{2} - bbigg)\[0.5em]
&= s(a + b) - frac{1 - s}{2} - sb\[0.5em]
&= s(a + b - b) - frac{1 - s}{2}\[0.5em]
&= sa - frac{1 - s}{2}\[0.5em]
end{align*}
$$



If $s=1$, $lfloor xrfloor = a - frac{1 - 1}{2} = a$.



If $s=-1$, $lfloor xrfloor = -a - frac{1 + 1}{2} = -a - 1 = -(a + 1)$.



This works because $lfloor pm y.uwv rfloor$ is y if the number is positive, and $-(y + 1)$ if the number is negative. e.g. $lfloor 1.2rfloor = 1$ but $lfloor -1.2rfloor = -2$.



Proving that your $ceil$ function works should go about the same way.



I realize I am three years late to this but I initially was going to post my own trigonometric floor:



$$
lfloor x rfloor = x - text{frac}(x)\[1.4em]
%
text{frac}(x) = text{sgn}Big(sin(2pi x)Big)Bigg( frac{cos^{-1}(cos(2pi x))}{2pi} - frac{1}{2} Bigg) + frac{1}{2}left| text{sgn}Big(sin(2pi x)Big)right|\[1.4em]
%
text{sgn}(x) = frac{1}{2}Bigg(frac{cot^{-1}(x) - cot^{-1}(-x)}{big|cot^{-1}(x)big|}Bigg)
$$



But yours seems a bit simpler.







share|cite|improve this answer














share|cite|improve this answer



share|cite|improve this answer








edited Dec 7 '18 at 4:53

























answered Jul 6 '18 at 1:15









phicrphicr

1438




1438












  • $begingroup$
    This is excellent and much better defined, thank you for sharing +1
    $endgroup$
    – Albert Renshaw
    Dec 4 '18 at 21:10


















  • $begingroup$
    This is excellent and much better defined, thank you for sharing +1
    $endgroup$
    – Albert Renshaw
    Dec 4 '18 at 21:10
















$begingroup$
This is excellent and much better defined, thank you for sharing +1
$endgroup$
– Albert Renshaw
Dec 4 '18 at 21:10




$begingroup$
This is excellent and much better defined, thank you for sharing +1
$endgroup$
– Albert Renshaw
Dec 4 '18 at 21:10


















draft saved

draft discarded




















































Thanks for contributing an answer to Mathematics Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f1545006%2fceiling-and-floor-function%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bundesstraße 106

Le Mesnil-Réaume

Ida-Boy-Ed-Garten