40 Reputation

8 years, 353 days

Replacing Text From fprintf...

Maple

I'm using maple to write text to an external text file. My code is

f := x-> arcsin(x);

file := "C:\\example.txt":

fopen(file,WRITE,TEXT):

fprintf(file,"%a",f(1)):

fclose(file):

The problem is that the output in my file example.txt reads "1/2*Pi" and I'd like it to be "1/2*pi". In other words, is it possible to have maple scan my file and replace the occurances of "Pi" with "pi"?

Importing Matrices into Maple ...

My question is very similar to this question however my .txt files are in a different format.

I've generated a .txt file with Macaulay2 that looks like this

| -1 0 9  -17 4   |

| 1  2 -3 7    17 |

I would like to import this file into maple and define a matrix M as this matrix. Is there any way to accomplish this?

Reordering the columns of a 2 by n matri...

I'm trying to write an algorithm that arranges the columns of an arbitrary 2xn matrix counter-clockwise starting at the point closest to (1,0). For example, when I input the matrix

Q := Matrix([

[ -1 ,  0 ,   0 , -1 ]
, [  0 ,  1 ,  -1 ,  0 ]

]);

into the algorithm, I would like the output to be

R := Matrix([

[  0 , -1 , -1 ,   0 ]
, [  1 ,  0 ,  0 ,  -1 ]

]);

Is there any package that could help me with this?

Listing the Unique Columns of a Matrix...

Maple

I have a matrix with repeated columns

with(LinearAlgebra):

Q := Matrix([1,1,1,0,0,0,-2,-1],[0,0,0,1,1,1,0,-3]);

I'd like to write a loop that defines u[1],...,u[n] to be the unique columns of Q. Is there a way to do this?

Defining a Function of a Pre-Defined Num...

Maple 17

I'm writing some code that computes a positive integer N and I'd like Maple to define a function of N variables. I've tried writing

f := (seq(t[i],i=1..N))-> MY EXPRESSION;