I am working on the front end of an engineering software, where I have an evaluator to return the value of a function at a point in a given domain, lets call it eval(f(x)) where f(x) is itself single parameter mathematical function, or a combination of such functions, and x is any real number.

I need to validate f(x) only over a continuous subset of the domain, and if the range of f(x) in the given domain is out of bounds, I am supposed to return an error.

I also have a given domain this function is to work over, and the range this function is supposed to spew results over. eval() itself returns certain error messages, such as 0 given inside a log function, (My backend can handle this at the domain's end point, so I need my frontend to not return an error when this case hits)

I basically want to know what individual values of the continuous domain I should evaluate my values at, and how do I evaluate my function in an exclusive range(so I can exclude the endpoints of my domain), what step size should I use to reasonably divide my given domain into values?

Keep in mind, I have no other mathematical operators apart from eval() I can use on my function, and I don't want to make my own for the sake of computer power, unless absolutely needed.

Extra info about the function: The f(x) is a standard or a combination of standard functions, it is never a piece-wise defined function. Also, I only care about the rules I have of my own about the function: (e.g. is log(9999)>2222) rather than if log(0) is valid or not). I can also make do with a check for the range being a continuous range, and not having infinities or any close values in it.

I also don't expect my users to enter functions which are indeterminate, I just want to check the validity of the range of the entered functions(Against my own rules) rather than the correctness of the function itself, in case the function is invalid, I actually want to ignore that since eval() already gives errors for those conditions(Apart from f(x) domain endpoints, which I need to ignore specifically)

I don't really expect f'(x) to have a very high value either(unless its going towards infinity(e.g. -log(x-1) at 1;

Bonus question:

In the future, my f(x) also might become f(x,y), with a similar restrictions on the domain of y, any advice on that?


I don't think you have given sufficient information. (Possibly you have not received sufficient information either.)

Given some knowledge about the bounds of $f'(x),$ you could use a finite number of observations of $f(x)$ to conclude that $f(x)$ was within certain bounds as long as $x$ is within certain bounds, but if $f(x)$ is just some arbitrary function, it could be zero everywhere except when $1.500001 < x < 1.500002$ and we could have $f(1.5000015) = 10^{100}.$ That's an extreme example, but it does illustrate that you need to know something more than simply "I have a function" before you can decide on a suitable step size.

You can estimate $f'(x)$ by evaluating $f(x)$ at slightly different values of $x,$ but as the previous example illustrated, there's no guarantee that any particular set of values you used when estimating $f'(x)$ will tell you how large $f'(x)$ can actually get.

In reality, you probably do have some kind of information like this about $f(x),$ even if it's very fuzzy information (such as, "The engineers wouldn't give me a function with such a large derivative as the one in the example").

TL;DR: You can't just treat your function as a black box. You need some kind of specific information about it, even if it's just that its derivative does not take on any absurdly large values in your domain.

  • $\begingroup$ Please look at my changes; thank you very much for the help! $\endgroup$ – BikerDude Apr 20 '17 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.