﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
6411	Improve zero crossing functions by using continuous expressions	Francesco Casella	Andreas Heuermann	"Zero crossing functions are currently implemented with discontinuous outputs. Conceptually speaking, {{{x > 2}}} is mapped into
{{{
zcf = noEvent(if x > 2 then 1 else -1);
}}}
Solvers try to find the event time using iterative algorithms. IDA uses a modified secant method. With this implementation, it reduces to the bisection method, which halves the error at each iteration, or equivalently gains 3 decimal digits every 10 iterations.

If we had a continuous zcf like
{{{
zcf = x - 2
}}}
the secant algorithm would converge in a single step.

The question of course is how to handle more complicated conditions such as 
{{{
if x > 2 and y < 3 and isActive then ...
}}}
where {{{x}}} and {{{y}}} are Real variables and {{{isActive}}} is a boolean variables. A trivial discontinuous implementation is
{{{
zcf = noEvent(if x > 2 and y < 3 and isActive) then 1 else -1)
}}}
but it won't be very efficient. A better one could be to consider
{{{
zcf1 = x - 2;
zcf2 = y - 3;
}}}
separately, or possibly to consider their product
{{{
zcf = (x - 2)*(y - 3)
}}}
which will change the sign whenever one of the two conditions switches from false to true or vice-versa.
"	defect	new	normal	2.0.0	Run-time	1.16.1			Karim Adbdelhak Philip Hannebohm
