### Search

 Search WWW Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

Support DFF - Shop

If you shop at Amazon anyway,  consider using this link.

We receive a few cents from each purchase.  Thanks

### Support DFF - Donate

If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Mensa® Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

(Hint: If you can wait, current year calendars are usually on sale in January.)

### Contact

 Search DelphiForFun.org only

 Freeth's Nephroid!

### Problem Description

Here's a function graphing program  I wrote in October, 2000.   It plots one or two expressions on a common set of X-Y axes.  It handles most arithmetic, trigonometric, log and power function  expressions and can print the resulting plots.

It also plots parametric expressions, for example x=sin(t); y=cos(t), for t = 0 to 360 degrees generates a circle with radius of 1.  Or for Freeth's Nephroid shown at right: x=(1+2*sin(T/2))*cos(T);  y=(1+2*sin(T/2))*sin(T)

### Background & Techniques

The program uses the TChart component that is included with Delphi Pro or Enterprise editions to draw the charts.

It also uses a freeware TExParser component to parse and evaluate the expressions.   This component was last modified and published by Stefan Hoffmeister. Details of credits  are included in comments section of Parser10.pas  I have modified it slightly to include arcsin and arccos functions and commented out the code that registers it as a component.   The Register procedure tells Delphi which tab of the Components panel to place a component on when you install it.  I'm not sure if it does anything if you simply compile the component into your program as we do here.  I also modified the name from the original TParser to TExParser since a TParser already exists in my version of Delphi (D5 Pro).  I'm also not sure what Borland's TParser does, but it doesn't parse and evaluate expressions.

Those components do most of the work for us.   We need to create the visual framework to handle getting the expressions, loading and saving expressions, calling the print setup dialog and the print routines when requested, etc.

The most complicated code that I wrote was to find the parametric variable, if one is used and the code to insert a multiplier of pi/180 inside of trig functions if the user checked a "Angles in degrees " checkbox in the expression definition dialog.  This is required because all trig functions in Delphi (and every other language that I'm familiar with)  expect angles to be in radians.

Addendum:  December 5, 2002:  Version 1.1 was posted today.  In addition to a couple of bug fixes, there are now Help pages describing the rules for defining the expressions to be graphed and some chart navigation features.  Charts can be zoomed and point values  displayed using the mouse.

June 17, 2004:  Version 1.2 adds smarter defaults for 2nd series and the ability to manually set the scale for the dependent variable (the vertical scale).  Also adds Fermat's Spiral and 8-petal rose charts  to samples.

March 1, 2007:  Version 1.3, SciGrapher13,  was posted today.  It fixes a number of minor problems with equation and expression formats.  (For example, embedded spaces within an expression formerly caused syntax errors.  Ok now.)    A new feature allows the use of named constants in the expressions defining X and Y.   New included sample graphs LemiconOfPascal,grf and St,LouisArch,grf, (an inverted catenary curve), both contain examples of named constant usage,

### Running/Exploring the Program

 Download  executable Download source  (Note: A Delphi version which includes the TChart  component is required to compile.  Also the Parser10 unit which evaluates expressions now resides in our library zip file of commonly used units.  Library file DFFVLIB10 or later is required to recompile SciGrapher13. ) Download current library file (DFFLibV15) required to recompile SciGrapher13.

### Suggestions for Further Explorations

 ArcSin and ArcCos currently return angles in radians even if the "Angles in degrees" box is checked.  Therefore expressions must include a multiply by 180/pi if results in degrees are required.  I think the program  should  insert that factor automatically. Add the ability to read files with sets of X-Y values for plotting (for example plotting results of experiments). Add the ability to specify axis values (so that a margin could be left around the plot for example). Add a title parameter to display at the top of the graph. Play with it.  Search on "interesting graphs" and you'll find a number of sites.  Here's a good site for starters: http://www-groups.dcs.st-and.ac.uk/~history/Curves/Curves.html Even the names are interesting!  (Witch of Agnesi, Pearls of de Sluze, and Freeth's Nephroid, for example). Some of the equations for these are given in polar coordinates.  There are simple conversions to get these into X-Y coordinate system.  If you need help, send me an email or check this Polar-Cartesian Math Topics page.
 Created: October 7, 2000 Modified: May 15, 2018