Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Hello Maple enthusiasts,

I am excited to share a sample worksheet on Ordinary Differential Equations (ODEs), created as part of my ongoing project—a book I am writing for undergraduate students. This book is designed to teach ODEs using Maple, offering an interactive and intuitive approach to solving differential equations.

As far as I know, there aren’t many books available in the Greek language that combine ODEs with Maple. In fact, I believe there’s only one other such resource, which highlights the lack of materials in this niche. My goal is to fill this gap by providing students and educators with a resource that is both practical and accessible, leveraging Maple's powerful capabilities to deepen understanding and simplify complex concepts.

The worksheet I’m sharing includes:

  • Step-by-step solutions to ODEs using Maple.
  • Graphical representations to visualize solutions, which I believe are invaluable for fostering comprehension.

I hope this preview sparks your interest and provides insight into the teaching style and structure of the upcoming book. I would love to hear your thoughts, feedback, or suggestions for topics you think should be included.

Solve the following differential equation

diff(y(x), x) = x*y(x)
with initial condition y(0) = 1

restart; with(plots); with(DEtools)

ode := diff(y(x), x) = x*y(x)

diff(y(x), x) = x*y(x)

(1)

ic := y(0) = 1

y(0) = 1

(2)

general_solution := dsolve(ode, y(x))

y(x) = c__1*exp((1/2)*x^2)

(3)

particular_solution := dsolve({ic, ode}, y(x))

y(x) = exp((1/2)*x^2)

(4)

soln := dsolve({ic, ode}, y(x), numeric)

``

(5)

p1 := odeplot(soln, [x, y(x)], x = -5 .. 5, labels = ["x", "y(x)"], color = green)

directionfield := dfieldplot(ode, [y(x)], x = -5 .. 5, y = -5 .. 5, color = blue, arrows = slim, scaling = constrained, axes = boxed)

display([p1, directionfield], view = [-5 .. 5, -5 .. 5])

 

NULL

Solve the following differential equation

diff(y(x), x) = x/y(x)
with initial condition y(0) = 2

restart; with(plots); with(DEtools)

ode1 := diff(y(x), x) = x/y(x)

diff(y(x), x) = x/y(x)

(6)

ic := y(0) = 2

y(0) = 2

(7)

dsolve(ode1, y(x))

y(x) = (x^2+c__1)^(1/2), y(x) = -(x^2+c__1)^(1/2)

(8)

NULL

soln := dsolve({ic, ode1}, y(x), numeric)

p1 := odeplot(soln, [x, y(x)], x = -5 .. 5, labels = ["x", "y(x)"], color = green)

directionfield := dfieldplot(ode1, [y(x)], x = -5 .. 5, y = -5 .. 5, color = blue, arrows = slim, scaling = constrained, axes = boxed)

display([p1, directionfield], view = [-5 .. 5, -5 .. 5])

 

NULL

Solve the following differential equation

dy/dx = e^y/(x^2+1)
with initial condition y(0) = -1

restart; with(plots); with(DEtools)

ode2 := diff(y(x), x) = exp(y(x))/(x^2+1)

diff(y(x), x) = exp(y(x))/(x^2+1)

(9)

ic := y(0) = -1

y(0) = -1

(10)

dsolve(ode2, y(x))

y(x) = ln(-1/(arctan(x)+c__1))

(11)

soln := dsolve({ic, ode2}, y(x), numeric)

p1 := odeplot(soln, [x, y(x)], x = -5 .. 5, labels = ["x", "y(x)"], color = green)

directionfield := dfieldplot(ode2, [y(x)], x = -5 .. 5, y = -5 .. 5, color = blue, arrows = slim, scaling = constrained, axes = boxed)

display([p1, directionfield], view = [-5 .. 5, -5 .. 5])

 

NULL

Solve the following differential equation

dy/dx = y^2+y
with initial condition y(1) = 2

restart; with(plots); with(DEtools)

ode3 := diff(y(x), x) = y(x)+y(x)^2

diff(y(x), x) = y(x)+y(x)^2

(12)

ic := y(1) = 2

y(1) = 2

(13)

dsolve(ode3, y(x))

y(x) = 1/(-1+exp(-x)*c__1)

(14)

soln := dsolve({ic, ode3}, y(x))

y(x) = 2/(-2+3*exp(-x)*exp(1))

(15)

DEplot(ode3, y(x), x = -5 .. 5, y = -5 .. 5, [[y(1) = 2]], color = blue, arrows = slim, scaling = constrained, axes = boxed)

 

NULL

Solve the following differential equation

y*dy/dx-x = 0
with initial condition y(0) = 4, y(1) = 2, y(-1) = -2and y(-2) = -4.

restart; with(plots); with(DEtools)

ode4 := y(x)*(diff(y(x), x))-x = 0

y(x)*(diff(y(x), x))-x = 0

(16)

ic := y(0) = 4

y(0) = 4

(17)

dsolve(ode4, y(x))

y(x) = (x^2+c__1)^(1/2), y(x) = -(x^2+c__1)^(1/2)

(18)

DEplot(ode4, y(x), x = -5 .. 5, y = -5 .. 5, [[y(1) = 2], [y(0) = 4], [y(-1) = -2], [y(-2) = -4]], color = blue, arrows = slim, scaling = constrained, axes = boxed)

 

 

 

NULL

Solve the following differential equation

dy/dx = 2*x+2*xy^2/y
with initial condition y(0) = 2.

restart; with(plots); with(DEtools)

ode5 := diff(y(x), x) = (2*x+2*x*y(x)^2)/y(x)

diff(y(x), x) = (2*x+2*x*y(x)^2)/y(x)

(19)

ic := y(0) = 2

y(0) = 2

(20)

dsolve(ode5, y(x))

y(x) = (exp(2*x^2)*c__1-1)^(1/2), y(x) = -(exp(2*x^2)*c__1-1)^(1/2)

(21)

psoln := dsolve({ic, ode5}, y(x))

y(x) = (5*exp(2*x^2)-1)^(1/2)

(22)

soln := dsolve({ic, ode5}, y(x), numeric)

p1 := odeplot(soln, [x, y(x)], x = -5 .. 5, labels = ["x", "y(x)"], color = green)

directionfield := dfieldplot(ode5, [y(x)], x = -5 .. 5, y = -3 .. 10, color = blue, arrows = slim, scaling = constrained, axes = boxed)

display([p1, directionfield], view = [-5 .. 5, -3 .. 10])

 

NULL


 

Download separable_diff_equations.mw

 

The following is not a profound problem, and there is an obvious solution,

but it came up, and I would like to learn more about it.

 

Even though I recommend the add procedure when summing up individual entities,

my students keep showing me how smart the sum procedure is. Which makes

our worksheets more readable and reproducible for Maple users who are less frequent.

 

For example:

 

restart; Xlist := [1, 2, 3]; N := numelems(Xlist)

3

Using palette icon:

sum(Xlist[n], n = 1 .. N)

6

Cool!  Which means

sum(Xlist[n], n = 1 .. N)

6

But if we use the same palette icon for a vector

Xvector := convert(Xlist, Vector); sum(Xvector[n], n = 1 .. N)

Error, bad index into Vector

Because I believe this fails

sum(Xvector[n], n = 1 .. N)

Error, bad index into Vector

 

Would someone please teach me how I can see why the sum of a list

works, but does the sum of a vector fail?

Download MaplePrimes_sum_list_vector.mw

On the website "Learning Physics using Maple" of professor Gould, in the example "Vectors: Calculation & Visualization". If you click on the PDF file under that title, you see an example of vectors in 2d.

But when you look at the solution, you see him use the vector v with an arrow to create a fucntional depending of two variables. Since he doesn't load any package, I cannot reproduce this notation to work. I am talking about this:

Is there a trick that I am not aware of in Maple?  The only way I know to have the arrow is to load the Physics package and the Vector package. And then you use the notation r_ to show r with an arrow.

I asked the question in the YouTube channel but did not receive any answer.  Too bad.

Thank you in advance for any help on that matter.

Hello everyone.
Please tell me how to take this integral.

int(1/((a^2 + x)^(3/2)*x), x = 0 .. infinity)

Assuming that a is greater than zero and real. Thanks in advance

Maple defaults to expressing output in terms of Cosines.

Is it possible to instruct maple to rather calculate the output  with Sine as the default ?

 hello
 how to get curve fitting parameters right?  is that any stragey to get a good estimate.

restart;

with(Statistics):with(plots):with(Optimization):with(LinearAlgebra):


# given data from strain rate curve
E_0[theta] := 7.883352314*10^9;
alpha[theta]:= 0.982

7883352314.

 

.982

(1)


# experimental creep data under 44 at 100 degree celcius
c_strain := Vector ([<<0>,<0.0284698>,<0.0533808>,<0.0782918>,<0.0996441>,<0.124555>,<0.142349>,<0.156584>,<0.16726>,<0.177936>,<0.181495>,<0.188612>,<0.192171>,<0.19573>,<0.19573>,<0.202847>,<0.206406>,<0.206406>,<0.209964>,<0.209964>,<0.209964>,<0.206406>,<0.209964>>]):

c_time := Vector ([<<0>,<0>,<0.048>,<0.192>,<0.352>,<0.544>,<0.704>,<0.896>,<1.088>,<1.312>,<1.52>,<1.76>,<1.984>,<2.208>,<2.464>,<2.736>,<3.088>,<3.392>,<3.664>,<4.016>,<4.352>,<4.592>,<4.832>>]):
sigma[0] := 44*10^6;
epsilon[0] := sigma[0]/E_0[theta];

44000000

 

0.5581381911e-2

(2)


# change vector to list
c_strain := convert(c_strain,list):
c_time := convert(c_time,list):

# extract zero from list
c_strain := c_strain [2..-1];
c_time := c_time [2..-1];

[0.284698e-1, 0.533808e-1, 0.782918e-1, 0.996441e-1, .124555, .142349, .156584, .16726, .177936, .181495, .188612, .192171, .19573, .19573, .202847, .206406, .206406, .209964, .209964, .209964, .206406, .209964]

 

[0, 0.48e-1, .192, .352, .544, .704, .896, 1.088, 1.312, 1.52, 1.76, 1.984, 2.208, 2.464, 2.736, 3.088, 3.392, 3.664, 4.016, 4.352, 4.592, 4.832]

(3)


# for further calculation need to know how many elements are in the list
M := nops(c_strain);
N := nops(c_time);

22

 

22

(4)


# constitutive equation
creep_strain := proc(t)
local i;
options operator, arrow;
epsilon[0]*(1 + alpha[theta]*add(-(B[i]*(-beta[i]*t + exp(-beta[i] *t) -1))/beta[i],i=1..3))
end proc;

proc (t) local i; options operator, arrow; epsilon[0]*(1+alpha[theta]*add(-B[i]*(-beta[i]*t+exp(-beta[i]*t)-1)/beta[i], i = 1 .. 3)) end proc

(5)


#define objective function

Digits := 9:
obj := add(
         (
           creep_strain(c_time[j])
           -
           c_strain[j]
         )^2
         , j=1..N
       ):


# curve fitting
opt := NLPSolve(obj,
{
  beta[1] >= 0,
    beta[2] >= 0,
    beta[3] >= 0,
    B[1] >= 0, B[1]<= 0.2,
    B[2] >= 0, B[2] <= 0.3,
    B[3] >= 0, B[3] <= 0.4
}
);

[.467521159408790410, [B[1] = HFloat(0.19999999999999996), B[2] = HFloat(0.30000000000000004), B[3] = HFloat(0.4), beta[1] = HFloat(1.2600715880722035e-9), beta[2] = HFloat(5.152129055134073e-9), beta[3] = HFloat(5.057870561183067e-9)]]

(6)

# plot the result
display(
   ScatterPlot(c_time, c_strain, symbol=circle, color=blue),
 
  plot(eval(creep_strain(t), opt[2]), t=0.00..max(c_time), color=black)
)

Download at_44_Mpa_at_100C.mw

Why do maple not contract over inert differentials ?
The last command just return the defining equation and refuses to contract.

See example below

restart;
with(Physics);
g_[[5, 29, 1]];
eq1 := g_[~mu, ~nu]*Diff(w(r, theta), mu)*Diff(w(r, theta), nu);
SumOverRepeatedIndices(eq1);

-----------------------------------------------------------------------------------
However Check return empty coordinates, which is completely contradictory.

Check(eq1, all);
      The repeated indices per term are: ((...),(...),...)

        , the free indices are: (...)

                    [{}], {~mu, ~nu}

I was not expecting odesteps to show steps for this ode, but crash the server each and everytime?

Anyone could find why? I am using Maple 2024.2 on windows 10 with latest Physics. This might indicate serious problem somewhere. Software should not really crash this easily.

interface(version);

`Standard Worksheet Interface, Maple 2024.2, Windows 10, October 29 2024 Build ID 1872373`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1827 and is the same as the version installed in this computer, created 2024, November 13, 9:16 hours Pacific Time.`

libname;

"C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

restart;

ode:=5*(1+t^2)*diff(y(t),t)=4*t*y(t)*(y(t)^3-1);

5*(t^2+1)*(diff(y(t), t)) = 4*t*y(t)*(y(t)^3-1)

dsolve(ode);

y(t) = 1/((t^2+1)^(6/5)*c__1+1)^(1/3), y(t) = -(1/2)/((t^2+1)^(6/5)*c__1+1)^(1/3)-((1/2)*I)*3^(1/2)/((t^2+1)^(6/5)*c__1+1)^(1/3), y(t) = -(1/2)/((t^2+1)^(6/5)*c__1+1)^(1/3)+((1/2)*I)*3^(1/2)/((t^2+1)^(6/5)*c__1+1)^(1/3)

Student:-ODEs:-ODESteps(ode);


 

Download crash_server_nov_18_2024.mw

here is small movie

 

 

For a system of 8 equations, it takes too long for me to solve it by using solve, but I can only give one solution by using fsolve. If I want solutions in other ranges, I need to provide a general range, but I don't know the range, how can I quickly find all the solutions?question1118.mw