T O P I C R E V I E W |
MantaManni |
Posted - 08/07/2020 : 06:48:50 AM OriginPro 2020 (64-bit) SR1 9.7.0.188 (Academic)
Hello together,
I am trying to implement a summation equation to OriginPro, but since I am not into programming at all, I guess someone here can help me with this.
So my equation is:

I managed to implement "standard" equations in the format y=mx+b, but since there is a summation occuring I have no clue how to handle with that, I already read that it was somehow possible with origin C, but I don't know how since I have no big mathematical but more a biological background.
Thank you very much in advance |
14 L A T E S T R E P L I E S (Newest First) |
YimingChen |
Posted - 08/31/2020 : 10:03:45 AM Hi,
the equation can't be solved analytically. We can probably give an approximate numerical solution. Please email the fitting function and data to <tech@originlab.com>.
James |
MantaManni |
Posted - 08/28/2020 : 11:20:44 AM Is there a way to define the beta_n positive roots in origin C?
Or better:
Can you give me a origin C script for this simplified equation?

That would be amazing! I really can't figure out how to only get the positive roots for ß_n.
Thank you very much in advance! |
YimingChen |
Posted - 08/25/2020 : 09:16:26 AM You can use Equation Solver app to solve a = b_n*tan(b_n). https://www.originlab.com/FileExchange/details.aspx?fid=393
But the app won't work for equation 7 with summation in it.
James
|
MantaManni |
Posted - 08/25/2020 : 05:22:57 AM Well it didn't work anyway for my data.
but how would you solve this equation in origin c?
 |
YimingChen |
Posted - 08/18/2020 : 4:57:44 PM Two things you might want to double check: 1. Is D same as Dst? 2. Is K same as Ka?
James |
MantaManni |
Posted - 08/17/2020 : 11:53:48 AM Hi all
I have a new equation with 2 sums this time. I tried my best, but can't find the error. My data is not fitting at all.


void _nlsfDiffusionsumbeta( // Fit Parameter(s): double D, double alp, double CSeq, double q, double Dst, double Ka, // Independent Variable(s): double x, // Dependent Variable(s): double& y) { const double m=10; const double n=10; const double l=0.000555; const double g=13100; // Beginning of editable part double bb=0; double cc=0; double K=sqrt(q/D); double Aeq=(CSeq/2*g)*(1-exp(-2*g*l)); for(int ii =0; ii<=n; ii++) { double ga=((2*ii+1)^2*pi^2*D)/(4*l^2); double f=((2*ii+1)*pi)/(2*l); bb = exp(-ga*x)*((-1)^ii*2*g+f*exp(-2*g*l))/((2*ii+1)*(4*q*l^2-D*pi^2*(2*ii+1)^2)*(4*g^2+f^2)) + bb; } for(int jj =0; jj<=m; jj++) { cc = ((((2*jj+1)*pi/2*l)*exp(-2*g*l)+(-1)^jj*2*g)/((4*g^2+((2*jj+1)*pi)/2*l)^2)*(2*jj+1))*exp(-1*(2*jj+1)^2*Dst*x) + cc; } y=(alp*(1-((8*g)/(pi*(1-exp(-2*g*l))))*cc)+(1-alp)*(1-((2*g*(exp(-2*g*l)*(2*g*cos(K*l)-K*sin(Ka*l))-2*g)/(1-exp(-2*g*l))*(4*g^2+K^2)*cos(K*l))*(exp(-q*x))*((32*q*l^2*g)/(pi*(1-exp(-2*g*l)))))*bb))*Aeq // End of editable part }
Maybe it is too obvious to see, and maybe someone can solve the problem :D |
MantaManni |
Posted - 08/11/2020 : 05:30:31 AM Thank you so much! Even though I still don't understand the mathematical background, why now the line starts at the initial value :D
Unfortunately this equation is shown and used in many publications for determining Diffusion coefficients, but none of the reports specified n. So I don't actually know which value for n is "correct" |
YimingChen |
Posted - 08/10/2020 : 3:15:14 PM If I set n to a large value 100 as constant, and put ga, f inside for loop:
double bb=0;
for(int ii =0; ii<=n; ii++)
{
double ga=-D*(2*ii+1)^2*pi^2*x/(4*L^2);
double f=(2*ii+1)*pi/(2*L);
bb = exp(ga)*(f*exp(-2*g*L)+(-1)^ii*(2*g))/((2*ii+1)*(4*g^2+f^2)) + bb;
}
y = (1-(8*g/pi*(1-exp(-2*g*L)))*bb)*Aeq;
The fitted line does start from original point.

James |
YimingChen |
Posted - 08/10/2020 : 11:47:23 AM Also in your oc code, ga and f should be defined inside for loop, as both has n that needs to be iterated.
James |
YimingChen |
Posted - 08/10/2020 : 09:56:38 AM You can force the fitted line go through (0,0) point. You can set a large weight for the data point. See this page: https://www.originlab.com/doc/Tutorials/Fitting-FixThroughPoint#Use_weighting
James
|
MantaManni |
Posted - 08/10/2020 : 07:57:57 AM So I finally managed to get the equation run.
It looks like this:
double bb=0; double ga=-D*(2*n+1)^2*pi^2*x/(4*L^2); double f=(2*n+1)*pi/(2*L); for(int ii =0; ii<=n; ii++) { if(floor(n)==ii) bb = exp(ga)*(f*exp(-2*g*L)+(-1)^n*(2*g))/((2*n+1)*(4*g^2+f^2)) + bb; else bb = exp(ga)*(f*exp(-2*g*L)+(-1)^ii*(2*g))/((2*ii+1)*(4*g^2+f^2)) + bb; } y = (1-(8*g/pi*(1-exp(-2*g*L)))*bb)*Aeq;
Here are my fitted data:

Unfortunately the fit always starts at y<1 which I don't expect since I want to start it at y=0
Do you have any guesses to get a better fit at all? |
YimingChen |
Posted - 08/07/2020 : 3:45:11 PM Hi,
Would you mind sending your data and parameter guesses to <tech@originlab.com> that we can check further? Thank you.
James |
YimingChen |
Posted - 08/07/2020 : 1:50:37 PM Please also check this tutorial page on fitting summation of infinite series. You will need to set a precision value. https://www.originlab.com/doc/Tutorials/Fitting-Summation
James |
Chris D |
Posted - 08/07/2020 : 10:22:05 AM You may refer to this forum post for some detailed information and insight into the subject: https://my.originlab.com/forum/topic.asp?TOPIC_ID=28114
Thanks, Chris Drozdowski Originlab Technical Support
|