Classic Fourier Series
|
02-01-2015, 05:34 PM
Post: #21
|
|||
|
|||
RE: Classic Fourier Series
(02-01-2015 05:12 PM)Snorre Wrote: Hi, great! Very "C" like I'll use this approach, then... What the meaning of zip() function, please? ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
02-01-2015, 05:48 PM
Post: #22
|
|||
|
|||
RE: Classic Fourier Series
(02-01-2015 05:34 PM)salvomic Wrote: What the meaning of zip() function, please? You could check the on calculator help Code:
Cheers, Terje |
|||
02-01-2015, 05:55 PM
Post: #23
|
|||
|
|||
RE: Classic Fourier Series
(02-01-2015 05:48 PM)Terje Vallestad Wrote: You could check the on calculator help yes, Terje, thank you! In this case it "unapply" the name of the variable... ok cheers ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
02-01-2015, 06:13 PM
(This post was last modified: 02-01-2015 06:16 PM by Snorre.)
Post: #24
|
|||
|
|||
RE: Classic Fourier Series
Hi,
what the help doesn't mention is that zip doesn't work only on lists/vectors but also on a bivariate function and two scalars. So, zip('+',2,3) gives 5. unapply turns an expression into a function (see on-calc help): unapply(expr,var1,...,varN) returns a function (var1,...,varN)->expr. In fact the aim was something like "unapply(expr,var)", but not with "var" itself being the parameter but its value (another variable, e.g. "x"). That is "var:=x; unapply(expr,var)" will return "(var)->expr" -- not the desired "(x)->expr". So, the zip construction evaluates "var" first before unapplying. |
|||
02-01-2015, 06:16 PM
(This post was last modified: 02-03-2015 03:53 PM by salvomic.)
Post: #25
|
|||
|
|||
RE: Classic Fourier Series
just a powerful command!
I didn't know it first... thanks a lot. ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
02-01-2015, 07:06 PM
Post: #26
|
|||
|
|||
RE: Classic Fourier Series
(02-01-2015 05:12 PM)Snorre Wrote: Hi, hi Snorre, I'm almost ready to put a very better program, melting yours and mine, very short and powerful... But I would have use "choose" for input to choose between two intervals for calculus (from 0 to 2PI or from -pi to pi), as the results seem to be different (they aren't but are correlated to those intervals)... However I get "Error: invalid input": is it not possible to use "CHOOSE" with a #cas program? :-( please, tell me... ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
02-01-2015, 08:37 PM
(This post was last modified: 02-01-2015 08:47 PM by Snorre.)
Post: #27
|
|||
|
|||
RE: Classic Fourier Series
Hello Salvo,
you're right. In general, changing the integration interval is like shifting the time function, which should result in different phase information only (the magnitudes shall stay the same). But that holds only for periodic functions (a basic assumption of fourier transformations). If you transform f(t):=t² in -pi..pi, you're assuming f is an endless repetition of the cup-like part pi²..0..pi² (in ASCII-art: ...uuuu...), if you do it on 0..2pi you're assuming f is an endless repetition of the raising 0..pi²..4pi² chunk (in ASCII-art: ...////...) -- these are two different time functions. You could put your choose box in a non-exported (private) PPL-function within the same program and call it like <programname>.<funcname>: Code: ChooseInterval() |
|||
02-01-2015, 09:14 PM
Post: #28
|
|||
|
|||
RE: Classic Fourier Series
(02-01-2015 08:37 PM)Snorre Wrote: Hello Salvo, ok! I'm trying this code: Code:
but it doesn't execute any Choice, always give a0, a1, b1, the last option (ELSE)... The program name here is FourCoeff, its function fourcoeff(args) Can you help me to find the last error, please? For the rest it should be ok... ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
02-01-2015, 09:31 PM
Post: #29
|
|||
|
|||
RE: Classic Fourier Series
Sorry, my fault -- didn't test it.
Try EXPR("FourCoeff.ChooseInterval()") instead of FourCoeff.ChooseInterval(). |
|||
02-01-2015, 09:47 PM
Post: #30
|
|||
|
|||
RE: Classic Fourier Series
(02-01-2015 09:31 PM)Snorre Wrote: Sorry, my fault -- didn't test it. yes! it's ok. The choose box is very elegant also. Works also with the piecewise function and (with some warnings) also with |sin(t)| I've now a doubt (I'm aging, hi): the correct formula for a0 and interval -π..π is divided by PI or by 2*PI? In some books of mine I find one and in others the other form... And finally we could also include in this program your routine for cx (exponential form coefficient)... What do you think? Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
02-01-2015, 10:19 PM
(This post was last modified: 02-01-2015 10:22 PM by Snorre.)
Post: #31
|
|||
|
|||
RE: Classic Fourier Series
Hello Salvo,
I think it's a matter of taste, but I do prefer the complex coefficients, because you see (ak,bk) directly (especially if you choose (a,b) format for complex numbers instead of a+b*i) and it's so easy to get the magnitude (abs) and phase (arg), which are in practice more interesting than sin/cos-parts. I do not know, how a0 is exactly defined. But since it should be the mean (DC-coefficient) I'd divide the integral by its width 2*pi. Greetings |
|||
02-01-2015, 10:33 PM
Post: #32
|
|||
|
|||
RE: Classic Fourier Series
(02-01-2015 10:19 PM)Snorre Wrote: I think it's a matter of taste, but I do prefer the complex coefficients, because you see (ak,bk) directly ... you are right, the complex coefficient are preferable... I'll think about make a program "all in one" or let two separate functions... Thank a lot for the effort, very appreciated! Greetings! salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
02-01-2015, 10:39 PM
Post: #33
|
|||
|
|||
RE: Classic Fourier Series | |||
02-01-2015, 11:00 PM
Post: #34
|
|||
|
|||
RE: Classic Fourier Series
(02-01-2015 10:39 PM)Snorre Wrote:(02-01-2015 10:33 PM)salvomic Wrote: you are right, the complex coefficient are preferable... ok yes, it's mazing the Prime! Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
02-01-2015, 11:24 PM
(This post was last modified: 02-01-2015 11:26 PM by salvomic.)
Post: #35
|
|||
|
|||
RE: Classic Fourier Series
FourCoeff Version "all in one":
Input something like function or expression (with variable) and k: g(t) -> "g, k", g(x) -> "g, x, k", "t^2, k", "x^2, x, k"... where k = (0), 1, 2, ... It calculate the Fourier coefficient (trigonometric and exponential). I hope the formulas be good, please control... The output is sure "wild", it must be presented more clean, sorry... My idea was to print the letter and the interval, but doing so the row is sure too long... Any help appreciated. Code:
Everyone can adapt it at his/hers needs Salvo M. ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
02-02-2015, 10:59 AM
(This post was last modified: 04-09-2015 10:18 PM by salvomic.)
Post: #36
|
|||
|
|||
RE: Classic Fourier Series
there was an error in a formula...
Output like vector, a little better than the first one... (Please tell me the true syntax of Return command: how to do to have two lines, ho to avoid "" and have "labels", without using ' ' (that evaluate expression)... Code:
∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
02-03-2015, 08:06 PM
(This post was last modified: 02-03-2015 08:42 PM by salvomic.)
Post: #37
|
|||
|
|||
RE: Classic Fourier Series
(02-01-2015 05:12 PM)Snorre Wrote: another approach:I like this approach! please, Snorre, help with this code (see thread with Han in http://www.hpmuseum.org/forum/thread-2992.html... I would like calculate curvilinear integral with input a function (x,y,z), a parametric curve [r(t), r(t), r(t)], low bound, high bound; then I would write also a program for line integral (vectorial function, so: [x,y,z] fun, [t,t,t] param, l, h)... I need some controls with the expression or function (for now if I put f and not f(x) Prime reset, as we now), for the parametric vector [t,...,...] e mostly for the variables in those two: they could be 2 or 3... Any help? With expression in x,y,z, vector [t...],l,h the function works well, the only control now is that there be 4 parameters... Code:
P.S. we could also continue in the other thread, if you want, as here we are a bit off topic ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
04-11-2015, 05:35 AM
(This post was last modified: 04-11-2015 05:36 AM by salvomic.)
Post: #38
|
|||
|
|||
RE: Classic Fourier Series
New version
Use, as always:fourcoeff(func, k) or fourcoeff(func, var, k), es. fourcoeff(COS(t/2), t, 1) of fourcoeff(x^2, 2)... This now permits a choose from 3 interval: [0, 2PI], [-PI, PI], [other], where "other" gives the opportunity to input a value for a parameter T to get an interval like [-T/2, T/2]; es. input 2 to have [-1, 1], for a non trigonometric function of a function... The program return then a_0, a_n, b_n (trigonometric form), and c_n (exponential form) of Fourier's Series for a given number (int: n -> 1, 2, 3...) Code:
(in case of error, substitute the underscript in RETURN {"[t₀,T] a₀ aₙ bₙ", a0,ak,bk, "cₙ", ck} with the _n ...) Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
10-09-2015, 09:37 PM
Post: #39
|
|||
|
|||
RE: Classic Fourier Series
Salvomic, you were asking how to Return two lines.
Does this help: "ABC" + CHAR(10) + "Def" Gives a string over two lines. RETURN "A" + CHAR(10) + "B" returns a two-line string. CHAR(10) is an ASCII linefeed. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
10-10-2015, 07:38 AM
Post: #40
|
|||
|
|||
RE: Classic Fourier Series
(10-09-2015 09:37 PM)StephenG1CMZ Wrote: Salvomic, you were asking how to Return two lines. thank you a lot, Stephen, I'll try it soon! Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)