Expression Reference

Expressions are used extensively throughout Yob. Calculated Columns, Functions, and custom Curve Fits all make use of user-defined expressions. This page is meant to serve as a reference for using expressions throughout the program. If you are new to using expressions, you may want to check out one of the following tutorials first:


General Rules

  • All expressions should follow the general syntax of mathematics. Order of operations applies.
  • All operators need to be explicit. For example, you cannot write 2x; you would have to write 2*x instead.

How to Tell When an Expression is Valid

In all of the places that you can edit expressions within Yob, the text field will let you know when your expression is invalid by turning its border red:


Referencing Other Items

Part of what makes expressions so effective is their ability to refer to other items. Accomplishing this is simple:

  • To reference a Function, simply use its name as you would when using built-in functions like sin(x) or abs(x). For example, f1(x + 2) + f2(x - 2) would be a valid way to reference Functions in an expression.

  • To reference a Curve Fit, the same principle applies but names are denoted with "cf" rather than "f". For example, cf1(x / 3) + sin(x) would be a valid way to reference a Curve Fit in an expression.

  • To reference a Data Set Column, use the Data Set name along with the column name. For example, d1c2 would reference the second column of the first Data Set. However, only Calculated Column expressions are allowed to reference Data Set Columns. This is demonstrated in the Advanced Data Sets tutorial and explained in greater detail in the Calculated Columns Reference.

Maintaining Referential Integrity

Allowing users to put references in their expressions gives them a lot of freedom, but doing to makes it necessary to impose a few restrictions to maintain referential integrity. Essentially, this just means that if an expression refers to another item,

  1. The item needs to exist. For example, f3(x) + 4 is not a valid expression if there are only 2 Functions that exist. Yob will recognize when this condition is not met and will consider it an invalid expression.
  2. The reference cannot create circular dependencies. For example, consider the following function definitions: f1(x) = f2(x) + 1, f2(x) = f1(x) - 1 If you look closely, you can probably see that trying to evaluate one of these functions would be rather unproductive. Yob will also recognize when this condition is not met and will consider it an invalid expression.

Removing Items

When you have several items that depend on each other, it can be problematic to remove one of them. Luckily, Yob automatically adapts the remaining items upon deletion to keep your intent in tact. Before it does so however, Yob will alert you if the item you're deleting is referenced in other expressions:

Ok will proceed with the deletion and make any necessary adaptions, and Cancel will abort the deletion. To resolve dependencies with the items that reference the deleted item, Yob will adapt your data in several ways:

Index Shifting (Applies to All Items)

Since all items are numbered, removing an item can affect the numbering of other items. Here's an example of how Yob would resolve an applicable situation:

Here, if we simply removed f2, there would be a gap between f1 and f3. To fix this, Yob simply shifts the indices of any functions after f2 (in this case, only f3) down by one. This causes f3 to now be f2, but f1's expression depended on f3 rather than f2. Yob corrects this by modifying f1's expression, as you can see in the image above.

Function Substitution (Functions and Curve Fits Only)

When a Function or Curve Fit is removed, and another expression depends upon it directly, Yob will replace all references to it with the contents of its expression.

In the example above, cf1's expression happened to be 0.485*x + 3.071.

Dependency Removal (Calculated Columns Only)

When a Data Set is removed, and a Calculated Column expression references one of its columns, nothing can be done to sensibly retain the expression. Yob will disable the Calculated Column and clear its expression. This leaves the data untouched, but the values will no longer be calculated.


The Independent Variable

Functions and Curve Fits both make use of the independent variable. In most cases, this is simply known as x, which is the case for f1(x) = sin(x) and cf1(x) = A*x + B.

However, some situations might warrant a more descriptive independent variable. Consider the example where you are plotting distance against time. In this scenario, it might make more sense for the independent variable to be t instead. This can be changed in the Labels menu:

Note

Changing this field will automatically update any affected expressions. For example, the cf1(x) = A*x + B example would become cf1(t) = A*t + B.


Built-in Operators

Yob expressions can contain any of these built-in operators:

OperatorDescription
+Addition
-Subtraction
*Multiplication
/Division
^Exponentiation

Built-in Functions

Yob expressions can contain any of these built-in functions:

NameDescription
sqrt(x)Square root of x
ln(x)Natural log (base e) of x
log(x)Log (base 10) of x
log10(x)Log (base 10) of x (for those who wish to be explicit)
abs(x)Absolute value of x
floor(x)Floor of x (round down)
ceil(x)Ceiling of x (round up)
round(x)x rounded to the nearest integer
random(x)Random value between 0 and x
sin(x)Sine of x (in radians)
cos(x)Cosine of x (in radians)
tan(x)Tangent of x (in radians)
csc(x)Cosecant of x (in radians)
sec(x)Secant of x (in radians)
cot(x)Cotangent of x (in radians)
asin(x)Inverse Sine (or Arcsine) of x (in radians)
acos(x)Inverse Cosine (or Arccosine) of x (in radians)
atan(x)Inverse Tangent (or Arctangent) of x (in radians)
acsc(x)Inverse Cosecant (or Arccosecant) of x (in radians)
asec(x)Inverse Secant (or Arcsecant) of x (in radians)
acot(x)Inverse Cotangent (or Arccotangent) of x (in radians)
sinh(x)Hyperbolic Sine of x
cosh(x)Hyperbolic Cosine of x
tanh(x)Hyperbolic Tangent of x
csch(x)Hyperbolic Cosecant of x
sech(x)Hyperbolic Secant of x
coth(x)Hyperbolic Cotangent of x
asinh(x)Inverse Hyperbolic Sine of x
acosh(x)Inverse Hyperbolic Cosine of x
atanh(x)Inverse Hyperbolic Tangent of x
acsch(x)Inverse Hyperbolic Cosecant of x
asech(x)Inverse Hyperbolic Secant of x
acoth(x)Inverse Hyperbolic Cotangent of x

Built-in Constants

Yob expressions can contain any of these built-in constants:

NameNumeric ValueAccepted Formats
E2.71828182846E, e
Pi3.14159265359PI, pi, π
Tau6.28318530718TAU, tau, τ
Phi1.61803398874PHI, phi, φ, ϕ