## 4029 Reputation

6 years, 181 days

## A temporary solution until someone here ...

A temporary solution until someone here will provide a clever one

restart:
M := `<|>`(`<,>`(1, 3, 2), `<,>`(4, 1, 3)):

# Structure of M

S := op(2, M);

{(1, 1) = 1, (1, 2) = 4, (2, 1) = 3, (2, 2) = 1, (3, 1) = 2,  (3, 2) = 3}

# Reverse S

T := map(u -> rhs(u)=[lhs(u)], S);

{1 = [1, 1], 1 = [2, 2], 2 = [3, 1], 3 = [2, 1], 3 = [3, 2],  4 = [1, 2]}

# A simple procedure to find a value "n"
# (should be improved to handle the case "n is not an element of M")

Find := proc(n) map(u -> if lhs(u)=n then rhs(u) end if, T); end proc:

Find(1);
Find(2);
Find(3);
{[1, 1], [2, 2]}
{[3, 1]}
{[2, 1], [3, 2]}

Find.mw

## fsolve(f, omega=4)      &...

fsolve(f, omega=4)
4.450852611 - 1.509500329*10^(-25)*I

fsolve(f, omega=5)
4.450852611 - 5.580307451*10^(-24)*I

As you observe the solution is complex (even the smallness of the imaginary part can suggest it is a numerical effect).
But this info is usefull and give you a hint to search a solution in a given interval:

fsolve(f, omega=1, complex, {omega=1-I..5+I}  );  # search in the xomplex square [1, 5]x[-I, I]

By the way: Do not use simplify in fsolve to spare computational time.

## Your integral is just the mathematical e...

Your integral is just the mathematical expectation of the random variable 0.3*p1+0.7*p2:

Mean(0.3*p1+0.7*p2)
0.01669578723

No need to look further

More than this :
CodeTools:-Usage(Mean(0.3*p1+0.7*p2))
memory used=101.54KiB, alloc change=0 bytes, cpu time=2.00ms, real time=19.00ms, gc time=0ns
0.01669578723

... and finally:
Mean(3/10*p1+(1-3/10)*p2)

## Hi, If you don't want to use a ...

Hi,

If you don't want to use a 'procedurelist' output and keep using an Array, you can buid a piecewise approximation of the second derivative where each "piece" is a 3rd order polynomial in x.
MaybeThis.mw

Nevertheless, as tomleslie said elsewhere in this thread (Rouben Rostamian too), you can easily isolate this second derivative from the original ode... then I'm not sure my answer is of any help ?

## A simpler way:E1 := x*y^3+5*x^2*y+3*a^2+...

A simpler way:

E1 := x*y^3+5*x^2*y+3*a^2+4*x*y+z^2+3*x-y+z+2:
_order := 2:           # truncation order
vars   := [x, y, z]:   # truncation variables
mtaylor(E1, vars, _order+1);

Simpler.mw

## Hi,    Question 1: There exi...

Hi,

Question 1:
There exits a package RootFindind with a procedure NextZero you could use In the same package. In the same package the procedure Isolate is also very useful.

Question 2: the content of the attached file could help you to get started

fsolve.mw

## Kitonum is right when he says "I th...

Kitonum is right when he says "I think first you need to specify the values of the parameters  lambda  and  ."

You will find in the attached file a workaround:

1. solve
2. once the roots known, select the regions where

A lot of work is to be done "by hand".

I would be interested to recieve the critics from Kitonum.

inequalitysolve.mw

## Use of RunWorksheet: Load the file Ru...

Use of RunWorksheet:

2. Put it in some directory "/..../Run.mw"
3. Open Maple In a new worksheet type the command
DocumentTools[RunWorksheet]( "/..../Run.mw", [r = .1, c = 1, mu = 1, Lambda = .1, fe = 20, fg = 5] )

Be careful: from my own experience RunWorksheet is very touchy to use.
Here are some constraints to respect (at least with Maple <= 2016):

1. Build your worsheet with its 2 sections "Inputs" and "calculation" BEFORE adding the attributes "InputSectionTitle" and "Calculation" (InputSectionTitle must have "Inputs" as  a value; Calculation has value "default").

2. Write each input in the "Inputs" section on separate lines.

3. For RunWorksheet either works and returns a result, eirther doesn't work and remains silent, use "writeto(SometextFile)" at the beginning of the "Calculation" section (have a look to the attached file).
Pay attention to the ending ";" or ":" which are easily omitted for the last command of a block.

Lastly, RunWorksheet has some limitations:

• you can't run a same worksheet on different processors/nodes by using the Grid package,
• some graphical functions are not supported (if my meory serves: dualaxisplot, plotdevice(SomeFormat, ...), ...

Run.mw

## Unless for polynomials system for which ...

Unless for polynomial systems for which you can specify the "maxsols" number of solutions to find, fsolve returns only one.
And of course the solution you get depends on your starting point (see fsolve[details] help page) or on the search interval you set (same help page).

An alternative is to use the function "Isolate" from package RootFinding.

You will find a few results in the attached file.

RootFinding.mw

## Still another way...

Not knowing all the subtitlies of the way Maple works, my first reflex when the arrow operator doesn't return the expected result is to use "unapply".
It goes well here:

for i from 1 to 3 do
f[i]:=unapply(P(i,1,1,x), x);
end do;

To Carl, vv and others: what are the pros and cons of all the solutions proposed here ?

product(1-1/k, k = 2 .. infinity)
= limit(product(1-1/k, k = 2 .. N), N=+infinity)
= limit((1-1/2)*(1-1/3)*...*(1-1/N)), N=+infinity)
= limit((1/2)*(2/3)*(3/4)*...*(1-1/N)), N=+infinity)   # the denominator of the term n is the numerator of term n+1
= limit(1/N, N=+infinity)
=0

Simpler than expanding (1-1/2)*(1-1/3)*.... = 1 - 1/2 - 1/3 - 1/4 - ... + 1/2*1/3 + 1/2*1/4 + ... + 1/3*1/4 + ... + triple products + quadruple products + and so forth...

## Before receiving a more astute answer he...

Before receiving a more astute answer here is a solution

Matrix.mw

## I'm not sure to understand what you...

I'm not sure to understand what you mean by "there is a spur at node 5"?

Mor of this, with your  [[14, 16, 1], [1, 2, 2], [2, 3, 7], [3, 4, 1], [4, 5, 3], [5, 6, 6], [6, 7, 4], [7, 1, 3], [8, 9, 7], [9, 10, 3], [10, 11, 3], [11, 12, 1], [12, 13, 6], [13, 14, 3], [14, 8, 3], [5, 10, 3], [7, 8, 3]] definition there are 15 vertices and 17 edges, not 14 and 16 (if I'm not mistaken, unless you count vertex 16 as a particular "source node" ?).

Besides, when you write [1, 2, 2], for instance, does it mean "there exist an arc from 1 to 2 of cost 2" or "there exist on arc from 1 to 2 and one arc from 2 to 1, both of cost 2"?

I guess you already know that GraphTheory contains a DijkstrasAlgorithm procedure (maybe it doen't suit you because of this
" spur at node 5" you mentioned).
Just in case I send you this little worksheet

Dijsktras.mw

## Maybe writedata could be useful (it depe...

Maybe writedata could be useful (it depends on the formats uou use)

Here is an example (to write in a file just change "terminal" by the name if the file)
N := 5:
A := Vector[row](N, i->i);
writedata(terminal, [convert(A, list)], [seq(float, n=1..N)]);
1    2    3    4    5

fd := fopen(MyFile):
writedata(fd, [convert(A, list)], [seq(float, n=1..N)]):
close(fd):

## Hint: The product will be complicated al...

Hint: The product will be complicated algebraically and you will need to apply first expand, then simplify to reduce the product of the eigenvalues to an integer. First try to do for a single matrix , then make a loop to do it 8 times.]

If this is the hint your teacher has given you, maybe it's not necessary to mention it here: let the people think they do not do you homework.
However this is a feeble hint: if you use RandomMatrix the resulting matrix contains only numbers (integers or floats depending on the  way you describe the generator [see the RandomMatriwx help page]).
Then Eigenvalues will return 3 numbers and their product trivial (no need to expand anything).
restart:
with(LinearAlgebra):
A := RandomMatrix(3, 3, generator=0..1.0):
EigA := Eigenvalues(A);
EigProduct := mul(Re~(convert(EigA, list)));
Determinant(A)

PS: if you want to verify that the product of the eigenvalues equals the determinant, it would be beter to generate a symbolic matrix :
A := Matrix(3, 3, symbol=a):

 First 28 29 30 31 32 33 Page 30 of 33
﻿