Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behaviour of the evaluate function #140

Open
orkolorko opened this issue Jan 4, 2023 · 3 comments
Open

Behaviour of the evaluate function #140

orkolorko opened this issue Jan 4, 2023 · 3 comments

Comments

@orkolorko
Copy link

Dear all,
I have a question on the behavior of the evaluate function, or to be more precise, on the behavior of the iscontained
function.

At the moment it is defined as

iscontained(a, tm::TaylorModelN) = a  domain(tm)-tm.x0

this leads to, in my opinion, unexpected behavior: as an example if tm is a Taylor model centered at 5, with domain [4,6],
then
tm(5)
fails the iscontained assertion, i.e., the evaluation fails on the expansion point.

Minimum failing code:

julia> tm = TaylorModel1(10, 5, Interval(4, 6))
 5 + 1 t + [0, 0]

julia> tm(5)
ERROR: AssertionError: iscontained(a, tm)

If this is a design choice of the package I think this should be documented.

@lbenet
Copy link
Member

lbenet commented Jan 6, 2023

Thanks @orkolorko for bringing this up and open the discussion. I agree that it may be counterintuitive and it requires documentation... as always, lack of time is the reason.

Let me argue why this is designed the way it is. The polynomial part is a truncated Taylor series, which has terms of the form $(x-x_0)^k$, where $x\in D$ is the actual value we are interested, $D$ is the domain, and $x_0\in D$ is the expansion point. The Taylor approximation makes sense if $h = x-x_0$ is "small enough"; $h$ is the quantity actually used in evaluate (defined in TaylorSeries.jl). So, in order to check that $h$ makes sense, we have to check that $x = x_0 + h \in D$, which is what iscontained does.

Does this explanation makes sense?

@orkolorko
Copy link
Author

Dear @lbenet ,
thank you, for the explanation.

I think it makes sense and I think it is a good interpretation of the mathematical idea,
i.e., the fact that TaylorModel1(6, 5, Interval(4,6)) is not a point, but a function with an associated domain
and expansion point.

I think what confused me the most is the tube plot in the documentation and the associated recipe:
Tube plot

tm6 = TaylorModel1(6, interval(x0), a)
ftm6 = f(tm6)
plot(ftm6, label="6th order")

plots a "tube" around the original function, but ftm6(x) is computing the value of

$$ \sum_{i=0}^6 a_i x^i+\Delta $$

In Mioara's thesis Def. 2.1.3, and in the documentation of the package a Taylor model is
defined as a polynomial such that

$$ P(x)-f(x)\in \Delta, \forall x \in [a,b] $$

but what is exposed by the interface is ftm6(x) = P(x+x_0), i.e., ftm6 is translated.

I think both the approaches work equally well but this needs clarifying; if you want I can try to write down a small note on this in the documentation and submit it as a pull request.

@lbenet
Copy link
Member

lbenet commented Jan 6, 2023

Yes, please, help us with the documentation or whatever other improvement it is worth adding to the package!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants