## Subprocedures in a main procedure ...

How to add any/many subprocedure in a mainprocedure?
Somehow the mainprocedure must deliver the input for the mainprocedure

Here is a example

Note: probably can this old procedure be rewritten in modern Maple programming language ?

 > restart;

Code to Find the Max and Min Values in a List A

 > maxmin:=proc(A,maxv::evaln,minv::evaln)
 > local i;
 > maxv:=A[1]; minv:=A[1];
 > for i from 2 to nops(A) do
 > if eval(maxv) < A[i] then maxv:=A[i] end if;
 > if eval(minv) > A[i] then minv:=A[i] end if;
 > end do;
 > RETURN()
 > end proc:
 >

Now we can call the maxmin procedure from a procedure named optimize, which is designed to create the polygonal approximation, use maxmin to find the largest and smallest y-values from among the vertices, and produce some graphic output.

See the documentation in the book.

Code to Approximate the Max and Min Values of a Function  f :

 > optimize:=proc(f,a,b,N,pic::evaln)
 > local X,Y,L,i,A,xmax,xmin;
 > X:=array(0..N);Y:=array(0..N);L:=array(0..N);
 > with(plots,display);
 > for i from 0 to N do
 > X[i]:=evalf(a+i*(b-a)/N);
 > Y[i]:=f(X[i]);
 > L[i]:=plot([[X[i],0],[X[i],Y[i]]],color=black):
 > end do;
 > A:=[seq(Y[i-1],i=1..N+1)];
 > maxmin(A,maxv,minv); # USE OF SECOND PROCEDURE --------------
 > xmax:={};xmin:={};
 > for i from 0 to N do
 > if Y[i]=maxv then xmax:=xmax union {X[i]} end if;
 > if Y[i]=minv then xmin:=xmin union {X[i]} end if;
 > end do; #----------------------------------------------------
 > pic:=display({seq(L[i],i=1..N)}):
 > print(`maximum y value is`,maxv,`and occurs at these x values`,xmax);
 > print(`minimum y value is`,minv,`and occurs at these x values`,xmin);
 > end proc:
 >

Note that you must execute the code that defines maxmin before the procedure optimize will work. This only make sense.

We test the optimize procedure with the following function

 > f:=x->3+10*(-x^2+x^4)*exp(-x^2);
 (1)

on the interval [-1, 4].

 > optimize(f,-1,4,150,pic);
 (2)
 > pic;

## How to get Black Hole temperature...

Hi.

Just trying to replicate a calculation, I would expect close to absolute zero, but my units are out

Black_hole_temp.mw

## EYRING POWELL FINITE DIFFERENCE ...

finite difference method

 >
 >
 >
 >
 >
 >
 (1)
 >
 (2)
 >
 (3)
 >
 (4)
 >
 (5)
 (6)
 >
 (7)
 >
 >
 >
 (8)
 >
 >

## Workbook move files impossible in 2021.2...

I can't move files in the navigator window anymore in Maple 2021.2.

Anyone else with the same problems?

## Error, (in PolynomialSystemSolvers:-PseudoResultan...

sometimes complicated equation is generated and attempt to solve it fail, which is OK. But there is a case, where Maple generates an internal error from solve(). The problem is that it is not possible to even capture this error using try...catch... end try so the whole program crashes.

Is there a way to trap such errors, so at least it can bypass it without solving it but without terminating the whole program?

According to help it says

The try statement provides a mechanism for executing statements in a controlled environment, where errors will not just cause the execution to halt with no warning.

Well. The above is not really true.

 > interface(version);

 > Physics:-Version()

 > restart;
 > eq:=-t^m*y+1/12*(-6*(-(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(2/3)+96*t^m*y)/(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(1/3))^(1/2)+1/12*6^(1/2)*((-(-6*(-(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(2/3)+96*t^m*y)/(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(1/3))^(1/2)*(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(2/3)+96*t^m*y*(-6*(-(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(2/3)+96*t^m*y)/(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(1/3))^(1/2)+72*(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(1/3))/(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(1/3)/(-6*(-(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(2/3)+96*t^m*y)/(108+12*(6144*(t^m)^3*y^3+81)^(1/2))^(1/3))^(1/2))^(1/2) = t^(m-1)*(-y+1/12*(-6*(-(108+12*(6144*y^3+81)^(1/2))^(2/3)+96*y)/(108+12*(6144*y^3+81)^(1/2))^(1/3))^(1/2)+1/12*6^(1/2)*((-(-6*(-(108+12*(6144*y^3+81)^(1/2))^(2/3)+96*y)/(108+12*(6144*y^3+81)^(1/2))^(1/3))^(1/2)*(108+12*(6144*y^3+81)^(1/2))^(2/3)+96*y*(-6*(-(108+12*(6144*y^3+81)^(1/2))^(2/3)+96*y)/(108+12*(6144*y^3+81)^(1/2))^(1/3))^(1/2)+72*(108+12*(6144*y^3+81)^(1/2))^(1/3))/(108+12*(6144*y^3+81)^(1/2))^(1/3)/(-6*(-(108+12*(6144*y^3+81)^(1/2))^(2/3)+96*y)/(108+12*(6144*y^3+81)^(1/2))^(1/3))^(1/2))^(1/2)):
 > sol:=solve(eq,m)  assuming t>0;

Error, (in PolynomialSystemSolvers:-PseudoResultant) too many levels of recursion

 > try     sol:=solve(eq,m)  assuming t>0; catch:     print("Cought error"); end try;

Error, (in PolynomialSystemSolvers:-PseudoResultant) too many levels of recursion

 >

## why use static for Objects?...

Other than saving few bytes of memory, why would one use ::static for methods of Object?

I found that if I use ::static, then I have to add prefix _self:- each time an object data member is referenced anywhere, making the code very hard to read.

Imagine having to write  _self:-x + 3* _self:-x^2 + 2* _self:-y^3 and so on all the time, instead of just x+3*x^2+2*y^3. (where it is assumed here that x,y happened to be object private data members and not local variables for a proc inside the module).

But then I found if I remove  ::static now _self:- no longer needed and can still get the benefit of using the object and the code works as before, but the code is now much more readable.

I know that by not using static, then a copy of each method is made for each new object.

I am OK with that. As I do not use that many objects any way (few at a time before GC cleans the ones I used).

But the benefit of much more readable code far outweights the little extra memory needed, and memory is cheap these days anyway. I got lots of RAM. An extra few MB's is not a big deal.

What Am I missing here? Why does all the Maple help and documenation say that one should use static for object methods then? But do not mention that by not using static:: then the code will become more readable since _self:- is not needed to be appeneded to each variable or method name.

Here is an example below to compare.

First example uses ::static methods, and the second does not.

One can see the difference The code is more clear in the second.   Is there something else I am overlooking by not using ::static . I am still learning OOP in Maple, and could be overlooking something else. I definitly do not want to code using _self:-variable_name all the time if I have to use OOP in Maple as it makes the code hard to read.

Notice that in both examples, and for the exported methods, I used _self as first argument. This is OK. This is meant to allow client of the object to call it using object:-method() syntax which is what I prefer instead of method(object,....). syntax.

I am talking about the execssive use of _self internal to the module/object code when having to use ::static. methods.

 > restart;
 > person_class_STATIC:=module()    option object;    local age:=5;       export set_age::static:=proc(_self,age,\$)            _self:-age:=age:    end proc:          export update_age::static:=proc(_self,age,\$)             do_the_update(_self)    end proc:          local do_the_update::static:=proc(_self,\$)       _self:-age:=_self:-age+1;       _self:-age:=sqrt(_self:-age^2+3);    end proc;    export get_age::static:=proc(_self,\$)            return _self:-age;    end proc:       end module:
 > o:=Object(person_class_STATIC); o:-set_age(100); o:-get_age(); o:-update_age(); o2:=Object(person_class_STATIC); o2:-get_age();

 > person_class_NO_STATIC:=module()    option object;    local age:=5;       export set_age:=proc(_self,_age,\$)            age:=_age:    end proc:          export update_age:=proc(_self,\$)             do_the_update()    end proc:          local do_the_update:=proc()       age:=age+1;       age:=sqrt(age^2+3);    end proc;    export get_age:=proc(_self,\$)            return age;    end proc:       end module:
 > o:=Object(person_class_NO_STATIC); o:-set_age(100); o:-get_age(); o:-update_age(); o2:=Object(person_class_NO_STATIC); o2:-get_age();

 >

## How to solve continuous time LQR optimal control p...

Suppose we have a "Finite-horizon, continuous-time LQR" optimal control problem. I am wondering how to solve Riccati DE and then determine state and control over time. Is it possible to analytically solve Riccati DEs? Suppose we have this example and we want to solve the problem based on the formulas in Wikipedia webpage.

A := Matrix(2, 2, [[2, 1], [1, -1]])

B := Vector[column](2, [3, 1])

Q := Matrix(2, 2, [[3, 0], [0, 2]])

R := 3

## why this difference in evaluation when using named...

Without trying it or looking down more, should these two code fragments give same output or not

```# CASE 1

restart;
A   :=   2;
B   :=   x+2*y;
t^2 * ( A * B );

#CASE 2
restart;
t^2*( 2 * (x+2*y)  );
```

One would expect both to give same output, right? CASE 1 just uses variables and CASE 2 just uses the values of these variables. I mean the semantics of CASE 1 and 2 are the same, given that Maple replaces each variable with its value when evaluating.

But Maple does not give same result.

One way to force same result when using variables is to use t^2*(eval(A*B));

My question is why CASE 1 gives different result from CASE 2?  I would have expected same output.

Maple 2021.2 on windows 10. Worksheet.

 > interface(version);

 > restart;
 > A:=2; B:=x+2*y; t^2*(A*B);

 > restart;
 > t^2*(2*(x+2*y));

 > restart;
 > A:=2; B:=x+2*y; t^2*(eval(A*B));

 >

## How do I code these examples?...

How do i code when i have to locate all maximum and minimum values, intervals of increase and decrease, and inflection points.

Thanks

## How can make substitutions of general expressions?...

I need to sustitute many similar expressions.
Somthing like:

subs( {f(x1)=h(x1), f(x2)=h(x2)...., f(xn)=h(xn)}, expression)

How can I ask Maple to substitute

f(anything) = h(same thing)?

(In Mathematica this can be done with x_)

Even more general, how can I substitute, for example,

F(f(x)) = H(h(x))
where f(x) is really 'anything'?

Thanks! Max

## How can complex transformations be used to tile th...

Initial text in the uploaded worksheet describes an attempt to partially tile the Poincare disk and asks to be shown how a known complex transformation can be used to accomplish this.

## Error in intsolve...

Hi,

I have a problem with intsolve which seems does not cover nonlinear equations:

my code is as follow:

intsolve(fracdiff(u(x, t), t, 1/2) = t^(1/2)*sin(x)/GAMMA(3/2), u(x, t));

But I face with the following error:

Error, (in intsolve) integral equation is not linear.

I searched but I did not find a solution or alternative code to this end.

Do you know the way?

The solution of equation shall be:

u(x,t)=t*sin(x)

## Log4j vulnerability in Maple?...

Are there any informations about a potential vulnerability in Maple due to the Log4j bug?

Maple is running on Java...

## Problems with contourplot...

Hello

I am trying to plot a contour in Maple2021, but I do not get a plot.

I appreciate a feedback.

~Best regards

## problem plot3d does not work ...

Under maple 2019 (linux ubuntu) I cannot make 3d plots !

Typing

plotd3d(sin(x*y),x=0..2,y=0..0.5);

does not produce any output and also the worksheet does not react any more. The only way to get out is to quit.

Btw: 2d plots work fine ...

What is wrong ? Thank you. Bs regards, Malte.

 First 66 67 68 69 70 71 72 Last Page 68 of 2141
﻿