Make this function continuous/numerically stable.

In summary, The conversation discusses a function that does not work near A=0 and the possibility of changing it to something that a computer can evaluate for any value of A. The function is shown to approach y=x when A->0 and there is a discussion about multiplying the numerator and denominator by something. It is suggested to evaluate the function as a power series instead of using the built-in exp() function when A is close to 0. There is also a mention of finding the limit of the function as A->B and using it as a replacement for the original function. Finally, there is agreement that AlephZero's expression is a good solution for small values of A.
  • #1
Unrest
360
1
Hello. I have a function which doesn't work near A=0. I want to change it to something that a computer can evaluate for any value of A.

y = [exp(Ax) - 1] / [exp(A)-1]

As you can see below, it approaches y=x when A->0.

I was wondering about multiplying the numerator and denominator by something.

[PLAIN]http://dl.dropbox.com/u/21857463/FunctionPlot.png
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
When A is close to 0, you could evaluate it as a power series instead of using the built-in exp() function.

y = x(1 + Ax/2! + (Ax)^2/3! + ...)/(1 + A/2! + A^2/3! + ...)
 
  • #3
AlephZero said:
y = x(1 + Ax/2! + (Ax)^2/3! + ...)/(1 + A/2! + A^2/3! + ...)

I think that won't work any better because the denominator still approaches 0 as A approaches 0. (you omitted the -1).

I think if I can find the limit of this as A->B, I can replace the function with the limit function instead. But I don't know any way to find limits except factorizing or dividing by powers of x, neither of which work here.
 
  • #4
(you omitted the -1)

No he didn't. Look at it again, carefully. He already subtracted the ones (numerator and denominator), factored, and then divided out "A".

AlephZero's expression is correct, and will work for small "A".
 
  • #5
TheoMcCloskey said:
AlephZero's expression is correct, and will work for small "A".

Oh yes, indeed. This should be a good solution.
 

Related to Make this function continuous/numerically stable.

1. How do I make a function continuous?

To make a function continuous, you need to ensure that there are no breaks or jumps in the graph of the function. This can be achieved by using appropriate mathematical techniques, such as finding the limit of the function at a point and making sure it equals the value of the function at that point.

2. Why is it important to make a function continuous?

A continuous function is easier to work with and analyze mathematically. It also ensures that the function is well-defined and behaves predictably, making it more useful in real-world applications. In addition, many mathematical theorems and concepts require functions to be continuous.

3. What does it mean for a function to be numerically stable?

A numerically stable function is one that does not produce large errors when calculated using finite precision arithmetic. This means that small changes in the input will result in small changes in the output, and the function will not produce wildly different results for inputs that are very close together.

4. How can I ensure numerical stability in my function?

To ensure numerical stability, you can use techniques such as avoiding cancellation errors, using appropriate data types and precision, and optimizing the algorithm used to calculate the function. It is also important to test the function with a range of inputs to identify any potential issues with numerical stability.

5. Are there any specific types of functions that are more prone to numerical instability?

Yes, some types of functions, such as those with large or rapidly changing derivatives, are more prone to numerical instability. Functions with singularities or discontinuities can also be problematic. It is important to carefully analyze and test these types of functions to ensure numerical stability.

Similar threads

Replies
5
Views
1K
Replies
2
Views
821
  • Calculus
Replies
17
Views
2K
Replies
11
Views
2K
Replies
3
Views
2K
Replies
3
Views
1K
  • Calculus
Replies
8
Views
2K
Replies
6
Views
3K
Replies
3
Views
1K
Replies
18
Views
2K
Back
Top