Navigation:  Menu Commands > Generate Menu >

Y=f(X) command (Generate menu)

JR   Viewer

Print this Topic Previous pageReturn to chapter overviewNext page

Generates X,Y pairs between a start and end point with a specified interval using a function that you specify.

Available operators are +, -, *, /, ^,>,<, and =. The inequality operators (>, <, and =)  result in 1.0 if the condition is true, 0.0 otherwise.

Function (sin, cos, etc.) arguments must be in parentheses. See the list of available functions.

You can use placeholder codes for certain data parameters. For example “$YMAX(2)” will be replaced with the maximum Y value of the second curve. For more information on placeholder codes click here.

You can create conditional equations with the if function. The if function takes the form if(test,if_true,if_false), where test is the condition you want to check, if_true is the value the equation takes if test is true, and if_false is the value taken if test is false. For example, "if x > 5 then y=x^2, otherwise y=(10-x)^2" can be expressed with if(x<5,x^2,(10-x)^2).

By default, angular input values are in radians. You can set angles to degrees by clicking the degrees option button.

DPlot will automatically substitute the value of pi (3.141592653589793...) for "PI", "pi", or "Pi"

NOTE: Be specific. DPlot does not interpret "2X" as "2*X".

Example:

With radians selected, Y=sin(Pi*x)

from X=0 to 2 results in:

Prevent divide by zero errors

If this box is unchecked, DPlot will trap divide by zero and many other math errors (e.g. logarithm of a non-positive value), report the value of x where the error occurred, and will not generate a curve. If this box is checked, when DPlot traps a math error it will shift x by a very small number and attempt the calculation again. This feature might be useful for generating curves of certain functions that would normally fail at specific values of x, e.g. sin(x)/x at x=0.

Constants

You can specify up to 10 constants to use in place of numerical values in your equation. Often the use of constants will make your equation more readable and less error-prone. For example, the Planck law for blackbody radiation as a function of wavelength is given by:

where

h =Planck's constant, 6.6262E-27 erg-sec

c = the speed of light, 2.99792458E+8 meters/sec

k = Boltzmann's Constant, 1.3807E-16 erg/deg. K

T = temperature, deg. K

Without using constants this equation can be expressed in DPlot as

y = 2*6.6262E-27*2.99792458E+8^2/x^5/(exp(6.6262E-27*2.99792458E8/(x*1.3807E-16*200))-1)

(for T=200K) which is a bit hard to decipher. Instead, you can use

y = 2*h*c^2/x^5/(exp(h*c/(x*k*200))-1) with c, h, and k defined as shown below:

Repeating for several temperatures gives:

Expand constants in legend

If unchecked, the legend for a generated curve will generally match the equation as entered (plus a few formatting changes for subscripts and superscripts). If checked, any constants in the equation will be replaced by their numeric values. For example, with Y=A+B*x+C*x^2+D*x^3+F*x^4 and Expand constants in legend unchecked, the legend will be A+B*x+C*x2+D*x3+F*x4. With Expand constants in legend checked, the legend might be 1.111-0.4366*x+0.04882*x2-0.001627*x3+5.613e-016*x4. If this expansion results in a character string longer than 80 characters, the constants A,B,C,etc. will be used.

Tip: You can hide the legend by right-clicking and selecting Hide Legend. Move the legend by clicking and dragging. Other legend parameters are accessible via the right-click menu, or by selecting the Legend/Labels command on the Text menu.

 

Open/Save as

These buttons allow you to read or save the entire setup for this function, including the equation, extents, constants, and other options. This might be handy if you have an operation that you frequently use and you use this command often enough that a particular operation migrates out of the most-recently-used list. We strongly suggest that you use the default folder location when saving a setup, so that you don't confuse the setup for this function with that for the X=f(T), Y=g(T) or Y=f(X,Y1,Y2,...) commands. (The saved files for the various Generate commands are not compatible.)

 


Page url: https://www.dplot.com/help/index.htm?helpid_f_of_x.htm