FC Coding is
One step from 1st Principles to Solution!

Home

CurvFit Icon CurvFit 6.71 ... Problem-Solving Application #1



CurvFit (tm): creates algebraic series
for fitting ones data.

Curve Fit Example Plot


CurvFit (tm) is a nonlinear curve fitting program. Sine, damped Sine, Lorentz, Modified Lorentz, Power (ie Polynomial) and Exponential series are presently available models to match your data. We strongly suggest trying a Lorentz series for data with multiple peaks or valleys. A calculator exists for interpolation &/or extrapolation of given data. CurvFit has proven excellent for hard to fit data. Hard to fit data may take more time -but- it can be done given the right series and parameter values. For start try curve fitting your data with a Lorentz series!

Anyone seeking an Online math tutor?


I specialize in solving Differential Equations (DEs) or systems. DEs may be explicit or implicit. There is an App, ODEcalc, on my website that is free and may be of help solving an ODE for you.

Phil Brubaker tutors Differential Equations and other App usage or modification of my Apps OnLine via Zoom from Roseburg, OR. He has a Bachelor degree in Math with a Minor in Electrical Engineering. Tutoring fee is $10/h. Contact Phil now!

A Lorentz function equals 1 / (1 + a x2). Lorentz function (model 1) fit to dataThis is a shortened form of the infinite series inverse (1 + Σ ai x2i). For practical purposes the shortened Lorentz function is accurate enough. The Lorentz function equals the derivative of the arctangent.

Irregular Heartbeat (AFib) is an example of what maybe detected when curve fitting ones Heartbeat. A Heartbeat may be a asymmetric curve where the fitting series of Lorentz function is a symmetric curve.

A Modified Lorentz function equals (1 + x) / (1 + a x2) = (1 + x) * Lorentz function! Mod. Lorentz function (model 2) fit to dataUse the modified Lorentz when minimizing number of terms in your curve fit series. (Someone suggested that the modified Lorentz is a Bessel function, is it?)

A Heartbeat may be a asymmetric curve where the fitting series of Modified Lorentz function is also asymmetric curve. A Thin-Film-Head in drives is what got us to create Modified Lorentz function by adding x / (1 + a x2) to the Lorentz function.

Fitting Sinusoidal data is simplified by sinusoidal data fit to model 5finding good initial starting values for given sinusoidal data. In order to do this try our SpectrumSolvers program using a simple spectral estimator (e.g. AutoCorr). A good estimator will calculate key frequencies. Use these key frequency values as initial starting values in CurvFit. Without these good initial frequencies values Curve fitting sinusoidal data can be tough.


Curve fitting is an Inverse Problem in some cases. For example, you might have some Ordinary Differential Equations (ODEs) where you know the solution data points but question some parameters in the ODEs. The target would be your data points and parameter values would be what you are trying to determine. Another example would be determining a electrical circuit parameters when you know the (target) circuit response desired. Curve fit data to model is quick and easy in a Calculus (level) programming language. There are many industry Inverse Problems that exist but are not classified as such.

CurvFit is an increased productivity example do to using Error between plotsCalculus programming ... ie. minutes to solve, days or years to understand solution and what it implies (e.g. wrong model, sampling rate error, etc.). CurvFit helps one learn ...

  • Whether math model is good for given data;
  • Convergence report tells whether a reasonable solution; and,
  • How to select new starting initial parameter values, model, sampling rate error, etc.)

CurvFit 6.71 Source code:



CurvFit was made possible do to a Calculus-level computer language. The source code (fit4user.fc) file is included in order to show the Calculus programming simplicity. CurvFit is a free (4 MB) download.

CurvFit 6.71 Output Plots:



(Click Any Image To Enlarge)

Plot of Error between Data & Curve
Error between Data & Curve

Both Data & Model Curve on Plot
Both Data & Model Curve


On this page, I will attempt to guide you through the various routines in order to create a 'picture' for you to understand what's going on. First, the code required and then a sample of output summary.

1. Introduce the Find statement that is used to tweak variables until ones objective(s) are met. The variables may have bounds and constraints that restrick where the selected solver may search for an Optimal solution.

! Find statement is key to tweak variables AND obtain an Optimal ! (i.e., Maximum / Minimum) solutions. FIND y0, a, pw50, t0; IN curve; ! variable list of those to tweak! BY AJAX; TO MATCH error ! objective Minimize / Match error variable!

2. This is a sample of code necessary to solve this problem, but hope it gives you an idea what is going on. Variables to tweak (e.g. y0) MUST always be on the rightside of an equal sign; so the solver can change a value when it wants too. Follow y0 variable throughout the code for seeing what is required. Plus, see y0 and other tweaked variables in output section.

model curve include 'fit.inc' errsum = 0.d0 do 20 i = 1, nPoints y = y0: x = time(i): eq = 0.d0 do 10 j = 1, nTerms call equ( j, x, eq) if(modelX .ne. 7) then y = y + eq else y = y + eq / abs( b(j)) endif 10 continue plotErr(i) = (y - data(i)): error(i) = plotErr(i)**2 20 continue end model equ( j, x, eq) include 'fit.inc' anorm = xnorm / ynorm if( modelx .eq. 1) then ! Lorentzian series xj = x - t0(j) eq = a(j) / (1 + (xj / (pw50(j)/2) )**2) else if( modelx .eq. 2) then ! Mod. Lorentzian series ooo endif end ooo

3. The following block shows a sample of output from the AJAX solver. The first column lists the variables being tweaked; some variables are arrays. The next column, INITIAL, shows initial values for variables that gets things rolling. The next columns are the values for that iteration. This problem required 20 iterations to solve for an optimal solution. Solution time was less than 1-second on a 5-year old PC.

--- AJAX SUMMARY, INVOKED AT FIT[18] FOR MODEL CURVE ---- CONVERGENCE CONDITION AFTER 20 ITERATIONS UNKNOWNS NOT CONVERGED CONSTRAINTS UNSATISFIED MAXIMUM ITERATIONS PERFORMED SPECIFIED CRITERIA UNSATISFIED LOOP NUMBER ......... [INITIAL] 1 2 UNKNOWNS y0 0.000000E+00 4.624447E-03 3.646318E-03 A ( 1) -1.000000E-01 -9.761766E-02 -1.436709E-01 A ( 2) 6.000000E-01 7.034542E-01 7.918994E-01 A ( 3) 1.400000E-01 9.029750E-02 4.250931E-02 PW50 ( 1) 8.000000E-01 1.010919E+00 8.739064E-01 PW50 ( 2) 6.000000E-01 5.116907E-01 5.499282E-01 PW50 ( 3) 8.000000E-01 8.376659E-01 8.564557E-01 T0 ( 1) -4.000000E-01 -5.360891E-01 -5.273902E-01 T0 ( 2) 0.000000E+00 1.576114E-02 1.308791E-02 T0 ( 3) 4.000000E-01 3.783130E-01 3.377194E-01 OBJECTIVE ||G|| 1.517197E+00 5.139380E-01 1.589208E-01 ooo LOOP NUMBER ......... [INITIAL] 19 20 UNKNOWNS y0 0.000000E+00 5.504426E-05 5.504427E-05 A ( 1) -1.000000E-01 -1.950214E-01 -1.950214E-01 A ( 2) 6.000000E-01 8.676625E-01 8.676625E-01 A ( 3) 1.400000E-01 -1.361461E-01 -1.361461E-01 PW50 ( 1) 8.000000E-01 8.722189E-01 8.722189E-01 PW50 ( 2) 6.000000E-01 6.854748E-01 6.854748E-01 PW50 ( 3) 8.000000E-01 6.750204E-01 6.750204E-01 T0 ( 1) -4.000000E-01 -5.477047E-01 -5.477047E-01 T0 ( 2) 0.000000E+00 6.123688E-02 6.123688E-02 T0 ( 3) 4.000000E-01 3.833468E-01 3.833468E-01 OBJECTIVE ||G|| 1.517197E+00 5.251907E-06 5.251907E-06 ! always decreasing ^^^ ? ---END OF LOOP SUMMARY

Are you ready to give it a try? First step is to download our free Calculus (Level) Compiler (i.e., FC-Compiler), install it, and run some Demo (example) files. Next, copy another (Demo) file and save it under another name in your 'user' folder. Edit this file with your equations and (math) models, then save it. Next, try executing it and see how it goes. Enjoy!


CurvFit 6.71
Download (4 MB) Information:


Last Updated: Nov. 27, 2023
First Published: Oct. 13, 1992
License: free software! Edit source and create your own version.
OS: Windows XP or newer
Requirements:Windows + Visual Basic 6.0 RunTime files
Publisher: Optimal Designs Enterprise

CurvFit 6.71
Click on right Link to
Download Now


Description (Click to download) Price
1.
CurvFit: Fits Lorentz, Sine, Damped Sine, etc. series to data. Learn the power of a Lorentz series to fitting real data!
0
All prices in US Dollars


Curve Fitting Problems in Industry:



  • Abnormal Heart Beats or EKGs;
  • Ebola epidemic in West Africa;
  • 1918 influenza pandemic in San Francisco, California;
  • Many Biological systems; and,
  • many many many more!

HTML code for linking to this page:



<a href=""><img style="float:left; width:100px" src="https://goal-driven.net/image/curvfit-icon.png"/> <strong>Nonlinear Curvefitting</strong> </a>: Lorentz Curve Fitting, Sine Curve Fitting, Damped Sinusoid CurveFitting, etc.

Links:



See more on Lorentz Curve Fitting, Sine Curve Fitting, Damped Sinusoid CurveFitting, etc.

Go to top

Problem-Solving Applications include:

CurvFit: a curve fitting program with Lorentzian, Sine, Exponential and Power series are available models to match your data.

Match-n-Freq: a Matched Filter program used to filter signals and slim pulses.

Industry Problem-Solving Descriptions include:

Business Strategies & War Gaming: Buy, Sell, Hold options may be tested for an entire company, individual plant(s), or whole product lines. Imagine an increase in control settings from a 1 or 2 digits (i.e., a guess value) to an 8+ digit accuracy resulting from a Calculus programming calculation!

Pulse Slimming to minimize InterSymbol Interference: via Arbitrary Equalization with Simple LC Structures to reduce errors.

Voice Coil Motor: basically an electromagnetic transducer in which a coil placed in a magnetic pole gap experiences a force proportional to the current passing through the coil.

Electrical Filter Design: find the transfer function's poles & zeros; H(s) = Yout(s) / Yin(s).

Digitized Signal from Magnetic Recording: Magnetic recording of transitions written onto a computer disc drive may produce an isolated pulse as shown.

AC Motor Design: a simulation program for A.C. motor design that was reapplied as a constrained optimization problem with 12 unknown parameters and 7 constraints.

PharmacoKinetics: an open-two- compartment model with first order absorption into elimination from central compartment is presented here.


 
Valid CSS! Calculus (level) Problem-Solving for Engineers & Scientists

Textbooks - Parameter Estimation 4 ODE/PDE - Signal Analysis / Spectral Estimation - Body Plasma - Solar Cell
Increasing Productivity Examples: AC Motor Design - Matched Filters - Pulse Slimming / InterSymbol Interference - Pilot (safe) Ejection - PharmacoKinetics Simulation - Business Strategies & War Gaming - BVP - Implicit Equations