Maple 2023 Questions and Posts

These are Posts and Questions associated with the product, Maple 2023

Hi, I am using ArchLinux and used Maple's official installer to install it. Whenever I export my Maple files as PDF all my "-" symbols are converted to "K" for some reason. Has anyone else had this issue or have an idea on how to fix it?

Below is a screenshot of what I mean. "-" has been replaced with "K"

Hello

I have a list with n positive integer numbers and a positive integer k.

I would like to write a Malple programm, that calculates, in how many ways k can be written as a sum of numbers in the list.

Easy examles: let the list be [2,3,6,9].

k=9 can be written in 4 ways: 9=9, 9=6+3, 9=3+3+3, 9=3+2+2+2. The result therefore shoud be 4.

k=8 can be written in 3 ways: 8=6+2, 8=3+3+2, 8=2+2+2+2. The result therefore shoud be 3.

Thank you very much your help!

GraphTheory:-GraphEqual says that G1 and G2 are equal, but GraphTheory:-AllPairsDistance gives different results instead: 

restart;

with(GraphTheory)

M := `<|>`(`<,>`(0, 0, 0), `<,>`(1, 0, 0), `<,>`(1, 1, 0))

G__1 := Graph(convert(-M, Matrix, datatype = integer[8]))

G__2 := Graph(convert(-M, Matrix, datatype = integer))

GraphEqual(G__1, G__2)

true

(1)

AllPairsDistance(G__1)

AllPairsDistance(G__2)

Matrix(%id = 36893491227039185244)

 

Error, (in GraphTheory:-AllPairsDistanceExt) negative cycle detected

 

 

Download allpairs.mw

So, which one is incorrect? Any reasons?

I have a very simple procedure that I wrote to get information for an inequality using data from two lists, upon which I can create a pointplot . Now I know people will see what I have done and probably cringe, and believe me I do as well. I know it is not efficient and there is probably a numerous number of ways to do it better but my procedural skills for Maple are lacking. 

From my file you will see what I am attempting to do,nonetheless I will mention it here. I have two lists X,W. for each value in I want to fine the value in W that yields F(X,L)<G(X,L) where F(X,L) is a complicated integral that I have to evalute numerically, I have tried using unapply as outline in https://www.mapleprimes.com/questions/229070-How-Can-I-Speed-Up-This-Numerical-Integral it however only made my problem worse. For small lists it seems to be reasonable but for larger precision it is not the useful. I have looked through the ?do help page and some other resources but to no avail. From what I have seen though I believe I should be using the until command in do but I can't figure it out with having two lists. 

Any help,tips or tricks will be greatly appreciated.

NumericScale.mw

Here is a symmetric matrix with three real parameters (`k__1`, `k__2`, and `k__3`).

mm:=<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\
,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,1,0,0,0,0,0,0,0,0,0,0\
,k__3-1/2,0,k__3-1/2,0,0,0,0,0,0,0,0,-1/2,0,1-2*k__3,0,-1/\
2,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,1,0,\
k__3,0,-1/2,0,0,0,0,0,0,0,0,0,k__3,0,-2*k__3,0,0,0,0,0,0,0\
,0,-1/2,0,0,0,0,0|0,0,0,0,0,0,-2*k__3,0,k__3-1,0,-1/2,0,0,\
0,0,0,0,0,0,0,k__3,0,1-2*k__3,0,0,0,0,0,0,0,0,k__1,0,0,0,0\
|0,0,0,0,0,k__3,0,1-4*k__3,0,k__3-1,0,0,0,0,0,0,0,0,0,(1-k\
__2)/2,0,k__3-1/2,0,0,0,0,0,0,0,0,1-2*k__3,0,0,0,0,0|0,0,0\
,0,0,0,k__3-1,0,1-4*k__3,0,k__3,0,0,0,0,0,0,0,0,0,k__3-1/2\
,0,(1-k__2)/2,0,0,0,0,0,0,0,0,1-2*k__3,0,0,0,0|0,0,0,0,0,-\
1/2,0,k__3-1,0,-2*k__3,0,0,0,0,0,0,0,0,0,1-2*k__3,0,k__3,0\
,0,0,0,0,0,0,0,k__1,0,0,0,0,0|0,0,0,0,0,0,-1/2,0,k__3,0,1,\
0,0,0,0,0,0,0,0,0,-2*k__3,0,k__3,0,0,0,0,0,0,0,0,-1/2,0,0,\
0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,-2*k__3,0,k__3,0\
,k__1,0,0,0,0,0,0,0,0,k__3-1,0,1-2*k__3,0,0,0,0,0,0,-1/2,0\
|0,0,k__3-1/2,0,0,0,0,0,0,0,0,0,0,k__2,0,-k__1+5*k__3-1/2,\
0,0,0,0,0,0,0,0,k__3-1/2,0,-k__1+5*k__3-1/2,0,1-2*k__3,0,0\
,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,k__3,0,1-2*k__3,0,k__3,\
0,0,0,0,0,0,0,0,k__3-1/2,0,k__3-1/2,0,0,0,0,0,0,-2*k__3,0|\
0,0,k__3-1/2,0,0,0,0,0,0,0,0,0,0,-k__1+5*k__3-1/2,0,k__2,0\
,0,0,0,0,0,0,0,1-2*k__3,0,-k__1+5*k__3-1/2,0,k__3-1/2,0,0,\
0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,k__1,0,k__3,0,-2*k__3,0,\
0,0,0,0,0,0,0,1-2*k__3,0,k__3-1,0,0,0,0,0,0,-1/2,0|0,0,0,0\
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\
,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\
,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,k__3,0,(1-k__2)/2,0,1-2*k__\
3,0,0,0,0,0,0,0,0,0,1-4*k__3,0,k__3-1/2,0,0,0,0,0,0,0,0,k_\
_3-1,0,0,0,0,0|0,0,0,0,0,0,k__3,0,k__3-1/2,0,-2*k__3,0,0,0\
,0,0,0,0,0,0,1-2*k__3,0,k__3-1/2,0,0,0,0,0,0,0,0,k__3,0,0,\
0,0|0,0,0,0,0,-2*k__3,0,k__3-1/2,0,k__3,0,0,0,0,0,0,0,0,0,\
k__3-1/2,0,1-2*k__3,0,0,0,0,0,0,0,0,k__3,0,0,0,0,0|0,0,0,0\
,0,0,1-2*k__3,0,(1-k__2)/2,0,k__3,0,0,0,0,0,0,0,0,0,k__3-1\
/2,0,1-4*k__3,0,0,0,0,0,0,0,0,k__3-1,0,0,0,0|0,0,0,0,0,0,0\
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\
|0,0,-1/2,0,0,0,0,0,0,0,0,0,0,k__3-1/2,0,1-2*k__3,0,0,0,0,\
0,0,0,0,1,0,k__3-1/2,0,-1/2,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,\
0,0,0,0,k__3-1,0,k__3-1/2,0,1-2*k__3,0,0,0,0,0,0,0,0,1-4*k\
__3,0,(1-k__2)/2,0,0,0,0,0,0,k__3,0|0,0,1-2*k__3,0,0,0,0,0\
,0,0,0,0,0,-k__1+5*k__3-1/2,0,-k__1+5*k__3-1/2,0,0,0,0,0,0\
,0,0,k__3-1/2,0,k__2,0,k__3-1/2,0,0,0,0,0,0,0|0,0,0,0,0,0,\
0,0,0,0,0,0,1-2*k__3,0,k__3-1/2,0,k__3-1,0,0,0,0,0,0,0,0,(\
1-k__2)/2,0,1-4*k__3,0,0,0,0,0,0,k__3,0|0,0,-1/2,0,0,0,0,0\
,0,0,0,0,0,1-2*k__3,0,k__3-1/2,0,0,0,0,0,0,0,0,-1/2,0,k__3\
-1/2,0,1,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,-1/2,0,1-2*\
k__3,0,k__1,0,0,0,0,0,0,0,0,0,k__3-1,0,k__3,0,0,0,0,0,0,0,\
0,-2*k__3,0,0,0,0,0|0,0,0,0,0,0,k__1,0,1-2*k__3,0,-1/2,0,0\
,0,0,0,0,0,0,0,k__3,0,k__3-1,0,0,0,0,0,0,0,0,-2*k__3,0,0,0\
,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\
,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,-1/\
2,0,-2*k__3,0,-1/2,0,0,0,0,0,0,0,0,k__3,0,k__3,0,0,0,0,0,0\
,1,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>#assuming'real':
cc:={evalindets}(LinearAlgebra:-IsDefinite(mm,query='positive_semidefinite'),`and`,op):

As the title says, I hope to find some values satisfying andseq('cc') (so `mm` becomes positive semidefinite). Unfortunately, these don't work: 

# SMTLIB:-Satisfy(cc);
Optimization:-Maximize(0, cc, initialpoint = eval({k__ || (1 .. 3)} =~ 'rand(-2e1 .. 2e1)'()));
Error, (in Optimization:-NLPSolve) no feasible point found for the nonlinear constraints
timelimit(1e2, RealDomain:-solve(cc, [k__ || (1 .. 3)](*, 'maxsols' = 1*)));
Error, (in RegularChains:-SemiAlgebraicSetTools:-CylindricalAlgebraicDecompose) time expired

 Is there a way to do so as accurately (and precisely) as possible?

 

Maple introduced "Copy as LaTeX" a few versions ago and I have used this feature exensively when it suddenly stopped working.

After som experiments I found the root cause and easy (but irritating) workaround for OSX

Problem:

"Copy as LaTeX" suddenly stops working ("Copy as MathML" still works fine)

Cause:

This problem appears if in “Display Setting”-tab in settings dialogue the “Input display” is set to “Maple Notation

In that case all attempts on “Copy as LaTeX” will be a null-function and not move anything at all into the copy buffer.

The “Copy as MathML” is not affected by this in the same way.

I have confirmed this on OSX in Maple versions 2022, 2023, and 2024

Workaround:

Adjusting “Display Setting”-tab in settings dialogue so that the “Input display” is set to “2-D Math” and “Apply Globally” makes it work again.

A bit annoying as a prefer the maple notation input and I cannot have this setting if I want the copy to latex to work.

Note:

in OSX this can also be fixed by removing the Maple preferences file and letting Maple restore it.

~/Library/Preferences/Maple/2023/Maple Preferences

Edit: Added 2024 as affected version.

Since I began to use Maple for teaching back in 2014 (now on 2023 version), the following happens to some students. 

While they are in math mode, the Maple engine suddenly stops being unable to do anything (even 2+2). Only way to solve this is to start a new document or restart Maple. I have seen this issue on both Mac and PC version. 

So my question is what causes this? 

Hi everyone,

I'd like to draw your attention to a package we recently uploaded to the Maple Cloud, here. You can download the package from the linked Cloud page, or directly from here as a workbook file: NaturalLanguage.maple. I'll include a lightly edited version of the "cover sheet" that introduces the package below. I have left the first four sections folded closed - you can see those in the linked Maple Cloud page or the workbook - because I think the last section is the most interesting.
 

Using natural language models in Maple


This package explores using large language models such as ChatGPT for processing natural language in Maple. Let's load the package from source, save it in this workbook, and load it.

restart

read "this:///lib/NaturalLanguage.mpl"

savelib('NaturalLanguage', "this://")

with(NaturalLanguage)

Warning, the NaturalLanguage package is an experimental package designed as an interface to publicly available large language models such as ChatGPT. Use of this package is entirely at the user's risk. Results may be inconsistent, misleading, or flat out incorrect. 

[Explain, GetCommand, GetMath, Query, RawQuery]

(1)

We note there is a warning: we will see output of large language models, which will often include inaccurate statements. Please keep this in mind - this is not (yet?) technology that you want to use to build a bridge!

We also note that there are five publically exposed commands. Let's look at them in turn.

RawQuery

   

Query

   

GetMath

   

GetCommand

   

Explain

 
• 

The Explain command asks the given model to explain the item in the query. After an explanation, you can ask for more detail by issuing the command Explain(more), Explain("go on"), Explain(elaborate), Explain(further), Explain("continue"), or minor variations. The item you ask about can be a mathematical expression, equation, list of equations, or a string.

• 

The default model is GPT-4; you can select the other model by using the model = ChatGPT option, or forcing use of the GPT-4 model by using the model = GPT4 option. Note that OpenAI may deprecate and disable models, so the set of models supported may change in the future.

display(Explain(x^2+y^2=1));display(Explain(x^2+y^2 = 1))

This equation represents a circle with a radius of 1 centered at the origin (0,0) on a coordinate plane.

 

display(Explain(more));display(Explain(more))

The equation x^2 + y^2 = 1 represents a circle in a two-dimensional plane (specifically, a Cartesian plane).

The center of the circle is at the origin of the coordinates (0,0) and its radius is 1. This is because any point (x, y) on the circle is a distance r (the radius) away from the center, and by the Pythagorean theorem, this distance is given by the square root of (x^2 + y^2). The fact that x^2 + y^2 = 1 implies that the radius r = sqrt(1) = 1.

This fundamental equation is also the unit circle in trigonometry, where angles are measured in radians. The coordinates (x, y) represent the cosine and sine of the angle respectively. The unit circle is a crucial concept in trigonometry, complex number theory, and calculus. It simplifies many mathematical concepts and provides a geometric interpretation of a variety of phenomena in physical sciences and engineering.

 

display(Explain(Re(exp(x*I + y*I)) = Re(exp(x*I)) * Re(exp(y*I)) - Im(exp(x*I)) * Im(exp(y*I))));display(Explain(Re(exp(I*x+I*y)) = Re(exp(I*x))*Re(exp(I*y))-Im(exp(I*x))*Im(exp(I*y))))

The equation seems to be using Euler's formula, which states that e^(ix) = cos(x) + i*sin(x). The 'Re' refers to the real part of a complex number, and 'Im' refers to the imaginary part. So, if you put Euler's formula in there your equation is equivalent to cos(x + y) = cos(x)cos(y) - sin(x)sin(y), which is basically the well-known trigonometric formula for the cosine of a sum. In a nutshell, it's dealing with the trigonometric identities and properties of exponential functions with complex numbers.

 

display(Explain("go on", model = ChatGPT));display(Explain("go on", model = ChatGPT))

The given equation appears to be dealing with the real part of a complex exponential expression. Let's break it down step by step to understand its meaning:

1. The equation involves the expression e^(i*x+i*y), where e represents Euler's number (~2.718), i is the imaginary unit (√(-1)), and x and y are real numbers.
2. The expression e^(i*x+i*y) can be rewritten using Euler's formula: e^(i*x+i*y) = cos(x+y) + i*sin(x+y). This is a complex number in the form a + bi, where 'a' represents the real part (Re) and 'b' represents the imaginary part (Im).
3. The real part of e^(i*x+i*y) is, therefore, Re(e^(i*x+i*y)) = cos(x+y).
4. The right side of the equation consists of the product of two complex exponential expressions: Re(e^(i*x))*Re(e^(i*y))-Im(e^(i*x))*Im(e^(i*y)).
5. The expression Re(e^(i*x)) represents the real part of e^(i*x), which is cos(x), and Im(e^(i*x)) represents the imaginary part of e^(i*x), which is sin(x).
6. Similarly, Re(e^(i*y)) represents the real part of e^(i*y), which is cos(y), and Im(e^(i*y)) represents the imaginary part of e^(i*y), which is sin(y).
7. Therefore, the right side becomes: (cos(x)*cos(y)) - (sin(x)*sin(y)).

So, the equation Re(e^(i*x+i*y)) = Re(e^(i*x))*Re(e^(i*y))-Im(e^(i*x))*Im(e^(i*y)) essentially states that the real part of e^(i*x+i*y) (i.e., cos(x+y)) is equal to the real part of e^(i*x) (i.e., cos(x)) multiplied by the real part of e^(i*y) (i.e., cos(y)), minus the imaginary part of e^(i*x) (i.e., sin(x)) multiplied by the imaginary part of e^(i*y) (i.e., sin(y)).

In simpler terms, the equation is connecting the real part of the sum of two complex exponential expressions with the product of the real parts and the difference of the imaginary parts of those individual expressions.

 

display(Explain(Re(sigma) < 0));display(Explain(Re(sigma) < 0))

The inequality "Re(sigma) < 0" is a statement in complex number theory. It is saying that the real part (Re) of a complex number sigma is less than zero. This means that the complex number is to the left of the imaginary axis in the complex number plane. This kind of inequality is often used in the study of complex functions, in areas such as control systems or signal processing in electrical engineering, and also in number theory and the study of dynamical systems in mathematics.

 

display(Explain(continue));display(Explain(continue))

The inequality "Re(sigma) < 0" is typically related to the field of complex numbers. Here, "Re" stands for the real part of a complex number and "sigma" is usually used to represent a complex number. So, "Re(sigma) < 0" is saying that the real part of the complex number sigma is negative.

Complex numbers are usually written in the form a + bi, where a and b are real numbers and i is the imaginary unit. The "Re" in "Re(sigma)" refers to the a part of this form, i.e. the real part of the complex number.

This inequality is often found in fields like control systems engineering or signal processing. For instance, in control systems, all the poles of a stable system must have a negative real part. Another context you might come across this inequality is in complex analysis, one might examine the region where the real part of a complex function is negative. So, the inequality "Re(sigma) < 0" expresses that a complex number is in the left half of the complex plane, which is often crucial for the stability of many systems in engineering.

 

display(Explain("The Maple command simplify"));display(Explain("The Maple command simplify"))

The Maple command "simplify" is used to simplify mathematical expressions. In Maple, this command applies various rules to reduce an equation or expression to its simplest or most compact form.

For example, if you have an equation like `(x^3 - x^2)/x^2`, using the simplify command would reduce it to `x - 1`. It simplifies algebraic expressions, performs factorization, combines like terms, cancel out common factors, etc.

The general syntax is `simplify(expr)`, where `expr` is the expression that you want to simplify. The simplified expression is returned as output.

Please note that the simplifications made by this command are based on general rules and may not always give the expected results for some specific expressions due to the complexity of mathematical simplifications.

 

display(Explain(continue, model=ChatGPT));display(Explain(continue, model = ChatGPT))

The Maple command "simplify" is used to simplify mathematical expressions. It takes an expression as input and attempts to find a simplified form by applying various algebraic rules and simplification techniques.

When you use the "simplify" command, Maple applies a series of simplification steps, which can include:

1. Expanding and factoring polynomials: This step expands products of terms and factors out common terms.
2. Simplifying fractions: The command simplifies fractions by canceling common factors in the numerator and denominator.
3. Simplifying trigonometric expressions: Maple applies trigonometric identities to simplify expressions involving trigonometric functions.
4. Simplifying logarithmic and exponential expressions: The command applies rules of logarithms and exponents to simplify expressions with these functions.
5. Simplifying square roots and radicals: It simplifies square roots by expressing them in simplest radical form.
6. Simplifying expressions involving absolute values: Maple simplifies absolute value expressions by considering different cases based on the sign of the argument.
7. Applying mathematical identities and rules: The command uses various mathematical identities and rules to simplify expressions further.

The "simplify" command in Maple is very powerful and can handle a wide range of mathematical expressions. However, it may not always produce the most simplified form, as simplification can sometimes be a subjective task. In such cases, you can try using other commands or options available in Maple to refine the simplification process.

To use the "simplify" command in Maple, you can simply type "simplify(expression)" where "expression" represents the mathematical expression you want to simplify.

 

display(Explain("Weight of a W10X54 beam?"))

The weight of a W10X54 beam refers to the weight specification of a beam in the W Beam series, commonly used in construction and engineering projects. The nomenclature "W10X54" is decoded as follows:

- W: it stands for 'wide flange', a type of structural steel beam where the flanges are parallel to each other.
- 10: it indicates the nominal depth of the wide flange, which is about 10 inches.
- 54: it indicates the weight of the beam per linear foot, which is about 54 pounds.

So, a W10X54 beam weighs 54 pounds per foot.

 

display(Explain(further))

"Weight of a W10X54 beam" refers to the weight of a specific kind of structural steel beam used in construction and architecture. The "W" stands for "wide flange", which is a particular type of I-beam.

The "10" means the nominal depth of the beam in inches (also known as its height when standing upright).

The "54" represents the beam's weight per foot in pounds. In other words, for every foot of length the beam has, it weighs 54 pounds.

 So if you have a W10X54 beam that is 10 feet long, its total weight would be 540 pounds (10 feet times 54 pounds per foot).

Please note that these are nominal dimensions and may not exactly match the true dimensions of the beam due to manufacturing variables.

 

NULL

 

What do you think? Will this be an important part of mathematical software in the near future, or are we still far away from that point? We'd love to hear your opinions.

I installed Maple 2023.1 update and immediately noticed a problem with the worksheet editor.

Specifically, the editor seems to be replacing "<" with "!" in the maple code. I first noticed the problem with code copied from the maple code editor into a worksheet, but then noticed the same problem with code on another worksheet which was loaded from file. Thus, it seems the problem is actually in the worksheet editor and not the copy paste function.  Note that the problem occurred immediately on reloading files after I restarted maple from the update. Normally, when this occurs, it starts after Maple has been loaded for an hour or more. Fortunately, when I restarted Maple and reloaded files, the problem seems to have cleared itself.

I have attached images showing the maple screen with the error, and also the specific code copied from the code editor to a worksheet for comparison.  I have also attached the worksheets in which I saw the problem. For now my goto workaround is to save and restart because the problem does not seem to corrupt the actual files even when I save them.

 

Attachments: chain.mw  chain2.mw

According to print - Maple Help (maplesoft.com),

calling print[N] instead of print where N is an integer between -2 and +3, temporarily overrides the prettyprint interface variable.

However, I find that 

print[-2]();
Error, prettyprint must be an integer in the range 0..3
print[-1]();
Error, prettyprint must be an integer in the range 0..3

Also, 

interface(prettyprint = -2);
Error, (in interface) prettyprint must be an integer in the range 0..3
interface(prettyprint = -1);
Error, (in interface) prettyprint must be an integer in the range 0..3

Did I miss something?

I'd like to reproduce Initial Value DDE of Neutral Type in Maple.
The differential equation is: 

deq := D(y)(t) = 2*cos(2*t)*y(t/2)^(2*cos(t)) + ln(D(y)(t/2)) - ln(2*cos(t)) - sin(t): # with y(0) = 1 and known D(y)(0)

Unfortunately, if I type valid initial values, Maple will simply generate , and yet if I just give a partial initial condition, Maple will display and only return incorrect results. 
 

restart;

interface(version)

`Standard Worksheet Interface, Maple 2023.1, Windows 10, July 7 2023 Build ID 1723669`

(1)

deq := (D(y))(t) = 2*cos(2*t)*y((1/2)*t)^(2*cos(t))+ln((D(y))((1/2)*t))-ln(2*cos(t))-sin(t)

RealDomain:-solve(subs(t = 0, y(0) = 1, deq), (D(y))(0))

2, -LambertW(-2*exp(-2))

(2)

dsolve({deq, y(0) = 1, (D(y))(0) = (2, -LambertW(-2*exp(-2)))[1]}, 'numeric', 'delaymax' = Pi, 'range' = 0 .. 2*Pi)

Error, (in dsolve/numeric/DAE/initial) too many initial conditions, the following are not needed: {D(y)(0) = 2}

 

dsolve({deq, y(0) = 1, (D(y))(0) = (2, -LambertW(-2*exp(-2)))[2]}, 'numeric', 'delaymax' = Pi, 'range' = 0 .. 2*Pi)

Error, (in dsolve/numeric/DAE/initial) too many initial conditions, the following are not needed: {D(y)(0) = -LambertW(-2*exp(-2))}

 

dsn := dsolve({deq, y(0) = 1}, 'type' = 'numeric', 'delaymax' = Pi, 'range' = 0 .. 2*Pi)

plots['odeplot'](dsn, 0 .. 2*Pi)NULL

Warning, cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up

 

`[Length of output exceeds limit of 1000000]`

 

Warning, cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up

 

 


 

Download ndelay.mw

The output is wrong. Note that "y(0) = 1" is insufficient to uniquely specify a solution, as "D(y)(0)" can be either -LambertW(-2/exp(2)) or 2. But Maple does not allow sufficient constraints here. How do I avoid such an unexpected behavior?

Maple's fsolve command can quickly solve expressions involving large floating point numbers where the (symbolic) solve command can take much longer attempting to solve the equivalent rational expression. For example, consider the following worksheet:

restart;

sys := {a + b^0.2784982189 = c+1, b + c^0.9575068354 = a+2, c + a^0.1576130817 = b+3};

{a+b^.2784982189 = c+1, b+c^.9575068354 = a+2, c+a^.1576130817 = b+3}

(1)

fsolve_start:=time[real]():

fsolve(sys);

{a = 3.561242843, b = 1.994950678, c = 3.773320855}

(2)

fsolve_elapsed_seconds:= time[real]()-fsolve_start;

0.50e-1

(3)

solve_start:=time[real]():

###warning, the following command may crash and/or execute indefinitely###

solve(sys);

solve_elapsed_hours:=(time[real]()-solve_start)/3600;


 

Download solve-fsolve-primes.mw

Here is a test: 

For small matrices, apart from the first call, the performance is almost perfect (🎉!). 
As a comparison, an equivalent test may be performed in modern Python:

As you can see, for 1024×1024, 2048×2048, 4096×4096, 8192×8192, and 16384×16384 matrices, Maple's performance gets pretty poor. Is the FFT procedure not well optimized for larger matrices? I do have read the Fourier Transforms in Maple, yet I cannot find any information on this subject. 
In accordance with the following output 

showstat(DiscreteTransforms::FFT_complex8, 3):

FFT_complex8 := proc()
       ...
   3   :-DiscreteTransforms:-FFT_complex8 := LinkExternal('hw_FFT',2003);
       ...
end proc

it appears that the code hasn't been developed for 20 years. Is it possible to improve the performance of the FFT built into Maple in order that the computation on such a 2¹⁴×2¹⁴ matrix can be achieved in about twenty seconds (rather than in two minutes)?

Note. For these matrices, exact transform results (see below) can be obtained symbolically.

for n from 0 to 12 do
    m := LinearAlgebra:-HankelMatrix(<$ (1 + 1 .. 2**n + 2**n)>, datatype = complex[8], shape = []): gc();
    print(n, andseq(abs(_) < HFloat(1, -10, 2), _ in SignalProcessing:-FFT(m, normalization = none, inplace = true) - Matrix(2^n, <2^(2*n)*(2^n + 1), <'2^(2*n - 1)*(:-cot((k - 1)/2^n*Pi)*I - 1)' $ 'k' = 1 + 1 .. 2^n>>, shape = symmetric, storage = sparse, datatype = complex[8])) (* faster than `rtable_scanblock` and `ArrayTools:-IsZero` and much faster (🎊!) than `comparray` and `verify/Matrix` with testfloat *) )
od:
 = 
                            0, true

                            1, true

                            2, true

                            3, true

                            4, true

                            5, true

                            6, true

                            7, true

                            8, true

                            9, true

                            10, true

                            11, true

                            12, true

However, the main goal is to test the numerical efficiency of Maple's fast Fourier transform algorithm.

Down below I am sharing with you the question and what I wrote as a solution so far. It includes the commands, functions, outputs, and errors. I am struggling with fixing my errors as I have tried numerous ways to correct them. However, I either get new errors or previous errors. Was wondering if someone can look at it and provide me advice, and a possible solution to the problem. 

In this question, you are given a cypher that was obtained using a Vigenere cypher, care of question 2, and are asked to decipher it.  You will use the approach outlined in Section 5.2 of the text.  There are two steps:  1)  Determine the key length by finding the shift which produces the maximum number of coincidences, 2)  use frequency analysis on the subsequences obtained by selecting symbols from the cypher at multiples of the key length to determine the key.  The details of these steps will be outlined below.  You will be asked to write several maple procedures that assist in this process.

restart;
with(StringTools):

with(LinearAlgebra):
cstr := "eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveolqlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvvzhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgyklhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvojikomtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhhapdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpveuzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyinky";
cstr := "eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveol\

  qlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvv\

  zhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgy\

  klhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvoji\

  komtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhha\

  pdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpv\

  euzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyin\

  ky"


n := Length(cstr);
                            n := 429


a)  Determine the key length.  Write a Maple function to determine the key length given the ciphertext obtained from a Vigenere cipher with unknown key using a specified alphabet.  Use one of the methods outlined in section 5.2 of the text: the Kasiski test (using trigrams) or the index of coincidence test. For the Kasiski test, the key length is suggested by the greatest common divisor of the distances between most of the repeated trigrams. For the index of coincidence test, construct the subsequences described in part (b) for various values of 
k;
. The 
k;
 value that yields the highest average index of coincidence of these subsequences most likely is the key length. 

KasiskiTest := proc(str)
  local i, j, n, trigrams, distances, gcds, freqs;
  n := StringTools:-Length(str);
  trigrams := table();
  distances := table();
  gcds := table();
  freqs := table();
  for i from 1 to n-2 do
    trigrams[str[i..i+2]] := [op(trigrams[str[i..i+2]]),i];
  end do;
  for j in trigrams do
    if nops(trigrams[j]) > 1 then
      distances[j] := map(diff,trigrams[j]);
      gcds[j] := igcd(op(distances[j]));
      freqs[gcds[j]] := freqs[gcds[j]] + 1;
    end if;
  end do;
  return maxloc(freqs);
end;

IndexCoincidenceTest := proc(str)
  local i, k, n, m, L, C, Convert, IC, avgIC;
  Convert := table();  n := StringTools:-Length(str);  
  for i from 1 to n do
    Convert[str[i]] := i-1;
  end do;
  L := Letter2Number(str,Convert); 
  IC := [];
  avgIC := [];
  for k from 1 to n/2 do
    C := [];
    for i from 1 to k do
      C[i] := seq(L[i+j*k],j=0..floor((n-i)/k));
    end do;
    IC[k] := map(DotProduct,C,C)/nops(C)^2;
    avgIC[k] := add(IC[k])/k;
  end do;
  return maxloc(avgIC);
end;

KasiskiTest(cstr);


                         maxloc(freqs)

IndexCoincidenceTest(cstr);
Error, (in IndexCoincidenceTest) expression sequences cannot be assigned to lists


b) Construct subsequences of the cypher by selecting characters at multiples of the key length.  I.E.  If k is the key length, then construct subsequences:  c1 = cstr[1],cstr[1+k],...,cstr[1+n/k],...,ck = cstr[k],cstr[2*k],...,cstr[floor(n/k)*k].  

Maple hint:  use seq and cat to form these strings.

cstr := "eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveolqlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvvzhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgyklhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvojikomtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhhapdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpveuzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyinky";
cstr := "eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveol\

  qlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvv\

  zhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgy\

  klhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvoji\

  komtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhha\

  pdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpv\

  euzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyin\

  ky"

Subsequences := proc(str,k)
  local i, n, C, S;
  n := StringTools:-Length(str);
  C := [];
  S := [];
  for i from 1 to k do
    C[i] := seq(str[i+j*k],j=0..floor((n-i)/k));
    S[i] := cat(op(C[i]));
  end do;
  return S;
end;

Warning, (in Subsequences) `j` is implicitly declared local
 Subsequences := proc (str, k) local i, n, C, S, j; n := 

    StringTools:-Length(str); C := []; S := []; for i to k do 

    C[i] := seq(str[i+j*k], j = 0 .. floor((n-i)/k)); S[i] := 

    cat(op(C[i])) end do; return S end proc


Subsequences(cstr,4);
Error, (in Subsequences) expression sequences cannot be assigned to lists


c) Calculate the character frequencies in the substrings formed from (b).  You should construct a list F=[f1/n,...,ft/n], where fi is the number of occurrences of symbol i in the string and n is the number of symbols in the string, and t is the number of symbols in the alphabet.  Don't forget that you can use evalf() to get a floating point approximation to the fractions fi/n, and you can use CountCharacterOccurrences() from the StringTools package to obtain the number of occurrences of the ith symbol. For the alphabet use a,...,z.  See question 1.

alphabet := Iota("a".."z");
            alphabet := "abcdefghijklmnopqrstuvwxyz"

CharacterFrequencies := proc(str,alphabet)
  local i, n, t, F, C;
  n := StringTools:-Length(str);
  t := StringTools:-Length(alphabet);
  F := [];
  C := StringTools:-CountCharacterOccurrences(str);
  for i from 1 to t do
    F[i] := evalf(C[alphabet[i]]/n);
  end do;
  return F;
end;

Error, attempting to assign to `StringTools:-CharacterFrequencies` which is protected
alphabet := "abcdefghijklmnopqrstuvwxyz";
S := Subsequences(cstr,4);
CharacterFrequencies(S[1],alphabet);

            alphabet := "abcdefghijklmnopqrstuvwxyz"

Error, (in Subsequences) expression sequences cannot be assigned to lists
Error, (in StringTools:-CharacterFrequencies) first argument must be a string


d) Determine the Ceasar shifts for the 5 subsequences from (b) and hence determine the key.  This is done by comparing the frequencies computed in (c) with the standard English letter probabilities given in the list FE.

You are to write a function FindShift(F1,F2) which takes as input F1 = the standard frequencies and F2 = the shifted frequencies.  The function FindShift(F1,F2) find the shift 
                              "s"

 which minimizes the error between the two lists of frequencies.  I.E.  For each possible shift 
                  "s=0,1,...,25 = nops(F1), "

compute the sum of the squares of the difference F1[i]-F2[i+s mod 26].  Find the value of 
                              "s"

 that minimizes this sum.  This will be the most likely shift.

Note that in the above sum, you will need to correct the indexing due to the fact that Maple indexes lists and arrays starting at 1 rather than 0.

Use the function FindShift to find the key used to create the cypher cstr.

FE := [0.8167000000e-1, 0.1492000000e-1, 0.2782000000e-1, 0.4253000000e-1, .1270200000, 0.2228000000e-1, 0.2015000000e-1, 0.6094000000e-1, 0.6966000000e-1, 0.1530000000e-2, 0.7720000000e-2, 0.4025000000e-1, 0.2406000000e-1, 0.6749000000e-1, 0.7507000000e-1, 0.1929000000e-1, 0.9500000000e-3, 0.5987000000e-1, 0.6327000000e-1, 0.9056000000e-1, 0.2758000000e-1, 0.9780000000e-2, 0.2360000000e-1, 0.1500000000e-2, 0.1974000000e-1, 0.7400000000e-3];
[0.08167000000, 0.01492000000, 0.02782000000, 0.04253000000, 

  0.1270200000, 0.02228000000, 0.02015000000, 0.06094000000, 

  0.06966000000, 0.001530000000, 0.007720000000, 0.04025000000, 

  0.02406000000, 0.06749000000, 0.07507000000, 0.01929000000, 

  0.0009500000000, 0.05987000000, 0.06327000000, 0.09056000000, 

  0.02758000000, 0.009780000000, 0.02360000000, 0.001500000000, 

  0.01974000000, 0.0007400000000]


FindShift := proc(F1,F2)
  local i, s, n, t, S, M;
  n := nops(F1);
  t := nops(F2);
  S := [];
  for s from 0 to n-1 do
    S[s+1] := add((F1[i]-F2[(i+s) mod t + 1])^2,i=1..n);
  end do;
  M := minloc(S);
  return M[2]-1;
end;

 FindShift := proc (F1, F2) local i, s, n, t, S, M; n := 

    nops(F1); t := nops(F2); S := []; for s from 0 to n-1 do 

    S[s+1] := add((F1[i]-F2[(`mod`(i+s, t))+1])^2, i = 1 .. n) 

    end do; M := minloc(S); return M[2]-1 end proc


with(StringTools);
alphabet := "abcdefghijklmnopqrstuvwxyz";
cstr := "eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveolqlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvvzhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgyklhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvojikomtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhhapdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpveuzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyinky";
FE := [0.8167000000e-1, 0.1492000000e-1, 0.2782000000e-1, 0.4253000000e-1, .1270200000, 0.2228000000e-1, 0.2015000000e-1, 0.6094000000e-1, 0.6966000000e-1, 0.1530000000e-2, 0.7720000000e-2, 0.4025000000e-1, 0.2406000000e-1, 0.6749000000e-1, 0.7507000000e-1, 0.1929000000e-1, 0.9500000000e-3, 0.5987000000e-1, 0.6327000000e-1, 0.9056000000e-1, 0.2758000000e-1, 0.9780000000e-2, 0.2360000000e-1, 0.1500000000e-2, 0.1974000000e-1, 0.7400000000e-3];
Subsequences := proc(str,k)
  local i, n, C, S;
  n := StringTools:-Length(str);
  C := [];
  S := [];
  for i from 1 to k do
    C[i] := seq(str[i+j*k],j=0..floor((n-i)/k));
    S[i] := cat(op(C[i]));
  end do;
  return S;
end;
CharacterFrequencies := proc(str,alphabet)
  local i, n, t, F, C;
  n := StringTools:-Length(str);
  t := StringTools:-Length(alphabet);
  F := [];
  C := StringTools:-CountCharacterOccurrences(str);
  for i from 1 to t do
    F[i] := evalf(C[alphabet[i]]/n);
  end do;
  return F;
end;
FindShift := proc(F1,F2)
  local i, s, n, t, S, M;
  n := nops(F1);
  t := nops(F2);
  S := [];
  for s from 0 to n-1 do
    S[s+1] := add((F1[i]-F2[(i+s) mod t + 1])^2,i=1..n);
  end do;
  M := minloc(S);
  return M[2]-1;
end;
S := Subsequences(cstr,4);
F := map(CharacterFrequencies,S,alphabet);
Shifts := map(FindShift,FE,F);
KeyLetters := map(Number2Letter,Shifts,alphabet);
Key := cat(op(KeyLetters));

[Anagrams, AndMap, ApproximateSearch, ApproximateSearchAll, 

  ArithmeticMean, Border, BorderArray, BorderLength, CamelCase, 

  Capitalize, CaseJoin, CaseSplit, Center, Centre, Char, 

  CharacterFrequencies, CharacterMap, Chomp, Chop, CommonPrefix, 

  CommonSuffix, Compare, CompareCI, Compress, 

  CountCharacterOccurrences, Decode, DecodeEntities, Delete, 

  DeleteSpace, DifferencePositions, Drop, EditDistance, Encode, 

  EncodeEntities, Entropy, Escape, Exchange, 

  ExpandCharacterClass, ExpandTabs, Explode, Fence, Fibonacci, 

  Fill, FirstFromLeft, FirstFromRight, FormatMessage, FormatTime, 

  FromByteArray, Generate, GenerateIdentifier, Group, 

  HammingDistance, HammingSearch, HammingSearchAll, Has, 

  HasASCII, HasAlpha, HasAlphaNumeric, HasBinaryDigit, 

  HasControlCharacter, HasDigit, HasGraphic, HasHexDigit, 

  HasIdentifier, HasIdentifier1, HasLower, HasOctalDigit, 

  HasPrintable, HasPunctuation, HasSpace, HasUpper, HasVowel, 

  Hash, Implode, Indent, IndexOfCoincidence, Insert, Iota, 

  IsASCII, IsAlpha, IsAlphaNumeric, IsAnagram, IsBalanced, 

  IsBinaryDigit, IsConjugate, IsControlCharacter, IsDerangement, 

  IsDigit, IsEodermdrome, IsGraphic, IsHexDigit, IsIdentifier, 

  IsIdentifier1, IsLower, IsMonotonic, IsOctalDigit, 

  IsPalindrome, IsPeriod, IsPermutation, IsPrefix, IsPrimitive, 

  IsPrintable, IsPunctuation, IsSorted, IsSpace, IsSubSequence, 

  IsSuffix, IsUpper, IsVowel, Join, Kasiski, LeftFold, 

  LeftRecursivePathOrder, Length, LengthSplit, Levenshtein, 

  LexOrder, LongestCommonSubSequence, LongestCommonSubString, 

  LowerCase, LyndonFactors, Map, MatchFence, MaxChar, 

  MaximalPalindromicSubstring, Metaphone, MinChar, 

  MinimumConjugate, MonotonicFactors, NGrams, NthWord, OrMap, 

  Ord, OtherCase, Overlap, PadLeft, PadRight, ParseTime, 

  PatternCanonicalForm, PatternDictionary, PatternEquivalent, 

  Period, Permute, PrefixDistance, PrimitiveRoot, Random, 

  Randomize, Readability, RegMatch, RegSplit, RegSub, RegSubs, 

  Remove, Repeat, Repeats, RevLexOrder, Reverse, RightFold, 

  RightRecursivePathOrder, Rotate, Search, SearchAll, Select, 

  SelectRemove, Sentences, Shift, ShortLexOrder, 

  ShortRevLexOrder, SimilarityCoefficient, Snarf, Sort, 

  SortPermutation, Soundex, Split, Squeeze, Stem, StringBuffer, 

  StringSplit, SubString, Subs, Substitute, SubstituteAll, 

  SuffixDistance, Support, SyllableLength, Tabulate, Take, 

  ThueMorse, ToByteArray, Trim, TrimLeft, TrimRight, Uncompress, 

  Unique, UpperCase, Visible, WildcardMatch, WordContaining, 

  WordCount, WordEnd, WordStart, Words, WrapText]


            alphabet := "abcdefghijklmnopqrstuvwxyz"

cstr := "eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveol\

  qlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvv\

  zhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgy\

  klhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvoji\

  komtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhha\

  pdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpv\

  euzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyin\

  ky"


FE := [0.08167000000, 0.01492000000, 0.02782000000, 

  0.04253000000, 0.1270200000, 0.02228000000, 0.02015000000, 

  0.06094000000, 0.06966000000, 0.001530000000, 0.007720000000, 

  0.04025000000, 0.02406000000, 0.06749000000, 0.07507000000, 

  0.01929000000, 0.0009500000000, 0.05987000000, 0.06327000000, 

  0.09056000000, 0.02758000000, 0.009780000000, 0.02360000000, 

  0.001500000000, 0.01974000000, 0.0007400000000]


Warning, (in Subsequences) `j` is implicitly declared local
 Subsequences := proc (str, k) local i, n, C, S, j; n := 

    StringTools:-Length(str); C := []; S := []; for i to k do 

    C[i] := seq(str[i+j*k], j = 0 .. floor((n-i)/k)); S[i] := 

    cat(op(C[i])) end do; return S end proc


Error, attempting to assign to `StringTools:-CharacterFrequencies` which is protected
 FindShift := proc (F1, F2) local i, s, n, t, S, M; n := 

    nops(F1); t := nops(F2); S := []; for s from 0 to n-1 do 

    S[s+1] := add((F1[i]-F2[(`mod`(i+s, t))+1])^2, i = 1 .. n) 

    end do; M := minloc(S); return M[2]-1 end proc


Error, (in Subsequences) expression sequences cannot be assigned to lists
                             F := 

Error, invalid input: FindShift uses a 2nd argument, F2, which is missing
KeyLetters := Number2Letter(Shifts, "abcdefghijklmnopqrstuvwxyz")

            Key := Shiftsabcdefghijklmnopqrstuvwxyz


e) Decipher cstr using the key found in (d) and your DecryptVigenere routine from question 2.  Note that the encrypted text will have blanks removed.

with(StringTools);
[Anagrams, AndMap, ApproximateSearch, ApproximateSearchAll, 

  ArithmeticMean, Border, BorderArray, BorderLength, CamelCase, 

  Capitalize, CaseJoin, CaseSplit, Center, Centre, Char, 

  CharacterFrequencies, CharacterMap, Chomp, Chop, CommonPrefix, 

  CommonSuffix, Compare, CompareCI, Compress, 

  CountCharacterOccurrences, Decode, DecodeEntities, Delete, 

  DeleteSpace, DifferencePositions, Drop, EditDistance, Encode, 

  EncodeEntities, Entropy, Escape, Exchange, 

  ExpandCharacterClass, ExpandTabs, Explode, Fence, Fibonacci, 

  Fill, FirstFromLeft, FirstFromRight, FormatMessage, FormatTime, 

  FromByteArray, Generate, GenerateIdentifier, Group, 

  HammingDistance, HammingSearch, HammingSearchAll, Has, 

  HasASCII, HasAlpha, HasAlphaNumeric, HasBinaryDigit, 

  HasControlCharacter, HasDigit, HasGraphic, HasHexDigit, 

  HasIdentifier, HasIdentifier1, HasLower, HasOctalDigit, 

  HasPrintable, HasPunctuation, HasSpace, HasUpper, HasVowel, 

  Hash, Implode, Indent, IndexOfCoincidence, Insert, Iota, 

  IsASCII, IsAlpha, IsAlphaNumeric, IsAnagram, IsBalanced, 

  IsBinaryDigit, IsConjugate, IsControlCharacter, IsDerangement, 

  IsDigit, IsEodermdrome, IsGraphic, IsHexDigit, IsIdentifier, 

  IsIdentifier1, IsLower, IsMonotonic, IsOctalDigit, 

  IsPalindrome, IsPeriod, IsPermutation, IsPrefix, IsPrimitive, 

  IsPrintable, IsPunctuation, IsSorted, IsSpace, IsSubSequence, 

  IsSuffix, IsUpper, IsVowel, Join, Kasiski, LeftFold, 

  LeftRecursivePathOrder, Length, LengthSplit, Levenshtein, 

  LexOrder, LongestCommonSubSequence, LongestCommonSubString, 

  LowerCase, LyndonFactors, Map, MatchFence, MaxChar, 

  MaximalPalindromicSubstring, Metaphone, MinChar, 

  MinimumConjugate, MonotonicFactors, NGrams, NthWord, OrMap, 

  Ord, OtherCase, Overlap, PadLeft, PadRight, ParseTime, 

  PatternCanonicalForm, PatternDictionary, PatternEquivalent, 

  Period, Permute, PrefixDistance, PrimitiveRoot, Random, 

  Randomize, Readability, RegMatch, RegSplit, RegSub, RegSubs, 

  Remove, Repeat, Repeats, RevLexOrder, Reverse, RightFold, 

  RightRecursivePathOrder, Rotate, Search, SearchAll, Select, 

  SelectRemove, Sentences, Shift, ShortLexOrder, 

  ShortRevLexOrder, SimilarityCoefficient, Snarf, Sort, 

  SortPermutation, Soundex, Split, Squeeze, Stem, StringBuffer, 

  StringSplit, SubString, Subs, Substitute, SubstituteAll, 

  SuffixDistance, Support, SyllableLength, Tabulate, Take, 

  ThueMorse, ToByteArray, Trim, TrimLeft, TrimRight, Uncompress, 

  Unique, UpperCase, Visible, WildcardMatch, WordContaining, 

  WordCount, WordEnd, WordStart, Words, WrapText]


alphabet := "abcdefghijklmnopqrstuvwxyz";
            alphabet := "abcdefghijklmnopqrstuvwxyz"

cstr := "eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveolqlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvvzhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgyklhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvojikomtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhhapdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpveuzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyinky";
cstr := "eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveol\

  qlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvv\

  zhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgy\

  klhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvoji\

  komtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhha\

  pdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpv\

  euzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyin\

  ky"


Key := [19, 4, 18, 19];
                     Key := [19, 4, 18, 19]

DecryptVigenere := proc(str,key,alphabet)
  local i, n, m, L, K, C, Convert, plain;
  Convert := table();  n := StringTools:-Length(alphabet);  
  for i from 1 to n do
    Convert[alphabet[i]] := i-1;
  end do;
  L := Letter2Number(str,Convert); 
  K := Letter2Number(key,Convert);
  m := nops(K);
  C := [];
  for i from 1 to nops(L) do
    C := [op(C),L[i]-K[i mod m + 1] mod n];
  end do;  
  plain := Number2Letter(C,alphabet);
  return plain;
end;
DecryptVigenere := proc (str, key, alphabet) local i, n, m, L, 

   K, C, Convert, plain; Convert := table(); n := StringTools:-L\

  ength(alphabet); for i to n do Convert[alphabet[i]] := i-1 

   end do; L := Letter2Number(str, Convert); K := Letter2Number(\

  key, Convert); m := nops(K); C := []; for i to nops(L) do C 

   := [op(C), `mod`(L[i]-K[(`mod`(i, m))+1], n)] end do; plain 

   := Number2Letter(C, alphabet); return plain end proc


DecryptVigenere(cstr,Key,alphabet);
Number2Letter([Letter2Number("eqjyvxvgiuphmrrrgzhvwrrukmrtijfbto\

  didtsjsgofwmfalkeveolqlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjt\

  hitzsqufklhihrvditvvvzhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvl\

  oiqdiiglhxtyewosksvgyklhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnf\

  jnodumfuuchqutjysvojikomtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxu\

  asvguepksjxaglvomrhhapdcponuewuntiwnakxkosnevufrwlspcivvetmhys\

  lgknoniykrrwzuuchdvpveuzoklhirlhhonkioretxrltyivgicsugbjsoatvp\

  bonjsoabcizotysxztyinky", Convert)[1]

   + 25 Letter2Number([19, 4, 18, 19], Convert)[2], Letter2Number("eqjyvxvgiuphmrrrgzhvwrrukmrtijfbtodidtsjsgofwmfalkeveolqlmhkfhrerhwuidejonvjuumklhliiwwnajxbonjthitzsqufklhihrvditvvvzhvwhihrvditvvvgsrrbunvqlmhkvhgdzpbmuvwvloiqdiiglhxtyewosksvgyklhecfrykyrqhgnzrjhukxkknwvrswyewosbrrcnfjnodumfuuchqutjysvojikomtesgbcirlcfrvzrlgwonxeqeowxkkmfvhgbjxuasvguepksjxaglvomrhhapdcponuewuntiwnakxkosnevufrwlspcivvetmhyslgknoniykrrwzuuchdvpveuzoklhirlhhonkioretxrltyivgicsugbjsoatvpbonjsoabcizotysxztyinky", 

  Convert)[2] + 25 Letter2Number([19, 4, 18, 19], Convert)[1]], 

  "abcdefghijklmnopqrstuvwxyz")

f) Decipher the Vigenere ciphers from Computer Problems 8 and 9 from Section 2.14 of the text.


xkju:= "xkjurowmllpxwznpimbvbqjcnowxpcchhvvfvsllfvxhazityxohulxqojaxelxzxmyjaqfs\
tsrulhhucdskbxknjqidallpqslluhiaqfpbpcidsvcihwhwewthbtxrljnrsncihuvffuxvoukjlj\
swmaqfvjwjsdyljogjxdboxajultucpzmpliwmlubzxvoodybafdskxgqfadshxnxehsaruojaqfpf\
kndhsaafvulluwtaqfrupwjrszxgpfutjqiynrxnyntwmhcukjfbirzsmehhsjshyonddzzntzmpli\
lrwnmwmlvuryonthuhabwnvw";
ocwy:= "ocwyikoooniwugpmxwktzdwgtssayjzwyemdlbnqaaavsuwdvbrflauplooubfgqhgcscmgz\
latoedcsdeidpbhtmuovpiekifpimfnoamvlpqfxejsmxmpgkccaykwfzpyuavtelwhrhmwkbbvgtg\
uvtefjlodfefkvpxsgrsorvgtajbsauhzrzalkwuowhgedefnswmrciwcpaaavogpdnfpktdbalsis\
urlnpsjyeatcuceesohhdarkhwotikbroqrdfmzghgucebvgwcdqxgpbgqwlpbdaylooqdmuhbdqgm\
yweuik";
xkju := "xkjurowmllpxwznpimbvbqjcnowxpcchhvvfvsllfvxhazityxohulx\

  qojaxelxzxmyjaqfstsrulhhucdskbxknjqidallpqslluhiaqfpbpcidsvcih\

  whwewthbtxrljnrsncihuvffuxvoukjljswmaqfvjwjsdyljogjxdboxajultu\

  cpzmpliwmlubzxvoodybafdskxgqfadshxnxehsaruojaqfpfkndhsaafvullu\

  wtaqfrupwjrszxgpfutjqiynrxnyntwmhcukjfbirzsmehhsjshyonddzzntzm\

  plilrwnmwmlvuryonthuhabwnvw"


ocwy := "ocwyikoooniwugpmxwktzdwgtssayjzwyemdlbnqaaavsuwdvbrflau\

  plooubfgqhgcscmgzlatoedcsdeidpbhtmuovpiekifpimfnoamvlpqfxejsmx\

  mpgkccaykwfzpyuavtelwhrhmwkbbvgtguvtefjlodfefkvpxsgrsorvgtajbs\

  auhzrzalkwuowhgedefnswmrciwcpaaavogpdnfpktdbalsisurlnpsjyeatcu\

  ceesohhdarkhwotikbroqrdfmzghgucebvgwcdqxgpbgqwlpbdaylooqdmuhbd\

  qgmyweuik"


 

 

We have just released updates to Maple and MapleSim.

Maple 2023.1 includes improvements to the math engine, Plot Builder, import/export, and moreWe recommend that all Maple 2023 users install this update.

This update is available through Tools>Check for Updates in Maple, and is also available from the Maple 2023.1 download page, where you can find more details.

In particular, please note that this update includes fixes to problems with Quantifier Elimination and Group  Theory, and improves performance after a period of inactivity, all of which were reported on MaplePrimes. Thanks for the feedback!

At the same time, we have also released an update to MapleSim, which contains a variety of improvements to MapleSim and its add-ons. You can find more information on the MapleSim 2023.1 download page.

First 13 14 15 16 17 18 19 Last Page 15 of 26