Items tagged with map

Experts,

This may sound like a dumb question, but i'm seeking a procedure to do it better.
 

``

 

with(combinat, setpartition) :
P := [$2..5] :

Tours := setpartition(P);M:=nops(Tours)

[[[5], [2, 3, 4]], [[2], [5], [3, 4]], [[3], [5], [2, 4]], [[4], [5], [2, 3]], [[2], [3], [4], [5]], [[2, 3, 4, 5]], [[2, 5], [3, 4]], [[2], [3, 4, 5]], [[2, 4], [3, 5]], [[3], [2, 4, 5]], [[2, 3], [4, 5]], [[4], [2, 3, 5]], [[3], [4], [2, 5]], [[2], [4], [3, 5]], [[2], [3], [4, 5]]]

 

15

(1)

 

number of elements in each 'group'

seq(nops(Tours[i]),i=1..nops(Tours))

2, 3, 3, 3, 4, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3

(2)

 

i need to add 1 to each 'subgroup' : These are the first two:

[[[1,op(Tours[1,1])],[1,op(Tours[1,2])]],[[1,op(Tours[2,1])],[1,op(Tours[2,2])],[1,op(Tours[2,3])]]]

[[[1, 5], [1, 2, 3, 4]], [[1, 2], [1, 5], [1, 3, 4]]]

(3)

 

I need to add 1 to each 'subgroup' in a more automatic way.

``


 

Download add_1.mw

 

Maple provides efficient vectorization and automatic parallelization for many common operators. For example

x -> 2*~x*~cos~(x*~x)

But in my application it is common to want to create rather long vectorized operators starting from some complicated symbolic computations. Doing conversions by hand from symbolic expressions to element-wise operations is laborious and error prone.

As a very simple example consider that it is possible to obtain (almost) the same result as above by writing the following as a vectorized operation

D(x->sin(x^2))~

But there are at least two problems with this. First of all it is not nearly as efficient as the first operator and second, perhaps not unrelated, is that the datatype returned when applying this operator to a Vector/rtable of hardware floats (e.g. datatype=float[8]) becomes something  more general.

My question is how can I convert a complicated symbolic expression into an efficient numeric element-wise vector operation?

I have tried several different approaches but so far without success. In the case above for example it seemed natural to expect that the following derivative

D(x->sin~(x^~2))

would produce a vectorized result, but this is not the case. In another attempt I was unable to see how to perform substitions into an expression, e.g. like this

unapply(subs(`*`=`*`~, cos=cos~, diff(sin(x),x)), x)

I would be glad to receive suggestions and/or references to relevant documentation. 

 

Hello everyone,

 

Is it normal that commands #1 and #2 below do not return the same thing ?

 

L := [`Norman.Mailer`, `Richard.Brautigan`]

#1

map(u -> convert(u, string), L);

["Norman.Mailer", "Richard.Brautigan"]


#2

`convert/string`~(L)

["`Norman.Mailer`", "`Richard.Brautigan`"]


Side question : I am not really familiar with the tilde operator and I often use map instead.
Does it exist a better practice in these matters ?

Thanks in advance

im just getting a generic recursive assignment plus first unused arg error

thats what the maple engine says im doing wrong ill get the number of recursives counted but i guess it just makes me the most angry because its like the same type of error for me every ******* time

Code & result:

> map((a::uneval,b)->'args',[a,b,c,d],1..4,x);       
['a, 1 .. 4, x', 'b, 1 .. 4, x', 'c, 1 .. 4, x', 'd, 1 .. 4, x']

> map((a,b::uneval)->'args',[a,b,c,d],1..4,x);           
[a, 1 .. 4, x, b, 1 .. 4, x, c, 1 .. 4, x, d, 1 .. 4, x]

Why is the output not:
['a', 1 .. 4, x, 'b', 1 .. 4, x, 'c', 1 .. 4, x, 'd', 1 .. 4, x]
and
[a, '1 .. 4', x, b, '1 .. 4', x, c, '1 .. 4', x, d, '1 .. 4', x]
?

let aa = map (+1.2) [1,2]
let bb = map (+1.4) [2,3]
foldr (aa . bb) [3.0,4.0]

I have a long list of two element lists, for example,

A := [ [2,3], [4,5] ,[6,7]];

I want apply '/' to the elements of each sublist.

The result will be

R := [2/3, 4/5, 6/7];

I do not need the list, I could use vectors or matrices.

Is it possible to do this other than by iteration?

Tom Dean

Assume we have a map f from a polynomial ring R to another polynomial ring S, I know how to compute kernel (a generator for the kernel ideal) of these maps by Singular, but I want to know can I do it with Maple too? Thanks.

An example;

Consider the homomorphism f:k[x,y]-->k[u,v] sending x to v and y to v^2 then using Singular;

ring r1=0,(x,y),lp;

ring r2=0,(u,v),lp;

ideal i=v,v2;

map f=r1,i;

setring r1;

kernel(r2,f);

_[1]=x2-y

So at above I took k a field of characteristic zero. The kernel is the ideal generated by x^2-y.

map(f, foldl(`*`, 1, a, b));
foldl(`*`, 1, map(f,a), map(f,b));

map(f, foldl(`+`, 0, a, b));
foldl(`+`, 0, map(f,a), map(f,b));

i discover it can auto calculate ring homomorphism, 

if i define a function f below

factor(map(f, foldl(`*`, 1, a, b))+map(f, foldl(`*`, 1, b, c))) = map(f, foldl(`*`, 1, a, c));

how to convert this f into a function with two input parameters?

 

Hello,

I have a maple code, which some expressions have more that 80000 terms and I need to double integrate them. The terms have sine, cossine trigonometric functions.

I tried to used de MAP command, it works for the first expressions but, after a while, Maple displays an error message related to too large expression.

Do you know how to handle large expressions ?

Thank you.

Hello,

I use a map() command to get the values of function for each element of vector. Here is an example of a simple task:

restart:

A:=[1,2,8];

f1:=x->2*x;
f1_table_A:=Vector([map(f1,A)]);

I would like to do the same with piecewise function but it doesn't work. Here is an example:

restart:
with(plots):
f:=2*x:
g:=x^2:

h:=x->piecewise( 0<=x and x<= 5, f, 5<x and x <= 10, g ) ;
A:=[1,2,8]:
h_table_A:=map(h,A):

Is it possible to work with piecewise function? Maybe someone has an idea how to do it in different way?

Kind regards,

Iza

Hi, 

What I want is quite simple but I have not seen it implemented anywhere yet. 

I have an explicit map F from the plane into itself. (not an ODE but simply a map) 

Then I have a set X, (something like a line segment or a rectangle in the plane) for which I 

really need to keep track of the images $F(X), F^2(X), F^3(X)$, and so on.

Is there a way to plot the image of a set in Maple? 

Thank you very much for your interests in the question. 

 

 

 

Is there a way to make the first part of this look like the second picture depicted here? Also after intigration is there a way to make the highlighted posrtion not have an "ln(e)" parts and just have the exponetials and there constants?

Obviously I dont want to have to manually input this section everytime, is there some command I can use to achieve this goal?

Above is the outcome I am getting at the current time... and I used map(expand,...) to do the expansion then simplifing it goes back to the origional. 

Below is the outcome I would like to achieve...you can see that this is a different method. The problem I have is this is the right click method of expansion and I am tring to build a program that solves matrix ODE's by just inputing the initial matrix and it doing everything so i can check my answers step by step. 

So my question is, is there another method of command input to get the bottom line in the below picture?

 

 

Page 1 of 1