Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Hallo, I would like to ask anyone have encountered this problem. I tried to update a matrix value using recurrence do but end up with "Error, recursive assignment". Here is the code. Any help is appreciated.

 

with(LinearAlgebra);
with(plots);
Nx := 200;
Nt := 200;
dx := 0.5e-2; dt := 0.2e-1;
A := Matrix(Nx, Nx);

for k to Nx do A[k, k] := -2.0 end do;
for j to Nx-1 do A[j+1, j] := 1.0 end do;
for j to Nx-1 do A[j, j+1] := 1.0 end do; A;
zeta := (.1*dt/dx)^2;
phi || 0 := Matrix(Nx, Nx);

fin := proc (t) options operator, arrow; cos(4*Pi*t) end proc;
phi || 0[(1/2)*Nx, (1/2)*Nx] := fin(0);
phi || 1 := (1/2)*zeta^2 . A . phi || 0; phi || 1[(1/2)*Nx, (1/2)*Nx] := fin(dt);

phinow := Matrix(Nx, Nx); phinext := Matrix(Nx, Nx); phibefore := Matrix(Nx, Nx);

phinow := phi || 1; phibefore := phi || 0;

for j from 2 to Nt do phinext := Zeta^2 . (A . phinow+phinow . A)+2.*phinow-phibefore; phi || j := Matrix(Nx, Nx); phinext[(1/2)*Nx, (1/2)*Nx] := fin(j*dt); phi || j := phinext; phibefore := phi || (j-1); phinow := phi || j end do;
Error, recursive assignment


for j to (1/5)*Nt do p || j := matrixplot(phi || j, heights = histogram, gap = 0.5e-2, labels = ["", "", ""]) end do;

plots[display](p || (1 .. 20), insequence = true);

Hi,

I solve numerically an ODE system which depends on 25 parameters.
I want to know the maximum value of the time at which a specific event is triggered, when these parameters vary (independently the one of the other) within a 25 dimensional hyperbox.

To solve this maximization problem, which I assume is local1, I would like to use NLPSolve

The attached zip (I use Mac OSX) contains:

  • a file that gives a full description of the problem (the original ".pages" file and its export as pdf),
  • an m file wich contains the solution procedure plus a few other variables needed to solve the problem,
  • the mw file which contains:
    • the reading of the m file,
    • the procedure (OBJ) which returns the trigerring time,
    • many attemps to find its maximum value using NLPSolve.

None of my attempts at using NLPSolve gave me the expected answer

Could you help me to fix this?

Thanks in advance

mw_and_m_files.zip

1: Initializing a local method (see the explanation file) with different points gave me different optimizers but all of them led to rather close values of the objective function. Thus the problem is either global instead of local, or convergence might not be achieved for all the initialization points (but keep in mind that I'm not interested in the location of the minimizer(s) but in the maximum value of if the time when the event is triggered).


Hi Every one. I was trying to solve three point boundary value problem but cound't get the solution. any help? 
u1 need to plot  -1..0 and u2 from 0..1 and shown in a single doamin -1..1


 

Hi!

I am so pleased to be here to look for help in using Maple.

I am trying to find solutions to a set of nonlinear systems of equations using fsolve.

This code I am tried to solve is shown as follow:

 nonlinearsystemforallsolution.mw

I can get one solution for three variables, however, it's clear there are some solutions missed.

My questions are listed as:

1) How do I get all solutions for a fixed variable of sigma?

2) How do I create a  loop to obtain the solutions for various values of sigma?

3) How to plot solution of each variables versus sigma? 

3) How do I determine the stability of each solution?

Many thanks in advance.

sincerely

 

As most Maple Primes readers have hopefully seen, Maplesoft is having our Maple Conference again this fall. This year we decided to add a space to the conference to showcase creative and artistic work that would be interesting to our Maple Community. The conference organizers asked me if I would coordinate and curate this exhibition of creative uses of Math and Maple, and I agreed. So now, I am asking the Maple community to send us your most creative work related to or using Maple.

The obvious thing to submit would be a beautiful digital plot or animation with an interesting mathematical story and of course, we are really interested to see those. But, we would are especially excited to see some art created with physcial media. I would love to see your knitting or needle point project that is inspired by a mathematical theme or was created with the help of Maple.

The full announcement can be found at the Maple Conference Art Gallery page. We would like to have all submissions by October 12th so that can review and finalize the gallery before the conference begins November 1st.

Oh yeah, there will also be prizes.

I can't wait to see what everyone sends in!

I have some more questions, now i get some more odd situations where an obvious answer cannot be given by solve. And a funtion cannot be plotted somehow. 

Here is the file. I tried to understand why, but it is not happening. They did it on purpose (i guess) to get simple questions, and show you that Maple sometimes does not have the answer right away. So you run into the "limitations" of the program right away so you are aware what could go wrong.

Find x with the help of a graph from: 2^x<1/2*x^2+2  

smartplot([2^x, (1/2)*x^2+2])

 

solve(2^x = (1/2)*x^2+2, x)

Warning, solutions may have been lost

 

RootOf(_Z^2-2*2^_Z+4)

(1)

"f(x):=2^(x)"

proc (x) options operator, arrow, function_assign; 2^x end proc

(2)

"g(x):=1/(2)x^(2)+2"

proc (x) options operator, arrow, function_assign; (1/2)*x^2+2 end proc

(3)

evalf(solve(f(x) = g(x), x))

Warning, solutions may have been lost

 

.8841764608-2.067784075*I

(4)

While the answer is obviously x=2 to be equal, and thus for values of x= (infinity;2> g(x) is larger, even if you would manually fill in the equetions,you get a value of 2. Both sides would get a solution of y=4. Somehow Maple does not give a straight answer.

``

2nd question
I have to plot this function, and it wont let me plot it..

"f(x):=(-2)^(x)"

proc (x) options operator, arrow, function_assign; (-2)^x end proc

(5)

plot(proc (x) options operator, arrow, function_assign; (-2)^x end proc)

 

I am not seeing a line, it is so odd.

``

Download Applied_Math_Part_1_questions_part_two.mw

The function

Hi!

The so called Haar system is given as the follwoing sequence of functions:

 

 

Someboy know how to code the above functions? For a given n, I think that the rpoblem is to find the numbre k in the above definition.

Many thanks in advance for you comments.

How to attach an m-file to a question?
Does it exist a rspecific repository where I can put an m-file? 

Suppose we have a function that we want to plot in different styles and to finally put all these different plots in one single plot.

When we use the plot command, it is easy to gather several plots in one single plot but when it commes to another special kind of plots (namely, DiscretePlot from DynamicSystems), there I am stuck.

Would you like help me to solve this problem? Thank you.

Here attached the corresponding worksheet.

altogether.mw

When I was drawing a plane graph, I found that the labels  of vertices were not displayed  and some edges even overlap when drawing because they were too close due to embedding.

restart:
with(GraphTheory):
g:=ConvertGraph("GsaCB{");
DrawPlanar(g,stylesheet=[vertexborder=false,vertexpadding=5,edgecolor = maroon,vertexcolor=gray,edgethickness=3])

So I thought that  option  Interactive  can adjust the position manually, but  at the same time I found that the style of  edges, such as the color and thickness, etc., is lost.  How to handle it? Is this a bug?

restart:
with(GraphTheory):
g:=ConvertGraph("GsaCB{");
DrawPlanar(g,stylesheet=[vertexborder=false,vertexpadding=5,edgecolor = maroon,vertexcolor=gray,edgethickness=3],layout=interactive)

Hello, ive got some trouble calculating this problem. Ive been looking at it for quite some time. I suspect you first need to differentiate to get the minimum value and then make it back to p. Time is ticking away, and i can just cant get it right. Its 2 questions out of some Dutch mathbook from 2007. It has a lot of Maple in it too. Just so to get a broad a view on maple as possible. I must say these maplebooks have quite the repertoirs. The other book "Advanced Problem Solving Using Maple" book turns you into some British chap. And this book:"toegepaste Wiskunde voor het hoger beroepsonderwijs deel 1"(translated applied math for higher job education part 1), turns you into the odd obnoxious Dutch mathematician... Well what can i say??

Here are the questions: 

1st Question:
For which values of p does the graph of the function: y=f(x)=(p*x^2)+3*p*x+1 have one intersection with the x-axis? When does it have two intersections with the x-axis? When does it have no intersections with the x-axis. 

2nd Question:
Given functions are: y=f(x)=(x^2)-6x+p+3, and y=g(x)=(4x^2)-(p-8)x+7. When do these functions have the same minimum value. Calculate p and the minimum value.

Greetings,

1st Question:
For which values of p does the graph of the function: y=f(x)=(p*x^2)+3*p*x+1 have one intersection with the x-axis? When does it have two intersections with the x-axis? When does it have no intersections with the x-axis.  

f(x) = p*x^2+3*p*x+1

f(x) = p*x^2+3*p*x+1

(1)

NULL

restart

2nd Question:
Given functions are: y=f(x)=(x^2)-6x+p+3, and y=g(x)=(4x^2)-(p-8)x+7. When do these functions have the same minimum value. Calculate p and the minimum value.

f(x) = x^2+p-6*x+3

f(x) = x^2+p-6*x+3

(2)

g(x) = 4*x^2-(p-8)*x+7

g(x) = 4*x^2-(p-8)*x+7

(3)

``

Download Applied_Math_Part_1_questions.mw

the function

I am looking for an output without denominator. I.e.:  2^(-1/3) instead of 2^(2/3)/2

Thank you

Given some intert expression like 4%*5 %+ 3 is there a way to progressively convert it to a non-inert expression(and evaluated expression)?

I'd like to see the stages without having to hard code it all. Value simply converts the expression all the way down. I'd like to see intermediate stages. Ideally it should followthe order of operations and hault when it reaches a fixed point(when the output equals the input).

e.g., value(exp, 3) will value the expression 3 times carrying out one one reduction of inert operations.

Hello

I have seen some examples of linear programming or integer programming in Maple. But, I am wondering how to solve a mixed-integer program when just some of the decision variables are integer and the rest are continuous? I would be thankful if you can share an example. 

Thanks

Hi everyone! It's been a remarkably long time since I posted on MaplePrimes -- I should probably briefly reintroduce myself to the community here. My name is Erik Postma. I manage the mathematical software group at Maplesoft: the team that writes most of the Maple-language code in the Maple product, also known as the math library. You can find a longer introduction at this link.

One of my tasks at Maplesoft is the following. When a request for tech support comes in, our tech support team can usually answer the request by themselves. But no single person can know everything, and when specialized knowledge of Maple's mathematical library is needed, they ask my team for help. I screen such requests, answer what I can by myself, and send the even more specialized requests to the experts responsible for the appropriate part of the library.

Yesterday I received a request from a user asking how to unwrap angles occurring in an expression. This is the general idea of taking the fact that sin(phi) = 'sin'(phi + 2*Pi), and similarly for the other trig functions; and using it to modify an expression of the form sin(phi) to make it look "nicer" by adding or subtracting a multiple of 2*Pi to the angle. For a constant, real value of phi you would simply make the result be as close to 0 as possible; this is discussed in e.g. this MaplePrimes question, but the expressions that this user was interested in had arguments for the trig functions that involved variables, too.

In such cases, the easiest solution is usually to write a small piece of custom code that the user can use. You might think that we should just add all these bits and pieces to the Maple product, so that everyone can use them -- but there are several reasons why that's not usually a good idea:

  • Such code is often too specialized for general use.
  • Sometimes it is reliable enough to use if we can communicate a particular caveat to the user -- "this will not work if condition XYZ occurs" -- but if it's part of the Maple library, an unsuspecting user might try it under condition XYZ and maybe get a wrong answer.
  • This type of code code generally doesn't undergo the careful interface design, the testing process, and the documentation effort that we apply to the code that we ship as part of the product; to bring it up to the standards required for shipping it as part of Maple might increase the time spent from, say, 15 minutes, to several days.

That said, I thought this case was interesting enough to post on MaplePrimes, so that the community can take a look - maybe there is something here that can help you with your own code.

So here is the concrete question from the user. They have expressions coming from an inverse Laplace transform, such as:

with(inttrans):
F := -0.3000*(-1 + exp(-s))*s/(0.0500*s^2 + 0.1*s + 125);
f := invlaplace(F, s, t)*u(t);
# result: (.1680672269e-1*exp(1.-1.*t)*Heaviside(t-1.)*(7.141428429*sin(49.98999900*t-
#         49.98999900)-357.*cos(49.98999900*t-49.98999900))+.1680672269e-1*(-7.141428429*sin
#         (49.98999900*t)+357.*cos(49.98999900*t))*exp(-1.*t))*u(t)

I interpreted their request for unwrapping these angles as replacing the expressions of the form sin(c1 * t + c0) with versions where the constant term was unwrapped. Thinking a bit about how to be safe if unexpected expressions show up, I came up with the following solution:

unwrap_trig_functions := module()
local ModuleApply := proc(expr :: algebraic, $)
  return evalindets(expr, ':-trig', process_trig);
end proc;

local process_trig := proc(expr :: trig, $)
  local terms := convert(op(expr), ':-list', ':-`+`');
  local const, nonconst;
  const, nonconst := selectremove(type, terms, ':-complexcons');
  const := add(const);
  local result := add(nonconst) + (
    if is(const = 0) then
      0;
    else
      const := evalf(const);
      if type(const, ':-float') then
        frem(const, 2.*Pi);
      else
        frem(Re(const), 2.*Pi) + I*Im(const);
      end if;
    end if);
  return op(0, expr)(result);
end proc;
end module;

# To use this, with f defined as above:
f2 := unwrap_trig_functions(f);
# result: (.1680672269e-1*exp(1.-1.*t)*Heaviside(t-1.)*(7.141428429*sin(49.98999900*t+
#         .27548346)-357.*cos(49.98999900*t+.27548346))+.1680672269e-1*(-7.141428429*sin(
#         49.98999900*t)+357.*cos(49.98999900*t))*exp(-1.*t))*u(t)

Exercise for the reader, in case you expect to encounter very large constant terms: replace the calls to frem above with the code that Alec Mihailovs wrote in the question linked above!

First 7 8 9 10 11 12 13 Last Page 9 of 1855