The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Declaring partial derives in NLSF
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

gbellidograins

Canada
Posts

Posted - 04/08/2008 :  4:29:04 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System: Windows XP

I have successfully defined my own fitting function based on the information contained in the NLSF Wizard of Origin 7.5. However, the time ORIGIN takes to perform the iterative analysis is unduly long. I read in the HELP menu that this can be solved by declaring the partial derivatives of my fitting function with respect to all fitting parameters. Since I am new to the NLSF programming language I don't know how (and where)to declare such partial derivatives (I do have them). When I added the equations after I declared my fitting function in C CODE builder, the fitting function program could not be compiled. This info is not in the HELP menu.

Thank you.

Echo_Chu

China
Posts

Posted - 04/09/2008 :  05:46:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Please look at following steps as an example
1. Open NLSF dialog
2. Select Function:New
3. Change Number of Parameters as 3. Select Derivative check box
4. Type following equation and derivative definition in Functon Definition Text box. Please note that each definition should be seperated by semicolon

y = P1 + P2 * x + exp(P3 * x); //User-defined equation
dy_P1 = 1; //Derivative definition of P1
dy_P2 = x; //Derivative definition of P2
dy_P3 = x * exp(P3 * x);//Derivative definition of P3;


5. Click Edit in Code Builder button to make sure the code and be successfully compiled in code builder
6. Save the Function.

If your new derivative equation fail to compile in Step5. It might because equation is not correct in OC format. Would you mind to show us your codes in Functon Definition Text box.


Echo
OriginLab Corp


Edited by - Echo_Chu on 04/09/2008 05:53:55 AM
Go to Top of Page

gbellidograins

Canada
Posts

Posted - 04/09/2008 :  12:58:10 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Echo,

Thank you so much for the reply. Your recommendation was actually useful. I must confess, though, that the solution is not trivial when one uses two or more functions to describe an experimental curve (i.e., when one uses the conditional "If" and "else"). In such cases the program will only run if each of the declared functions and its corresponding derivatives are declared between brackets. For instance, for two functions similar in form to the one you suggested an analogous situation to the one I encountered will be solved as follows:
if ( x < P1)
{
y = P1 + P2 * x + exp(P3 * x);
dy_P1 = 1;
dy_P2 = x;
dy_P3 = x * exp(P3 * x);
}
else
{
y = P1 - P2 * x - exp(P3 * x);
dy_P1 = 1;
dy_P2 = -x;
dy_P3 = -x * exp(P3 * x);
};

Hope this helps other people out there with a similar problem.

gbellidograins
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000