COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Trapezium rule #2 418513

• Email
• Follow

```Hi,

I've been working on this problem for quite a while but really not sure whether my approach is correct. I'm looking to create an mfile to perform to an integral using the trapezoidal rule where the strip length will increase geometrically such that

(delta) xn = r^(n-1) * (delta) x1
where r could be the constant and (delta) xn is the width of the nth strip

This is the code i've got so far:

r=input('Input r');
a=(100.*(1-r))/(1-(r.^100));
b=1;
T=0;
for n=1:100
x=(r.^(n-1)).*a;
A=((1/b)+(1/(b+x))).*x.*0.5;
T=T+A;
b=b+x;
end
disp(T)

NB I've used the sum of the geometric progression to calculate (delta) x1

To me it seems a bit simple but is this as effective. Could there be a better method? or perhaps a function that does the job quicker?

Any advice or help would be greatly appreciated!

Thank you!
```
 0
Reply Azara 1/13/2011 3:51:04 PM

See related articles to this posting

```"Azara " <azara.2009@yahoo.co.uk> wrote in message <ign718\$vi\$1@fred.mathworks.com>...
> Hi,
>
> I've been working on this problem for quite a while but really not sure whether my approach is correct. I'm looking to create an mfile to perform to an integral using the trapezoidal rule where the strip length will increase geometrically such that
>
> (delta) xn = r^(n-1) * (delta) x1
> where r could be the constant and (delta) xn is the width of the nth strip
>
> This is the code i've got so far:
>
> r=input('Input r');
> a=(100.*(1-r))/(1-(r.^100));
> b=1;
> T=0;
> for n=1:100
>     x=(r.^(n-1)).*a;
>     A=((1/b)+(1/(b+x))).*x.*0.5;
>     T=T+A;
>     b=b+x;
> end
> disp(T)
>
> NB I've used the sum of the geometric progression to calculate (delta) x1
>
> To me it seems a bit simple but is this as effective. Could there be a better method? or perhaps a function that does the job quicker?
>
> Any advice or help would be greatly appreciated!
>
> Thank you!

The trapezoidal rule is already implemented in matlab

doc trapz
doc cumtrapz
```
 0
Reply Paulo 1/13/2011 4:18:05 PM

1 Replies
427 Views

Similar Articles

12/5/2013 8:26:56 AM
page loaded in 47307 ms. (0)

 Reply:

Similar Artilces:

Standard verses extended rule
I am using a C3640 12.3(11)t to route 130 PC's out to corporate WAN. NAT uses standard rule. Would I benifit by removing standard rule and NAT using extended rule, and what would these benefits be. Router is equipped with and is running Firewall feature set. IPS is active. I am not sure how standard vs extended rules effect firewall or overall routing performance. Router currently averages 15% CPU and Mem usage averages 35%. Thanks in advance. In article <%A6Rd.920\$OU1.61@newssvr21.news.prodigy.com>, stormrunner'_removethis'@comcast.net says... > I am using a C3640 12.3(11)t to route 130 PC's out to corporate WAN. NAT > uses standard rule. Would I benifit by removing standard rule and NAT using > extended rule, and what would these benefits be. Router is equipped with and > is running Firewall feature set. IPS is active. I am not sure how standard > vs extended rules effect firewall or overall routing performance. Router > currently averages 15% CPU and Mem usage averages 35%. > Let's say like this: if you don't know if you would benifit from extended rule versus standard, then you probably don't need

90/10 rule... source?
Hello :) I am looking for a (the) original paper on the 90/10 rule of program execution. So far I found this reference @ARTICLE{Knuth71, AUTHOR = "Donald E. Knuth", TITLE = "An Empirical Study of {FORTRAN} Programs", JOURNAL = "Software---Practice and Experience", VOLUME = 1, PAGES = {105--133}, YEAR = 1971 } but I couldn't get my hands on a copy of that paper. Is it the one I am looking for? Cheers, Jens [That's probably the one you want. It was the first to use the term program profiling, and it was big... looking for a (the) original paper on the 90/10 rule of program >execution. So far I found this reference > >@ARTICLE{Knuth71, > AUTHOR = "Donald E. Knuth", > TITLE = "An Empirical Study of {FORTRAN} Programs", > JOURNAL = "Software---Practice and Experience", > VOLUME = 1, > PAGES = {105--133}, > YEAR = 1971 >} > >but I couldn't get my hands on a copy of that paper. Is it the one I >am looking for? > >[That's probably the one you want. It was the first to use the term >program

flex default rule
Hi all, here's what I can't quite figure out: Rule: multi-line text values are enclosed in "\n;" Relevant flex specs: NL (\r|\n|\r\n) WS [ \t\r\n\b\012] SEMI ^; %x YYSEMI %option c++ %debug %% <INITIAL>{SEMI} { cerr "Entering YYSEMI" << endl; BEGIN YYSEMI; } <YYSEMI>{SEMI} { cout << buf.c_str() << endl; // buf is an std::string BEGIN INITIAL; } <INITIAL>[^{SEMI}] { cerr << "in YYSEMI, token" << yytext << endl; buf.append( yytext ); } Input: ; Solution Structure and Backbone Dynamics of Component IV Glycera dibranchiata Monomeric Hemoglobin-CO ; Final output (from second rule): olution tructure and Backbone Dynamics of Component V Glycera dibranchiata onomeric Hemoglobin-CO Trace output: --accepting rule at line 114(";") Entering YYSEMI --accepting rule at line 189(" ") in YYSEMI, token: --(end of buffer or a NUL) --accepting default rule ("S") --(end of buffer or a NUL) S--accepting rule at line 189("o") in YYSEMI, token: o .... --accepting rule at line 189("n") in YYSEMI, token: n --(end of buffer or a NUL

[9fans] plumber rule for WikiWords
Moin, I use the following plumbing rule to "emulate" wiki like functions in acme: type is text data matches '([A-Z]+[a-z]+[A-Z]+[a-z]+)*\$' data set wiki/\$0.txt plumb to edit Most of the time it works but if I use a LongWikiWord it opens WikiWord.txt instead of LongWikiWord.txt. It depends on where I click on the word. If I click on Long nothing happens and if I click on Wiki it opens WikiWord. Is this a problem of the rule or a "feature"? I use acme from Plan 9 ports. Many thanks Matthias > I use the following plumbing rule to "emulate" wiki like functions in > acme: > > type is text > data matches '([A-Z]+[a-z]+[A-Z]+[a-z]+)*\$' > data set wiki/\$0.txt > plumb to edit > > Most of the time it works but if I use a LongWikiWord it opens > WikiWord.txt instead of LongWikiWord.txt. It depends on where I click > on the word. If I click on Long nothing happens and if I click on Wiki > it opens WikiWord. > > Is this a problem of the rule or a "feature"? I use acme from Plan 9 > ports. i don't think your rule matches LongWikiWord because the rule will only match words

Weird Mail rule problem
I've got some rules to sort mail into various folders. One rule has look for something in the To field, same thing in the From field and if Any criteria is met then it moves the email to a folder and plays a particular sound. In the past, this rule only worked automatically when receiving email. For Sent mail, I always had to manually apply the rule. It seems like since the last Update (10.5.2), something very strange is happening. On receiving the an email that matches, the email is moved to the folder, but the sound is not played. When I send email that matches, it plays... when I Apply > Rules manually. > > Has anyone else seen this sort of behavior? You are not alone. Leopard seems unable to play rule-based sounds for incoming mail. My "incoming" sounds usually play the next time I send mail out. -- schram@webenet.net is a filtered spam magnet. Email replies may get lost. Try <http://public.xdi.org/=chris.schram> instead. -- Posted via a free Usenet account from http://www.teranews.com In article <pan.2008.02.20.06.27.38.611384@webenet.net>, Chris Schram <schram@webenet.net> wrote: > On Tue, 19 Feb 2008 22:14

Hilbert Transform multiplication rule
Bedrosian's derivation of the Hilbert product rule, H[f(x)g(x)]=f(x)H[g(x)], where g is often the high frequency carrier cos(w_0t+P), stipulates that either F(w) and G(w) don't overlap, or f(x) and g(x) are both analytic. A few questions: A) does non-overlapping mean that F(w) and G(w) don't overlap, or that F(w)*G(w) goes to zero at some point in between the two spectra (like a Nyquist-type arrangement? B) What happens when they overlap? Is the result of a Hilbert-based demodulation technique for overlapping F(w) and G(w) a simple aliasing? C) (this one might be tough) The original Bedrosian paper refers to a more general form than the r(t)cos(w_0t +P) type modulation, which is r(t)cos(w_0t+P(t)), where the phase offset is a function of time (derived by Kelly). Bedrosian points out that the Hilbert product rule for a carrier with constant phase offset requires non-overlapping signals or two analytic signals, while the less specific form requires no spectral restriction. This suggests that the less specific form is not subject to aliasing. Is this true? What does this mean practically? Does it mean that if you have access to the actual carrier

composite simpson rule
Find the largest value of h, rounded to 1 decimal, for which the value of the following integral can be determined inside a tolerance of 10 by using the Composite Simpson Rule. Make use of a table and portray the iterates of at least 5 different h-values.

Footnote rule help
Dear All, In my two column layout, I need the footnote rule should be upto columnwidth for first page alone and the remaining pages it should be 10mm. How can I achive it? Thanks and Regards, Saravanan,M. On Dec 2, 6:13=A0pm, TeX_Saravanan <Saravanan_Typeset...@yahoo.co.in> wrote: > Dear All, > > In my two column layout, I need the footnote rule should be upto > columnwidth for first page alone and the remaining pages it should be > 10mm. How can I achive it? > > Thanks and Regards, > Saravanan,M. Dear All, I solved my problem. Thanks, Saravanan,M. On Dec 3, 2:47=A0am, TeX_Saravanan <Saravanan_Typeset...@yahoo.co.in> wrote: > I solved my problem. > It would be much appreciated if you could share your secret; perhaps others can benefit from it and/or suggest better solution(s). Regards, Tariq

Bayes' Decision Rule
I'm implementing Bayes Decision Rule. For this purpose I'm using Multivariate Normal Distribution. But, in some cases Covariance matrix becomes singular (there isn't inverse Covariance matrix). What is the solution? What can I do? (I think that, i can add a very little to a value which is in the same lines in the matrix. Or changing the distribution. But, what is the true answer? I don't know). Please help. Murat Aykut. Murat Aykut wrote: > I'm implementing Bayes Decision Rule. That sounds great because it gives the impression that you are using the optimal Classifier: The Bayes Classifier. However, the Bayes Classifier is based on a priori knowledge of unit-sum class-conditional priors (Pi, i=1,2...c) and unit-area class-conditional probability density functions (p(x|i),i=1,2...c). Given those, the unit-sum input-conditional class posterior probability functions (P(i|x),i=1,2...c) can be obtained from Bayes Rule p(x,i) = P(i|x)*p(x) = p(x|i)*Pi via P(i|x) = p(x|i)*Pi/p(x) where p(x,i) is the joint probability density function and p(x) is the mixture probability density function p(x) = SUM(i=1,c){ p(x|i)*Pi }. Then, given the input x, the Bayes

PRM (Predictive Rule Mining)
Hi, I finally get along with FOIL. Still, I heard that PRM (Predictive Rule Mining) should have superior performance. Does someone know where to download this? I know where a Java version is available but I would expect the performance of a Java program to be rather poor. Thus, I am looking for a C-version. Best regards, Tim [ comp.ai is moderated ... your article may take a while to appear. ] On May 15, 3:53 am, Tim vor der Brueck <nos...@nospam.de> wrote: > I know where a Java version is available but I would expect the > performance of a Java program to be rather poor. Thus, I am looking for > a C-version. That assumption is unfounded. Java programs still have a moderate penalty in terms of memory usage, but generally have little or no penalty in terms of run-time. Take for example Jruby, the Java implementation of Ruby. It is generally *faster* than the C implementation. [ comp.ai is moderated ... your article may take a while to appear. ] Ted Dunning <ted.dunning@gmail.com> writes: >That assumption is unfounded. Java programs still have a moderate >penalty in terms of memory usage, but generally have little or no >penalty in terms