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
 Origin Forum
 Curve fitting with intermediate variables
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

sevny

USA
5 Posts

Posted - 02/22/2013 :  12:13:35 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8.0
Operating System:Win

Hello, I got another question about nonlinear curve fitting.
I am trying to do curve fitting with a set of equations with intermediate variables. Different from the problem before, these equations can be combined and expressed as one equation of y=f(x) form,however, the one equation will be super-complex to write down. Therefore I introduced several intermediates and seperated the equation into several equations (as follows).So in principle, the fitting and simulation should be straightforward. The problem is, when I tried to simulate the curve with a set of parameters, I got no curve appeared on the coordinates. And compiling was no problem. I am not sure if it is because the equations are still too complex for the computer to handle, as when I testing with simpler equations but similar format, it worked well. Please help me check the equations, if it is the reason, how can I solve the problem? Thank you very much for any comment.

void _nlsfTwosite_with_n(
// Fit Parameter(s):
double Vi, double V0, double R0, double M0, double L0, double fi, double K1, double K2,
double H1, double H2, double n1, double n2,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
// Beginning of editable part
double ft1,ft2,p1,q1,r1,p2,q2,r2,L1,L2,x11,x12,x21,x22;
ft1=R0/(R0+x);
ft2=ft1/fi;
p1=1/K1+1/K2+(n1+n2)*M0*ft1-L0*(1-ft1);
q1=(n1/K2+n2/K1)*M0*ft1-(1/K1+1/K2)*L0*(1-ft1)+1/(K1*K2);
r1=-L0*(1-ft1)/(K1*K2);
p2=1/K1+1/K2+(n1+n2)*M0*ft2-L0*(1-ft2);
q2=(n1/K2+n2/K1)*M0*ft2-(1/K1+1/K2)*L0*(1-ft2)+1/(K1*K2);
r2=-L0*(1-ft2)/(K1*K2);
L1=-p1/3-2^(1/3)*(-p1^2+3*q1)/(3*(-2*p1^3+9*p1*q1-27*r1+3*3^0.5*(-(p1*q1)^2+4*q1^3+4*p1^3*r1-18*p1*q1*r1+27*r1^2)^0.5)^(1/3))+(-2*p1^3+9*p1*q1-27*r1+3*3^0.5*(-(p1*q1)^2+4*q1^3+4*p1^3*r1-18*p1*q1*r1+27*r1^2)^0.5)^(1/3)/(3*2^(1/3));
L2=-p2/3-2^(1/3)*(-p2^2+3*q2)/(3*(-2*p2^3+9*p2*q2-27*r2+3*3^0.5*(-(p2*q2)^2+4*q2^3+4*p2^3*r2-18*p2*q2*r2+27*r2^2)^0.5)^(1/3))+(-2*p2^3+9*p2*q2-27*r2+3*3^0.5*(-(p2*q2)^2+4*q2^3+4*p2^3*r1-18*p2*q2*r2+27*r2^2)^0.5)^(1/3)/(3*2^(1/3));
x11=K1*L1/(1+K1*L1);
x12=K1*L2/(1+K1*L2);
x21=K2*L1/(1+K2*L1);
x22=K2*L2/(1+K2*L2);
y=M0*V0*ft1*(n1*(x11-x12)*H1+n2*(x21-x22)*H2)/(Vi*L0);
// End of editable part
}

Edited by - sevny on 02/22/2013 12:33:57 PM

Shirley_GZ

China
Posts

Posted - 02/25/2013 :  03:02:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

When the parameter Vi=1, V0=1, R0=1, M0=1, L0=1, fi=1, K1=1, K2=1, H1=1, H2=1, n1=1, n2=1, and X equals a value (such as 2 or 1.5), the parts of the equations (L1 and L2),
"-(p1*q1)^2+4*q1^3+4*p1^3*r1-18*p1*q1*r1+27*r1^2"
and
"-(p2*q2)^2+4*q2^3+4*p2^3*r2-18*p2*q2*r2+27*r2^2"
are negative. So the intermediate variables L1 and L2 are missing values.

So you got no curve appeared when you tried to simulate the curve.

Originlab Technical Service Team

Edited by - Shirley_GZ on 02/25/2013 03:16:05 AM
Go to Top of Page

sevny

USA
5 Posts

Posted - 02/25/2013 :  10:35:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot for your reply Shirley. I tried to use different values for the parameters, like Vi=6E-6, V0=0.00143, R0=20, M0=1E-5, L0=2E-4, fi=0.995813, K1=1E7, K2=1E14, H1=-10, H2=2, n1=0.5, n2=0.5, which were from the experiments (or close estimations), but still no curve; while reseasonable result was obtained when using Mathematica to solve a series of such equations with these parameter values.


Edited by - sevny on 02/25/2013 10:39:30 AM
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