Code

Results

Quick Reference

The Calcpad language includes the following elements (click an item to insert):

Real numbers: digits "0" - "9" and decimal point ".";

Complex numbers: re ± imi (e.g. 3 - 2i);

Variables:

- Latin letters "a" - "z", "A" - "Z";
- Greek letters "α" - "ω", "Α" - "Ω";
- digits "0" - "9";
- comma ",";
- "_" for subscript;
A variable name must start with a letter. Names are case sensitive.

Operators:

"!" - factorial;
"^" - exponent;
"/" - division;
"÷" - force division bar;
"\" - division;
"%" - reminder;
"*" - multiplication;
"-" - minus;
"+" - plus;
"" - equal to;
"" - not equal to;
"<" - less than;
">" - greater than;
"" - less or equal;
"" - greater or equal;
"=" - assignment;

Custom functions of type f (x; y; z; ...);
Built-in functions:

abs(x) - absolute value/magnitude;
sin(x) - sine;
cos(x) - cosine;
tan(x) - tangent;
csc(x) - cosecant;
sec(x) - secant;
cot(x) - cotangent;
sinh(x) - hyperbolic sine;
cosh(x) - hyperbolic cosine;
tanh(x) - hyperbolic tangent;
csch(x) - hyperbolic cosecant;
sech(x) - hyperbolic secant;
coth(x) - hyperbolic cotangent;
asin(x) - inverse sine;
acos(x) - inverse cosine;
atan(x) - inverse tangent;
acsc(x) - inverse cosecant;
asec(x) - inverse secant;
acot(x) - inverse cotangent;
asinh(x) - inverse hyperbolic sine;
acosh(x) - inverse hyperbolic cosine;
atanh(x) - inverse hyperbolic tangent;
acsch(x) - inverse hyperbolic cosecant;
asech(x) - inverse hyperbolic secant;
acoth(x) - inverse hyperbolic cotangent;
log(x) - decimal logarithm;
ln(x) - natural logarithm;
log_2(x) - binary logarithm;
sqrt(x) - square root;
cbrt(x) - cubic root;
root(x; y) - n-th root;
atan2(x; y) - the angle whose tangent is the quotient of x and y;
round(x) - round to the nearest integer;
floor(x) - round to the lower integer;
ceiling(x) - round to the greater integer;
trunc(x) - round to the nearest integer towards zero;
re(x) - rhe real part of a complex number;
im(x) - rhe imaginary part of a complex number;
phase(x) - rhe phase of a complex number;
random(x) - a random number between 0 and x;
min(x; y; z...) - minimum of multiple values;
max(x; y; z...) - maximum of multiple values;
sum(x; y; z...) - sum of multiple values = x + y + z...;
sumsq(x; y; z...) - sum of squares = x² + y² + z²...;
srss(x; y; z...) - square root of sum of squares = sqrt(x² + y² + z²...);
average(x; y; z...) - average of multiple values = (x + y + z...)/n;
product(x; y; z...) - product of multiple values = x·y·z...;
mean(x; y; z...) - geometric mean = n-th root(x·y·z...);
if(<cond>; <value-if-true>; <value-if-false>) - conditional evaluation;
switch(<cond1>; <value1>; <cond2>; <value2>;...; <default>) - selective evaluation;
take(n; a; b; c...) - returns the n-th element from the list;
line(x; a; b; c...) - linear interpolation;
spline(x; a; b; c...) - Hermite spline interpolation;

Comments: "Title" or 'text' in double or single quotes, respectively.

HTML, CSS, JS and SVG are allowed.

Graphing and plotting:

$Plot{ f(x) @ x = a : b } - simple plot;
$Plot{ x(t) | y(t) @ t = a : b } - parametric;
$Plot{ f1(x) & f2(x) & ... @ x = a : b } - multiple;
$Plot{ x1(t) | y1(t) & x2(t) | y2(t) & ... @ t = a : b } - multiple parametric;
$Map{ f(x; y) @ x = a : b & y = c : d } - 2D color map of a 3D surface;
PlotHeight - height of plot area in pixels;
PlotWidth - width of plot area in pixels;

Iterative and numerical methods:

$Root{ f(x) = const @ x = a : b } - root finding for f(x) = const;
$Root{ f(x) @ x = a : b } - root finding for f(x) = 0;
$Find{ f(x) @ x = a : b } - similar to previous, but x is not required to be a precise solution;
$Sup{ f(x) @ x = a : b } - local maximum of a function;
$Inf{ f(x) @ x = a : b } - local minimum of a function;
$Area{ f(x) @ x = a : b } - numerical integration;
$Slope{ f(x) @ x = a } - numerical differentiation;
$Sum{ f(k) @ k = a : b } - iterative sum;
$Product{ f(k) @ k = a : b } - iterative product;
$Repeat{ f(k) @ k = a : b } - general inline iterative procedure;
Precision - relative precision for numerical methods [10-2; 10-16] (default is 10-12)

Program flow control:

Simple:
    #if <condition>
        <Your code here>
    #end if

Alternative:
    #if <condition>
        <Your code here>
    #else
        <Some other code>
    #end if

Complete:
    #if <condition1>
        <Your code here>
    #else if <condition2>
        <Your code here>
    #else
        <Some other code>
    #end if

You can add or omit as many "#else if's" as needed. Only one "#else" is allowed. You can omit this too.

Iteration blocks:

Simple:
    #repeat <number of repetitions>
        <Your code here>
    #loop

With conditional break:
    #repeat <number of repetitions>
        <Your code here>
        #if <condition>
            #break
        #end if
        <Some more code>
    #loop

Output control:

#hide - hide the report contents;
#show - always show the contents (default);
#pre - show the next contents only before calculations;
#post - show the next contents only after calculations;
#val - show only the calculated results;
#equ - show the complete equations (default);
#noc - show only equations without results (no calculations);
#round n - rounds to n digits after the decimal point.
Each of the above commands is effective after the current line until the end of the report or another command that overwrites it.

Breakpoints for step-by-step execution:

#pause - calculates to the current line and waits until resumed manually;
#input - renders an input form to the current line and waits for user input.

Units for trigonometric functions: #deg - degrees, #rad - radians; #gra - grades;

Separator for target units: |;

Return angles with units: ReturnAngleUnits = 1;

Dimensionless units: .%, ;

Angle units: °, , , deg, rad, grad, rev;

Metric units (SI and compatible):

Mass: g, hg, kg, t, kt, Mt, Gt, dg, cg, mg, μg, ng, pg, Da, u;
Length: m, km, dm, cm, mm, μm, nm, pm, AU, pm;
Time: s, ms, μs, ns, ps, min, h, d;
Frequency: Hz, kHz, MHz, GHz, THz, mHz, μHz, nHz, pHz, rpm;
Speed: kmh;
Electric current: A, kA, MA, GA, TA, mA, μA, nA, pA;
Temperature: °C, Δ°C, K;
Amount of substance: mol;
Luminous intensity: cd;
Area: a, daa, ha;
Volume: L, mL, cL, dL, hL;
Force: dyn, N, daN, hN, kN, MN, GN, TN, kgf, tf;
Moment: Nm, kNm;
Pressure: Pa, daPa, hPa, kPa, MPa, GPa, TPa,
     dPa, cPa, mPa, μPa, nPa, pPa,
     bar, mbar, μbar, atm, at, Torr, mmHg;
Viscosity: P, cP, St, cSt;
Energy work: J, kJ, MJ, GJ, TJ, mJ, μJ, nJ, pJ,
      Wh, kWh, MWh, GWh, TWh, cal, kcal, erg,
      eV, keV, MeV, GeV, TeV, PeV, EeV;
Power: W, kW, MW, GW, TW, mW, μW, nW, pW, hpM, ks,
    VA, kVA, MVA, GVA, TVA, mVA, μVA, nVA, pVA,
    VAR, kVA, MVA, GVA, TVA, mVA, μVA, nVA, pVA;
Electric charge: C, kC, MC, GC, TC, mC, μC, nC, pC, Ah, mAh;
Potential: V, kV, MV, GV, TV, mV, μV, nV, pV;
Capacitance: F, kF, MF, GF, TF, mF, μF, nF, pF;
Resistance: Ω, , , , , , μΩ, , ;
Conductance: S, kS, MS, GS, TS, mS, μS, nS, pS,
       , k℧, M℧, G℧, T℧, m℧, μ℧, n℧, p℧;
Magnetic flux: Wb, kWb, MWb, GWb, TWb, mWb, μWb, nWb, pWb;
Magnetic flux density: T, kT, MT, GT, TT, mT, μT, nT, pT;
Inductance: H, kH, MH, GH, TH, mH, μH, nH, pH;
Luminous flux: lm;
Illuminance: lx;
Radioactivity: Bq, kBq, MBq, GBq, TBq, mBq, μBq, nBq, pBq, Ci, Rd;
Absorbed dose: Gy, kGy, MGy, GGy, TGy, mGy, μGy, nGy, pGy;
Equivalent dose: Sv, kSv, MSv, GSv, TSv, mSv, μSv, nSv, pSv;
Catalytic activity: kat;

Non-metric units (Imperial/US):

Mass: gr, dr, oz, lb, kip, st, qr, cwt_UK, cwt_US, ton_UK, ton_US, slug;
Length: th, in, ft, yd, ch, fur, mi, ftm, cable, nmi, li, rod, pole, perch, lea;
Speed: mph, knot;
Temperature: °F, Δ°F, °R;
Area: rood, ac;
Volume (fluid): fl_oz_UK, gi_UK, pt_UK, qt_UK, gal_UK, bbl_UK, bu_UK;
       fl_oz_US, gi_US, pt_US, qt_US, gal_US, bbl_US, bu_US;
Force: ozf, lbf, kipf, tonf, pdl;
Pressure: osi, osf, psi, psf, ksi, ksf, tsi, tsf, inHg;
Energy work: BTU, therm, quad;
Power: hp, hpE, hpS.
















  
Note: The web version does not support modules and macros.

How does it work?

  1. Enter your formulas and text into the "Code" area on the left.
  2. Press Enter or click to calculate. The results will appear in the "Results" box on the right.
  3. Click "Preview" to preview and print the calculation notes.

You can use variables, functions and units of measurement in expressions, e.g.: 4cm + 3in. To convert to other units, add vertical bar "|" and target units at the end: 4cm|in.

The Calcpad language also supports complex numbers, custom functions, plotting, numerical methods, sums, products, conditional statements, iteration blocks, etc. Check our quick reference or the complete user manual.

Example:

"Quadratic equation example:
a = 3 ', ' b = 4 ', ' c = -5
f(x) = a*x^2 + b*x + c '= 0
'Discriminant - ' D = b^2 - 4*a*c
#if D < 0
    'D < 0. No real roots exist.'
    $Plot{f(x) @ x = -3 : 2}
#else
    x_1 = (-b - sqr(D))/(2*a)
    x_2 = (-b + sqr(D))/(2*a)
    $Plot{f(x) & x_1|0 & x_2|0 @ x = -3 : 2}
#end if