Skip to content

Repository files navigation

Chplot - Arbitrary functions plotting and computations

Chplot is a Python >= 3.9 module to plot any arbitrary mathematical expressions as well as data series from files, and compute its derivatives and integrals, where it equals zero, linear and non-linear regressions, and much more !

Installation

chplot is available on Pypi, and You can install it with the command:

python -m pip install chplot

You can also install it by cloning this repo and installing it directly:

git clone https://github.com/charon25/Chplot.git
cd Chplot
python -m pip install .

To check it is properly installed, just run and check it outputs the current version:

python -m chplot --version

This module requires the following third-party modules:

  • matplotlib >= 3.6.1
  • mpmath >= 1.2.1
  • numpy >= 1.23.4
  • scipy >= 1.9.3
  • shunting_yard >= 1.0.12
  • tqdm >= 4.64.1

Usage

In the rest of this README, the term "expression" will refer to any mathematical expression, possibly with one variable (by default x but can be changed).

From a CLI

This module is primarly intended to be used in the command-line. To do this, use the following command:

python -m chplot [expression1, [expression2, ...]] [additional-parameters...]

Where all the additional parameters are documented in the CLI options section. Note that there can be no expression, as data can come from other sources.

A lot of examples are given in the Examples section.

Important note

You need to surround any expression with double quotes (") if it contains a space (). Furthermore, due to the working of the argparse Python module and the majority of shells, you may have to surround any expression with double quotes (") if it contains a caret (^). Finally, if it starts with a dash (-) you may also need to add a space () or a 0 before it. For instance, you need to write " -x" or "0-x" to get the function f(x) = -x and "x^2" (instead of just x^2) to get the square function.

From Python code

The chplot module can also be used from another program. Code snippets:

# Use this to use the built-in PlotParameters classimportchplotparameters=chplot.PlotParameters()
chplot.plot(parameters)
# Use this to use another object and set default valuesimportchplotparameters= ... # any objectchplot.set_default_values(parameters) # add any missing field with its default valuechplot.plot(parameters)

All the PlotParameters arguments are summarized in the CLI options section.

CLI options

No option is mandatory.

CLI options
PlotParameters class equivalentExpected argumentsEffect
$\emptyset$expressions: list[str]Any number of expressions (including none of them) or filepathsThe expressions of the mathematical functions to plot and do computations on. If using the CLI, filepaths can also be provided, and There can by none of them.
-v
--variable
variable: strOne stringThe variable going of the horizontal axis. Can be more than one character. Note that the variable will override any constant of function with the same name. Defaults to x.
--no-sndisable_scientific_notation: bool$\emptyset$Disable the automatic conversion of scientific notation in every expression (e.g. 1.24e-1 to 1.24*10^(-1)). Defaults to False.
-n
--n-points
n_points: intOne positive integer (excluding zero)The number of points on the horizontal axis for the plotting of the expressions. Defaults to 10001.
-i
--integers
is_integer: bool$\emptyset$Forces the points where the expressions are computed to be integers between the specified limits. The number of points will not exceed what is specified with the -n parameter. Defaults to False.
-x
--x-lim
x_lim: tuple[float|str|None, float|str|None]Two expressionsThe horizontal axis bounds (inclusive) where the expression are computed. First argument is the min, second is the max. Any expression (such as 2pi or 1+exp(2)) is valid. It is also the graph default horizontal axis, but they can be automatically adjusted to accomodate the plotted data. Defaults to 0 1.
-xlog
--xlog
is_x_log: bool$\emptyset$Forces a logarithmic scale on the horizontal axis. If some horizontal axis bounds are negative, will modify them. Defaults to False.
-y
--y-lim
y_lim: tuple[float|str|None, float|str|None]Two expressionsThe vertical axis bounds (inclusive) of the graph. First argument is the min, second is the max. Any expression (such as 2pi or 1+exp(2)) is valid. If not specified, will use matplotlib default ones to accomodate all data. Will restrict the graph to them is specified.
-z
--y-zero
must_contain_zero: bool$\emptyset$Forces the vertical axis to contain zero. Defaults to False.
-ylog
--ylog
is_y_log: bool$\emptyset$Forces a logarithmic scale on the vertical axis. If some vertical axis bounds are negative, will modify them. Defaults to False.
-xl
--x-label
x_label: strOne stringLabel of the horizontal axis. Defaults to nothing.
-yl
--y-label
y_label: strOne stringLabel of the vertical axis. Defaults to nothing.
-t
--title
title: strOne stringTitle of the graph. Defaults to nothing.
-rl
--remove-legend
remove_legend: bool$\emptyset$Removes the graph legend. Defaults to False.
--no-plotno_plot: bool$\emptyset$Does not show the plot. However, does not prevent saving the figure. Defaults to False.
-dis
--discontinuous
markersize: int|NoneOne optional positive integer (excluding zero)Transforms the style of the graph from a continuous line to discrete points with the specified radius. If present without a value, will defaults to a radius of 1. If the --integer parameter is also present, will still affect the points radius.
--squaresquare_graph: bool$\emptyset$Forces the graph to be a square (aspect ratio of 1). Defaults to False.
-lw
--line-width
line_width: floatOne positive float (excluding zero)Width of the plotted functions. Will not affect regressions. Defaults to 1.5 (matplotlib defaut).
-c
--constants
constants: list[str]One string or more, either a filepath or of the forme <name>=<expression>Adds constants which may be used by any other expressions (including axis bounds). They must either be of the form <name>=<expression> (eg a=4sin(pi/4)) or be filepath containing lines respecting this format. Note that filepaths are only accepted in the CLI. May override already existing constants and functions. If a constant refers to another one, it should be defined after. Defaults to nothing.
-f
--files
data_files: list[str]One or more filepathsAdds data contained in CSV files as new functions to the graph. See the CSV files format section for more details. Defaults to nothing.
-s
--save-graph
save_figure_path: strOne filepathSaves the graph at the specified path. If not included, will not save the figure (default behavior).
-d
--save-data
save_data_path: strOne filepathSaves the graph data (x and y values) at the specified path in CSV format. If not included, will not save the data (default behavior).
-p
--python-files
python_files: list[str]One or more filepathsAdds functions contained in Python files. See the Additional Python function format section for more details. Defaults to nothing.
--zeroszeros_file: str|NoneOne optional filepathComputes where the expressions equal zero. If not included, will not compute it (default behavior), else if included without argument, prints the results to the console, else writes it to the given file.
-int
--integral
integral_file: str|NoneOne optional filepathComputes the integral of all functions on the entire interval where it is plotted. Note that it does not add the antideritive of the functions to the graph, but only computes the area under them on their definition interval. If not included, will not compute it (default behavior), else if included without argument, prints the results to the console, else writes it to the given file.
-deriv
--derivative
derivation_orders: list[int]At least one positive integer (excluding zero)Computes and adds to the graph the derivative of the specified orders of every other function. Note that the higher the order, the more inaccuracy and unstability it has. Furthermore, the derivative computation will shave off a few points on each side, so the derivatives are defined on a smaller interval.
-reg
--regression
regression_expression: strOne expressionComputes the coefficients of the given regression to get the best fit to every other function. The regression parameters should have the form _rX where X is any string made of digits, letters and underscores and starting with a letter (eg _ra0). The regressions will also be added in the final graph. When using the CLI, the expression can also be one of a few default keywords (listed in Regression default keywords).

Options synergies

Every option that computes something based on the functions will act on every function defined before it applies. The order of application is the following (each item applies to all the previous ones):

  • Base expressions & file data
  • Regressions
  • Derivations
  • Integrals & zeros

For instance, this means every regression will also be derivated, and every derivative will be integrated.

CSV files format

The --file option will accept any CSV file respecting those rules:

  • the column delimiter is eitehr a comma (,), a semicolon (;), a space () or a tabulation (\t) ;
  • the decimal separator is either a dot (.) or a comma (,) if the column delimiter is something else (for countries and language using them, such as French or German) ;
  • text entry containing the column delimiter must be surrounded by double quotes (") ;
  • to have double quotes (") in a text entry, just double them ("").

The first column will be considered the horizontal axis data for the entire file. Each subsequent column will be a new function. They might all be of different lengths, and some value may be missing. Any missing value in the first column will ignore the whole line.

The first non numerical line will be used as label for the functions.

Examples

The file

x,"First y","Second ""y""",ThirdY,EmptyColumn0,0,,0,1,10,100,,2,20,,2000,3,30,300,3000,4,40,400,,

Will result in the following functions (represented as (x,y) couples):

  • First y: (0, 0), (1, 10), (2, 20), (3, 30), (4, 40)
  • Second "y": (1, 100), (3, 300), (4, 400)
  • ThirdY: (0, 0), (2, 2000), (3, 3000)

Note that the last column does not have any values, so it won't be registered at all.

The file

x;y1;y20,0;1,0;2,10,3;1,2;2,50,6;1,55;2,1231;1,825;2,99

Will result in the following functions:

  • y1: (0, 1), (0.3, 1.2), (0.6, 1.55), (1, 1.825)
  • y2: (0, 2.1), (0.3, 2.5), (0.6, 2.123), (1, 2.99)

Regression default keywords

When using Chplot from the command line and using the --regression command, a keyword can be specified instead of an expression to get usual regression expression. Those keywords are listed below :

Keyword
Mathematical function
Equivalent expression
const
constant
$f(x) = m$_rm
lin
linear
$f(x) = ax + b$_ra * x + _rb
pN
polyN
polynomialN
where $N \in \mathbb{N} $
$$f(x) = \sum_{i=0}^N a_i x^i$$_ra0
_ra1 * x + _ra0
_ra2 * x^2 + _ra1 * x + _r0
...
power$f(x) = k x^\alpha$_rk * x^_ralpha
powery$f(x) = k x^\alpha + y_0$_rk * x^_ralpha + r_y0
log$f(x) = a \ln(x) + b$_ra * ln(x) + _rb
exp$f(x) = a \mathrm{e}^{bx}$_ra * exp(x * _rb)
expy$f(x) = a \mathrm{e}^{bx} + y_0$_ra * exp(x * _rb) + _ry0

Note that poly0 is equivalent to constant and poly1 is equivalent to linear.

Additional Python function format

Chplot expression can accept functions usable in any expression directly from other Python files. Those file must respect those rules:

  • they must be in the same directory as the console when using the CLI (and in the same directory as the python execution when using the code version [NOT TESTED]) ;
  • all functions to add must be decorated with the @plottable decorator (importable with from chplot import plottable). The decorator must indicate how many arguments is expected by the function, either directly or with the arg_count keyword (i.e. @plottable(1) or @plottable(arg_count=2)) ;
  • all functions must only accept int or float and must only return one value accepted by the float() built-in function of Python, such as, but not limited to, int, float or bool (if not, will be considered as the same as a raised Exception) ;
  • to indicate an error in the computation (such as a division by zero or the square root of a negative number), the function can either raise an exception or return math.nan (or float('nan')). Note that an exception will completely stop the computation at that point while nan will be used in the rest of the expression, which may change the result slightly.

Everything other than those rules is allowed, such as importing other modules. The name of the Python function will be the same as the name used in the expression.

Examples

The Python file functions.py

fromchplotimportplottableimportmath@plottable(1)definc(x: float) ->float:
returnx+1@plottable(arg_count=2)definvradius(x: float, y: float) ->float:
ifx==y==0:
raiseZeroDivisionErrorreturn1/math.sqrt(x*x+y*y)
defdec(x: float) ->float:
returnx-1@plottabledefdouble(x: float) ->float:
returnx*2

Will define 2 new functions usable in expression: inc and invradius. dec does not have the decorator and will be ignored, and double does not indicate how many parameters it accepts, and therefore will also be ignored (but a warning will be logged).

This means, the following command is valid:

python -m chplot "inc(invradius(x, 5))" -x 1 inc(2) -p functions.py

Available functions

Chplot is bundled by default with more than 60 mathematical and physical constants and over 200 mathematical functions from the default math module, scipy.special, mpmath as well as custom made ones. They are all described in the following sections. The documentation of functions from math or the third-party modules can be found in their respective wikis: math, scipy.special, mpmath.

There are also the 5 base operations : +, -, *, /, ^.

Constants

nan and _ are valid constants that both evaluates to math.nan. They can be used to remove some points from the graph (for instance with the if or in functions, see below). inf is also a valid constant evaluating to math.inf.

Mathematical constants

chplot nameNameUsual symbolExact valuechplot value
piPi$\pi$$\pi$$3.141\ 592\ 653\ 589\ 793$
tauTau$\tau$$2\pi$$6.283\ 185\ 307\ 179\ 586$
eEuler's number$e$$$\exp(1) = \sum_{n=0}^{+\infty} \frac{1}{n!}$$$2.718\ 281\ 828\ 459\ 045$
ga
em
Euler-Mascheroni's constant$\gamma$$$\lim_{n\to\infty} \left( \sum_{k=1}^n \left( \frac{1}{k}\right) - \log n \right)$$$0.577\ 215\ 664\ 901\ 532 9$
phiGolden ratio$\phi$$\frac{1}{2} (1 + \sqrt{5})$$1.618\ 033\ 988\ 749\ 895$
sqrt2Square root of 2$\sqrt{2}$$\sqrt{2}$$1.414\ 213\ 562\ 373\ 095\ 1$
aperyApery's constant$$\zeta(3) = \sum_{n=1}^{+\infty} \frac{1}{n^3} $$$1.202\ 056\ 903\ 159\ 594$
brunBrun's constant$B_2$Sum of the reciprocal of the twin primes$1.902\ 160\ 583\ 104$
catalanCatalan's constant$G$$$\sum_{n=0}^{+\infty} \frac{(-1)^n}{(2n + 1)^2} $$$0.915\ 965\ 594\ 177\ 219$
feigenbaumdFirst Feigenbaum's constant$\delta$$4.669\ 201\ 609\ 102\ 990\ 67$
feigenbaumaSecond Feigenbaum's constant$\alpha$$2.502\ 907\ 875\ 095\ 892\ 82$
glaisherGlaisher-Khinkelin's constant$A$$$\lim_{n\to\infty} \frac{\Pi_{k=1}^{n} k^k}{n^{\frac{n^2}{2} + \frac{n}{2} + \frac{1}{12}}\cdot\mathrm{e}^{-\frac{n^2}{4}}}$$$1.282\ 427\ 129\ 100\ 622\ 6$
khinchinKhinchin's constant$K_0$$$\prod_{r=1}^{+\infty} \left(1 + \frac{1}{r(r+2)} \right)^{\log_2 r}$$$2.685\ 452\ 001\ 065\ 306\ 2$
mertensMeissel-Mertens's constant$M$$$\gamma + \sum_{p\text{ prime}}\left(\ln\left(1 - \frac{1}{p}\right) + \frac{1}{p} \right)$$$0.261\ 497\ 212\ 847\ 642\ 77$

Physical constants

The constants, their values and their units are taken from https://en.wikipedia.org/wiki/List_of_physical_constants.

chplot nameQuantitySymbolchplot value (in SI units)Units
a0Bohr's radius$a_0$$5.291\ 772\ 109\ 03\times10^{-11}$$\text{m}$
alphaFine-structure constant$\alpha$$7.297\ 352\ 569\ 3\times10^{-3}$---
bWien's wavelength displacement law constant$b$$2.897\ 771\ 955\times10^{-3}$$\text{m}\cdot\text{K}$
bpWien's entropy displacement law constant$b_{\text{entropy}}$$3.002\ 916\ 077\times10^{-3}$$\text{m}\cdot\text{K}$
bpWien's frequency displacement law constant$b'$$5.878\ 925\ 757\times10^{10}$$\text{Hz}\cdot\text{K}^{-1}$
cSpeed of light in vacuum$c$$2.997\ 924\ 58\times10^8$$\text{m}\cdot\text{s}^{-1}$
c1First radiation constant$c_1$$3.741\ 771\ 852\times10^{-16}$$\text{W}\cdot\text{m}^2$
c1LSecond radiation constant$c_{1L}$$1.191\ 042\ 972\ 397\ 188\times10^{-16}$$\text{W}\cdot\text{m}^2\cdot\text{sr}^{-1}$
c2Second radiation constant$c_2$$1.438\ 776\ 877\times10^{-2}$$\text{m}\cdot\text{K}$
dnuCsHyperfine transistion frequency of Cesium-133$\Delta\nu_{\text{Cs}}$$9.192\ 631\ 770\times10^{9}$$\text{Hz}$
ecElementary charge$e$$1.602\ 176\ 634\times10^{-19}$$\text{C}$
EhHartree's energy$E_h$$4.359\ 744\ 722\ 207\ 1\times10^{-18}$$\text{J}$
epsilon0
eps0
Vacuum electric permittivity$\varepsilon_0$$8.854\ 187\ 812\ 8\times10^{-12}$$\text{F}\cdot\text{m}^{-1}$
eVElectronvolt value in Joule$1.602\ 176\ 634\times10^{-19}$$\text{J}$
FFaraday's constant$F$$9.648\ 533\ 212\ 331\ 002\times10^4$$\text{C}\cdot\text{mol}^{-1}$
GGravitational constant$G$$6.674\ 3\times10^{-11}$$\text{m}^3\cdot\text{kg}^{-1}\cdot\text{s}^{-2}$
gGravity of Earth$g$$9.806\ 65$$\text{m}\cdot\text{s}^{-2}$
G0Conductance quantum$G_0$$7.748\ 091\ 729\times10^{-5}$$\text{S}$
geElectron g-factor$g_e$$-2.002\ 319\ 304\ 362\ 56$---
GF0Fermi coupling constant
Reduced Fermi constant
$$G^0_F$$$4.543\ 795\ 7\times10^{14}$$\text{J}^{-2}$
gmuMuon g-factor$g_\mu$$-2.002\ 331\ 841\ 8$---
gPProton g-factor$g_P$$5.585\ 694\ 689\ 3$---
hPlanck's constant$h$$6.626\ 070\ 15\times10^{-34}$$\text{J}\cdot\text{Hz}^{-1}$
hbReduced Planck's constant$\hbar$$1.054\ 571\ 817\times10^{-34}$$\text{J}\cdot\text{s}$
kBBoltzmann's constant$k$, $k_B$$1.380\ 649\times10^{-23}$$\text{J}\cdot\text{K}^{-1}$
keCoulomb's constant$k_e$$8.987\ 551\ 792\ 3\times10^9$$\text{N}\cdot\text{m}^2\cdot\text{C}^{-2}$
KJJosephson's constant$K_J$$4.835\ 978\ 484\times10^{14}$$\text{Hz}\cdot\text{V}^{-1}$
m12CAtomic mass of carbon-12$m(^{12}\text{C})$$1.992\ 646\ 879\ 92\times10^{26}$$\text{kg}$
M12CMolar mass of carbon-12$M(^{12}\text{C})$$1.199\ 999\ 999\ 58\times10^{-2}$$\text{kg}\cdot\text{mol}^{-1}$
meElectron mass$m_e$$9.109\ 383\ 701\ 5\times10^{-31}$$\text{kg}$
mmuMuon mass$m_\mu$$1.883\ 531\ 627\times10^{-28}$$\text{kg}$
mnNeutron mass$m_n$$1.674\ 927\ 498\ 04\times10^{-27}$$\text{kg}$
mpProton mass$m_p$$1.672\ 621\ 923\ 69\times10^{-27}$$\text{kg}$
mtTop quark mass$m_t$$3.078\ 4\times10^{-25}$$\text{kg}$
mtauTau mass$m_\tau$$3.167\ 54\times10^{-27}$$\text{kg}$
muAtomic mass constant$m_u$$1.660\ 539\ 066\ 6\times10^{-27}$$\text{kg}$
MuMolar mass constant$M_u$$9.999\ 999\ 996\ 5\times10^{-4}$$\text{kg}\cdot\text{mol}^{-1}$
mu0Vacuum magnetic parmeability$\mu_0$$1.256\ 637\ 602\ 12\times10^{-6}$$\text{N}\cdot\text{A}^{-2}$
muBBohr's magneton$\mu_B$$9.274\ 010\ 078\ 3\times10^{-24}$$\text{J}\cdot\text{T}^{-1}$
muNNuclear magneton$\mu_N$$5.050\ 783\ 746\ 1\times10^{-27}$$\text{J}\cdot\text{T}^{-1}$
NAAvogadro constant$N_A$$6.022\ 140\ 76\times10^{23}$$\text{mol}^{-1}$
RMolar gas constant$R$$8.314\ 462\ 618\ 153\ 24$$\text{J}\cdot\text{mol}^{-1}\cdot\text{K}^{-1}$
reClassical electron radius$r_e$$2.817\ 940\ 326\ 2\times10^{-15}$$\text{m}$
RinfRydberg's constant$R_\infty$$1.097\ 373\ 156\ 816\times10^7$$\text{m}^{-1}$
RKVon Klitzing's constant$R_K$$2.581\ 280\ 745\times10^{4}$$\Omega$
RyRydberg's unit of energy$R_y$$2.179\ 872\ 361\ 103\ 5\times10^{-18}$$\text{J}$
sigmaStefan-Boltzmann's constant$\sigma$$5.670\ 374\ 419\times10^{-8}$$\text{W}\cdot\text{m}^{-2}\cdot\text{K}^{-4}$
sigmaeThomson's cross section$\sigma_e$$6.652\ 458\ 732\ 1\times10^{-29}$$\text{m}^2$
VmSiMolar volume of silicon$V_m(\text{Si})$$1.205\ 883\ 199\times10^{-5}$$\text{m}^3\cdot\text{mol}^{-1}$
Z0Characteristic impedance of vacuum$Z_0$$3.767\ 303\ 136 \ 68\times10^2$$\Omega$

Astronomical constants

All the planets data are taken from : https://nssdc.gsfc.nasa.gov.

chplot nameQuantitychplot value (in SI units)Units
MsunSun mass$1.988\ 5\times10^{30}$$\text{kg}$
MmercuryMercury mass$3.301\times10^{23}$$\text{kg}$
MvenusVenus mass$4.867\ 3\times10^{24}$$\text{kg}$
MearthEarth mass$5.972\ 2\times10^{24}$$\text{kg}$
MmoonMoon mass$7.346\times10^{22}$$\text{kg}$
MmarsMars mass$6.416\ 9\times10^{23}$$\text{kg}$
MjupiterJupiter mass$1.898\ 13\times10^{27}$$\text{kg}$
MsaturnSaturn mass$5.683\ 2\times10^{26}$$\text{kg}$
MuranusUranus mass$8.681\ 1\times10^{25}$$\text{kg}$
MneptuneNeptune mass$1.024\ 09\times10^{26}$$\text{kg}$
MplutoPluto mass$1.303\times10^{22}$$\text{kg}$
McharonCharon mass$1.586\times10^{21}$$\text{kg}$
RsunSun volumetric mean radius$6.957\times10^{8}$$\text{m}$
RmercuryMercury volumetric mean radius$2.439\ 7\times10^{6}$$\text{m}$
RvenusVenus volumetric mean radius$6.051\ 8\times10^{6}$$\text{m}$
RearthEarth volumetric mean radius$6.371\times10^{6}$$\text{m}$
RmoonMoon volumetric mean radius$1.737\ 4\times10^{6}$$\text{m}$
RmarsMars volumetric mean radius$3.389\ 5\times10^{6}$$\text{m}$
RjupiterJupiter volumetric mean radius$6.991\ 1\times10^{7}$$\text{m}$
RsaturnSaturn volumetric mean radius$5.8232\times10^{7}$$\text{m}$
RuranusUranus volumetric mean radius$2.536\ 2\times10^{7}$$\text{m}$
RneptuneNeptune volumetric mean radius$2.462\ 2\times10^{7}$$\text{m}$
RplutoPluto volumetric mean radius$1.188\times10^{6}$$\text{m}$
RcharonCharon volumetric mean radius$6.06\times10^{5}$$\text{m}$
AUAstronomical unit in meters$1.495\ 978\ 707\times10^{11}$$\text{m}$
lyLight-year in meters$9.460\ 730\ 472\ 580\ 8\times10^{15}$$\text{m}$
pcParsec in meters$3.085\ 677\ 581\ 491\ 367\ 3\times10^{11}$$\text{m}$

From default math module

Documentation: https://docs.python.org/3/library/math.html

chplot name(s)math nameNumber of argumentsNotes
acosacos1
acoshacosh1
asinasin1
asinhasinh1
atanatan1
atanhatanh1
atan2atan22
cbrtcbrt1
ceilceil1
copysigncopysign2
coscos1
coshcosh1
degreesdegrees1
distdist4dist(x1, y1, x2, y2) is interpreted as math.dist((x1, y1), (x2, y2))
erferf1
erfcerfc1
expexp1
expm1expm11
floorfloor1
fmodfmod2
gammagamma1
hypothypot2
lgamma
lngamma
lgamma1
log
ln
log1
log10log101
log1plog1p1
log2log21
radiansradians1
remainderremainder2
sinsin1
sinhsinh1
sqrtsqrt1
tantan1
trunctrunc1

From scipy.special

Documentation: https://docs.scipy.org/doc/scipy/reference/special.html

chplot name(s)scipy.special nameNumber of argumentsNotes
agmagm2
Aiairy1First output
Aipairy1Second output
beibei1
beipbeip1
berber1
berpberp1
betabeta2
betaincbetainc3
betaincinvbetaincinv3
betalnbetaln2
Biairy1Third output
binom
binomial
binom2
Bipairy1Fourth output
Chishichi1Second output
Cisici1Second output
digammadigamma1
eAiairye1First output
eAipairye1Second output
eBiairye1Third output
eBipairye1Fourth output
ellipeellipe1
ellipeincellipeinc2
ellipkellipk1
ellipkincellipkinc2
elliprcelliprc2
elliprdelliprd3
elliprfelliprf3
elliprgelliprg3
elliprjelliprj4
erfcinverfcinv1
erfierfi1
erfinverfinv1
factorial
fac
factorial1
fresnelcfresnel1Second output
fresnelsfresnel1First output
gammaincgammainc2
gammainccgammaincc2
gammainccinvgammainccinv2
gammaincinvgammaincinv2
hurwitz
hurwitzzeta
zeta2
hyp0f1hyp0f12
hyp1f1hyp1f13
hyp2f1hyp2f14
hyperuhyperu3
it2struve0it2struve01
itmodstruve0itmodstruve01
itstruve0itstruve01
iv
besseli
iv2
jv
besselj
jv2
keikei1
keipkeip1
kerker1
kerpkerp1
kv
besselk
kv2
lambertwlambertw1
loggammaloggamma1
modstruve
struvel
modstruve2
psipsi1
rgammargamma1
Shishichi1First output
Sisici1First output
sincpisinc1
struve
struveh
struve2
yv
bessely
yv2
zetazeta1

From mpmath

Documentation: https://mpmath.org/doc/current/

chplot name(s)mpmath nameNumber of argumentsNotes
acotacot1
acothacoth1
acscacsc1
acschacsch1
altzeta
eta
altzeta1
angerjangerj2
asecasec1
asechasech1
backlundsbacklunds1
barnesgbarnesg1
betainc2betainc4
chebytchebyt2
chebyuchebyu2
clcosclcos2
clsinclsin2
cospi
cospi
cospi1
cotcot1
cothcoth1
coulombccoulombc2
coulombfcoulombf3
coulombgcoulombg3
csccsc1
cschcsch1
Eiei1
ellipfellipf2
ellippiellippi3
fac2fac21
ffff1
fibfib1
fibonaccifibonacci1
gammainc2gammainc3
gegenbauergegenbauer3
harmonicharmonic1
hermitehermite2
hyp1f2hyp1f24
hyp2f0hyp2f03
hyp2f3hyp2f35
hyp3f2hyp3f26
hyperfachyperfac1
jacobijacobi4
laguerrelaguerre3
legendrelegendre2
legenplegenp3
legenqlegenq3
lerchphilerchphi3
lili1Computes li(x, offset=False)
Lili1Computes li(x, offset=True)
lommels1lommels13
lommels2lommels23
nzetazerosnzeros1
pcfdpcfd2
pcfupcfu2
pcfvpcfv2
pcfwpcfw2
polyexppolyexp2
polylogpolylog2
primepiprimepi1
primezetaprimezeta1
rfrf1
riemannrriemannr1
scorergiscorergi1
scorerhiscorerhi1
secsec1
sechsech1
secondzetasecondzeta1
siegelthetasiegeltheta1
siegelzsiegelz1
sincsinc1
stieltjesstieltjes1
superfacsuperfac1
Wlambertw1
weberewebere2
whitmwhitm3
whitwwhitw3

Probability functions

chplot nameNameArgumentsExpression
normpdfNormal distribution PDF$x, \mu, \sigma$$$\frac{1}{\sigma\sqrt{2\pi}}\mathrm{e}^{-\frac{1}{2}\left(\frac{x - \mu}{\sigma} \right)^2}$$
normcdfNormal distribution CDF$x, \mu, \sigma$$$\frac{1}{2}\left(1 + \mathrm{erf}\left(\frac{x - \mu}{\sigma\sqrt{2}}\right) \right)$$
unormpdfUnit normal distribution PDF$x$$$\frac{1}{\sqrt{2\pi}}\mathrm{e}^{-\frac{x^2}{2}}$$
unormcdfUnit normal distribution CDF$x$$$\frac{1}{2}\left(1 + \mathrm{erf}\left(\frac{x}{\sqrt{2}}\right) \right)$$
tripdfTriangle distribution PDF$x, a, b, c$$$0 \text{ if } x\leq a \text{ or } x &gt; b$$
$$\frac{2(x-a)}{(b-a)(c-a)} \text{ if } a &lt; x\leq c$$
$$\frac{2(b-x)}{(b-a)(b-c)} \text{ if } c &lt; x\leq b$$
tricdfTriangle distribution CDF$x, a, b, c$$$0 \text{ if } x &lt; a$$
$$\frac{(x-a)^2}{(b-a)(c-a)} \text{ if } a\leq x\leq c$$
$$1 - \frac{(b-x)^2}{(b-a)(b-c)} \text{ if } c &lt; x\leq b$$
$$1 \text{ if }b &lt; x $$
uniformpdfUniform distribution PDF$x, a, b$$$0 \text{ if } x &lt; a \text{ or } x &gt; b$$
$$\frac{1}{b-a} \text{ if } a\leq x\leq b$$
uniformcdfUniform distribution CDF$x, a, b$$$0 \text{ if } x &lt; a$$
$$\frac{x-a}{b-a} \text{ if } a\leq x\leq b$$
$$1 \text{ if }b &lt; x $$
exppdfExponential distribution PDF$x, \lambda$$$0 \text{ if } x &lt; 0$$
$$\lambda\mathrm{e}^{-\lambda x} \text{ if } 0\leq x$$
expcdfExponential distribution CDF$x, \lambda$$$0 \text{ if } x &lt; 0$$
$$1 - \mathrm{e}^{-\lambda x} \text{ if } 0\leq x$$
studentpdfStudent's t-distribution PDF$x, \nu$Wikipedia
studentcdfStudent's t-distribution CDF$x, \nu$Wikipedia
betapdfBeta distribution PDF$x, \alpha, \beta$Wikipedia
betacdfBeta distribution CDF$x, \alpha, \beta$Wikipedia
chi2pdf
khi2pdf
Chi-squared distribution PDF$x, k$Wikipedia
chi2cdf
khi2cdf
Chi-squared distribution CDF$x, k$Wikipedia
gammapdfGamma distribution PDF$x, \alpha, \beta$Wikipedia
gammacdfGamma distribution CDF$x, \alpha, \beta$Wikipedia
cauchypdfCauchy distribution PDF$x, x_0, \gamma$$$\frac{1}{\pi\gamma\left(1 + \left(\frac{x - x_0}{\gamma}\right)^2\right)}$$
cauchycdfCauchy distribution CDF$x, x_0, \gamma$$$\frac{1}{\pi}\arctan\left(\frac{x - x_0}{\gamma}\right) + \frac{1}{2}$$

To use the ( $k, \theta$ ) parametrization of the gamma distribution, just apply $\alpha = k$ and $\beta = \frac{1}{\theta}$.

Other functions

In this table, $\{x\}$ represents the fractional part of $x$.

chplot nameArgumentsExpression
relu
ramp
$x$$0 \text{ if } x &lt; 0$
$x \text{ if } 0\leq x$
lrelu$x, a$$a\cdot x \text{ if } x &lt; 0$
$x \text{ if } 0\leq x$
sigm
sigmoid
$x$$$\frac{1}{1 + \mathrm{e}^{-x}}$$
sign
sgn
$x$$-1 \text{ if } x &lt; 0$
$0 \text{ if } x = 0$
$+1 \text{ if } x &gt; 0$
lerp$x, m_x, M_x, m_y, M_y$$$m_y + (M_y - m_y)\frac{x - m_x}{M_x - m_x}$$
lerpt$t, m, M$$M + t * (M - m)$
heaviside$x$$0 \text{ if } x &lt; 0$
$\frac{1}{2} \text{ if } x = 0$
$1 \text{ if } x &gt; 0$
rect$x$$0 \text{ if } x &lt; -\frac{1}{2} \text{ or } x &gt; \frac{1}{2}$
$1 \text{ if } -\frac{1}{2} \leq x \leq \frac{1}{2}$
triangle
tri
$x$$0 \text{ if } x &lt; -1 \text{ or } x &gt; 1$
$1 - |x|; \text{ if } -1 \leq x \leq 1$
sawtooth$x$$2\{x - \frac{1}{2}\} - 1$
squarewave
sqwave
$x$$\frac{1}{2} \text{ if } \{x\} = 0 \text{ or } \{x\} = \frac{1}{2}$
$1 \text{ if } \{x\} &lt; \frac{1}{2}$
$0 \text{ if } \frac{1}{2} &lt; \{x\}$
trianglewave
triwave
$x$$4\{x\} \text{ if } \{x\} &lt; \frac{1}{4}$
$2-4\{x\} \text{ if } \frac{1}{4} \leq \{x\} &lt; \frac{3}{4}$
$4\{x\} + 4 \text{ if } \frac{3}{4} &lt; \{x\}$
abs$x$$|x|$
min$a, b$$\min(a,b)$
min3$a, b, c$$\min(a,b,c)$
min4$a, b, c, d$$\min(a,b,c,d)$
max$a, b$$\max(a,b)$
max3$a, b, c$$\max(a,b,c)$
max4$a, b, c, d$$\max(a,b,c,d)$
if$x, T, F$$F \text{ if } x &lt; 0$
$T \text{ if } 0\leq x$
ifn$x, T, F$$T \text{ if } x\leq 0$
$F \text{ if } 0 &lt; x$
ifz$x, T, F$$T \text{ if } x = 0$
$F \text{ if } x\neq 0$
in$x, L, U, T, F$$T \text{ if } L\leq x\leq U$
$F \text{ if } x &lt; L \text{ or } U &lt; x$
out$x, L, U, T, F$$F \text{ if } L\leq x\leq U$
$T \text{ if } x &lt; L \text{ or } U &lt; x$

Notes :

  • out(x, L, U, T, F) = in(x, L, U, F, T)
  • if(x, T, F) = in(x, 0, inf, T, F)
  • ifn(x, T, F) = in(x, -inf, 0, T, F)
  • ifn(x, T, F) = if(-x, T, F)
  • It is possible to use _ inside one of these function to remove some part of the graph.

Alphabetically-sorted list of every included constants and functions

Click to reveal
_a0absacosacoshacot
acothacscacschagmAiAip
alphaaltzetaangerjaperyasecasech
asinasinhatanatan2atanhAU
bbacklundsbarnesgbeibeipbent
berberpbesselibesseljbesselkbessely
betabetacdfbetaincbetainc2betaincinvbetaln
betapdfBibinombinomialBipbp
bruncc1c1Lc2catalan
cauchycdfcauchypdfcbrtceilchebytchebyu
Chichi2cdfchi2pdfCiclcosclsin
copysigncoscoshcospicotcoth
coulombccoulombfcoulombgcsccschdegrees
digammadistdnuCseeAieAip
eBieBipecEhEiellipe
ellipeincellipfellipkellipkincellippielliprc
elliprdelliprfelliprgelliprjemeps0
epsilon0erferfcerfcinverfierfinv
etaeVexpexpcdfexpm1exppdf
Ffacfac2factorialfeigenbaumafeigenbaumd
fffibfibonaccifloorfmodfresnelc
fresnelsGgG0gagamma
gammacdfgammaincgammainc2gammainccgammainccinvgammaincinv
gammapdfgegegenbauerGF0glaishergmu
gPhharmonichbheavisidehermite
hurwitzhurwitzzetahyp0f1hyp1f1hyp1f2hyp2f0
hyp2f1hyp2f3hyp3f2hyperfachyperuhypot
ififnifzininfit2struve0
itmodstruve0itstruve0ivjacobijvkB
kekeikeipkerkerpkhi2cdf
khi2pdfkhinchinKJkvlaguerrelambert
lambertwlegendrelegenplegenqlerchphilerp
lerptlgammaLililnlngamma
loglog10log1plog2loggammalommels1
lommels2lrelulym12CM12Cmax
max3max4McharonmeMearthmertens
minmin3min4MjupiterMmarsMmercury
MmoonmmumnMneptunemodstruvemp
MplutoMsaturnMsunmtmtaumu
Mumu0muBmuNMuranusMvenus
NAnannormcdfnormpdfnzetazerosout
pcpcfdpcfupcfvpcfwphi
pipolyexppolylogprimepiprimezetapsi
RradiansrampRcharonreRearth
rectreluremainderrfrgammariemannr
RinfRjupiterRKRmarsRmercuryRmoon
RneptuneRplutoRsaturnRsunRuranusRvenus
Rysawtoothscorergiscorerhisecsech
secondzetasgnShiSisiegelthetasiegelz
sigmsigmasigmaesigmoidsignsin
sincsincpisinhsqrtsqrt2squarewave
sqwavestieltjesstruvestruvehstruvelstudentcdf
studentpdfsuperfactantanhtautri
triangletrianglewavetricdftripdftriwavetrunc
uniformcdfuniformpdfunormcdfunormpdfVmSiW
weberewhitmwhitwyvZ0zeta

Graph and computations examples

Every file referenced in any commands can be found in the resources folder.

CLI parameters

Expressions

python -m chplot x
python -m chplot x " -x+1""x^2"

python -m chplot resources/files/equations.txt


-v parameter

python -m chplot t(t-1) -v t
python -m chplot sin(var*3) -v var


Overriding constant with variable:

python -m chplot c
python -m chplot c -v c


--no-sn

The expression in the first command is interpreted as $x\times1.2\cdot10^{-1}=0.12x$, and as $1.2\mathrm{e}\cdot x - 1$ in the second.

python -m chplot "x*1.2e-1"
python -m chplot "x*1.2e-1" --no-sn


-x, -y parameters

Using expressions in the horizontal axis bounds:

python -m chplot "x^2+x" -x -3 3
python -m chplot x -x " -sqrt(2)""zeta(3)"

Using expressions in the vertical axis bounds and restricting the graph:

python -m chplot fac(x) -x 0 6
python -m chplot fac(x) -x 0 6 -y 0.5 1.5


-n, -i, --dis parameters

The -i parameter removes the line between points.

python -m chplot cos(x) -x 0 10 -n 20
python -m chplot cos(x) -x 0 10 -i


python -m chplot sqrt(x) -x 0 100 -i
python -m chplot sqrt(x) -x 0 10 --dis 10 -n 35


-xlog, -ylog parameters

python -m chplot "2^x" -x 1 100 -ylog
python -m chplot "ln(x)" -x 1 100 -xlog


Log axis will adjust the bounds to remove negative points:

python -m chplot "x^3.5" -x 1 100 -xlog -ylog
python -m chplot "x" -x -5 5 -xlog
python -m chplot "x" -x -5 -1 -xlog

The second command generates a warning:

[CHPLOT] WARNING: x-axis scale is logarithmic, but its lower bound (-5.0) is negative, x-axis will be truncated to positive values

The third command generates en error:

[CHPLOT] CRITICAL: x-axis scale is logarithmic, but both its lower (-5.0) and upper (-1.0) bounds are negative, cannot graph anything

-z parameter

python -m chplot "sin(x)+10" -x 1 10pi
python -m chplot "sin(x)+10" -x 1 10pi -z


-xl, -yl, -t, -rl parameters

python -m chplot zeta(x) -x 1 10 -y 0 3
python -m chplot zeta(x) -x 1 10 -y 0 3 -xl "Variable x" -yl "Zeta(x)" -t "Zeta function on [1 ; 10]" -rl


-square, -lw parameters

python -m chplot cbrt(x) --square
python -m chplot cbrt(x) -lw 5


-c parameter

If a constant requires another one, define it after:

python -m chplot a*x+b -c a=2 b=7
python -m chplot "a*x^2-b*x+1" -c a=8pi/19 "b=a^2-1"


Constants can also be an expression, or come from a file:

python -m chplot cos(a*x) -c "a=(sqrt(2) - zeta(3)) / sin(1.5)" -x 0 50
python -m chplot "a*x^3+b*x^2+c*x+d" -c resources\files\constants.txt -x -10 10


-f parameter

All the CSV format are summarized in the CSV files format section.

python -m chplot -f resources\files\data.csv


-d parameter

python -m chplot x "x(x+1)""x(x+1)(x+2)/2""x(x+1)(x+2)(x+3)/6" -d resources\files\saved_data.csv

The data can be found in the saved_data.csv file.


-p parameter

The file functions.py must be in the directory from where the command is executed.

python -m chplot "frac(x)+3""is_prime(x)""rnd(x, x/2)" -p functions.py -x 0 10


--zeros

python -m chplot sin(x) -x -7 7 --zeros
python -m chplot "x^2-2""in(x, 0.2, 0.3, 0, -2x+1)" -x 0 2 --zeros

The result of these commands (besides the plot) are the following. The first are the zeros of the function $\sin(x)$ on [-7 ; 7]: $\pm 2\pi$, $\pm \pi$ and $0$. Then the zero of $x^2-2$ is $\sqrt{2}$. Finally the last expression is completely zero on the interval [0.2 ; 0.3] and at $1/2$.

===== ZEROS OF THE FUNCTIONS =====
Note that non-continuous functions may give false zeros. Furthermore, some zeros may be missing if the graph is tangent to the x-axis.
- On the interval [-7.0 ; 7.0], the functionf(x) = sin(x) equals zero...
at x = -6.2831853072
at x = -3.1415926536
at x = 0.0
at x = 3.1415926536
at x = 6.2831853072
===== ZEROS OF THE FUNCTIONS =====
Note that non-continuous functions may give false zeros. Furthermore, some zeros may be missing if the graph is tangent to the x-axis.
- On the interval [0.0 ; 2.0], the functionf(x) = x^2-2 equals zero...
at x = 1.4142135624
- On the interval [0.0 ; 2.0], the functionf(x) = in(x, 0.2, 0.3, 0, -2x+1) equals zero...
on [0.2 ; 0.3]
at x = 0.5

--integral

python -m chplot "1/x" -x 1 e --integral
python -m chplot "x^2""exp(x)" --integral

The result of these commands (besides the plot) are the following.$$\int_1^e\frac{dx}{x} = 1$$ $$\int_0^1x^2dx = \frac{1}{3}$$$$\int_0^1\exp(x)dx=e - 1$$

===== INTEGRALS OF THE FUNCTIONS =====
Note that the more points, the smallest the error and that floating point numbers may introduce errors. Furthermore, discontinuous functions may indicate really huge error margins.
- ∫f(x)dx = 1.0000000021279944
where f(x) = 1/x on [1.0 ; 2.718]
===== INTEGRALS OF THE FUNCTIONS =====
Note that the more points, the smallest the error and that floating point numbers may introduce errors. Furthermore, discontinuous functions may indicate really huge error margins.
- ∫f(x)dx = 0.33333333499999834
where f(x) = x^2 on [0.0 ; 1.0]
- ∫f(x)dx = 1.7182818298909472
where f(x) = exp(x) on [0.0 ; 1.0]

--deriv parameter

The second command illustrates the instability of the higher order derivatives.

python -m chplot "sin(x)" --deriv 1 2 3 4 -x 0 4pi
python -m chplot "exp(x)" --deriv 1 4 7 -n 100000


Synergy between --deriv and --zeros/--integral.

python -m chplot "x^2+2" -x -3 3 --deriv 1 --zeros --integral
===== ZEROS OF THE FUNCTIONS =====
Note that non-continuous functions may give false zeros. Furthermore, some zeros may be missing if the graph is tangent to the x-axis.
Furthermore, on derivatives and file data, zeros are approximated using linear interpolation, and may be far from their real values.
- On the interval [-3.0 ; 3.0], the functionf(x) = x^2+2 never equals zero.
- On the interval [-2.998 ; 2.998], the functionf(x) = d/dx * (x^2+2) equals zero...
at x = 0.0
===== INTEGRALS OF THE FUNCTIONS =====
Note that the more points, the smallest the error and that floating point numbers may introduce errors. Furthermore, discontinuous functions may indicate really huge error margins.
The x-axis limits on derivatives are slightly tighter because of the algorithm used. This may be counteracted by adding more points.
- ∫f(x)dx = 30.000000359996804
where f(x) = x^2+2 on [-3.0 ; 3.0]
- ∫f(x)dx = 6.18809004038144e-14
where f(x) = d/dx * (x^2+2) on [-2.998 ; 2.998]

--reg

Default keyword usable in the CLI.

python -m chplot "sin(x)"" -exp(x)" --reg lin

===== REGRESSION COEFFICIENTS OF THE FUNCTIONS =====
Regression function: reg(x) = a * x + b
- Function f(x) = sin(x)
Coefficients:
a = 0.85583 (exact 0.8558336726408089)
b = 0.03178 (exact 0.031776961574734974)
Accuracy on [0.000 ; 1.000]:
R2 = 0.9948573993162803
|err|<= 0.046139649407647365
|rel err|<= 317.625449951033
Copyable expression:
f(x) = (0.8558336726408089) * x + (0.031776961574734974)
- Function f(x) = -exp(x)
Coefficients:
a = -1.69032 (exact -1.6903174201716293)
b = -0.87314 (exact -0.8731372047610497)
Accuracy on [0.000 ; 1.000]:
R2 = 0.9837173025833181
|err|<= 0.15482720352636603
|rel err|<= 0.12686279523895028
Copyable expression:
f(x) = (-1.6903174201716293) * x + (-0.8731372047610497)

Arbitrary expression for regression (here: $a + \frac{b}{x} + \frac{c}{x^2}$).

python -m chplot "x""x^2-3x+2" -x 1 2 --reg "_ra + _rb/x + _rc/x^2"

===== REGRESSION COEFFICIENTS OF THE FUNCTIONS =====
Regression function: reg(x) = a + b/x + c/x^2
- Function f(x) = x
Coefficients:
a = 4.32347 (exact 4.323472460240034)
b = -6.08251 (exact -6.082510526066791)
c = 2.7852 (exact 2.7852046542434103)
Accuracy on [1.000 ; 2.000]:
R2 = 0.9990492201082051
|err|<= 0.026166588416653536
|rel err|<= 0.026166588416653536
Copyable expression:
f(x) = (4.323472460240034) + (-6.082510526066791)/x + (2.7852046542434103)/x^2
- Function f(x) = x^2-3x+2
Coefficients:
a = 1.70398 (exact 1.7039810825081398)
b = -5.44646 (exact -5.446461246934391)
c = 3.8091 (exact 3.809103050454299)
Accuracy on [1.000 ; 2.000]:
R2 = 0.8852455638434826
|err|<= 0.06697377834548113
|rel err|<= 669.2141410779176
Copyable expression:
f(x) = (1.7039810825081398) + (-5.446461246934391)/x + (3.809103050454299)/x^2

Regression on file data.

python -m chplot -f resources\files\data.csv --reg poly2

===== REGRESSION COEFFICIENTS OF THE FUNCTIONS =====
Regression function: reg(x) = a2 * x^2 + a1 * x + a0
- Function f(x) = data.csv - vy(t)
Coefficients:
a2 = 0.0 (exact -5.0979039530237654e-08)
a1 = -9.81 (exact -9.809999897491432)
a0 = 10.0 (exact 9.999999965897445)
Accuracy on [0.000 ; 2.030]:
R2 = 1.0
|err|<= 3.608967524826312e-08
|rel err|<= 2.809290005481242e-06
Copyable expression:
f(x) = (-5.0979039530237654e-08) * x^2 + (-9.809999897491432) * x + (9.999999965897445)
- Function f(x) = data.csv - y(t)
Coefficients:
a2 = -4.905 (exact -4.904999983961847)
a1 = 10.0 (exact 9.999999961872113)
a0 = 0.0 (exact 1.7338066957762713e-08)
Accuracy on [0.000 ; 2.030]:
R2 = 1.0
|err|<= 1.7338066957762713e-08
|rel err|<= 1.7041982824835924e-07
Copyable expression:
f(x) = (-4.904999983961847) * x^2 + (9.999999961872113) * x + (1.7338066957762713e-08)

Synergy between --reg and --deriv/--zeros/--integral.

python -m chplot log2(x) -x 1 3 --deriv 1 --reg lin --zeros --integral

===== REGRESSION COEFFICIENTS OF THE FUNCTIONS =====
Regression function: reg(x) = a * x + b
- Function f(x) = log2(x)
Coefficients:
a = 0.76193 (exact 0.7619286641417374)
b = -0.58912 (exact -0.5891228449973627)
Accuracy on [1.000 ; 3.000]:
R2 = 0.9808243468285833
|err|<= 0.17280581914437476
|rel err|<= 598.4874010749205
Copyable expression:
f(x) = (0.7619286641417374) * x + (-0.5891228449973627)
===== ZEROS OF THE FUNCTIONS =====
Note that non-continuous functions may give false zeros. Furthermore, some zeros may be missing if the graph is tangent to the x-axis.
Furthermore, on derivatives and file data, zeros are approximated using linear interpolation, and may be far from their real values.
- On the interval [1.0 ; 3.0], the functionf(x) = log2(x) equals zero...
at x = 1.0
- On the interval [1.0 ; 3.0], the functionf(x) = Regression [log2(x)] never equals zero.
- On the interval [1.001 ; 2.999], the functionf(x) = d/dx * (log2(x)) never equals zero.
- On the interval [1.001 ; 2.999], the functionf(x) = d/dx * (Regression [log2(x)]) never equals zero.
===== INTEGRALS OF THE FUNCTIONS =====
Note that the more points, the smallest the error and that floating point numbers may introduce errors. Furthermore, discontinuous functions may indicate really huge error margins.
The x-axis limits on derivatives are slightly tighter because of the algorithm used. This may be counteracted by adding more points.
- ∫f(x)dx = 1.8694974171793488
where f(x) = log2(x) on [1.0 ; 3.0]
- ∫f(x)dx = 1.8694689665720188
where f(x) = Regression [log2(x)] on [1.0 ; 3.0]
- ∫f(x)dx = 1.583424040388957
where f(x) = d/dx * (log2(x)) on [1.001 ; 2.999]
- ∫f(x)dx = 1.5226382424208345
where f(x) = d/dx * (Regression [log2(x)]) on [1.001 ; 2.999]

Possible improvements

  • Parallelizing computation of expressions.

About

Plot abritrary math expressions, and compute zeros, derivatives, integrals, regression and more!

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages