Closed Expression for a certain function

54 Views Asked by At

Is there a closed expression for this Graph :

enter image description here

If there is , please help me to find it

2

There are 2 best solutions below

0
On

Simply looking at the graph, I can combine the linear and constant sections like so: $$ f(x) = \left\{ \begin{array}{ccc} 1, & x<4\\ 5-x, & 4 \leq x \leq 5\\ 0, & 5 < x \leq 8 \\ x-8, & 8 < x < 9 \\ 1, & 9 \leq x \end{array} \right. $$ Nothing difficult here.

0
On

There's a closed form expression that, rather than using a piecewise linear function with five pieces, uses absolute value functions. The function

$$ f_1(x) = \frac{(x - 8) + |x - 8|}{2} - \frac{(x - 9) + |x - 9|}{2} $$

is constant at 0 until $x = 8$, then linearly increases to 1 at $x = 9$, then is constant at 1. Similarly, the function

$$ f_2(x) = 1 - \frac{(x - 4) + |x - 4|}{2} + \frac{(x - 5) + |x - 5|}{2} $$

is constant at 1 until $x = 4$, decreases linearly to 0 at $x = 5$, and then is constant at 0. Adding $f_1$ and $f_2$ gives the function you want.

I'd also like to indicate how you can come up with a formula like this. The key observation is that the graph of $y = x + |x|$ has a sharp bend at $x = 0$. Once I know that, I can use things like $x + |x|$ as building blocks to make more complicated functions like yours. If I want a function with a bend at $x = 8$, I can translate the graph $y = (x - 8) + |x - 8|$. What if I want a function with bends at $x = 8$ and $x = 9$? Well, it's probably going to look something like

$$ y = a(x - 8) + b|x - 8| + c(x - 9) + d|x - 9|, $$

where $a, b, c, d$ are some numbers I'll have to figure out. How do I do that? By plugging numbers in for $x$ and $y$. I want the graph to go through $(8, 0)$, so when I plug in 8 for $x$ and 0 for $y$, I get $0 = -c + d$, which tells me that $c = d$. Similarly, if I want the graph to go through $(9, 1)$, I learn that $1 = a + b$, or $b = 1 - a$. Now I've got my formula down to

$$ y = a(x - 8) + (1 - a)|x - 8| + c(x - 9) + c|x - 9|, $$

which only has two unknown parameters. I could keep plugging points in, like $(7, 0)$ and $(10, 1)$, and solve for $a$ and $c$, but at this point I might also just throw the formula into Desmos, create sliders for $a$ and $c$, and drag them around until I find the right values. In either case, now we've gotten the $f_1(x)$ from above, and I can use a similar approach to get $f_2(x)$ (again, Desmos is very helpful for this sort of thing).