## How can I force subs to do all substitutions...

I was working through an old text book, trying to understand a different problem.  I came across this problem in an exercise set and thought it was simple.  Until I tried it.

The difficlty I had was in using subs to substitute all values.  I had to use subs 2 or 3 times to get all substitutions.  How can I avoid this?

## Prove if F is the fibonacci sequence,
restart;
with(combinat, fibonacci):
F := n -> fibonacci(n);  ## F(n+1) = F(n)+F(n-1); F(1) = 1;
## the problem
P := n-> F(n+1)*F(n+2) - F(n)*F(n+3);
##
check_low := proc(n)
local idx;
for idx to n do
print(P(idx),(-1)^idx);
end do;
end proc;
check_low(1);
check_low(2);
check_low(3);
check_low(4);

## Assume true for n=k
A := P(k) = (-1)^k;

notation := { F(k)   = a,
F(k+1) = b,
F(k+2) = c,
F(k+3) = d,
F(k+4) = e };

## some fibonacci definitions
fibs := [ e = c + d,  d = b + c, c = a + b ];

eq1 := subs(notation,A);
eq1 := subs(fibs,eq1);
eq1 := subs(fibs,eq1);  ## have to repeat to get only a and b in the expression

eq2 := subs(notation,P(k+1));
eq2 := subs(fibs, eq2);
eq2 := subs(fibs, eq2);
eq2 := subs(fibs, eq2);  ## have to repeat to get only a and b in the expression
## Reduce eq2 to (-1)^(k+1)
simplify(eq2 = -lhs(eq1));
verify(eq2, -lhs(eq1), equal);
evalb(eq2); simplify(%);  ## Ah, this is why I need equal in verify.
evalb(-lhs(eq1)); simplify(%);

testeq(eq2, -lhs(eq1));

## How can I prevent the creation of random variables...

Hi,

Suppose you have to do some sequence of operations on a random variable (RV), and that you need to repeat this for several RV of the same family (e.g. exponential RV), differing only in the values of their parameters.

Here are two examples do code this.
1/ probably the most natural way to proceed (?)
restart:
with(Statistics):
X := a -> RandomVariable(Exponential(a)):
for n from 1 to 100 do
S := X(n);
# here are some operations to do
end do:
anames(alluser);

The last instruction indicates that 103 user variables have been created (X, n, S and 100 random variables).
Note that adding one of the commands S := 'S'; or unassign('S') before the end of the loop just unassigns S but not remove the variables named _ProbabilityDistribution, ..., _ProbabilityDistribution98.

2/ To prevent this inflation of random variables I thought to use the procedure Specialize:
restart:
with(Statistics):
X := RandomVariable(Exponential(a)):
for n from 1 to 100 do
S := Specialize(X, [a=n]):

# here are some operations to do
end do:
anames(alluser);

This doesn't change the situation.

So my (multiple) question:

• How can I prevent the creation of the objects _ProbabilityDistribution, ..., _ProbabilityDistribution98 given only one of them is used for a given value of the loop counter (once the operations have been done I pass to another random variable) ?
• How can I unassign a random variable ?
Maybe it is not possible as suggested by the help page about "_": "Any symbol beginning with an underscore (_) is effectively reserved for use only by library code. It is not available to users." ?

## Plotting a 3D Array...

Hello everyone,

I have the following problem:

I have an array of data dataarray[i,j,k] whose elements are either 1 or -1. I also have three vectors x[i], y[j] and z[k] (the axis).  I want to represent the data of dataarray so I have two different volumes: A green volume such as dataarray(x,y,z)=1 and a red one with dataarray(x,y,z)=-1. Is that possible? In case that it is, how can I do that?

Thank you very much in advance

## Question about product/ mul functions [mul(functio...

Hi!

I am trying to determine the weights of a Gauß quadrature rule, the code I currently have is this:

for i from 1 to n do
RekursivesZwischenergebnis:=1;
for j from 1 to n do
if i <> j then
RekursivesZwischenergebnis:= RekursivesZwischenergebnis*((x-GaußKnoten[j])/(GaußKnoten[i]-GaußKnoten[j]))
end if;
end do;
GaußGewichteAlt[i]:=int(RekursivesZwischenergebnis,x=-1..1);
end do;

The code works, is inefficient however. I want to use the product or mul function, however I dont know how to tell Maple not to multiply

((x-GaußKnoten[j])/(GaußKnoten[i]-GaußKnoten[j]))

if j=i.  mul(function(j), j=1..n,j<>i) doesnt work. Any efficient suggestions?

## C compiler optimization flag -01 -- -03...

Hello,

I'm compiling a maple procedure to a C code with the Compiler command. I was wondering if it is possible to change the optimization flag, for example -03  for gcc? Is there a way to maybe change a file in the Maple directory that specifies the compiler options?

## animate images/create movi...

with(IterativeMaps): with(ImageTools):

BP := proc(f, S, I, m, M, xm, xM)
local L;
L := Bifurcation([x], f, S, m, M, xmin=xm, xmax=xM, height=800, width=1300, iterations=I+500):
ArrayTools:-Dimensions(L):
ColouringProcedures:-HueToRGB(L):
Embed(L);
L:
end proc:

F := []:
f := [sign(r)*ln(abs(r))*cot(x)*(log[2+abs(r)](abs(x)) - x*sin(x))]:

F := [op(F), BP(f, [0.1], 10000, -10, 10, -15, 15)]:
F := [op(F), BP(f, [0.2], 10000, -10, 10, -15, 15)]:

F := [op(F), BP(f, [0.3], 10000, -10, 10, -15, 15)]:

F := [op(F), BP(f, [0.4], 10000, -10, 10, -15, 15)]:

I was trying to create some images of some bifurcations. I can't seem to create an animation from the images.

Also, Embed works great but each call to BP overwrites the previous image(rather than creating a new image)... Preview works but doesn't scale the images up properly.

## How can type limit as mathtype?...

How can type limit proc() and use print to export expression as mathtype?

 (1)

## StringTools Questions (Maple 2020)...

I was reviewing the StringTools features and I'm curious about some parts of it.

(1)     Here is a section from the StringTools[Length] help topic:

Notice that, like length, the Length command counts the number of bytes in the string, not the number of characters.
Length("d303251cembre");
9

When I execute the command in Maple 2020, it actually returns 13 instead of 9.  The length command also returns 13.  I do not understand the information from StringTools[Length] help.  I looked back to Maple 18 and it did not include these lines in the help topic.

(2)   I am confused about the rng argument in StringTools commands of LowerCase, UpperCase and OtherCase.  It seems that these commands consider -2 as the last character in the string.  The help topic shows this:

UpperCase("abcdefghij", 3 .. -2);
"abCDEFGHIJ"

I'm expected to use -1 as the last character such as:

S:="This is a test";
S[-4..-1];
"test"

(3)  Next, I looked at StingTools[SubString].  The help topic gives the following example:

SubString("abcdef", -5 .. -3);
"bcd"
That works like I expected.  So, -1 is the last character for SubString.

Thanks,
Lee

## Maple 2020 What's New example gives incorrect resu...

Hello,

I have installed Maple 2020 and I tried some examples of the new capabilities of command is:

restart;
is(0 <= (a - b)^2 + (c - d)^2) assuming real;

It gives FAIL instead of true,

Similarly the simpler example

is(x = 0) assuming (0 < abs(x));

also gives FAIL incorrectly.

Perhaps, does this problem relate to a problem with calling SMTLIB package?

Best Regards,

## How can I display the graph this 3 dimension curve...

Here is the deal, I made a programm so as to display the curve of a ping pong ball. But Maple isn't able to solve the 3 ODE system analytically. I then decided to make Maple solve them numerically and it actually works, great. However, there's still a big problem : how can I display the graph of the solutions ? I'd like you to give your opinion on a way to solve the problem. Thanks ;)

 >
 (1)
 >
 (2)
 >
 (3)
 >
 (4)
 >
 (5)
 >
 (6)
 >
 (7)
 >
 (8)
 >
 (9)
 >
 (10)
 >
 (11)
 >
 (12)
 >
 (13)
 >
 (14)
 >
 (15)
 >
 (16)
 >
 (17)
 >
 (18)
 >
 >
 >

## Reducing Run-time for solving a nonlinear ODE...

Hi

I want to employ FDM to solve nonlinear ODE. Since large expressions in terms of s[1] are generated, the program lose its efficiency for N>6 (It requires long run-time). Please amend the program, if it is possible to reach more precision for N>10. Moreover, is there a Maple command to dsolve this ode?

Thanks alot

restart;

sy := 2400.:

Hp := 0.1e9:

P := -900.:

a := 20.:

c := 21.:

N := 6:

s[0] := P:

h := (c-a)/N:

Et := (r*(diff(sr(r), r))-sy)/Hp:

Er := (sy-r*(diff(sr(r), r)))/Hp:

ode := simplify(Er-Et-r*(diff(Et, r))*(1+(diff(Et, r))*r/(2+4*Et))):

ode:=subs(diff(sr(r), r, r) = (s[k+1]-2*s[k]+s[k-1])/h^2, diff(sr(r), r) = (s[k+1]-s[k-1])/(2*h), r = h*k+a, ode):

for k to N-1 do

s[k+1] := solve(ode, s[k+1])[1]

end do:

s[1] := fsolve(s[N] = -200., s[1] = -900 .. -100);

plots[pointplot]([seq([h*k+a, s[k]], k = 0 .. N)]);

## how to plot fft?...

Hi, i have accelerometer readings saved as a CVS file., these file contains time data, then the accelerometer data in g's. (recorded at 700hz)

I need to analyse the data for hand-arm vibration and be able to plot the frequency/time.

i have managed to fft the data but im struggling to plot this.

thanks for the help!!!

## Divergence Tensor...

I am trying to calculate the divergence of a tensor field (in this specific case of a cauchy stress tensor (tensor of second order)). I am trying to use the DifferentialGeometry as well as the tensor package. I tried doing it somewhat similar to calculating the divergence of a tensor of first order, which worked fine with this code:

```>with(DifferentialGeometry): with(Tensor): with(Tools): >DGsetup([x,y,z],T); >v := DGzip([v__x(x,y,z,t),v__y(x,y,z,t),v__z(x,y,z,t)],[D_x,D_y,D_z],"plus"); >Divergence(v);```

However when I tried something similar with a tensor of second order it returened an error:

```>sigma := evalDG(sigma__11 * D_x &t D_x + sigma__12 * D_x &t D_y + sigma__13 * D_x &t D_z                  + sigma__21 * D_y &t D_x + sigma__22 * D_y &t D_y + sigma__23 * D_y &t D_z                   + sigma__31 * D_z &t D_x + sigma__32 * D_z &t D_y + sigma__33 * D_z &t D_z); >Divergence(sigma); Error, (in DifferentialGeometry:-Tools:-Divergence) expected argument to be a vector field. Received _DG([["tensor", T, [["con_bas", "con_bas"], []]], [`...`]])```

Is there a different command in order to compute the divergence of a tensor of second order compared to the command for a tensor of first order or am I making an enitrely different mistake?
Would really appreciate some help

## Images on Maple Primes....

Images posted on Maple Primes, if too large, are scaled down to match the post size. Is there a way to attach a scroll bar to allow full scale viewing instead?

## what dose the results mean for a derivative of a f...

Hello!

I have a question about a calculation of a differential of a functional.

I think dW(Y(t), t)/dt equals W  +W'Y .

There is some problem when I try to calculate it in Maple as below:

diff(w(y(t), t), t);
/ d      \
D[1](w)(y(t), t) |--- y(t)| + D[2](w)(y(t), t)
\ dt     /
I don't know it right or wrong; and  what does the D[1],D[1] mean?

I hope i can get your help!

Thanks!

 First 293 294 295 296 297 298 299 Last Page 295 of 2143
﻿