## how to plot different values of Mh...

How to get a plot for different values of Mh.

like Mh=[1 2 3 4]

Code:

restart;

m:=10;H:=1;Mh:=1;b:=0.02; a:=0.05;V:=array(0..m); V[0]:=1-exp(-t);

for k from 1 to m do

if k=1 then chi:=0;

chi:=1;

fi;

p:=0;

for j from 0 to k-1 do

p:=p+(V[k-1-j]*diff(V[j],t\$2)-diff(V[k-1-j],t)*diff(V[j],t)-a*(2*diff(V[k-1-j],t)*diff(V[j],t\$3)-diff(V[k-1-j],t\$2)*diff(V[j],t\$2)-V[k-1-j]*diff(V[j],t\$4)));  od;

p:=(p+diff(V[k-1],t\$3)-b*(diff(V[k-1],t\$2)+t*diff(V[k-1],t\$3))-Mh*diff(V[k-1],t))*h*H;

p:=factor(p);

V[k]:=(-int(p,t)+0.5*exp(t)*int(exp(-t)*p,t)+0.5*exp(-t)*int(exp(t)*p,t)+chi*V[k-1]+C1+C3*exp(-t));

v:=unapply(V[k],t);

V[k]:=frontend(expand,[V[k]]);  V[k]:=subs(C3=solve(eval(subs(t=0,diff(V[k],t))),C3),V[k]); V[k]:=frontend(expand,[V[k]]);

V[k]:=subs(C1=solve(eval(subs(t=0,-V[k]-diff(V[k],t))),C1),V[k]);

od:

appr:=0;

for k from 0 to m do

appr:=appr+V[k];

od:

u_appr:=unapply(appr,(h,t)):

u_appr_1:=unapply(diff(u_appr(h,t),t),(h,t)):

evalf(u_appr_1(-0.4,t)):

with(plots);

plot([u_appr_1(-0.4,t)],t=0..4,0..1.2,color=[black],axes=frame):

this plot for Mh=1:

## Why is the result not evaluated?...

Hi,

How do I change the definition of g to get the result f(1, 2)(x) = 2*t+3 ?

f := a*x+b;
g := (a,b) -> x -> f;

## How to modify an differential equation which passe...

Hey, I need to modify a differential equation passed to a procedure. My problem is that this code works fine:

```restart;
ode := diff(y(x), x) = y(x):
y := unapply(exp(x), x):
ode;
exp(x) = exp(x)
```

But this doesn't:

```restart;
ode := diff(y(x), x) = y(x);
p1 := proc (eq)
local y;
y := unapply(exp(x), x);
eq
end proc:
p1(ode);
d
--- y(x) = y(x)
dx
```

How to solve this problem?

## Command support large number...

May I know any command that able to support the large number even up to 2000 bits?

## Error, (in type/algext) too many levels of recursi...

I made a typo below, I did not mean to put [...] around the solution. But why Maple throws an error on this only?

```restart;
ode:=diff(y(x),x) = exp(x)*sin(x)+y(x)*cot(x);
my_sol:=[sin(x)*(exp(x)+_C1)];
odetest( y(x)=my_sol,ode) assuming x::real
```

Error, (in type/algext) too many levels of recursion

But on other ODE's, it works

```restart;
ode:=diff(y(x),x) = y(x);
my_sol:=[_C1*exp(x)];
odetest( y(x)=my_sol,ode) assuming x::real
```

[0]

I'll correct my type and remove the []. But the question is, should Maple have thrown an error? And why only on this one? Would this be considered a bug?

Removing the [] from the first example above, the error is gone and 0 is returned.

Maple 2019.1, Physics V 395 on windows 10

## How to use ssystem and friends...

I am getting my feet wet with Maple's system calls, like ssystem. I am considering to use Maple to run something like a Python script for certain numeric calculations, based on Maple-generated results. I am using Mac OS X (macOS for newer versions).

Maple's Help gives the basics and that works. For the specific Python example; I can run a simple script by using

ssystem("python -c A=2;print(A)"); # \n instead of ; works also.

Presumably I can do this with longer scrpts as well.

However, it appears that, when creating the process, Maple does not setup the environment the user (me) gets through initialization files like .profile, .cshrc or the like. As a result even a simple "python -c import sys" fails; presumably because the environment where Python looks for the module isn't setup. I tried

ssystem("source .cshrc");

but that fails as well. Trying to be clever and invoking a login shell (ssystem("tcsh -lc <command>");) also leads nowhere.

The Help page does say that ssystem() does not give access to all shell commands; is there somewhere documentation that says what works and what is not supported?

I am aware that Maple2018 and newer have more support in form of the Python package, but right now I need my code to be backward compatible to Maple2015 so this new package does not solve my issue for the older installation I am also using. Also, Python is not necessarily the only language I want to use.

Any suggestions would be welcome.

Mac Dude

## how to apply two for loops ...

How to apply two for loops to solve ode problem.

code:

restart; with(plots); fcns := {T(eta), f(eta)};
m := .5; bet := 1; na := 1/6; N := 5;
eq1 := (diff(f(eta), `\$`(eta, 3)))*pr+m-m*(diff(f(eta), `\$`(eta, 1)))+((m+1)*(1/2))*(diff(f(eta), `\$`(eta, 2)))*f(eta) = 0;
eq2 := diff(T(eta), `\$`(eta, 2))+((m+1)*(1/2))*(diff(T(eta), `\$`(eta, 1)))*f(eta) = 0;
bc := f(0) = 0, (D(f))(0) = 0, (D(f))(N) = 1, (D(T))(0) = -bi*(1-T(0)), T(N) = 0;
bi:= [seq(1..4,0.1)];  NN := nops(bi);
pr:=[seq(1..2,0.1)];  NN1 := nops(pr);
for i  from 1 to NN do
for j from 1 to NN1 do

R := dsolve(eval({bc, eq1,eq2}, bi[i],pr[j]), fcns, type = numeric, method = bvp[midrich], maxmesh=2400):
X1||[i,j]:=rhs(-R(0)[3]):
end do:
end do:

Have a good day.

## Error while animation in 2d...

B1 := plots:-animate(plots:-pointplot, [[seq(X(kk, j), j = 1 .. 10)], [seq(Y(kk, j), j = 1 .. 10)]], kk = [seq(1 .. 50)], symbolsize = 25, symbol = solidcircle, colorscheme = ["valuesplit"])

gives error

Error, unsupported type of index, kk

Here X and Y are 50*10 matrices

## How to restrict matrix elements to whole numbers...

A minor question ....

Does anybody know how to format a matrix so all elements are presented in whole numbers?

It's more a niggle than anything .. I want to retain decimals in my worksheet but wish only to have the matrix display integer values.

Thank you!

## Generate large primes commands...

May I know which commands able to generate large prime up to 2000 bits in maple?

## Subsindets/evalindets fail recurse, is this a bug?...

I believe this is a bug:

```
(((Q(a)^3)^(5/4))^(15/7))^(6/8);
subsindets(%, anything^rational, proc(x) if type(x, specfunc(anything, Q)^rational) then 'Q(x)' else 'x' fi end)<>
subsindets(%, specfunc(anything, Q)^rational, Q);
```

## How can I measure and tabulate the distance betwee...

Mapleprimes.mwMapleprimes.mwMapleprimes.mwMapleprimes.mwMapleprimes.mw

Suppose we have a number of points, n, in the x-y plane and the location of each point is known.

I wish to evaluate the straight-line distance from point to point and tabulate these values (i.e. A to B, A to C, A to D, B to C, B to D, etc) and then plot the points in question.

In this attached worksheet, I have given an example of 4 points and I would welcome all suggestions on how to do this.

## Strange behavior of sqrt function....

I'm new to Maple.

My problem is that if I input the command sqrt(3.0), for example, I get this strange result:

1.81847767202745*10^(-58) + (7.53238114626421*10^(-59))*I

The results is the same, no matter the argument of sqrt.

Also, when using ln, I get this:

-265.745524189222 + 0.785398163397448*I

Again, no matter the argument of ln, the result is the same.

What is happening?

## Galerkin Finite Element Method using maple...

Dear maple user  any one suggest me how to solve  second order coupled differential equation using galerkin finite element method for 8 elements and 10 elements using maple codes

## How to find all occurrences of a pattern in an exp...

I thought I remembed how to do this once in Maple, or asking something like this here, but may be it was something similar. But I am not able to figure it now or remember.

Given an expression, I want to find all occuranes of a pattern in it.  Not just one.  So this is like using patmatch but over and over again untill all patterns found. I'll give an example to make it easy to explain.

Given

`expr := y^2*sin(1/y) + y^(3/2) + y + x*y^7;`

I want to find all patterns of form y^n  so the result should be

`{y^(3/2), y^7, y^2, 1/y, y}`

This below is how it is done in Mathematica, but having hard time translating this code to Maple.

The last line below does the actual repeated pattern matching. That line was not written by me. It is something from Mathematica forum at stackexchange and I use it all the time and it works well.

```ClearAll[x,y,n]
expr = y^2*Sin[1/y] + y^(3/2) + y + x*y^7;
pat = y^n_.;
Last@Reap[expr /. a : pat :> Sow[a], _, Sequence @@ #2 &]```

I looked at hastype also. But hastype will only tell me if the pattern is there or not. May be I did not use it right.

```restart;
expr := y^2*sin(1/y) + y^(3/2) + y + x*y^7;
hastype(expr,symbol^(anything));
```

Gives true

I tried patmatch, but again, it only find one:

```restart;
expr := y^2*sin(1/y) + y^(3/2) + y + x*y^7;
if patmatch(expr,a::anything+y^(n::anything)+b::anything,'la') then
assign(la);
n;
fi;
```

And the above is not even robust for finding one. Since I have to change the pattern again to account for multiplication/addition cases between terms.

Is it possible to do in Maple the same thing I show in Mathematica? I am sure it is possible, but can't now find the right function in Maple.

Maple 2019.1

 First 371 372 373 374 375 376 377 Last Page 373 of 2141
﻿