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
 All Forums
 Origin Forum
 Origin Forum
 How to plot the multiplicity function?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
titties Posted - 09/03/2005 : 2:03:34 PM
Origin Version (Select Help-->About Origin): 7.5
Operating System: XP home

Hi, how do i plot the multiplicity function with origin?

It looks as follows:

g(N,s)=N!/((0.5N+s)!*(0.5N-s)!) for N=10 and ! is factorial u know; for example 4!=4*3*2*1=24

i could really use the help..

Thx

From SpIRit
10   L A T E S T    R E P L I E S    (Newest First)
titties Posted - 09/09/2005 : 03:02:47 AM
quote:
Just remember that x! = nag_gamma( x+1 ) no matter what x is. I hope you're aware that you don't have to name your function multiplicity_function. You can have several different functions in your file...


ok, I'll keep that in mind

and to call the function in the col(b), i just use:

Functionname(N,col(A)[i]) 
?
Mike Buess Posted - 09/08/2005 : 5:25:30 PM
I used n1 and n2 just to shorten the expression for the return value. You could do without n1 in your latest function...

double multiplicity_function(int N, int n)
{
double n2 = N-n;
return (nag_gamma( N + 1 )*2^n) / (nag_gamma( n + 1 ) * nag_gamma( n2 + 1));
}

Just remember that x! = nag_gamma( x+1 ) no matter what x is. I hope you're aware that you don't have to name your function multiplicity_function. You can have several different functions in your file...

double multiplicity_func1(int N, int n)
{
}

double multiplicity_func2(int N, int n)
{
}

etc. You can choose nearly any names you like.

Mike Buess
Origin WebRing Member
titties Posted - 09/08/2005 : 5:11:10 PM
oh yes.. it had to be a capital N, thx.. my bad... it works now..

so everytime i have to make a binomialcoefficient, i shall make two "double" with n1 and n2 defined to whatever I want, and then in the return value i have to make the expression with N, n1, n2 etc. in a nag_gamma added to 1?
Mike Buess Posted - 09/08/2005 : 5:02:06 PM
This return value fits your formula better...

(nag_gamma( N + 1 )*2^n) / (nag_gamma( n1 + 1 ) * nag_gamma( n2 + 1))

Mike Buess
Origin WebRing Member
titties Posted - 09/08/2005 : 4:42:03 PM
ok, now i have a new function:

g(N,n)=((2^n)*N!)/(n!*(N-n)!)

would this be correct in the code builder?

 double multiplicity_function(int N, int n) 
{
double n1 = n;
double n2 = N-n;
return (nag_gamma( n + 1 )*2^n) / (nag_gamma( n1 + 1 ) * nag_gamma( n2 + 1));
}


and then in the col(b)=box:
 multiplicity_function(15,col(A)[i]) 


if i want N to be 15 ofcourse, and n to be the variable (from 0 to 15)

cause it looks really weird, i dont get the correct data.... lol.
it is actually the upper of the two graphs..

Edited by - titties on 09/08/2005 4:50:58 PM
Mike Buess Posted - 09/08/2005 : 3:44:47 PM
Double-click on the curve and select Connect: Spline or B-spline.

Mike Buess
Origin WebRing Member
titties Posted - 09/08/2005 : 2:12:26 PM
thank you so much Mike. It realy helped.. I appriciate it..

by the way, is there anyway to smoothen out the graph so it is coninueous? like this done with maple:


instead of this done with origin:


You can see it is edgy cause it is taken the points -5,-4..5 and makes a straight line between them, it should be like the top graph.. Note that the two grafs are not a plot of the same funcktion; it was just to show the example. The black burrish stuff on the bottom graph is just a result of high compression

thx

Edited by - titties on 09/08/2005 3:16:00 PM
Mike Buess Posted - 09/04/2005 : 2:39:06 PM
1> Open CodeBuilder and select File > New.
2> Select 'C File' on the list at the left.
3> Enter a file name such as Muliplicity.
4> Check the 'Add to Workspace' and 'Fill with default contents' options.
5> Select your OriginC folder as location.
6> Click OK.
7> Your new file should now be showing in CodeBuilder. Go to the bottom, enter a new line and paste this function at that location...

double multiplicity_function(int n, int s)
{
double n1 = 0.5*n + s;
double n2 = 0.5*n - s;
return nag_gamma( n + 1 ) / (nag_gamma( n1 + 1 ) * nag_gamma( n2 + 1));
}

8> Select Tools > Build and your new function is ready to use.
9> Close CodeBulder and open a new Origin worksheet. I assume you want to plot the function against integer s>=0 so right-click on column A, select Set Column Values, enter i-1 in the col(A)= box and click OK. That will fill column A with the values 0, 1, 2, etc.
10> Right-click on column B, select Set Column Values again and enter the following expression in the col(B)= box...

multiplicity_function(10,col(A)[i])

Click OK to fill column B with the values you want. Note that col B will contain no values for rows>6 because your function is undefined for N=10 and s>5.
11> Create a graph by selecting column B and choosing a plot type (probably Scatter) on the Plot menu.

The last 3 steps can be incorporated into the OriginC function which might be better if you need plots for a series of N values and not just N=10. I can suggest a function if you tell me how you would like the results plotted. (Same graph or different graphs, and so on.)

...This function will plot the multiplicity curves for a range of N from N1 to N2. Just copy the function to your Multiplicity.c file (do not replace the existing function) and rebuild (Tools > Build). Then close CodeBuilder, open the script window and execute the function by typing this...

multiplicity_graph N1 N2 <press Enter>

For example, to plot the values for N=1 through 20 enter multiplicity_graph 1 20. To plot only N=10 enter multiplicity_graph 10 10.
#Start of plotting function
void multiplicity_graph(int N1 = 1, int N2 = 30)
{
int i,j,N3,N4,NN = N2 - N1 + 1;
Worksheet wks;
wks.Create("Origin.otw");
wks.DeleteCol(1);
Dataset dd;
for(i=1;i<=NN;i++)
{
N3 = N1 + i - 1;
wks.AddCol("B" + N3);
wks.Columns(i).SetLabel("N=" + N3);
dd.Attach(wks,i);
N4 = N3 / 2;
if( 2*N4 < N3 )
N4++;
dd.SetSize(N4 + 1);
for(j=0;j<=N4;j++)
dd[j] = multiplicity_function(N3,j);
}
dd.Attach(wks,0);
dd.Data(0,N4);
GraphPage gp;
gp.Create("Origin.otp");
GraphLayer gl(gp.GetName());
for(i=1;i<=NN;i++)
gl.AddPlot(wks.GetCurve(i), IDM_PLOT_LINESYMB);
gl.Rescale();
gl.GroupPlots(0);
gl.LT_execute("xb.text$=s");
gl.LT_execute("legend");
}


Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 09/04/2005 4:39:45 PM
titties Posted - 09/04/2005 : 1:45:49 PM
Thx for your reply Mike

Do I have to do actual programming? I really cant figure out, where to put the
quote:
double multiplicity_function(int n, int s)
{
double n1 = 0.5*n + s;
double n2 = 0.5*n - s;
return nag_gamma( n + 1 ) / (nag_gamma( n1 + 1 ) * nag_gamma( n2 + 1));
}
=> g(10,2) = multiplicity_function(10,2)

I have tried in the scipt and the worksheet script window? but no plots.. lol



Maple is a bit easier, though much more ugly graphs.

thx
Mike Buess Posted - 09/03/2005 : 3:12:20 PM
This topic will give you two or three methods for computing the factorial function...
http://www.originlab.com/forum/topic.asp?TOPIC_ID=3617

See also the Compute Factorial example at http://www.originlab.com/index.aspx?s=8&lm=243

...Probably easiest to modify the function in the second link like this
double multiplicity_function(int n, int s)
{
double n1 = 0.5*n + s;
double n2 = 0.5*n - s;
return nag_gamma( n + 1 ) / (nag_gamma( n1 + 1 ) * nag_gamma( n2 + 1));
}
=> g(10,2) = multiplicity_function(10,2)

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 09/04/2005 11:52:05 AM

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000