thank you for the discussion, that was very enlightening.
I was a little hasty since I only looked at the "if()" not working at all.
but "plot(funktion, r1..r2)" does what I want.
1/x, where is a length in m, will of cause not fit into a plot where another part of the result is a length. So I have to "fill up" my units and then I get a proper result and a proper evaluation of my if-statment.
(My real code is quite entangled, I did not want to show the whole mess...)
There are many nested functions, this method still works fine.
funktion := x -> if 2*Unit('m') < x then Unit('m'^2)/x; else 2*Unit('m'); end if;
r1 := 1.0*Unit('m');
r2 := 6*Unit('m');
plot(funktion, r1 .. r2);