## 1551 Reputation

12 years, 131 days

## Is this a bug with composition ?...

Maple

Consider the following situation: I have a function f, say

f:=x -> 1+x^2/n;

I want to compute the composition of f with itself; e.g.

g:=f@@n;
eval(g(x),n=3);

So it appears eval does evaluate the threefold composition but not at n=3. Obviously I can wrap this example in a subs() or another eval to get the replacement done; but it is a bit curious and I wonder whether this behaviour is as designed or an "undocumented feature."

I ran across this when investigating whether or how to do the composition for an arbitrary n (so I can e.g. find the limit for n=infinity) and really wanted to ask about that, but I see that such a question was dealt with before by Joe Riel using rsolve so I'll see first how far that approach gets me. In my case the function will be a polynomial vector function with vectorial arguments, providing for some additional challenge.

Mac Dude.

## Codeprofiling created procs?...

Maple

Hi,

In a simulation code I use "module-factory" concepts (where a module has a proc; the proc in turn returns another module that has all the procs one wants) a fair bit to keep the code readable and maintainable.

At this point I have the code mostly doing what I want it to, but the run time could be improved (read: I want it to go faster). So I have started working with CodeTools:-Profiling. Quickly I am running into the Profile() function apparently not being able to deal with my generated procedures.

Is there a way out? In other locations I read about procs to be profiled having to be in a Maple library; this is the case for my routines (it all is in a big module with procs, submodules etc.). I'd rather not rewrite the code extensively just to allow profiling (in particular I would not really like to abandon the module-factory scheme), but of course I can do some modification.

Any suggestions?

M.D.

## How to plot a Bode diagram?...

Maple

Hi, does anyone know how to plot a Bode diagram (phase and amplitude plot)? I am not looking for preparation of data but rather for the technicality of producing a plot that looks like I want, given I have data in the right form (which in my case are three Vectors: frequency, amplitude and phase).

Below is a rough sketch of what I am looking for. Note that the amplitude is on a log scale. It would be acceptable having to take the log of the data "by hand" to allow both vertical scales to be linear (I'd just convert the amplitudes to dB). The important things are the common frequency scale (horizontal) and the separation of amplitude and phase. I know plots has  dualaxisplot, and I know I can use plots:-transform to move a curve around, but I want the two axes on the left side, below each other, rather on the left and right. I'd like the frequency scale in the middle between the two curves, although I could settle on that scale to be below both curves.

I had some look around the Maple applications but did not find anything looking like this.

Thanks,

Mac Dude

## how to distribute a sum ...

Maple

I have an expression like this (from an earlier computation):

2*(sum(A*cos(omega*t)^2+cos(omega*t)*B*sin(omega*t)-cos(omega*t)*ymeas(t), t));

I want to distribute the sum over the terms in the expression, i.e.

sum(A*cos(omega*t)^2,t)+sum(cos(omega*t)*B*sin(omega*t,t)+sum(cos(omega*t)*ymeas(t), t)));

I suspect defining a rule and using applyrule should be the way to go, but for the heck of it I can't figure how to do it. The best I can manage is getting the Maple kernel hung with the following construct:

distSum:=sum(A::algebraic+B::algebraic+C::algebraic,D=algebraic)=sum(A,D)+sum(B,D)+sum(C,D);

applyrule(distSum,(5)); # (5) referrs to the expression on line 2 (and it is a proper label in my Maple wrkbook).

I have asked similar questions before and gotten answers; but I am not able to find what I need in MapePrimes (or my faorites, for that matter).

Thanks for any help,

Mac Dude

## Are local variables in a proc persistent...

Maple 15

Hi,

I want to write a proc to calculate exponential averages. Each call will add one data point to the averge. To do that, I need to store the previous average. I can do that by handing the previous average back to the proc at the next call, but I'd rather store it in the proc. Is there a way to guarantee that a variable---once set---remains alive keeping the last value upon entering the proc again? Note that I need the variable to be local to each instance of the proc since I will have several of these running in parallel (I intend to create these procs using the module factory scheme outlined in the programming guide). So I cannot store the previous average in a global variable since that would not be unique to a given instance.

Any ideas out there?

TIA,

Mac Dude

 First 8 9 10 11 12 13 14 Last Page 10 of 23
﻿