Carl Love

## 26658 Reputation

11 years, 228 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

## x &^ e mod n...

It looks like your Alphabet is shifted by one. I get "Y"=58, "e"=70, "s"=84. Regardless of that, the encryption steps are the same. The essential command is the inert modular exponentiation operator x &^ e mod n. I also did the decryption, partly for to verify the encryption and partly for my own amusement.

with(StringTools):
Alphabet:=cat(Select(IsPrintable,convert([seq(i,i=1..255)],bytes))):
AlphaToNum:= table([seq](Alphabet[k] = k, k= 1..length(Alphabet))):
plaintext:= "Yes":
NumText:= [seq](AlphaToNum[c], c in plaintext);
[58, 70, 84]
n, e:= 119, 7:
Crypted:= (c-> c &^ e mod n) ~ (NumText);
[114, 77, 84]
To decrypt:
f:= ifactor(n);
(7) (17)
phi:= expand(map(x-> x-1, f));
96
d:= 1/e mod phi;
55
Decrypted:= (c-> c &^ d mod n) ~ (Crypted);
[58, 70, 84]
cat(seq(Alphabet[k], k in Decrypted));
"Yes"

## ImportData()...

Save your file in Excel. I think as a CSV file would be best (Comma-Separated Values). Then in Maple, give the command ImportData(); and follow the dialog. Once you get that done, post a followup to this, and we can proceed with the plotting. Also post a followup if you have any trouble with the dialog.

## Outside regions...

mrmathexpert wrote:

How can I control the specific regions that I want to highlight? For example, from pi/2 to 3pi/2: outside or the left side of the y-axis bounded; and from 3pi/2 to pi/2, outside or the right side of the y-axis bounded.

You can do the left side and the right side separately, each side consisting of two polarplot commands, and paste all four together with display. I'm not sure if this is what you were trying to describe:

 > p1:= plots:-polarplot(2+cos(x), x= -Pi/2..Pi/2, color= red, filled= [color= yellow]): p2:= plots:-polarplot(2+cos(x), x= Pi/2..3*Pi/2, color= red, filled= [color= white]): p3:= plots:-polarplot(2, x= Pi/2..3*Pi/2, color= blue, filled= [color= yellow]): p4:= plots:-polarplot(2, x= -Pi/2..Pi/2, color= blue, filled= [color= white]): plots:-display([p4,p2,p3,p1]);

Note that the order of the plots in the display command matters: They are printed in the reverse of the order that they appear in the command. I don't think this is documented.

## Vertices need to be integers, symbols, o...

GraphTheory:-Graph vertices need to be integers, symbols, or strings; arbitrary expressions are not allowed. So 2, `*`, function, cos, y, and z are valid; but 2*y, 3*z, and cos(x+2*y) are not.

## subsindets and collect...

The command that you want is subsindets (or possibly evalindets). Here's an appropriate analogy: subsindets is to indets as applyop is to op.

I think you should collect like terms with respect to the integrals, like this

collect(eq2, Int);

so that each specific integrand only occurs once.

Tell me exactly which integrands you are trying to select. You said "like" phi[i](y)*diff(w(y), y). Do you mean exactly that integrand? Or would phi[i](y)*diff(w(y), y)^2 also count as "like"?

Once you answer that, I can give you a type specification that you can use with subsindets.

## eval and extraneous brackets...

Assuming that those square brackets are really there (which I find a bit strange), the command is

(op@eval)(w1(x), op ~ ([sol]));

and likewise for w2(x).

If the square brackets are not actually there, then change (op@eval) to simply eval in the above command.

If the square brackets are really there, you should post the commands that got you to that point, because there may be something wrong.

## There must be a syntax change. Try this....

There must have been a syntax change between Maple 13 and Maple 17 that I am not aware of. So sorry about this. Try this please: Make your first command

kernelopts(opaquemodules= false);

I am not sure that will work.

Joe Riel (or any expert who can answer): Was it once true that only module exports could be accessed with thismodule, but now locals can be accessed thus also? Also, were keyword parameters introduced after MAPLE 13?

## Statistics:-Probability and RandomVariab...

 > restart;
 > macro(RV= Statistics:-RandomVariable, P= Statistics:-Probability, N= Normal):
 > x:= RV(N(6.05, sqrt(.0004/9))):
 > P(x < 6.035);

 > Z:= RV(N(0,1)):
 > P(Z < -2.25);

 >

## Use < p > for handy Vector-Matrix conver...

Use < p > for handy Vector-to-Matrix conversion, and use ^%T for transpose.

KroneckerProduct(< p >, < p >^%T);

## Upper bounds of loops don't match...

In the Matlab, the upper bound of the inner loop is the index of the outer loop; whereas in the Maple, the two loops have the same upper bound. The closest matching Maple code to your Matlab is

for j from 1 to N do
for i from irem(j-1,2) to j by 2 do
Dhat[i+1,j+1]:= 2*j
end do
end do;

You can also use (j-1) mod 2; I prefer irem in this case.

## Need to deal with the constants of integ...

Before you can plot it, you need to deal with the six constants of integration _C1, ..., _C6. Can you find six initial or boundary conditions?

## Use finite-field arithmetic...

You should post your matrix or the worksheet that contains it. If the entries are rational functions, then we can compute the answer numerically over different finite fields and reconstruct the final answer via Chinese remaindering. A lot of this functionality is already built into Maple if you use the correct options for the Determinant command. And I'll work on that when you post your matrix.

In the worst case, there could be 14! ~ 87 billion terms in the determinant; so you may need to be satisfied with the value of the determinant at specific numeric values of the variables.

## Extra constant "ga"...

In addition to Preben's Answer: There's an extra constant, ga, in the fourth equation, for which no value is provided. If you provide a value for this, then it only expects 9 boundary conditions.

## A module that does it...

Sorry this took a few days. It was a bit more complicated than I anticipated. The main complexity was that Graphs need to have unqiue labels for each vertex, but, of course, we may want to repeat labels in the tree.

I welcome any critiques of my module. Especially, I'd like to know if there are any modern aspects modules that I could have used.

(* Written by Carl Love, 16-Mar-2013.

A module to convert a function tree representation (such as is returned by ToInert
or various commands in XMLtools) into a tree represented in the GraphTheory package
*)
FunctionToTree:= module()
local
(*____________________________________________________________________________________
Phase 1: Build a representation of the tree in tables with each vertex represented by
by an integer and each edge by an ordered pair of integers.
``````````````````````````````````````````````````````````````````````````````````````*)
# Vertices is a table that maps the original functional representation of the
# node to an integer.  VertexLabels is simply the inverse of that table.
Vertices::table, VertexLabels::table, Vertex_index::nonnegint,

# Edges is a set (stored as a table indexed by an integer for efficiency)
# of ordered pairs of vertices in their integer representation.
Edges::table, Edge_index::nonnegint,

Edge_index:= Edge_index + 1;
Edges[Edge_index]:= [Vertices[e[1]], Vertices[e[2]]]
end proc,

Vertex_index:= Vertex_index + 1;
Vertices[x]:= Vertex_index;
VertexLabels[Vertex_index]:= x
end proc,

# Recursive
local x::function;
for x in f do
#Make functions unique.
if assigned(Vertices[x]) then  x:= convert(op(0,x), `local`)(op(x))  fi;
#Leaves are type function but not function(function).
if x::function(function) then thisproc(x) end if;
end do
end proc,
(*__________________________________________________________________________________
Phase 2: Shorten the function labels to something that can be shown on a plot of the
tree but which is still meaningful.
`````````````````````````````````````````````````````````````````````````````````````*)
# Prefix is the number of chars at the beginning of each function name that
# can be trimmed off.  For example, if every function name begins _Inert_, then
# Prefix should be set to 7.  This value is passed in by the user.
Prefix::nonnegint,

# Labels is a table mapping the string form of the shortened function names to
# alternative (usually abbreviated) representations.  For example, "SUM" can be
# mapped to `+`.  This is passed in by the user.
Labels::table,

#Shorten the function names
StripName:= proc(f::function)
local f0:= sprintf("%a", op(0,f))[Prefix+1 .. -1];
`if`(assigned(Labels[f0]), Labels[f0], nprintf("%s", f0))
end proc,

ShortenLabels:= proc()
local k::nonnegint, f::function, f0::symbol;
VertexMap:= table();
for k to Vertex_index do
f:= VertexLabels[k];
f0:= StripName(f);
if not f::function(function) then
#For leaves, display the function operands also.
f0:= nprintf("%Q", `if`(f0 = ``, op(f), f0(op(f))))
end if;
if assigned(VertexMap[f0]) then f0:= convert(f0, `local`) fi;
VertexMap[f0]:= f;
VertexLabels[k]:= f0
end do
end proc,
(*____________________________________________________________________________________
Main
``````````````````````````````````````````````````````````````````````````````````````*)
ModuleInits:= proc()
Edges:= table();
Edge_index:= 0;
Vertices:= table();
VertexLabels:= table();
Vertex_index:= 0
end proc,

ModuleApply:= proc(func::function(function), {Labels::table:= table(), Prefix::nonnegint:= 0})
ModuleInits();
thismodule:-Prefix:= Prefix;
thismodule:-Labels:= Labels;

ShortenLabels();  #Phase 2
#Subs the short labels into the integer labels, then build and return the graph
GraphTheory:-Graph(subs(op(eval(VertexLabels)), convert(Edges, set)))
end proc
;
# VertexMap is a table mapping the short labels to their original functions
export VertexMap::table;
end module;

A module to convert a function tree representation (such as is returned by ToInert or by various commands in XMLtools) into a tree represented in the GraphTheory package.

 >
(* Written by Carl Love, 16-Mar-2013.

 > Func:= ToInert(x+2*y*z^2);

I came up with a scheme to abbreviate the vertex labels. In the line below, you need to map the second part of the _Inert_ function names to display labels. Note that the display label can be the empty name ``. Also note that this table must map strings (things in double quotes) to names (things in single backquotes).

 > Abbrs:= table(["SUM"= `+`, "PROD"= `*`, "INTPOS"= ``, "NAME"= ``, "POWER"= `^`]):

The Prefix= 7 argument tells it to strip off the first 7 characters of each function name.

 > G:= FunctionToTree(Func, Labels= Abbrs, Prefix= 7);

For any given tree, it's hard to say which command of DrawNetwork of DrawGraph will display it better. Neither is great.

 > GraphTheory:-DrawNetwork(G);

 > GraphTheory:-DrawGraph(G);

The module exports a table VertexMap that shows the correspondence between the vertex labels and the original functional representation.

 > eval(FunctionToTree:-VertexMap);

 >
 > Func:= ToInert([1,2,3,4]);

 > G2:= FunctionToTree(Func, Labels= Abbrs, Prefix= 7);

 > GraphTheory:-DrawNetwork(G2);

 >