[Mathematica] Accuracy of a function

Click For Summary
SUMMARY

The discussion centers on the accuracy discrepancies in Mathematica when evaluating a function with different numerical representations. Specifically, the user notes that f[0.01] yields incorrect results due to machine precision limitations, while f[1*^-2] maintains infinite precision, resulting in accurate outcomes. The solution identified is the use of SetAccuracy[] to enforce desired precision on function arguments. Additionally, for numeric functions, AccuracyGoal and WorkingPrecision can be utilized to manage precision effectively.

PREREQUISITES
  • Understanding of Mathematica syntax and functions
  • Familiarity with numerical precision concepts in computational mathematics
  • Knowledge of SetAccuracy[] function in Mathematica
  • Awareness of AccuracyGoal and WorkingPrecision settings
NEXT STEPS
  • Explore the SetAccuracy[] function in detail within Mathematica
  • Research the implications of AccuracyGoal and WorkingPrecision in numeric computations
  • Learn about the N[] function for controlling decimal precision in Mathematica
  • Investigate best practices for managing numerical precision in complex functions
USEFUL FOR

Mathematica users, computational mathematicians, and anyone dealing with precision issues in numerical evaluations.

guerom00
Messages
90
Reaction score
0
Hello all :smile:

I have a very complicated function, let's call if f.

My problem : f[0.01] does not give the same result as f[1*^-2] because of accuracies. In the first case, the argument 0.01 has machine precision which is not sufficient in my case and the result is wrong.
In the second case, the argument 1*^-2 has infinite precision. This infinite precision is being carried out throughout the function and the final result is correct.

So, you see my point : how to force a certain accuracy on the argument of a function ?

Thanks in advance :smile:
 
Physics news on Phys.org
I answer to myself : I found SetAccuracy[] which I can apply to the argument of my function. Is that the correct way to do ?
 
Well if you just make the input of your function have infinite precision that will carry through unless you use numeric functions. In those you can use AccuracyGoal and WorkingPrecision, otherwise if you just need to keep a certain number of decimals you can use N[exp,decimal number] which may help.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
5
Views
4K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K