## How can I create a Vector using symbolic name for ...

Asked by:

I have the following example.

> A:= Vector(3,symbol=v)

A:=

>v[1]:= 5

v[1]:=5

> A

Is there any way such that v[1] is actually referring to the first element in the vector? In other words, changing v[1] actually modifies the vector A.

If the question does not make sense, then here is the actual scenario that I faced.

I need to solve a system of equations in the form of

2 = c[2] + a[1],
2 = 2*c[3] + a[2],
-2 = -3*c[1] + a[3],
-1 = -2*c[2] + a[1],
-1 = -c[3] + a[2],
1 = a[3]

where a[i], c[i] refers to the entries in the vector.

`solve` returns the following:

[[a[1] = 1, a[2] = 0, a[3] = 1, c[1] = 1, c[2] = 1, c[3] = 1]]

I then did an `assign(%)`. However, the entries in A and C are not changed. I want the answer returned by solve to be properly applied to the entries of the vectors.

## How can I store a result directly to a function in...

Asked by:
a := x -> x + 1;
b := x -> a(x) + x^2;
a := x -> x + 5;
b(x);
2
x  + x + 5

However, I wish my b(x) to be x^2 + x + 1. How could I do it?

## Using an package modifies the behaviour of functio...

Asked by:

I have the following code snippet.

f := x^11 + 2*x^9 + 2*x^8 + x^6 + x^5 + 2*x^3 + 2*x^2 + 1;
g := 2*x^10 + x^7 + 2*x^4 + x;

Gcd(f, g) mod 3;
9      6    3
x  + 2 x  + x  + 2
with(Algebraic);
Gcd(f, g) mod 3;
6
x  + 1

It is surprising to me that using a package actually changes the behaviour of functions not in the package!

Is this a bug or a feature that I am not aware of?

## Determinants, Gauss and Cramer

Maple 2021

Applications to develop exercises on systems of equations using the technique of determinants, Gauss and Crammer. For science and engineering students. In spanish.

Determinantes_Gauss_Crammer.mw

Lenin Araujo

Ambassador of Maple

## Locally flat coordinates with arbitrary metric Gen...

Asked by:

I have just started using the GR functions available in Maple and have struggled to implement locally flat coordinates whilst using an arbitrary metric. I would like Maple to know that the first partial of g_ is 0 but that the second may not be. This knowledge would help simplify down some of the bulky expressions for the Riemann tensor in terms of g_. Any suggestions would be great as I have very little background knowledge with the submodule.

Thanks!

For_mapleprimes.mw

## Why does solve give me 2 wrong answers?...

Asked by:

Why do I get 2 wrong answers here?

I see that they are all false but the last answer is close enough for my purposes

 =    =  =  =  =

Download Not_working.mw

## How to quickly find the spectral radius of a matr...

Asked by:

The spectral radius  is maximum of the absolute values of the eigenvalues of the matrix A.  We can use the function SpectralRadius in Student package. But we noticed a sentence in the help document:

The output from this procedure will be as symbolic as computationally feasible. If the exact spectral radius of A is too time-consuming to compute, it may be computed numerically.

This means that SpectralRadius will evaluate the exact value when it can. Anyway, the internal evaluation process will take time. So for the sake of efficiency, we just want the numerical results of the spectral radius of a matrix.

I tried to write the following function, but I feel that it is not very efficient, especially for solving characteristic polynomials and their roots.  I even feel that there is a way to find the spectral radius without taking the absolute value of all the eigenvalues and ordering them.

```Spectralradius := proc(A::Matrix)
local Spectrum;
Spectrum := sort(abs~([fsolve(LinearAlgebra:-
CharacteristicPolynomial(A,x)=0,x )]),`>`);
Spectrum[1]
end proc:```

One example: In general, the matrices I encounter come from adjacency matrices of graphs, which are always real symmetric. So their eigenvalues are always real. But the Eigenvalues command very slow because it's always trying to get the exact value. So If we use Eigenvalues  to find all the eigenvalues and then sort them, it will be very slow.  Thus  I'm thinking about finding the numerical results.

 > with(LinearAlgebra): with(GraphTheory): G2:=Graph({{1,2},{2,3},{3,1},{3,4}}): A2:=AdjacencyMatrix(G2): Eigenvalues(A2);
 (1)
 > evalsN:=evalf(%);
 (2)
 (3)
 > with(Student): SpectralRadius(A2)
 (4)
 >

Maybe I need a way to find all the numerical eigenvalues of a real symmetric matrix not using  CharacteristicPolynomial or Eigenvalues.

Download zlc_1.mw

## Why does print to PDF put content without leftmost...

Asked by:

macOS 12.3 + Maple 2021.2

* --> Print
* --> Print to PDF

The created document essentially has no left border (margin). This has been a problem over at least the last three versions in Maple. I end up having to use an extra PDF cropping tool to reset the margins on the document.

What is the solution to this problem?

## Why does Copy as image not work?...

Asked by:

macOS 12.3 + Maple 2021.2

* select a region on a document
* context click
* --> Copy as image

Copy as image does not put an image on the clipboard.

What is solution?

## How to implement decomposition function respect ba...

Asked by:

I describe my problem accurately in mws file. I have a step function

 > First step. This is f(x) function
 >
 (1)
 > Next step. I try to approximate this function f(x) using wavelet transform, and  I  want to decomposite this function, choose wavelet Haar function and scaling functon  , choose basisn funtion from multiresolution analysis of the Lebesgue space  L^2(R). I choose  such wavelet fucntion  from space MRA V0 and scaling function from space MRA V0:
 >
 (2)
 >
 (3)
 > After I try approximate initial function f(x), decomposed using such contruction:
 >
 >
 > where coeff m shows, space MRA, to which the basis function belongs, and kk shows,basis function shift (x-k)
 > i.e. I try decompose function respective to basis function, where coeffs calculate the such way:
 >
 >
 > The approximation is considered satisfactory if the following condition is  true:
 >
 >
 > For example  calculate that such way:
 >
 > if the wavelet Haar functions:
 >
 (4)
 >
 > Then vector of Haar functions compute using the follow code:
 >
 >
 > Then integrals
 >
 >
 > where  is an d-square matrix called an operational matrix of integration
 >
 >
 > And now, it's not working, so I have troubles for calculate coeffs and writing and  plotting this result, so, I have some questions: 1) How to calculate coeffs and   for my fucntion f(x) and get value of coeffs? 2) How to implement integration and write the final sum (approximation of function f(x)? 3) How to calculate
 >
 >
 > and plot initial function f(x) and approximation sum at one plot?
 > Do I understand correctly that I need to calculate this integral for my function on each interval of my function?
 >
 >
 > How to implement this procedure?

Code for calculating procs a I try ude from this source: http://www.m-hikari.com/ams/ams-2012/ams-125-128-2012/sunmonuAMS125-128-2012.pdf

Download LR1.mw

I would be very grateful for any help!

## Syntax for the seq function with units...

Asked by:

So all I'm trying to do is a simple sequence like seq(i^2, i=1..10, 1) but with units.  The seq function is part of the Units:-Standard and Units:-Simple packages.  I couldn't find any examples with units in the help system.  For my first attempt, I tried to create a simple sequence of values with units using what is, to me, a logical syntax.  I have included the Maple input below.  I bolded the input.

with(Units:-Standard);
[*, +, -, /, <, <=, <>, =, Im, Re, ^, abs, add, arccos, arccosh, arccot, arccoth, arccsc, arccsch, arcsec, arcsech, arcsin,

arcsinh, arctan, arctanh, argument, ceil, collect, combine, conjugate, cos, cosh, cot, coth, csc, csch, csgn, diff, eval,

evalc, evalr, exp, expand, factor, floor, frac, int, ln, log,  log10, log2, max, min, mul, normal, polar, root, round, sec,

sech, seq, shake, signum, simplify, sin, sinh, sqrt, surd, tan,   tanh, trunc, type, verify]

seq(ii, ii = 1.0*Unit('m') .. 10.0*Unit('m'), 1.0*Unit('m'));

Error, (in Units:-Standard:-seq) wrong number (or type) of parameters in function seq

Can anyone show me the correct syntax for this?  Is there something in the help?  I tried it in 2021 and 2022 with the same result.

## Maple 2021.2 (for Linux) sometimes does not shown ...

Asked by:

I am using Maple 2021.2 on Ubuntu Linux 20.04 LTS. Sometimes the Maple after start does not show Sig in part of top Maple desktop panel. So I need to restart Maple and 2nd or 3rd start is mostly OK. After that is the situation for some time good.

See attached snapshot... Any idea what is wrong?

## infolevel gives different output depending on orde...

Asked by:

I set infolevel[dsolve]:=2; and first time I use it, it gives very long output. Next time I use it on same ode with same command it gives much shorter output.

Why is that and how to make it give the shorter output from first call?  This is very strange behavior.  One would expect the same output each time. The worksheet attached shows that first time it is used, the output is very long. At the end of the worksheet the call is made again with same infolevel, and now output is much smaller.

(getting error uploading worksheet. Will try again. Unable to do insert content keep getting error from this site. So I am just attaching it as link. May be due to large size of the worksheet)

infolevel_changes.mw

## The strange behavior of IsSubgraphIsomorphic requ...

Asked by:

The IsSubgraphIsomorphic command accepts either two undirected graphs or two directed graphs as input.  It returns true if G1 is isomorphic to some subgraph of G2. The GraphTheory [IsSubgraphIsomorphic] command was introduced in Maple 2021.

If a graph T is isomorphic to some subgraph T' of  a graph GIsSubgraphIsomorphic(T,G)  will  return true. But there is no option to return T'. That makes it hard to check manually.

I've seen  IsSubgraphIsomorphic behaving strangely lately. I want to check whether K8-P6 contains K7-K3 as its subgraph.

```T:=DeleteEdge(CompleteGraph(7),{{1,2},{2,3},{3,1}},inplace= false):
G:=DeleteEdge(CompleteGraph(8),{{1,2},{2,3},{3,4},{4,5},{5,6}},inplace= false):
IsSubgraphIsomorphic(T,G)```

true

I think theoretically, the result of IsSubgraphIsomorphic is not correct. I also tested it from Mathematica, and it worked as I expected.

```h = EdgeDelete[ CompleteGraph[7], {1 <-> 2, 2 <-> 3, 3 <-> 1}];
g = EdgeDelete[ CompleteGraph[8], {1 <-> 2, 2 <-> 3, 3 <-> 4, 4 <-> 5, 5 <-> 6}];
IsomorphicSubgraphQ[h, g]```

False

I wonder what went wrong.

PS: Subgraph isomorphism is a question I've asked before, and we can refer to the following links and code. https://www.mapleprimes.com/questions/226937-How-To--Test--A--Graph--Whether-Contains

```with(GraphTheory):
with(combinat):
T:=DeleteEdge(CompleteGraph(7),{{1,2},{2,3},{3,1}},inplace= false):
G:=DeleteEdge(CompleteGraph(8),{{1,2},{2,3},{3,4},{4,5},{5,6}},inplace=false):
nE,nV := NumberOfEdges(T), NumberOfVertices(T):
# Produce all subgraphs of G which have the same number of edges and vertices as the "test" sub-graph T
U:=choose(Edges(G),nE): nops(%):
U1:=select(t -> (nops(`union`(t[]))=nV), U): nops(%):
gL:= Graph~(U1): nops(%):
ans:= [ seq
( `if`
( IsIsomorphic( T, gL[j] ),
j,
NULL
),
j=1..numelems(gL)
)
]:
if   numelems(ans)>0
then HighlightSubgraph( G, gL[ans[1]], edgestylesheet=[thickness=4, color="Red"]);
DrawGraph(G, style=spring);
fi;```

These codes are due to tomleslie  and  vv. According to above codes, it seems that there is something wrong with IsSubgraphIsomorphic too.

## formatting the output generated by writeto(filenam...

Asked by:

I capture the output of dsolve after setting infolevel to some file so I can later read that output and put it in my own document (Latex).

Currently what I do is set infolevel, then use writeto(file_name) to send all the output that would normally go to standard output to the text file, then later do readline to read it back for further processing.

The problem is that Maple does not put the output in the file the same way as it appears on the screen when using worksheet.

For example, all newlines are lost. So everything comes out in one line in the file_name .  I am not sure why that is.

Is there an option or trick to make the output not lose the newlines? It also seems to format things differently in the file. An example will make this clear

When running this code

```restart;
currentdir("... set the directory to where you want to save the file to ..");

infolevel[:-dsolve]:=5;
writeto("output_of_dsolve.txt");  #send all output to file
sol:=dsolve(diff(y(x),x)=sin(x),y(x));
close("output_of_dsolve.txt"):
writeto(terminal); #to send output back to terminal

```

When I open the file output_of_dsolve.txt this is what shows

````Methods for first order ODEs:``--- Trying classification methods ---``trying a quadrature``<- quadrature successful`     solAssignyApplyFunction(x)equalsuminus0cosApplyFunction(x) + _C1, [

Typesetting:-mprintslash([sol := y(x) = -cos(x) + _C1],

[y(x) = -cos(x) + _C1])]

```

But in the worksheet, when I run the same code without writeto("output_of_dsolve.txt");  so output goes to terminal as normal, here it is how it looks like

Is there a way to keep the newlines? And why there is some extra stuff in the file that do not show on the screen? Should one change the Settings for Display before doing the above? Currently the default I have is typesetting level is "Extended". Do not know if this affects it or not.

Is the above method the only way to capture the output of dsolve from infolevel to a text file? It looks like Maple uses `` in the file in place where there should be a newline (CR) inserted.

Update

I did this experiment but there is still some strange formatting coming out in the file. Here is an example

```restart;

interface(typesetting=standard): #added this
interface(prettyprint=0):  #added this
currentdir(".....");

:-infolevel[:-dsolve]:=5;
writeto("output_of_dsolve.txt");
sol:=dsolve(diff(y(x),x)=sin(x),y(x));
close("output_of_dsolve.txt"):
writeto(terminal);
```

And now the text file has this

``Methods for first order ODEs:``--- Trying classification methods ---``trying a quadrature``<- quadrature successful`Typesetting:-mprintslash([(sol := y(x) = -cos(x)+_C1)],[y(x) = -cos(x)+_C1])`

What is Typesetting:-mprintslash at the end of the line above? it is duplicate.

And how to get rid of it? Is there another settings to set other than interface(typesetting=standard): and interface(prettyprint=0): ?

 First 6 7 8 9 10 11 12 Last Page 8 of 31
﻿