Items tagged with convert convert Tagged Items Feed

For example, I havd matrix m:=[0 1 0 1 0 1 0], I want to convert it back to m:=[0,1,0,1,0,1,0]. Can someone help to solve? Thank you.

A wealth of knowledge is on display in MaplePrimes as our contributors share their expertise and step up to answer others’ queries. This post picks out one such response and further elucidates the answers to the posted question. I hope these explanations appeal to those of our readers who might not be familiar with the techniques embedded in the original responses.

The Question: Transforming functions to names

Bendesarts wanted to know how to make programmatic changes to characters in a list. He wrote:

I have this list :


I would like to create this list automatically:


In other words, how can I remove the 3 characters "(t)" and replace it by "_"

Do you have ideas to do so ?

Thanks a lot for your help

Joe Riel provided a complete answer that had three different approaches. He wrote:

Map, over the list, a procedure that extracts the name of the function and catenates an underscore to it. The function name is extracted via the op procedure, e.g. op(0,f(a,b,c)) evaluates to f. Thus 


Note that this fails if the name of a function is indexed, e.g. f[2](a). No error is generated but the catenation doesn't evaluate to a symbol. Presumably that isn't an issue here.  One way to handle that case is to first convert the indexed name to a symbol, then catenate the underscore.  So a more robust version is


However, if you are actually dealing with indexed names you might want a different result. Another way to do the conversion, and combine it with the catenation, is to use nprintf, which generates a name (symbol). Thus

map(f -> nprintf("%a_", op(0,f)),T);


Let’s discuss each approach by understanding the definitions and functionalities of the commands used. 

The map command, map(fcn, expr, arg1, ..., argN) applies a procedure or name, fcn, to the operands or elements of an expression, expr. The result of a call to map is a copy of expr with the ith operand of expr replaced by the result of applying fcn to the ith operand.  This concept is easier to grasp by looking at a few examples related to the usage of map in this question.

Example 1.  map(x-> x2,x+y)         returns     x2+y2                    

Example 2. map(a -> a-b, sin(x))    returns     sin(x-b)


The cat function, cat(a,b,c,…), is commonly used to concatenate (or join) string and names together. This function’s parameters: a,b,c…, can be any expressions.

Example 1. cat(a,2)                      returns     a2

Example 2.  cat(“a”,3,sin(x))          returns    “a3sin(x)”


The op function, op(i..j,e), extracts operands from an expression. The parameters i and j are the integers indicating positions of the operands and e is the expression. For functions, as in this example, op(0,e) is the name of the function.

Example 1.  op(0,alpha(t))            returns   the symbol alpha

Example 2.  op(0, sin(x))              returns    sin


Now analyzing Joe Riel's code will be easier.

  1. map(f->cat(op(0,f),_),T);

In this approach Joe is extracting the name of the functions, alpha and beta, and then concatenating it to the underscore symbol. Then using the mapping function he applies the previous procedure to the list T.

  1. map(f->cat(convert(op(0,f),'symbol'),_),T);

This approach is a lot similar to the previous one, but he added the convert function in case the function inside of map was indexed. Convert(expr, form, arg3,..), is used to change an expression from one form to another. In this example op(0,f) has been changed from type name to type symbol.

  1. map(f -> nprintf("%a_", op(0,f)),T);

Again this is a similar approach but it uses nprintf. This command, nprintf(fmt,x1,..xn), is based on a C standard library command of the same name. It uses the format specifications in the fmt string to format and writes the expression into a Maple symbol, which is returned. In this example the format specified is the algebraic format “%a”.


This blog was written by Maplesoft’s intern Pia under the supervision of Dr. Robert Lopez. We both hope that you find this useful. If there is a particular question on MaplePrimes that you would like further explained, please let us know. 

Hi everyone,


I converted a code from Maple 18 to Fortran 77 but the code is badly cut, for instance:

cg = -(F * h * p ** 2 - F * h * q ** 2 + 0.2D1 * F * k * p * q + c
     #os(F) * sqrt(-e ** 2 + 0.1D1) * p ** 2 - cos(F) * sqrt(-e ** 2 + 0.

Is there an option which can force the line cut to be done in an optimized way?

Thank you very much for your help!




Hi, anyone know hot i need to continue my command to get 462 from [4,6,2]?

Thank you~=]]




Hi, how i need to continue my command to get [4,6,8] from 468?

Thank you~=]]


When I subtract (in base 10) 235 (octal digits) from its reverse I get  [-1,-1,2]. converting this list to number equals 189 (base 10)....divisible by 7. [I would think the list would be [9,8,1] ;

in wolfram alpha 532 base 8 - 235  base 8 = 189 base 10 ).

Converting 189 to octal yields 275. All this is done correctly in Maple.

Now when I add 275 base 8 to 572 (edit: not 575 as I had before) base 8 I should get 1067 base 8, but I don't....

for sure i've done something silly

Sorry for disturbing you. I am wondering if there is an easier approach in Maple that could convert a system of second order differential equations into matrix form. Of course, we could do it by hand easily if the degrees of freedom is small. I would like to know if we could use Maple to do so. 

Here is an example with 6 degrees of freedom: the variables are u, v, w, alpha, beta and gamma. And, this is a uncoupled system.

Vector(6, {(1) = 2*R^2*(diff(w(t), t))*Pi*Omega*h*rho+R^2*(diff(u(t), t, t))*Pi*h*rho-R^2*u(t)*Pi*Omega^2*h*rho = 0, (2) = R^2*(diff(v(t), t, t))*Pi*h*rho = 0, (3) = -2*R^2*(diff(u(t), t))*Pi*Omega*h*rho+R^2*(diff(w(t), t, t))*Pi*h*rho-R^2*w(t)*Pi*Omega^2*h*rho = 0, (4) = (1/4)*R^4*Pi*(diff(alpha(t), t, t))*h*rho+(1/12)*R^2*Pi*(diff(alpha(t), t, t))*h^3*rho+(1/6)*R^2*Pi*(diff(gamma(t), t))*Omega*h^3*rho-(1/12)*R^2*Pi*alpha(t)*Omega^2*h^3*rho = 0, (5) = (1/2)*R^4*Pi*(diff(beta(t), t, t))*h*rho-(1/2)*R^4*Pi*beta(t)*Omega^2*h*rho = 0, (6) = (1/4)*R^4*Pi*(diff(gamma(t), t, t))*h*rho+(1/12)*R^2*Pi*(diff(gamma(t), t, t))*h^3*rho-(1/6)*R^2*Pi*(diff(alpha(t), t))*Omega*h^3*rho-(1/12)*R^2*Pi*gamma(t)*Omega^2*h^3*rho = 0});

The objective is to reform it into matrix form : M*diff(X(t), t, t)+C*diff(X(t), t)+K*X(t)=F.

Thank you in advance for taking a look. 

Hi, anyone know the command to convert a digit to 8 bits binary number ?

Thanks for help..

Is there a way in Maple to convert a list into a string of numbers?

So [1,2,3,4,5] -> 12345

I have tried Maple help, but there are too many convert commands to try them all.
And the ones I have tried didn't work.


How can I quickly  convert a maple file ful of equations into MathML in Word, nt losing the upper and lower index structure - basically to be able to count each letter in MS Word 2013?

When I tried via Latex or MathML, I have lost the letter structure and got the conversion as an image.


Executing HelpTools:-Database:-ConvertAll(): produced file apparently without content. How can all content within DirectSearch.hdb be converted to a .help file accessible through help in Maple 2016?

I get the maple result as a product and sum off terms


x= (a+b*c)/d

i want to convert it to

x= a/d+b*c/d

i try to use convert(x,?)  


Is there a built-in Maple function to convert decmial inches to inch fraction. For example 1.74 as 1+3/4 ?

Trival to do in Delphi or c++ or even create a Maple function. However I would rather use a built-in function.


a1:= f(x) :
> T1 :=simplify((taylor(a1,x=alpha,N+3))):
> E1:=subs([seq(((D@@i)(f))(alpha) = 0,i=1..m-1),f(alpha)=0,x=e[n]+alpha],T1):
> g1 :=(convert(simplify(series((E1,e[n]=0,N))),polynom));


When executing the following orders,



convert(a, symbol);


the result is .6e-2.


How to make Maple return the form 0.006, just as the original?

1 2 3 4 5 6 7 Last Page 1 of 41