MaplePrimes Questions

Is it possible to use the Maple command timelimit(time, procedure(.......)) inside a loop of the type "for j                     do        procedure(.......)                   end do" without getting the error 'time expired" that forgets that value of j and  continue with the next value of j. How?

Is it possible in Maple Flow to reference to another worksheet as you can in Maple? If so, how would you do that? Thanks in advance for your help.

I'm attempting to visualize temperature averages across a 2 dimentional space (e.g., a square plate) with fixed heat sources. The 3rd dimension (z axis) represents temperature.  I have created several visualizations but have questions about how these plots work.  The model is attached and the questions will make sense once you open the worksheet.

  1. Using the "colorscheme" option on a couple of matrixplots, I get the error "[Length of output exceeds limit of 1000000]" and the plot doesn't show.  However using the "display()" command on those same plots does render the plot.  Is there a way around this error (i.e., rendering the plot directly) or should I just suppress the error using a colon at the end of the plot statement and rely on display() to show the plot?
  2. I've created a heat map as one of the visualizations.  Is there a way to access the color values at each of the "cells" of the heat map? I would like to use these colors elsewhere in the model but I'm not sure if there is a way to access the color values.
  3. Using a 3D point plot as one of the visualization options, I use the colorschemes with options "xgradient", "ygradient", and "zgradient".  For some reason, "xgradient" and "ygradient" work as expected but "zgradient" looks the same as "ygradient".  How do I get the color transition to change along the z axis rather than only x and y axes?

Thank you for your help on these questions.

temperature_profile_(experimental)(v01).mw

According to Maple help, the plots:-display function can be called with parameter (P).

P - a set, list or Array (one- or two-dimensional) of plot structures, or an animation structure

Both in the last section of the help function, and code in this example (https://mapleprimes.com/questions/236270-Plot-Objects-Created-Created-With-Geometry), it apparently can be called differently.

  • display(A, B, view = [-3*Pi .. 3*Pi, -1 .. 1])
  • display(F, draw(B))

A, B or F, draw(B) er graphics objects, but the call format is neither a set, list or Array.

Is the explanation for plots:-display incorrect, or am I missing something here?

Hi,
I have a function "w" that the eval command does not gives the correct value of its first derivative at a fixed point. I guess the problem is due to sqrt() terms, but I can't fix it. 
eval.mw

Hello everyone! I have found this document from Maple 18 (2014) that will be very usefull for my school work, but when i copy it into Maple 2022 i get the error message, "action, does not evaluate to a module" Is there any way for me to fix this? What i have been able to read is that i have to go in and update the code, but i have absolute no idea on how to do it? 

Kind Regards Samuel 

Regressionmodeller._Skal_laves_til_maple_22_og_23.mw

How can I plot stream lines between two concentric spheres?

Hi,

I am using Maple 2020 to numerically solve/generate numerical plots for my impulsive control problem.

The optimal control problem is:

T is time from0 to T where T is the terminal time

K(t), B(t) and M(t) are state variables

w(t) is a control variable

a(ti) is the impulsive control variable at time ti,

a(ti) \in [0,1] for i=1,2,…,N

ggamma, ttheta, ddelta1, ddelta 2, c1 and c2 are constants

K(T)=M(T)=0 B(T)>0

K'(t)=ggamma*K(t)*w(t)-ttheta*M(t)

B’(t)=ggamma*K(t)+ttheta*M(t)*B(t)

M’(t)=M(t)-ggamma*w(t)

M(ti)=M(ti-)+a(ti)M(ti)*ddelta1

K(ti)=K(ti-)-a(ti)K(ti)*ddelta2

Objective: maximize B(T)-integral from 0 to T of c1*(w(t))^2dt-sum i=1 to N of c2*a(ti)

Here is the code I enter to MAple:

restart;

# Define the constants
ggamma := 1.0;
ttheta := 2.0;
ddelta1 := 0.1;
ddelta2 := 0.2;
c1 := 0.5;
c2 := 0.3;
T := 5.0; # Terminal time

# Define the impulsive changes in M(t)
impulse_changes := proc (t)
    local ti_values, imp_values, result;
    ti_values := [1.0, 2.0, 3.0]; # Example impulsive time instants
    imp_values := [0.2, 0.1, 0.3]; # Corresponding impulsive control values
    result := 0;
    for i from 1 to nops(ti_values) do
        if t = ti_values[i] then
            result := result + imp_values[i]*M(ti_values[i])*(ddelta1 - ddelta2);
        end if;
    end do;
    return result;
end proc;

# Define the system of differential equations
diffeqs := {diff(K(t), t) = ggamma*K(t)*w(t) - ttheta*M(t),
            diff(B(t), t) = ggamma*K(t) + ttheta*M(t)*B(t),
            diff(M(t), t) = M(t) - ggamma*w(t)};

# Define the impulsive controls
impulse_controls := [1.0, 0.5, 0.8]; # Example impulsive control values

# Define the initial values and conditions
initial_values := [K(0) = 0, B(0) = 0, M(0) = 0];

# Define the final conditions
final_conditions := [K(T) = 0, M(T) = 0, B(T) > 0];

# Define the objective function to be maximized
objective := B(T) - int(c1*w(t)^2, t = 0 .. T) - add(c2*impulse_changes(ti), ti = 1.0 .. 3.0);

# Solve the system of differential equations numerically
sol := dsolve({diffeqs, initial_values, final_conditions}, numeric, output = listprocedure);

# Find the optimal control trajectory w(t) using optimization
w_optimal := optimize(objective, numeric, maximize);

# Evaluate the optimal control and state trajectories
optimal_controls := [seq(w_optimal(t), t = 0.0 .. T, 0.1)];
state_trajectories := [sol[2](t), sol[3](t), sol[4](t)];

optimal_controls, state_trajectories;

I am getting the error:

"Error, (in dsolve/numeric/process_input) system must be entered as a set/list of expressions/equations"

as soon I run after the sol:= function.

I would appreciate any help with fixing my code!

Thank you very much!

Hafiz_basin_of_attraction_.mw

[moderator: see also this earlier Question]

Hi Users!

I hope everyone is fine. I want to plot any function say
f := exp(cos(x)+sin(x)) for x=a..b for any n say 12 so that h := (b-a)/n. 

For a=0, b=3 and n=12 I got h=1/4 and plot of f is:

But I want the plotting as given bellow where the value of f(x) is mentioned and girds line.

I am waiting for your answer. Thanks in advance.

 

Just wanted to ask, what the issue here is:

restart;
Int(1/(1 - x*ln(x)), x);
IntegrationTools:-Change(%,u=1-x*ln(x),u);

doesn't give the proper transformation. It gives

Int(1/u,u)

Solving for x and writing the transformation in terms of LambertW gives something else, if I'm not mistaken.

Dear Users!

I hope everyone is fine here. I wrote the following statements with the print command:

restart; NN := [4, 6, 8]; a := 0; b := 2; n := 4;
h := evalf((b-a)/n); print("The domain of intergation is [a,b] = ", [a, b]);
f := exp(x); print("The given function is ", f);
Exact := evalf(int(f, x = a .. b)); print("The exact integration in [a,b] is ", Exact);
print("The value of h to divide the domain [a,b] into n subintervals is ", h);
print("Numerical integration in [a,b] is going to perform when h via RECTANGULAR METHOD for n = ", n);

The output is:

                          0.5000000000
        "The domain of integration is [a,b] = ", [0, 2]
                "The given function is ", exp(x)
       "The exact integration in [a,b] is ", 6.389056099
"The value of h to divide the domain [a,b] into n subintervals is ", 0.5000000000
"Numerical integration in [a,b] is going to perform when h via RECTANGULAR METHOD for n = ", 4

I want the actual values of a,b, n and h highlighted in above as:

                            0.5000000000
        "The domain of integration is [a,b] = ", [0, 2]
                "The given function is ", exp(x)
       "The exact integration in [0,2] is ", 6.389056099
"The value of h to divide the domain [0,2] into 4 subintervals is ", 0.5000000000
"Numerical integration in [0,2] is going to perform when 0.5 via RECTANGULAR METHOD for n = ", 4

The code below runs as expected up through the 4th line. At that point ans_all should contain all the multipule ansers to the equation being looked at. I want to look at just the first solution and I would expect the way to do this would be ans_all[1]. However the command ans_all[999999999] is valid, which indicates to me that that's not how you do that. So.... how do I get just the first answer?

equ := sqrt(1 + (-4 + 4*sqrt(2))*x + (16 - 12*sqrt(2))*x^2 + (-24 + 16*sqrt(2))*x^3 + (15 - 8*sqrt(2))*x^4)/(1 + (-4 + 4*sqrt(2))*x + (22 - 12*sqrt(2))*x^2 + (-36 + 28*sqrt(2))*x^3 + (33 - 20*sqrt(2))*x^4):
anit_dev_equ := int(equ,x):
ans_root := eval(anit_dev_equ, [x = 1]) - eval(anit_dev_equ, [x = 0]):
ans_all := allvalues(ans_root):
ans_all[999999999]

could any one help  to plot this.

Here is my code.

PWS.mw

I need to make the graph i have attached match the image below.

Is there any wrong with unknown parameter i found?How to solve this.Please Help.

Dear Maple professionals

I have written two procedures in Maple that are run flawlessly. But when I wrote a simple third procedure that calls those two, I face an error. Can you guide me if I am missing anything? The code is attached. Thank you in advance!
 

``

restart

with(plots)

c := 1; cr := 0.3e-1*c; u := 1; sExp := 0.6e-1*c; s := .65*c

v := 3*c

NULL

FirmModelPP := proc (alpha, delta) local p0, xi0, q0, Firmpf0, G0, Recpf0, Unsold0, Environ0; option remember; xi0 := 1; p0 := min(s+sqrt((v-s)*(c-s)), delta*v+sExp); q0 := u*(v-p0)/(v-s); f(N) := 1/u; F(N) := N/u; G0 := int(F(N), N = 0 .. q0); Firmpf0 := (p0-c)*q0-(p0-s)*G0; Recpf0 := (sExp-cr)*xi0*q0; Environ0 := q0+G0; Unsold0 := G0; return p0, q0, Firmpf0, Recpf0, Unsold0, Environ0 end proc

FirmModelFC := proc (alpha, beta, delta) local p00, xi00, q00, Firmpf00, G00, Recpf00, Unsold00, Environ00, pr00; option remember; xi00 := 1; p00 := s+sqrt((v-s)*(c-s)); if p00 < delta*v+sExp then q00 := u*(v-p00)/(v-s); f(N) := 1/u; F(N) := N/u; G00 := int(F(N), N = 0 .. q00); Firmpf00 := (p00-c)*q00-(p00-s)*G00; Recpf00 := `&xi;00*q00*`(sExp-cr); Unsold00 := G00; Environ00 := q00+Unsold00 else q00 := alpha*u*(v-p00)/(v-s); f(N) := 1/u; F(N) := N/u; G00 := int(F(N), N = 0 .. q00/alpha); pr00 := p00-delta*v; Firmpf00 := (p00-c)*q00-alpha*(p00-s)*G00; Recpf00 := (beta*(pr00-sExp)+sExp-cr)*xi00*q00-(1/2)*(pr00-sExp)*beta^2*xi00^2*q00^2/(u*(1-alpha)); Unsold00 := G00; Environ00 := q00+Unsold00 end if; return p00, q00, Firmpf00, Recpf00, Unsold00, Environ00 end proc

NULL

NULL

"CurrentMetrics:= proc(alpha,beta,delta) option remember;  local  p, q, Firmpf,Recpf,Unsold,Environ; "

Error, unterminated procedure

"CurrentMetrics:= proc(alpha,beta,delta) option remember;  local p, q, Firmpf,Recpf,Unsold,Environ; "

 

"if (FirmModelFC(alpha,beta,delta)[3]>=FirmModelPP(alpha,delta)[3]) then    p:=FirmModelFC(alpha,beta,delta)[1]:  q:=FirmModelFC(alpha,beta,delta)[2]:   Firmpf:=FirmModelFC(alpha,beta,delta)[3]:  Recpf:=FirmModelFC(alpha,beta,delta)[4]:  Unsold:=FirmModelFC(alpha,beta,delta)[5]:   Environ:=FirmModelFC(alpha,beta,delta)[6]:     else   p:=FirmModelPP(alpha,delta)[1]:  q:=FirmModelPP(alpha,delta)[2]:   Firmpf:=FirmModelPP(alpha,delta)[3]:   Recpf:=FirmModelPP(alpha,delta)[4]:  Unsold:=FirmModelPP(alpha,delta)[5]:   Environ:=FirmModelPP(alpha,delta)[6]:    end if :  return p,q,Firmpf,Recpf, Unsold,Environ;  end proc: "

Error, unable to parse

"if (FirmModelFC(alpha,beta,delta)[3]>=FirmModelPP(alpha,delta)[3]) then p:=FirmModelFC(alpha,beta,delta)[1]:  q:=FirmModelFC(alpha,beta,delta)[2]:   Firmpf:=FirmModelFC(alpha,beta,delta)[3]: Recpf:=FirmModelFC(alpha,beta,delta)[4]:  Unsold:=FirmModelFC(alpha,beta,delta)[5]: Environ:=FirmModelFC(alpha,beta,delta)[6]:    else p:=FirmModelPP(alpha,delta)[1]:  q:=FirmModelPP(alpha,delta)[2]:   Firmpf:=FirmModelPP(alpha,delta)[3]: Recpf:=FirmModelPP(alpha,delta)[4]:  Unsold:=FirmModelPP(alpha,delta)[5]: Environ:=FirmModelPP(alpha,delta)[6]:   end if :  return p,q,Firmpf,Recpf, Unsold,Environ;  end proc: "

 

NULL

plot(['CurrentMetrics(alpha, .2, .2)[3]'], alpha = 0. .. 1.0, linestyle = [solid], legend = ["Firm's profit with delta=0.2"], labels = [alpha, "Firm profit"], labeldirections = ["horizontal", "vertical"], color = [blue], axes = boxed)

Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

 

 

NULL

NULL

NULL

NULL

NULL

NULL


 

Download Call_two_procedures_in_another_one.mw

 

First 58 59 60 61 62 63 64 Last Page 60 of 2308