File:Piecewise linear function gnuplot.svg

Summary

Description
English: Plot of the piecewise linear function
Date
Source Own work
Author Jochen Burghardt
Other versions File:PiecewiseLinear.png * File:Piecewise linear function.svg * File:Piecewise linear function gnuplot.svg
Gnuplot source code
set xrange [-5:5]
set yrange [-3:3]
set xtics 1
set ytics 1

f(x) =  (            x <= -3    ? -3 - x        \   
        : -3 <= x && x <=  0    ? x + 3         \   
        :  0 <= x && x <=  3    ? 3 - 2*x       \   
        :                         0.5*x - 4.5   \   
        )

set grid

# y axis
set arrow from 0,-3 to 0,3 nohead lt 8

#x axis
  plot           0    with lines lt 8 lw 1 title ""

# plot the function
#replot           f(x) with lines lt 6 lw 3 title ""

# plot the function in pieces to avoid artifacts at interval boundaries
replot [x=-5:-3] f(x) with lines lt 6 lw 3 title ""
replot [x=-3: 0] f(x) with lines lt 6 lw 3 title ""
replot [x= 0: 3] f(x) with lines lt 6 lw 3 title ""
replot [x= 3: 5] f(x) with lines lt 6 lw 3 title ""
pause -1

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Category:CC-BY-SA-4.0#Piecewise%20linear%20function%20gnuplot.svg
Category:Self-published work Category:Piecewise linear functions Category:Images with Gnuplot source code Category:Files by User:Jochen Burghardt
Category:CC-BY-SA-4.0 Category:Files by User:Jochen Burghardt Category:Images with Gnuplot source code Category:Piecewise linear functions Category:Self-published work