File:Piecewise linear function gnuplot.svg

Uploaded by Jochen Burghardt
Upload date 2020-09-30T12:22:08Z
MIME type image/svg+xml
Dimensions 802 × 603 px
File size 71.4 KB

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.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

30 September 2020

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