-1

Consider a graph of an equation like y = sin(x).

Now suppose that I want to have a single equation where y gets the same value that it would get in the following computer code:

if (y - sin(x) <= 45) {
    y = sin(x);
}
else {
    y = 0;
}

How would I mathematically build the above logic into a single math equation with no externally defined functions, for graphing (or really any other purpose)?

Note: this is a question about standard math notation, not a particular calculator.

CommaToast
  • 199
  • 1
  • 7
  • There may be something in the user's manual for the calculator. (If the calculator did not come with a manual, look for one online; some product manuals aren't shipped because they assume you will just get it from the Web anyway.) If you really can't figure it out, tell us the brand and exact model of the calculator; perhaps someone here will know that model. – David K Dec 31 '16 at 23:02
  • This is specific to your particular calculator. – copper.hat Dec 31 '16 at 23:12
  • OK, that's not what I had intended to ask about. I have revised the question to accurately reflect what I was really trying to ask. – CommaToast Jan 01 '17 at 03:04
  • 1
    In your code the final value of $y$ depends on the original value of $y$. Is that intended? –  Jan 01 '17 at 03:26

3 Answers3

2

\begin{equation} y=\begin{cases} \sin(x), & \text{if $(y - \sin(x) \leq 45)$}.\\ 0, & \text{otherwise}. \end{cases} \end{equation}

jimjim
  • 9,675
1

I don't know how calculators behave, but we can use indicator functions for this: $$y := x 1[y-x \leq 45] + y 1[y-x > 45]$$ where $1[\phi]$ is defined to be zero if $\phi$ is false, and $1$ if $\phi$ is true.

  • So what you're saying is that you have to externally define some function "1[φ]"? Is there no way to define it inside the equation itself? I mean is there really no math symbol that already exists that lets you write this without defining the function externally? – CommaToast Jan 01 '17 at 02:56
  • Also, I just revised the question, since I realized I had phrased it wrong. Please check it out and update your answer accordingly, – CommaToast Jan 01 '17 at 03:05
  • Well, different people have different notation for the indicator functions, but "indicator function" is a well-known phrase. – Patrick Stevens Jan 01 '17 at 03:53
0

In MATLAB: u =(y-x < 45)*x +(y-x>= 45)*sin(x);

John Hughes
  • 93,729
  • Thanks. I just revised the question, since I realized I had phrased it wrong. Please check it out and update your answer accordingly, – CommaToast Jan 01 '17 at 03:06