Switch Function: Interval Restriction for Functions

  • Context: Undergrad 
  • Thread starter Thread starter pondzo
  • Start date Start date
  • Tags Tags
    Function Switch
pondzo
Messages
168
Reaction score
0
Hi i was wondering if there is such a function/operator/something that restricts a function within an interval. I know that doesn't make a lot of sense but ill show you what i mean;

Say i want to define f(x) = x for 0<x<a and f(x) = sqrt(x) for x>a. Now i know this is easily represented as a piecewise function, but i do not want this to be a pieceswise function.

So instead I define g(x) = &{x} + %{sqrt(x)} where the &{} is some type of operator that is 1 when 0<x<a and 0 elsewhere and the %{} is a similar operator that is 1 when x>a and 0 elsewhere. What this 'operator' (probably not the right term) is effectively doing is switching the function for a given interval... i apologise for the abstractness.
 
Mathematics news on Phys.org
HEY! I know about this! I hope you're still watching this thread. I frequently need "mathematical cheat codes" which implement weird functions in terms of what you normally put into a calculator.

Consulting my recipe book, there's a few ways to do this. For clarity, I'll name the function which is 1 until x, then turns to 0, f(x); and the function which is 0 until x, then turns to 1, g(x).

You can derive these both from the sgn(x) function, which you can implement with f(x) / |f(x)|. Using the rules for translating and stretching functions, you end up with:

f(x) = (x-A)/(2abs(x-A)+(1/2)

g(x) = (A-x)/(2abs(A-x)+(1/2)

If you aren't allowed to use the absolute value function, you can implement that with sqrt(f(x)^2). Due to how only the principal value is taken.

Note, the above functions are indeterminate at x = 0. You can use the Kronecker delta function to get a function which is 0 at all points except A, where it is some number you specify. This is 0^abs(x), assuming your use-case assumes indeterminate values to be zero, and not, say, an error.

If indeterminate values are a problem, you can use the particularly evil identity sgn(x) = tanh(1000000x).

So, the most rigorous function I can give is f(x) = tanh(1000000(x-A))/2+1/2 and g(x) = tanh(1000000(A-x))/2+1/2

Your final function R(x) will just be xf(x)+sqrt(x)g(x).
 
pondzo said:
but i do not want this to be a pieceswise function.
Why?
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K