Hello Rachid
My attempts to address this didn't work as I hoped. I'll leave the artifacts you mentioned for Alfred to comment on.
I think the bigger issue is the gaps you've got (and the places where it doesn't even reach 1 and -1 in the section x > 8.5).
Here's one approach (which can be optimised, for sure), for a curve like this:
I plotted an ordinary functiongraph for x < 2, then for x > 2 I've plotted curves where the interval between points gets less as we increase the x-value.
This (mostly) produces a solid block as expected in the part of the curve where x > 4.5. I say "mostly" because small tweaks in the width or height of the canvas can still give us small gaps.
I did this hoping the artifacts you're seeing would be reduced (hoping that JSXGraph's plotting algorithm would be happier with more 'accurate' points to plot, but it wasn't the case.)
I also tried fiddling with lineCap (where I hoped 'round" would reduce those sharp peaks, but once again, no. It seems it only affects the beginning and end of a curve, not the joins within.
I also tried messing with
numberPointsHigh, but this didn't seem to have any effect, either.
Anyway, over to Alfred.
Regards
Murray