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
 LabTalk Forum
 Progam an integrale fonction.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

hancok

Norway
Posts

Posted - 11/25/2004 :  3:28:14 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.0
Operating System: Windows NT 2000

Hi,
I am trying to integrate (non graphically) the function by programming:
F(x)= x^2 exp (-1/x) from x=0.1 to 3.5

I have found the command "integrate" but when I write the following lines nothing happens...:

for (i=1; i<=31; i ++)
{
data1_C[i]= data1_B[i]^2*exp(-1/data1_B[i]);
};
integrate -r data1_C data1_B;

I would like to have the result of the integration in the column data1_D for example.
Is it possible?
thanks a lot for your helps.
Best regards,
Marc

Mike Buess

USA
3037 Posts

Posted - 11/25/2004 :  5:03:12 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Marc,

Use this after the integate command...

Data1_D=_integ_Area;

Mike Buess
Origin WebRing Member
Go to Top of Page

hancok

Norway
Posts

Posted - 11/26/2004 :  04:23:45 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Mike!
Go to Top of Page

hancok

Norway
Posts

Posted - 11/26/2004 :  06:52:15 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi again,
it seems I have now a strange result of the integrale:
Data1_a(x)
1
6
11
16
21
26
31
36
41
46
51
56
61
66
71
76
81
86
91
96
101


Data1_b(y) which is the result of the function I want to integrate.
5,97531E-56
2,15E-12
4,75426E-8
2,71862E-6
2,63356E-5
1,16839E-4
3,41206E-4
7,73934E-4
0,00149
0,00255
0,00401
0,00592
0,00833
0,01126
0,01475
0,01882
0,02349
0,02878
0,0347
0,04127
0,0485


if I write the commands:
integ data1_b;
if (mks1 >= 0)
{
i1 = mks1;
i2 = mks2;
}
else
{
get data1_a -b i1;
get data1_a -e i2;
}
type -a "Integ of data1_b from zero";
type "i = $(i1) --> $(i2)";
type "x = $(integ.x1) --> $(integ.x2)";
type "Area\tPeak at\tWidth\tHeight";
type "$(integ.area)\t$(integ.x0)\t$(integ.dx)\t$(integ.y0)";


I get in a script window:

Integ of data1_b from zero
i = 1 --> 21
x = 1 --> 101
Area Peak at Width Height
1,10432 101 15 0,0485


But if I write the commands:
integrate -r Data1_b Data1_a;
Data1_c=_integ_area;


then I get:
Data1_C(y)
0
3,5
12
25,5
44
67,5
96
129,5
168
211,5
260
313,5
372
435,5
504
577,49999
655,99999
739,49998
827,99996
921,49994
1019,99992


Here, the values are way too high. I guess each value in data1_c that I get should represent the area of a small trapeze(or rectangle) and the summ of these values should give the total aera under the curve data1_b(y) which is 1,10432 according the first calculation.
However, if I add all the values from data1_c I will get a much bigger number than 1,10432.
So I guess I am doing something wrong somewhere because to me these two ways of programming should give the same results....?

Hope you guys can help me..
thanks a lot.
Marc
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/26/2004 :  07:57:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Marc,

Sorry, I'm a bit confused. Why are you using the X column as an integration baseline? Also, the integral is the final value of Data1_C, or integ.area, not the sum of Data1_C.

Mike Buess
Origin WebRing Member
Go to Top of Page

hancok

Norway
Posts

Posted - 11/26/2004 :  08:38:28 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Actually, I thought the integration baseline was the values over which I integrate the function
f(x)=x^2*exp(-1/x).

Since I want to integrate f(x) from x=1(=Data1_a[1]) to x=101(=data1_a[21]) I thought the X column should be the integration baseline...
The column Data1_b is the result of f(x) for the values x = data1_a .

So I guess I misunderstood the used of the intergration baseline...
So what values for the integration baseline should I used then?
Marc
Go to Top of Page

hancok

Norway
Posts

Posted - 11/26/2004 :  09:07:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
OK
I just wrote:
integrate data1_b;
and it worked...
So that was the intergration baseline I put which was my problem...
thanks !
Marc
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/26/2004 :  09:52:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Marc,

The integration baseline is a dataset that needs to be subtracted (prior to integration) from the dataset you want to integrate. Typically it represents an instrumental artifact such as a DC, sloping or rolling curve riding on the "true" curve. The integration limits are taken directly from the X column... from x1=Data1_a[1] to xN=Data1_a[N].

...You can restrict the integration region to a subset of the full range, say rows 8 through 16, like this...

integrate data1_b -b 8 -e 16;

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/26/2004 09:57:53 AM
Go to Top of Page

Dizzy

Germany
Posts

Posted - 11/30/2004 :  12:02:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
I would like to know how to get the area of an integrated data (value of the complete area of selected data to integrate) into a column like parameters from fitting with gauss or similar, like it is in the folowing script:

for (test=2; test<=%(data2,@#); test++){
%A=data2!wks.col$(test).label$;
Result2_a[test-1]="%A";
nlsf.begin();
nlsf.func$="gauss";
nlsf.setDepend(y,%(data2,test));
nlsf.x$="data2_A";
nlsf.constr$="";
nlsf.p1=100;
nlsf.p2=3.7;
nlsf.p3=0.02;
nlsf.p4=780;
nlsf.tolerance=0;
nlsf.fit(15);
Result2_b[test-1]=nlsf.p4;
Result2_c[test-1]=nlsf.p3;
nlsf.end();
}

Here I get a column with the values of the desired parameter. But with a loop above and integrate command I have no idea to manage that. The problem is to get only one value of integration not the whole function. When I try to use data1_b=integ.area I get the same value listed through out the entire column.

Any simple things to do for solving the problem?
Thanks - this forum helps me a lot!!

Tom
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/30/2004 :  2:11:14 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If you want to put the area in separate column, say Result2_d[test-1], you can do this...

for (test=2; test<=%(data2,@#); test++){
%A=data2!wks.col$(test).label$;
Result2_a[test-1]="%A";
nlsf.begin();
nlsf.func$="gauss";
//nlsf.setDepend(y,%(data2,test));
nlsf.fitdata$=%(data2,test); // I recommend this... simpler than above
nlsf.x$="data2_A";
nlsf.constr$="";
nlsf.p1=100;
nlsf.p2=3.7;
nlsf.p3=0.02;
nlsf.p4=780;
nlsf.tolerance=0;
nlsf.fit(15);
Result2_b[test-1]=nlsf.p4;
Result2_c[test-1]=nlsf.p3;
nlsf.end();
integ -a -q %(data2,test); // integrate without shading or creating _integ_area dataset
Result2_d[test-1]=integ.area; // integral area
}

Of course you need to create col D in the Result2 wks before you try this.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/30/2004 2:13:44 PM
Go to Top of Page

Dizzy

Germany
Posts

Posted - 12/01/2004 :  07:47:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Mike!
Thanks for helping me - it works fine now.

Have a lovely advent season...

Tom
tomgm@hotmail.com
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