官术网_书友最值得收藏!

Plotting a function

gnuplot can be used as a tool to interactively explore the structure of mathematical functions, as well as to create illustrations for publication or education. It has built-in knowledge of both elementary functions, such as sine and cosine, and some special functions, such as Bessel functions and elliptic integrals. The following figure shows the plotting of the besj0(x) function:

Plotting a function

Getting ready

Start up an interactive gnuplot session and make sure that your graphic terminal of choice is selected, and working, using the set term command (for example, at the console you simply type gnuplot, and, to change the default terminal to X Windows, type set term x11).

How to do it…

Type plot besj0(x) at the console. The plot in the figure should pop up immediately.

There's more…

Gnuplot understands a big handful of mathematical functions, listed in Section 13.1 of the official manual (the official gnuplot documentation can be found at gnuplot's home, http://gnuplot.info/). It also understands all the basic mathematical operators, with a syntax similar to Fortran or C, so you can combine functions into expressions, as shown in the following command:

plot [-5:5] (sin(1/x) - cos(x))*erfc(x)

In the previous command, we have also shown how to use the [a:b] notation to limit the plot to a specified range on the x-axis.

主站蜘蛛池模板: 山东省| 隆林| 德惠市| 丁青县| 平昌县| 民县| 桑植县| 兴义市| 高州市| 嘉祥县| 温宿县| 岗巴县| 湘潭县| 闽侯县| 启东市| 德昌县| 佳木斯市| 维西| 祥云县| 十堰市| 阿克陶县| 峨眉山市| 靖江市| 会宁县| 新田县| 罗江县| 顺平县| 东源县| 江城| 赣榆县| 兰西县| 长宁区| 龙岩市| 庐江县| 东莞市| 绥江县| 普洱| 延庆县| 全南县| 常宁市| 富蕴县|