# Define A Rectangular Signal

### #1

Posted 19 October 2005 - 12:15 AM

i define a rectangular signal rect(x) = piecewise(-1/2<x<1/2,1,0,0).

The problem is that if i try to Integrate rect(x) from -inf to +inf or -T to +T the calculator calc rect(x)=1 FOR ANY x.

Ex.

integrate rect(x) from -10 to +10 :

real rect area:

1

Classpad300 solution

20

Sorry for my English.

Thanks

Alvise

### #2

Posted 19 October 2005 - 09:53 AM

You see, there is a doubt about this issue that even Saltire employees cannot solve. Sorry for this off-topic, but we are really interested. About the bug, wait till the next year for the new OS version 3! Thank you! Bye!

### #3

Posted 19 October 2005 - 05:05 PM

On my ClassPad I get 0... .

And in the Graph application, I can't integrate it.

To know if your ClassPad has an internal buzzer, use the addin Chip8. Tap 1=>Chip8Sys\ChipBzz in Main, then run Chip8 and tap [Options][Sound On], and try some games.

### #4

Posted 19 October 2005 - 07:20 PM

### #5

Posted 21 October 2005 - 12:55 AM

I get 0 in OS 2.20. This is obviously erroneous, but, in fact, I'm not surprised: ClassPad uses numerical integration to compute this integral, because the CAS cannot compute the corresponding indefinite integral. Now, I suspect that ClassPad's built-in numerical integration is based on some kind of the Romberg's method, which is very accurate, but it isi define a rectangular signal rect(x) = piecewise(-1/2<x<1/2,1,0,0).

The problem is that if i try to Integrate rect(x) from -inf to +inf or -T to +T the calculator calc rect(x)=1 FOR ANY x.

*not*suitable for signal functions. A simpler numerical method, such as adaptive trapezoidal, is prefferable for such functions, but ClassPad's CAS is not a Numerical Analysis tool, and has only a standard numerical integration method. However, you can compute this integral very easily by using my Numerical Analysis library "LuaNumAn", written in the Lua programming language. In the upcoming version of LuaNumAn, adaptive trapezoidal integration is available as a function called TrapAdapt. Using this function, the integral can be computed very easily. Here are some screenshots:

You can see the program that computes the integral from -20 to 20, then plots the signal (thin line) together with the integral of rect(u) from u=-1.5 to u=x, for all x within the range [-1.5,1.5] (thick line). Using LuaNumAn, the integral can be computed accurately, and in no time .

Indeed. However, the built-in "Graph" application can be used to produce the above graph, but it is extremely slow: Try to plot the function integral(piecewise(-0.5<=u<=0.5,1,0,0),u,-1.5,x,1.5) in the "Graph" application, if you dare: ClassPad plots it correctly, but it needs more than one hour! In CPLua, and using LuaNumAn, the graph needs only a few seconds to be plotted, although it computes the integral for many upper limits, in order to plot the thick line.And in the Graph application, I can't integrate it.

Hmm, don't be so sure. Of course, getting 0 as a result is a bug, but this doesn't mean that ClassPad cannot be used for signals exercises. Just switch to CPLua, then write a program for this on your own, or simply use my LuaNumAn library .Strange, I got 0 too. Now I know I shouldn't use CP to solve my signals exercices...

### #6

Posted 21 October 2005 - 11:49 AM

### #7

Posted 21 October 2005 - 12:09 PM

You are welcome. Note that you need the upcoming version of LuaNumAn, which includes adaptive trapezoidal integration. The current version, 1.30, only supports Romberg integration. However, you can easily solve the problem with Romberg integration, but be warned that the Romberg method is very fast only for sufficiently smooth functions, and your rectangular signal is not a smooth function. The solution I gave in my previous post is based on adaptive trapezoidal method, which is ideal for this case. I'm planning to release the new version of LuaNumAn within the next week.Thank you. I will try.

### #8

Posted 21 October 2005 - 03:23 PM

### #9

Posted 21 October 2005 - 05:17 PM

Alvise > CPLua is still in development, you can only work with temporary beta versions so there are currently no available downloads on any website But look in the CPLua subforum, there is a link to download the last beta

### #10

Posted 21 October 2005 - 05:44 PM

### #11

Posted 21 October 2005 - 06:09 PM

You still need the manager to send or receive the mcs files though.

### #12

Posted 21 October 2005 - 06:22 PM

### #13

Posted 21 October 2005 - 07:42 PM

### #14

Posted 23 October 2005 - 01:13 PM

Advertising was not my true intention (but you probably know that). I just wanted to show that you can make ClassPad much more useful by using CPLua Numerical Analysis programs. But if that forces you to release an official version sooner than you are planning, I'm happy for that .Aww, because of PAP's skills in making advertising for CPLua I am really forced to provide an official version quite soon

Indeed. I thought that adding just a rather elementary numerical method, such as adaptive trapezoidal, would not be a good reason to release a new version of LuaNumAn. In fact, I'm waiting for the "mat" package to be added in CPLua, to make all necessary conversions in all matrix-related LuaNumAn libraries, then release the new version. But if someone wants adaptive trapezoidal here and now, I can release LuaNumAn 1.31.Actually PAP said that it would be available in the next version

### #15

Posted 24 October 2005 - 01:23 PM

Is it possible to integrate a function WHITHOUT ANY ERROR?

If yes, it would be very great.

I recently found that on my ClassPad : integral(sqrt(1-x?)) from -1 to 1 = -pi/2

so : -2*integral(sqrt(1-x?)) from -1 to 1 = pi

<end of stupid question>

But I think many people found this before me!

### #16

Posted 24 October 2005 - 02:16 PM

It should be pi/2, not -pi/2...I recently found that on my ClassPad : integral(sqrt(1-x?)) from -1 to 1 = -pi/2

You are just integrating the half of the trigonometric circle, and it is a circle with radius=1, thus of course this integral = pi/2

Note that the only way to perform an integral "without any error", is precisely to use an Algebra System (CAS)

### #17

Posted 25 October 2005 - 10:57 AM

Well, I don't think that this is a stupid question; everybody asks this, whenever he/she starts to use numerical methods.<stupid question>

Is it possible to integrate a function WHITHOUT ANY ERROR?

If yes, it would be very great.

Now, you should realize that Numerical Analysis is not magic; it tries to solve a problem which usually cannot be solved analytically. Numerical Analysis aims to solve problems that will never be solved by a CAS, simply because there is no analytic solution, or because this solution is very time consuming to be computed by a CAS. In other words, Numerical Analysis solves "unsolvable problems". That being said, it is clear there is no numerical method able to solve

*any*problem with perfect accuracy, and such a "perfect" method will never be. However, in some particular cases, a numerical method may return a perfect result, without any error. Examples: try to integrate Alvise's rectangular function by:

q,err=TrapAdapt(rect,-0.5,0.5)or by

q=Romberg(rect,-0.5,0.5)You will see that you get exactly 1, i.e., the result is exact. But this is an exception: for example, integrating the same function from x=-2 to x=2 gives a result which is highly accurate, but not exact. If you think how these numerical methods work, you will easily realize why this happens.

Yes, this is the rule, and it's true to, say, the 99.99% of the cases; there are however some exceptions, as explained before. You can say that "Numerical Analysis starts where the CAS stops", and this happensNote that the only way to perform an integral "without any error", is precisely to use an Algebra System (CAS)

*very*often. I'm not referring to ClassPad's CAS, I'm referring to

*any*CAS.

Well, TrapAd is included in the new version of LuaNumAn. I know that I said I was planning to release it later, but I finally decided to do it now, for reasons explained in the LuaNumAn topic. You can now reproduce to graph I posted here, which solves your problem.In the images up here i see a function LuaNumAn/TrapAd , in my luaNumAn 1.30 libs i havn't that function....

### #18

Posted 31 December 2005 - 06:54 PM

Thank you. I will try. I'll check the about speacker during the afternoon.

**ClassPad Plus had an speaker or not?!**

Please tell me! I'm dying!

### #19

Posted 31 December 2005 - 08:05 PM

**NO!**

### #20

Posted 01 January 2006 - 01:08 AM

My first post in 2006

To test whether CP300 Plus has speaker, you can download new add-in on Classpad.org site. After accessing it, press + or - or EXE then if you hear the beep, your CP has speaker.

2006 will be a revolution year of CP?

**In Casio and Saltire, we hope.**

### #21

Posted 01 January 2006 - 01:29 AM

......but it's only 8:30PM...

edit: LOL I just realized that you live in Vietnam

### #22

Posted 01 January 2006 - 11:59 AM

Thanks! But I didn't expect to hear such load answer! Anyway.

NO!

### #23

Posted 01 January 2006 - 01:29 PM

Thanks! But I didn't expect to hear such load answer! Anyway.

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users