3 ms·
i can't think of use of 'if' in a math function; however, if is implicitly used in input, say 0<x<1, f(x)=x, 1<x<3, f(x)=x^2 i see a lot of loop though, summat
by dingleberry 10y ago
i can't think of use of 'if' in a math function; however, if is implicitly used in input, say 0<x<1, f(x)=x, 1<x<3, f(x)=x^2
i see a lot of loop though, summation is so a double integral is loop within loop. i can't think a code analogue with derivative
fta, i take that if in function body makes an ugly code.
- gmfawcett 10y agoLots of math functions are defined with 'if' -- the absolute value, the Heaviside step function, etc.
- samastur 10y agoThat's because you are thinking of continuous functions. You have actually gave an example of a non-continuous one, it's just that you think of it as two functions connected with input conditional. Other replier already gave you some common example, but let me add another one: signum(x), which returns if number is negative, positive or zero.