## How to generate a random integer with customized p...

Hi everyone,

In the RandomTools package, the Generate(integer(range = A..B)) function generates a random integer in the range A..B. All integers in that range have the same probability to be generated, that is, 1/nops([seq(A..B)]). However, I would like to specify the probabilities of each integer. How to do so?

Example: range = 1..5. Instead of P(X=j)=1/5 with j =1,2,3,4,5, let's say the probabilities should be as follows:

P(X=1) = 0.2, P(X=2) = 0.5, P(X=3) = P(X=4) = P(X=5) = 0.1

How to generate a random integer between 1 and 5 with these probabilities?

## Animate with background...

Hello Guys and Girls,

I have a problem with animate command with background option..

I attached my maple worksheet for your review.

Could you help me out?  Thanks.

I love Maple,

Sincerely

Ali Guzel

## How do show all roots in the equation with Bairsto...

I'm trying show the all roots of equations using Bairstow's methodt, but only shows the roots of Quadratic Factor and don't show the others roots of the other equation. Thanks

This the code:

 >
 1   -0.6441699    0.1381090       0.3558        1.138   2   -0.5111131    0.4697336       0.1331       0.3316   3   -0.4996865    0.5002023      0.01143      0.03047   4   -0.5000001    0.5000000   -0.0003136   -0.0002023   5   -0.5000000    0.5000000    6.413e-08    9.268e-09   6   -0.5000000    0.5000000            0            0 Q(x)=(1)x^3 + (-4)x^2 + (5.25)x^1 + (-2.5) Remainder: 0(x-(-0.5))+(0) Quadratic Factor: x^2-(-0.5)x-(0.5) Zeros: 0.4999999993, -0.9999999997

Only show two roots: 0.4999999993, -0.9999999997, but the other roots are missing: 2, -1, 1+0.5i, 1-0.5i approximately, any solution?

I think it's in this part, but I can't think of how to implement it to get the missing roots.

## Implicitplot returns nothing...

I'm trying to graph the solution to:

[7.72-7.72*B]*[-7.717267500*a] = 662204.4444*B^2

with a as the independent variable (X-Axis) and B as the dependant variable (Y-Axis). I've been using the command:

implicitplot([7.72-7.72*B]*[-7.717267500*a] = 662204.4444*B^2, a = 10 .. 15000, B = 0.1e-1 .. 1)

I dont get any errors, but the graph is ust a blank graph that is -10..10 for both axis (at least they are labelled correctly)

Any help as to how to solve this woud be greatly apprecated (either fixing syntax or recommending another command).

Note: These ranges are correct....a will be something between 0 and 20,000 and B will be between 0 and 1

Thank you! - Bob

## Question:How do I plot this function with the plot...

i want to plot

u(x,y,z,t)=tanh(x+y+z-wt),  (w is a constant)

## how to represent a recurent suite...

restart; F := rsolve({16*s(n+1) = 2+12*s(n)-2*s(n-1), s(1) = 1, s(2) = 5/8}, s); Error, (in s) cannot determine if this expression is true or false: n

## How to fix unexpected animation options, and bette...

Hi,

I'm having trouble converting a static plot to animated plot:

Also I've been considering using functional operators instead of expressions so that there's no reuse of variable s when drawing different curves, though I'm not sure if this will be harder to differentiate since diff(expr, s) does not work on a functional operator meaning I'd have to do unapply(diff(f(s),s),s) which seems a long route and I'm not sure if it's what I'm looking for (in terms of simplification).

Thanks guys

agentpath.mw

## How to fix arctan sign, and solve tricky parametri...

Hi,

I'm trying to create an agent vehicle which drives along a path of a uniform width, and finds the distance to the edge of the path directly ahead of it. Like this:

The aim is to somewhat simulate how far the agent can see down the road.

Since the thickness of a plot curve is unrelated to the units of the axis, and has no means of interacting with objects this would be no use.

I also considered shadebetween function, however this only can shade between the y values of 2 functions, so for a vertical curve it cannot produce any width to the path.

I then realised using parametric equations of form (x(t), y(t)) would likely make most sense and wrote some code which roughly gets the boundarys at a fixed distance from the centre path equation, by adding the x-y components of the reciprocal of the gradient:

For certain simple path equations such as this one, it roughly works other than the areas between which the boundary curves overlap themselves (I would need to find these points of intersection and break the curves up to remove these squigly inner bits). Any advice on this would be much appreciated cause this seems like it will be tricky, if not computationally heavy.

More annoyingly, due to the nature of the trig functions involved, for more complex graphs which include a vertical turning point, the left and right boundaries seem to swap over:

and

Clearly this is not the behaviour I had in mind.. and I'm not sure what I can do to fix it, I think maybe using piecewise trig may be a potential solution to avoid the jumping from + to -, though I'm not sure where I would put these breakpoints (I've tried just using abs(arctan(...)) with no luck).

If anyone could help wih this that would be really appreciated, or even suggest a better approach to this problem!

Thanks

[code] agentpath.mw

## Warning, model is not of full rank...

Hello,

I am doing a regression analysis, but some of my model says: Warning, model is not of full rank. Can anyone help what to do with that?

Rok := Vector([2013, 2014, 2015, 2016, 2017, 2018], datatype = float);

TrzbyCelkemEmco := Vector([1028155, 1134120, 1004758, 929584, 995716, 1152042], datatype = float);

KubickaTrzby = Statistics:-PolynomialFit(3, Rok, TrzbyCelkemEmco, x);

Thank you :)

## solving nonlinear algebraic system...

I am trying to solve a set of equations

Why are the results not the same as the following results?

Is there any other way to get the correct answer?

 >
 >
 (1)
 >
 (2)
 >
 (3)
 >
 (4)
 >
 (5)
 >
 (6)
 >
 (7)
 >
 >
 (8)
 >
 (9)
 >
 (10)
 >
 >
 (11)
 >

## Coupled PDEs:Error, (in pdsolve/numeric/animate) u...

Analysis of the semiclassical (SC) momentum rate equations

Plotting the ICs and BCs and examining sensitivity to the Re and Im forces

MRB: 24/2/2020, 27/2/2020, 2/3/2020.

We examine solution of the SC version of the momentum rate equations, in which O terms for  are removed. A high level of sensitivity to ICs and BCs makes solution finding difficult.

 > restart;
 > with(PDETools): with(CodeTools):with(plots):

We set up the initial conditions:

 > ICu := {u(x, 0) = .1*sin(2*Pi*x)}; ICv := {v(x, 0) = .2*sin(Pi*x)};
 (1)
 > plot([0.1*sin(2*Pi*x),0.2*sin(Pi*x)],x = 0..2, title="ICs:\n u(x,0) (red), v(x,0) (blue)",color=[red,blue],gridlines=true);

The above initial conditions represent a positive velocity field  (blue) and a colliding momentum field (red).

Here are the BCs

 > BCu := {u(0,t) = 0.5*(1-cos(2*Pi*t))};
 (2)
 > BCv := {v(0,t) = 0.5*sin(2*Pi*t),v(2,t)=-0.5*sin(2*Pi*t)};
 (3)
 > plot([0.5*(1-cos(2*Pi*t)),0.5*sin(2*Pi*t),-0.5*sin(2*Pi*t)],t=0..1,color=[red,blue,blue],linestyle=[dash,dash,dot],title="BCs:\n u(0,t) (red-dash),\n v(0,t) (blue-dash), v(1,t) (blue-dot)",gridlines=true);
 >

We can now set up the PDEs for the semiclassical case.

 > hBar:= 1:m:= 1:Fu:= 0.2:Fv:= 0.1:#1.0,0.2
 > pdeu := diff(u(x,t),t)+u(x,t)/m*(diff(u(x,t),x)) = Fu;
 (4)
 > pdev := diff(v(x,t),t)+u(x,t)/m*(diff(v(x,t),x))-hBar*(diff(u(x,t),x\$2))/(2*m)+v(x,t)*(diff(u(x,t),x))/m = Fv;
 (5)
 > ICu:={u(x,0) = 0.1*sin(2*Pi*x)};
 (6)
 > ICv:={v(x,0) = 0.2*sin(Pi*x/2)};
 (7)
 > IC := ICu union ICv;
 (8)
 > BCu := {u(0,t) = 0.5*(1-cos(2*Pi*t)), D[1](u)(2,t) = 0.1*cos(2*Pi*t)};
 (9)
 > BCv := {v(0,t) = 0.2*(1-cos(2*Pi*t))};
 (10)
 > BC := BCu union BCv;
 (11)

We now set up the PDE solver:

 > pds := pdsolve({pdeu,pdev},{BC[],IC[]},time = t,range = 0..2,numeric);#'numeric' solution
 (12)
 > Cp:=pds:-animate({[u, color = red, linestyle = dash],[v,color = blue,linestyle = dash]},t = 30,frames = 400,numpoints = 400,title="Semiclassical momentum equations solution for Re and Im momenta u(x,t) (red) and v(x,t) (blue) \n under respective constant positive forces [0.2, 0.1] \n with sinusoidal boundary conditions at x = 0, 1 and sinusoidal initial conditions: \n time = %f ", gridlines = true,linestyle=solid):Cp;
 (13)

Observations on the quantum case:

The classical equation for  is independent of the equation for .   (red) is a solution of the classical Burgers equation subject to a force 0.2, but  is NOT influenced by .  On the otherhand,  (blue) is a solution of the quantum dynamics equation subject to force 0.1 and is influenced by .   This one way causality (u )  is a feature of the semiclassical case, and it emphasises the controlling influence of the classical , which modulates the quantum solution for .  Causally, we have u.

The initial conditions are of low momentum amplitude:0.1 for the classical  (red) field and.2 for  (blue)  but their influence is soon washed out by the boundary conditions  and  that drive the momentum dynamics.

The temporal frequency of the boundary condition on the -field is twice that of the classical -field. This is evident in the above blue transient plot. Moreover, the boundary condition on the classical -momentum (red), drives that field in the positive direction, initially overtaking the quantum  field, as consistent with the applied forces [0.2, 0.1]. Although initially of greater amplitude than the classical field, the  momentum field is asymptotically of the same amplitude as the  field, but has greater spatial and temporal frequency, owing to the boundary conditions.

Referring to the semiclassical momentum rate equations, we note that the classical field  (red) modulates the quantum momentum rate equation for .

 >
Given a text passage, determine:
    1. If it contains a mathematical question (including word problems or calculations)
    2. If an answer to that mathematical question is provided in the text

First, describe the content structure you found in 1-2 sentences.

Then provide your analysis in the following format:
TYPE: <one of the following values>
- NO_QUESTION
- SINGLE_QUESTION
- SINGLE_QUESTION_WITH_ANSWER
- MULTIPLE_QUESTIONS
- MULTIPLE_QUESTIONS_WITH_ANSWERS
system
## How to generate a random integer with customized p...

Hi everyone,

In the RandomTools package, the Generate(integer(range = A..B)) function generates a random integer in the range A..B. All integers in that range have the same probability to be generated, that is, 1/nops([seq(A..B)]). However, I would like to specify the probabilities of each integer. How to do so?

Example: range = 1..5. Instead of P(X=j)=1/5 with j =1,2,3,4,5, let's say the probabilities should be as follows:

P(X=1) = 0.2, P(X=2) = 0.5, P(X=3) = P(X=4) = P(X=5) = 0.1

How to generate a random integer between 1 and 5 with these probabilities?

## Animate with background...

Hello Guys and Girls,

I have a problem with animate command with background option..

I attached my maple worksheet for your review.

Could you help me out?  Thanks.

I love Maple,

Sincerely

Ali Guzel

## How do show all roots in the equation with Bairsto...

I'm trying show the all roots of equations using Bairstow's methodt, but only shows the roots of Quadratic Factor and don't show the others roots of the other equation. Thanks

This the code:

 >
 1   -0.6441699    0.1381090       0.3558        1.138   2   -0.5111131    0.4697336       0.1331       0.3316   3   -0.4996865    0.5002023      0.01143      0.03047   4   -0.5000001    0.5000000   -0.0003136   -0.0002023   5   -0.5000000    0.5000000    6.413e-08    9.268e-09   6   -0.5000000    0.5000000            0            0 Q(x)=(1)x^3 + (-4)x^2 + (5.25)x^1 + (-2.5) Remainder: 0(x-(-0.5))+(0) Quadratic Factor: x^2-(-0.5)x-(0.5) Zeros: 0.4999999993, -0.9999999997

Only show two roots: 0.4999999993, -0.9999999997, but the other roots are missing: 2, -1, 1+0.5i, 1-0.5i approximately, any solution?

I think it's in this part, but I can't think of how to implement it to get the missing roots.

## Implicitplot returns nothing...

I'm trying to graph the solution to:

[7.72-7.72*B]*[-7.717267500*a] = 662204.4444*B^2

with a as the independent variable (X-Axis) and B as the dependant variable (Y-Axis). I've been using the command:

implicitplot([7.72-7.72*B]*[-7.717267500*a] = 662204.4444*B^2, a = 10 .. 15000, B = 0.1e-1 .. 1)

I dont get any errors, but the graph is ust a blank graph that is -10..10 for both axis (at least they are labelled correctly)

Any help as to how to solve this woud be greatly apprecated (either fixing syntax or recommending another command).

Note: These ranges are correct....a will be something between 0 and 20,000 and B will be between 0 and 1

Thank you! - Bob

## Question:How do I plot this function with the plot...

i want to plot

u(x,y,z,t)=tanh(x+y+z-wt),  (w is a constant)

## how to represent a recurent suite...

restart; F := rsolve({16*s(n+1) = 2+12*s(n)-2*s(n-1), s(1) = 1, s(2) = 5/8}, s); Error, (in s) cannot determine if this expression is true or false: n

## How to fix unexpected animation options, and bette...

Hi,

I'm having trouble converting a static plot to animated plot:

Also I've been considering using functional operators instead of expressions so that there's no reuse of variable s when drawing different curves, though I'm not sure if this will be harder to differentiate since diff(expr, s) does not work on a functional operator meaning I'd have to do unapply(diff(f(s),s),s) which seems a long route and I'm not sure if it's what I'm looking for (in terms of simplification).

Thanks guys

agentpath.mw

## How to fix arctan sign, and solve tricky parametri...

Hi,

I'm trying to create an agent vehicle which drives along a path of a uniform width, and finds the distance to the edge of the path directly ahead of it. Like this:

The aim is to somewhat simulate how far the agent can see down the road.

Since the thickness of a plot curve is unrelated to the units of the axis, and has no means of interacting with objects this would be no use.

I also considered shadebetween function, however this only can shade between the y values of 2 functions, so for a vertical curve it cannot produce any width to the path.

I then realised using parametric equations of form (x(t), y(t)) would likely make most sense and wrote some code which roughly gets the boundarys at a fixed distance from the centre path equation, by adding the x-y components of the reciprocal of the gradient:

For certain simple path equations such as this one, it roughly works other than the areas between which the boundary curves overlap themselves (I would need to find these points of intersection and break the curves up to remove these squigly inner bits). Any advice on this would be much appreciated cause this seems like it will be tricky, if not computationally heavy.

More annoyingly, due to the nature of the trig functions involved, for more complex graphs which include a vertical turning point, the left and right boundaries seem to swap over:

and

Clearly this is not the behaviour I had in mind.. and I'm not sure what I can do to fix it, I think maybe using piecewise trig may be a potential solution to avoid the jumping from + to -, though I'm not sure where I would put these breakpoints (I've tried just using abs(arctan(...)) with no luck).

If anyone could help wih this that would be really appreciated, or even suggest a better approach to this problem!

Thanks

[code] agentpath.mw

## Warning, model is not of full rank...

Hello,

I am doing a regression analysis, but some of my model says: Warning, model is not of full rank. Can anyone help what to do with that?

Rok := Vector([2013, 2014, 2015, 2016, 2017, 2018], datatype = float);

TrzbyCelkemEmco := Vector([1028155, 1134120, 1004758, 929584, 995716, 1152042], datatype = float);

KubickaTrzby = Statistics:-PolynomialFit(3, Rok, TrzbyCelkemEmco, x);

Thank you :)

## solving nonlinear algebraic system...

I am trying to solve a set of equations

Why are the results not the same as the following results?

Is there any other way to get the correct answer?

 >
 >
 (1)
 >
 (2)
 >
 (3)
 >
 (4)
 >
 (5)
 >
 (6)
 >
 (7)
 >
 >
 (8)
 >
 (9)
 >
 (10)
 >
 >
 (11)
 >

## Coupled PDEs:Error, (in pdsolve/numeric/animate) u...

Analysis of the semiclassical (SC) momentum rate equations

Plotting the ICs and BCs and examining sensitivity to the Re and Im forces

MRB: 24/2/2020, 27/2/2020, 2/3/2020.

We examine solution of the SC version of the momentum rate equations, in which O terms for  are removed. A high level of sensitivity to ICs and BCs makes solution finding difficult.

 > restart;
 > with(PDETools): with(CodeTools):with(plots):

We set up the initial conditions:

 > ICu := {u(x, 0) = .1*sin(2*Pi*x)}; ICv := {v(x, 0) = .2*sin(Pi*x)};
 (1)
 > plot([0.1*sin(2*Pi*x),0.2*sin(Pi*x)],x = 0..2, title="ICs:\n u(x,0) (red), v(x,0) (blue)",color=[red,blue],gridlines=true);

The above initial conditions represent a positive velocity field  (blue) and a colliding momentum field (red).

Here are the BCs

 > BCu := {u(0,t) = 0.5*(1-cos(2*Pi*t))};
 (2)
 > BCv := {v(0,t) = 0.5*sin(2*Pi*t),v(2,t)=-0.5*sin(2*Pi*t)};
 (3)
 > plot([0.5*(1-cos(2*Pi*t)),0.5*sin(2*Pi*t),-0.5*sin(2*Pi*t)],t=0..1,color=[red,blue,blue],linestyle=[dash,dash,dot],title="BCs:\n u(0,t) (red-dash),\n v(0,t) (blue-dash), v(1,t) (blue-dot)",gridlines=true);
 >

We can now set up the PDEs for the semiclassical case.

 > hBar:= 1:m:= 1:Fu:= 0.2:Fv:= 0.1:#1.0,0.2
 > pdeu := diff(u(x,t),t)+u(x,t)/m*(diff(u(x,t),x)) = Fu;
 (4)
 > pdev := diff(v(x,t),t)+u(x,t)/m*(diff(v(x,t),x))-hBar*(diff(u(x,t),x\$2))/(2*m)+v(x,t)*(diff(u(x,t),x))/m = Fv;
 (5)
 > ICu:={u(x,0) = 0.1*sin(2*Pi*x)};
 (6)
 > ICv:={v(x,0) = 0.2*sin(Pi*x/2)};
 (7)
 > IC := ICu union ICv;
 (8)
 > BCu := {u(0,t) = 0.5*(1-cos(2*Pi*t)), D[1](u)(2,t) = 0.1*cos(2*Pi*t)};
 (9)
 > BCv := {v(0,t) = 0.2*(1-cos(2*Pi*t))};
 (10)
 > BC := BCu union BCv;
 (11)

We now set up the PDE solver:

 > pds := pdsolve({pdeu,pdev},{BC[],IC[]},time = t,range = 0..2,numeric);#'numeric' solution
 (12)
 > Cp:=pds:-animate({[u, color = red, linestyle = dash],[v,color = blue,linestyle = dash]},t = 30,frames = 400,numpoints = 400,title="Semiclassical momentum equations solution for Re and Im momenta u(x,t) (red) and v(x,t) (blue) \n under respective constant positive forces [0.2, 0.1] \n with sinusoidal boundary conditions at x = 0, 1 and sinusoidal initial conditions: \n time = %f ", gridlines = true,linestyle=solid):Cp;
 (13)

Observations on the quantum case:

The classical equation for  is independent of the equation for .   (red) is a solution of the classical Burgers equation subject to a force 0.2, but  is NOT influenced by .  On the otherhand,  (blue) is a solution of the quantum dynamics equation subject to force 0.1 and is influenced by .   This one way causality (u )  is a feature of the semiclassical case, and it emphasises the controlling influence of the classical , which modulates the quantum solution for .  Causally, we have u.

The initial conditions are of low momentum amplitude:0.1 for the classical  (red) field and.2 for  (blue)  but their influence is soon washed out by the boundary conditions  and  that drive the momentum dynamics.

The temporal frequency of the boundary condition on the -field is twice that of the classical -field. This is evident in the above blue transient plot. Moreover, the boundary condition on the classical -momentum (red), drives that field in the positive direction, initially overtaking the quantum  field, as consistent with the applied forces [0.2, 0.1]. Although initially of greater amplitude than the classical field, the  momentum field is asymptotically of the same amplitude as the  field, but has greater spatial and temporal frequency, owing to the boundary conditions.

Referring to the semiclassical momentum rate equations, we note that the classical field  (red) modulates the quantum momentum rate equation for .

 >
user
It seems like you are working on a complex problem involving the solution of coupled partial differential equations (PDEs) that describe the semiclassical momentum rate equations. The equations you are solving are:

1. The classical momentum equation for \( u(x,t) \):
   \[
   \frac{\partial u(x,t)}{\partial t} + \frac{u(x,t)}{m} \frac{\partial u(x,t)}{\partial x} = F_u
   \]

2. The quantum momentum equation for \( v(x,t) \):
   \[
   \frac{\partial v(x,t)}{\partial t} + \frac{u(x,t)}{m} \frac{\partial v(x,t)}{\partial x} - \frac{\hbar}{2m} \frac{\partial^2 u(x,t)}{\partial x^2} + \frac{v(x,t)}{m} \frac{\partial u(x,t)}{\partial x} = F_v
   \]

You have set up the initial conditions (ICs) and boundary conditions (BCs) for these equations and are using Maple's `pdsolve` function to solve them numerically. However, you are encountering an error when trying to animate