MaplePrimes Questions

Hey

Does Maple have the equivalent of the MROUND Excel command?

Or can someone kindly make a procedure.

eg

MROUND(1986,10)=1990

MROUND(492,5)=490

thanks!

I am not getting the hemisphere which I thought was my expression (equation) represents.

Can anyone help me find my mistake.

with(plots);
implicitplot3d(z <= sqrt(-x^2 - y^2 + 9), x = -3 .. 3, y = -3 .. 3, z = 0 .. 3, coords = spherical);

Thanks in advance.

Doubt_ImplicitPlot.mw

Hello everyone

I observe the following "strange" case and I am wondering if I am missing something. So, any insights are more than appreciated. The case is the followin:

When I use

with(Optimization):
Interactive(x + y, {x = 0 .. 1, y = 0 .. 1, 1 <= x + y})

I get: objective =1, x=y=.5

However, If I run

with(Optimization):
Minimize(x + y, {x >=0,x<=1, y>=0,y<=1, 1 <= x + y})

then I get: objective =1, x=1, y=0

Why there is such a difference? Because of there are multiple solutions? 

Setup:
I am working with a 'large' data set( ~70MB .csv file).  Using the import command I can import the data into a maple worksheet.  After import the dimension of the imported object 434000 rows by 30 columns.  The first 2 columns contain time stamp strings, the rest are numeric. 

Issue:
Importing this data set takes about 5 minutes everytime the command is called, which is everytime the worksheet is opened or re executed.  This is a lot of redundent processing.

Question:
Is there a way that I can import the data once and have it saved as a variable in the variable manager associated with the worksheet?  I want to avoid using the import command in a reduent manner.

Dear Maple community,

I'm trying to solve iteratively a system of (non-)linear equations and, to better understand the dynamics behind this process, would like to know the new/updated values of the unknowns after each iteration. Unfortunately, I wasn't able to implement this myself and was wondering whether you could give me hand?

Specifically, consider the following system of 4 non-linear equations in 4 unknowns: y[1], y[2], y[3], y[4]:

(EQ1): y[1]=f(y[1], y[2], y[3], y[4])

(EQ2): y[2]=f(y[1], y[2], y[3], y[4])

(EQ3): y[3]=f(y[1], y[2], y[3], y[4])

(EQ4): y[4]=f(y[1], y[2], y[3], y[4])

The goal is to set-up an iterative process along the following lines:

Step 1: Set the values of y[1] through y[4] on the right-hand side (RHS) equal to 1 and calculate the respective values of y[1] through y[4] on the left-hand side (LHS). Store the latter LHS values as {y[1]^0, y[2]^0, y[3]^0, y[4]^0}.

Step 2: Substitute {y[1]^0, y[2]^0, y[3]^0, y[4]^0} on the RHS, update the LHS values and store those as {y[1]^1, y[2]^1, y[3]^1, y[4]^1}.

Iterate Step 2 until convergence (which should yield the exact same result as with solving numerically the above system of 4 equations using the fsolve(.) command). Importantly, I would like to "retrieve" the values of each variable y[k]^i at each iteration i, where k=1,2,3,4, and i=0,1,... and use them for further analysis. 

Iterative_solutionQ.mw

with your help i solved ODE for Elziki transform ...but now i am facing some issues for PDE...elziki transform is like laplace ...but having 1/v in product...if any one can solve pde for laplace ... then please help me out.pde_elziki.mw

I was tasked updating an old maple program (written +20 years ago using Maple version 3 I believe) and came across a line I'm unsure the meaning of. The line is: beta := [rhobar2$rowdim(A)]:

rhobar2 is the square of the mean of a data set and A is a Matrix with 3 columns and 12 rows. I'm just unsure what the $ operator is or is doing to the data. Any help would be appreciated. I'm new to this, sorry if this seems trivial.

hi, do you know how can we smooth this ellipse and make it more clear?

thickness, grid, numpoints don't help

restart;
with(plots);
f := (x, y) -> x^2 + y^2 - 12*x + 16*y;
display(plot3d(f(x, y), x = -9 .. 9, y = -9 .. 9), pointplot3d([[6, -8, f(6, -8)]], color = red, symbol = solidcircle, symbolsize = 18), view = [-4.2 .. 8.2, -8.2 .. 4.2, -100 .. 100], plot3d([cos(t), sin(t), 1 - 12*cos(t) + 15*sin(t)], t = 0 .. 2*Pi, orientation = [-15, 68, 5]));
 

Let (C):f(x)=1/(x^2-2x).Find the equation of the circle touching the graph $(C )$ at three points?

Hi 

As the titel states: It is possible to create a asymptotic bode plot in maple?

I know how to do a normal bode plot with the DynamicSystem package. But is it possible to get a straight line approximation/ asymptotic bode plot instead?

I discovered the MRB constant (CMRB) while using Maple. Since then, I've found many formulas related to it, including its integrated analog the MKB constant (MKB). They're both found in Google scholar!

However, I am stuck on proving the following.

Also prove the above equation, ReMKB+NoMKB-CMRB=0.

All my similar proofs are found at

https://www.mapleprimes.com/posts/214522-Formulas-For-The-MRB-Constant?sp=214522

Dear Users!

Hope everything going find with you. I want to generate sequence of Spline[i,p], p=1…M as given bellow

restart; M := 3;
for p while p <= M do
(x-x[i])*B[i, p-1]/(x[i+p]-x[i])+(x[i+p+1]-x)*B[i+1, p-1]/(x[i+p+1]-x[i+1]);
B[i, p] := collect(%, [`$`(B[i+s, 0], s = 0 .. M)]);
B[i+1, p] := eval(%, i = i+1)
end do;
for p while p <= M do
Spline[i, p] := B[i, p]
end do

The expression for Spline[i,1] and Spline[i,2] are fine but the expressions of Spline [i,p] p>2 is not in simplified form I got the its simplification like given bellow for Spline[i,3]

Spline[i, 3]:=(x-x[i])^3*B[i, 0]/((x[i+3]-x[i])*(x[i+2]-x[i])*(x[i+1]-x[i]))+(((x-x[i])*(x-x[i]))*(x[i+2]-x)/((x[i+3]-x[i])*(x[i+2]-x[i])*(x[i+2]-x[i+1]))+(x-x[i])*(x[i+3]-x)*(x-x[i+1])/((x[i+3]-x[i])*(x[i+3]-x[i+1])*(x[i+2]-x[i+1]))+(x[i+4]-x)*(x-x[i+1])^2/((x[i+4]-x[i+1])*(x[i+3]-x[i+1])*(x[i+2]-x[i+1])))*B[i+1, 0]+((x-x[i])*(x[i+3]-x)^2/((x[i+3]-x[i])*(x[i+3]-x[i+1])*(x[i+3]-x[i+2]))+(x[i+4]-x)*(x-x[i+1])*(x[i+3]-x)/((x[i+4]-x[i+1])*(x[i+3]-x[i+1])*(x[i+3]-x[i+2]))+((x[i+4]-x)*(x[i+4]-x))*(x-x[i+2])/((x[i+4]-x[i+1])*(x[i+4]-x[i+2])*(x[i+3]-x[i+2])))*B[i+2, 0]+(x[i+4]-x)^3*B[i+3, 0]/((x[i+4]-x[i+1])*(x[i+4]-x[i+2])*(x[i+4]-x[i+3]));

I am waiting for positive respone. Please take care and thanks in advance

timelimit() has improved in Maple 2021, and I thought it works now for everything. 

https://www.mapleprimes.com/maplesoftblog/213986-Introducing-Maple-Learn-officially#comment204444

But unfortunately,, it still hangs on some dsolves when I was testing something. Here is an example

restart;
ode:=(y(x)^4-a^2*x^2)*diff(y(x),x)^2+2*a^2*x*y(x)*diff(y(x),x)+y(x)^2*(y(x)^2-a^2)=0;
timelimit(60,dsolve(ode,y(x)))

The above has one minute timeout. But its been running for 20 minutes now. Here is another example that hangs

restart;
ode:=(diff(y(x),x) = (-y(x)^2+4*a*x)^3/(-y(x)^2+4*a*x-1)/y(x));
timelimit(60,dsolve(ode,y(x)))

I have found many more dsolve examples that hang with timelimit. Will update later. May be they will help find the cause.

Hopefully this timelimit issue will be fixed in some future release.  hangs in Maple commands even when using timelimit makes it very hard to run long scripts that run over many problems, since do not know when/where it will hang and have to restart and clean things manually each time.

Window 10. Maple 2021

Update March 15,2022

Here is another example of timelimit taking so much longer than asking for, it is pretty much useless.

I will use this question to collect such examples in one place. Here I asked for one minute (60 seconds, CPU time) timeout. Maple actually timedout after using 1381 CPU seconds which is 23 times as much as requested.

restart;

ode:=x^2*(x^2+1)*diff(y(x),x$2)+7*x*exp(x)*diff(y(x),x)+9*(1+tan(x))*y(x)=0;
current_time:=time();
try
   timelimit(60,dsolve(ode))
catch:
   print("Good. Timelimit worked");
end try;
time_used := time()-current_time;

x^2*(x^2+1)*(diff(diff(y(x), x), x))+7*x*exp(x)*(diff(y(x), x))+9*(1+tan(x))*y(x) = 0

7292.312

"Good. Timelimit worked"

1381.078

1381/60.

23.01666667

 


 

Download timelimit_example_march_15_2022.mw

Help says

The timelimit function evaluates the expression x, but gives up if the evaluation takes longer than the number of seconds specified by t.
Note: In some cases, the execution may not abort at exactly the time limit imposed, but will abort as soon as it can do so safely.  This can happen when execution is in critical sections of certain built-in routines.

For me, the above makes no sense at all. What does "as soon as it can do safely"? I am not running the code to control an airplane flight full of people here. This is some code running on my PC at home to do some calculation. It can abort right away. It will not hurt me physically or hurt my PC to do so. 

So what does "do so safely" actually mean? Safety of what exactly?

Compare the above example to Mathematica where it times out at almost exactly to the requested timeout. Here I ask for 3 seconds timeout

I am not asking for exact timeout. But asking for 1 minute timeout and getting 8 minutes is not good at all.

1.5 minutes is OK. even 2 minutes is OK. 

I have more examples to add. But will do that later.

Update

Quick try with Maple 2022 shows timelimit has much improved. Here are 3 examples from above. First one asks for 60 seconds limit, it finishes in 288 seconds.   Second one asks for 60 seconds, it finishes in 96 seconds. Third one asks for 60 seconds and finishes in 73 second.

This is much much better than in Maple 2021. Thanks for the Maple engineers who improved this.

interface(version)

`Standard Worksheet Interface, Maple 2022.0, Windows 10, March 8 2022 Build ID 1599809`

restart;

ode:=x^2*(x^2+1)*diff(y(x),x$2)+7*x*exp(x)*diff(y(x),x)+9*(1+tan(x))*y(x)=0;
current_time:=time();
try
   timelimit(60,dsolve(ode))
catch:
   print("Good. Timelimit worked");
end try;
time_used := time()-current_time;

x^2*(x^2+1)*(diff(diff(y(x), x), x))+7*x*exp(x)*(diff(y(x), x))+9*(1+tan(x))*y(x) = 0

430.171

"Good. Timelimit worked"

288.766

ode:=(y(x)^4-a^2*x^2)*diff(y(x),x)^2+2*a^2*x*y(x)*diff(y(x),x)+y(x)^2*(y(x)^2-a^2)=0;
current_time:=time();
try
   timelimit(60,dsolve(ode))
catch:
   print("Good. Timelimit worked");
end try;
time_used := time()-current_time;

(y(x)^4-a^2*x^2)*(diff(y(x), x))^2+2*a^2*x*y(x)*(diff(y(x), x))+y(x)^2*(y(x)^2-a^2) = 0

718.953

"Good. Timelimit worked"

96.875

ode:=(diff(y(x),x) = (-y(x)^2+4*a*x)^3/(-y(x)^2+4*a*x-1)/y(x));
current_time:=time():
try
   timelimit(60,dsolve(ode))
catch:
   print("Good. Timelimit worked");
end try;
time_used := time()-current_time;

diff(y(x), x) = (-y(x)^2+4*a*x)^3/((-y(x)^2+4*a*x-1)*y(x))

"Good. Timelimit worked"

73.203

 

Download better_time_limit_with_maple_2022.mw


restart; with(plots); a := .8; N := 4; for k to N while k <> j do t[k] := sinh(x[k]+I*a)^N*(product(sinh(1/2*(x[k]-x[j]-(2*I)*a)), j = 1 .. N))/(sinh(x[k]-I*a)^N*(product(sinh(1/2*(x[k]-x[j]+(2*I)*a)), j = 1 .. N))) end do

.8

 

4

 

-1.000000000*sinh(x[1]+.8*I)^4*sinh((1/2)*x[1]-(1/2)*x[2]-.8*I)*sinh((1/2)*x[1]-(1/2)*x[3]-.8*I)*sinh((1/2)*x[1]-(1/2)*x[4]-.8*I)/(sinh(x[1]-.8*I)^4*sinh((1/2)*x[1]-(1/2)*x[2]+.8*I)*sinh((1/2)*x[1]-(1/2)*x[3]+.8*I)*sinh((1/2)*x[1]-(1/2)*x[4]+.8*I))

 

-1.000000000*sinh(x[2]+.8*I)^4*sinh((1/2)*x[1]-(1/2)*x[2]+.8*I)*sinh((1/2)*x[2]-(1/2)*x[3]-.8*I)*sinh((1/2)*x[2]-(1/2)*x[4]-.8*I)/(sinh(x[2]-.8*I)^4*sinh((1/2)*x[1]-(1/2)*x[2]-.8*I)*sinh((1/2)*x[2]-(1/2)*x[3]+.8*I)*sinh((1/2)*x[2]-(1/2)*x[4]+.8*I))

 

-1.000000000*sinh(x[3]+.8*I)^4*sinh((1/2)*x[1]-(1/2)*x[3]+.8*I)*sinh((1/2)*x[2]-(1/2)*x[3]+.8*I)*sinh((1/2)*x[3]-(1/2)*x[4]-.8*I)/(sinh(x[3]-.8*I)^4*sinh((1/2)*x[1]-(1/2)*x[3]-.8*I)*sinh((1/2)*x[2]-(1/2)*x[3]-.8*I)*sinh((1/2)*x[3]-(1/2)*x[4]+.8*I))

 

-1.000000000*sinh(x[4]+.8*I)^4*sinh((1/2)*x[1]-(1/2)*x[4]+.8*I)*sinh((1/2)*x[2]-(1/2)*x[4]+.8*I)*sinh((1/2)*x[3]-(1/2)*x[4]+.8*I)/(sinh(x[4]-.8*I)^4*sinh((1/2)*x[1]-(1/2)*x[4]-.8*I)*sinh((1/2)*x[2]-(1/2)*x[4]-.8*I)*sinh((1/2)*x[3]-(1/2)*x[4]-.8*I))

(1)

list4 := fsolve({t[1] = -1, t[2] = -1, t[3] = -1, t[4] = -1}, {x[1], x[2], x[3], x[4]}); list4 := fsolve({t[1] = -1, t[2] = -1, t[3] = -1, t[4] = -1}, {Im(x[1]) = .5 .. 1, Im(x[2]) = .5 .. 1, Im(x[3]) = -1 .. -.5, Im(x[4]) = -1 .. -.5})

``


Download system.mw


 

Download system.mw

 

Solving a system of equations

I want to solve the following system (please see the code) for small even N=4,8,16. They said that the roots lie on the lines Im x_i = ±π/2 and they are symmetric with respect to the imaginary axis. For N=4, I tried with fsolve directly but the roots are:

 x[1] = -3.799588601-1.570796327*I,

 x[2] = -3.799588601-1.570796327*I,

 x[3] = .1196098914-1.570796327*I,

 x[4] = 1.110549099-1.570796327*I

these solutions are not valid because half of them should have +π/2 as an imaginary part, and they should be mutually distinct and also symmetric with respect to the imaginary axis. Therefore, for N=4  I am expecting solutions of these form :

x[1] = a_1-I* π/2,

x[2] = -a_1-I* π/2,

x[3] = a_1+I* π/2,

x[4] = -a_1+I* π/2,

I tried with fslove({system}, {Im(x[1]) = .5 .. 1, Im(x[2]) = .5 .. 1, Im(x[3]) = -1 .. -.5, Im(x[4]) = -1 .. -.5}) but it does not work! I do not know what should I do to make Fsolve locate the wanted solutions. Thanks in advance!

 

I found a big problem.

When adding kernelopts('assertlevel'=2): which I like to have it on all the time to catch (actual) errors, but now Maple server hangs then crashes on what should be no issue at all. 

This happens when I am using an object, which is used at global type. Here is a MWE

restart;

interface(warnlevel=4);
kernelopts('assertlevel'=2);

local ode_type:=module()
    option object;
    export ode;
    local ModuleLoad::static:=()->
           TypeTools:-AddType(':-ode_type', ode_type);
    ModuleLoad()       
end module:

A:=module()
  export foo:=proc()
    C:-foo();
  end proc;

  local B:=module()
    export foo:=proc()
      local ODE::ode_type;
      return ODE;
    end proc;
  end module;

  local C:=module()
    export foo:=proc()
      local the_ode::ode_type;  #THIS CAUSES the hang
                                #using the_ode::':-ode_type'; makes no difference
      #DEBUG
      the_ode:=B:-foo();
    end proc;
  end module;
end module;

There is nothing wrong with the above code as far as I can see. But now A:-foo(); crashes the Maple server.

If I change the line local the_ode::ode_type; to local the_ode; i.e. remove the type on the local variable, it works.

So assert thinks the type being returned is not ode_type

It also works if I remove the assert and keep the type there. Like this

restart;

interface(warnlevel=4);

local ode_type:=module()
    option object;
    export ode; 
    local ModuleLoad::static:=()->
           TypeTools:-AddType(':-ode_type', ode_type);
    ModuleLoad()       
end module:

A:=module()
  export foo:=proc()
    C:-foo();
  end proc;

  local B:=module()
    export foo:=proc()
      local ODE::ode_type;
      return ODE;
    end proc;
  end module;

  local C:=module()
    export foo:=proc()
      local the_ode::ode_type;  #NOW IT WORKS
      the_ode:=B:-foo();
    end proc;
  end module;
end module;

In my actual code, when I remove the kernelopts('assertlevel'=2); I do get correct final output. So it is not like I am bypassing some wrong code or something. The code works as expected.

Now now I have two choices, either remove  kernelopts('assertlevel'=2); or remove the type from the defintion of the local variables, when the type of object defined as above.

edit

another version below. When I copied the code above from my .mpl files to the worksheet to make a MWE, there was a local next to the object module (because that is how it is in my main code), and I did not notice it at first.

When I removed it to make new MWE in the worksheet, an error still shows up. But now Maple server do not hang/crash but it still does not like the assignment being made. So here is another version

restart;
interface(warnlevel=4);
kernelopts('assertlevel'=2):


ode_type:=module()  #note that local ode_type:=module()  crashes Maple.
    option object;
    export ode; #can be list      
    local ModuleLoad::static:=()->
           TypeTools:-AddType(':-ode_type', ode_type);
    ModuleLoad()       
end module:

A:=module()
  export foo:=proc()
    C:-foo();
  end proc;

  local B:=module()
    export foo:=proc()
      local ODE::ode_type;
      return ODE;
    end proc;
  end module;

  local C:=module()
    export foo:=proc()
      local the_ode::ode_type;
      #DEBUG();
      the_ode:=B:-foo();
    end proc;
  end module;
end module;

And now A:-foo(); do not crash the server, but still gives error

     Error, (in foo) assertion failed in assignment to the_ode, expected ode_type, got ODE

Why? since ODE is of type ode_type, and I am returning. Can one not return Object like this? 

Is there something I am doing wrong?

 

 

First 402 403 404 405 406 407 408 Last Page 404 of 2427