# How to convert an expression to a function with lossless precision?

2 views (last 30 days)

Show older comments

Chenguang Yan
on 27 Sep 2020

Commented: Walter Roberson
on 28 Sep 2020

##### 4 Comments

Ameer Hamza
on 27 Sep 2020

### Accepted Answer

Walter Roberson
on 27 Sep 2020

Is there a lossless conversion method?

NO, there is no lossless conversion method.

A few years ago I encountered a paper that showed an explicit function that had the property that for any given finite numeric precision, there were inputs to the function for which the error due to rounding could be made arbitrarily large compared to the actual value of the function at the location. The paper showed that no matter how many guard digits you used for rounding purposes, the rounding error could be arbitrarily large relative to the correct value.

I do not recall now what the demonstration function used was, but it was not a complicated function. Something along the lines of x+(1/x) but a bit more developed.

I have myself encountered nonlinear equalities that when I evaluated to a million digits, I still could not decide if the equality was true. The symbolic manipulations said that the equalities held, but because the expressions were so different I was trying to verify whether the symbolic package had made a conversion mistake... and I couldn't decide based on numeric techniques. The rounding issues even at a million digits were substantial.

So, NO. There cannot be any finite numeric technique that can give enough precision to solve arbitrary nonlinear least squares.

##### 6 Comments

Walter Roberson
on 28 Sep 2020

### More Answers (2)

madhan ravi
on 27 Sep 2020

vpa(f_func(sym(sol1), sym(sol2)))

##### 3 Comments

madhan ravi
on 27 Sep 2020

When you use matlabFunction() , it converts it into double precision, why not use subs()?

### See Also

### Categories

### Products

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!