tomleslie

13841 Reputation

20 Badges

15 years, 1 days

MaplePrimes Activity


These are replies submitted by tomleslie

@Christopher2222 

Maple 2021

ScientificConstants[GetValue] is not working in at least Maple 2021 and Maple 2022

No mention of Maple Flow - if you had mentioned Maple Flow, I wouldn't even have attempted an answer

if you uploaded a usable worksheet someone might investigate this

However, if I try to download from  Question#3.mw all I get is the error Page not Found.

Try downloading your own upload - just to see if it works!

@nm 

You state (emphasis added)

The first ode you see is a screen shot of the maple help page to show that the syntax using series worked. That was not an example of mine. It is just screen shot of the help page to show that the syntax in help page worked but gives error when I used it.

The first worksheet (odetest.mw) attached below is obtained directly from Maple help by using (in the help browser) the menu commands View -> Open Page as Worksheet. This whole worksheet has then been re-executed (using !!! in the Maple toolbar). Everything executes with no errors. So I still cannot replicate the problem implied by your remark

the syntax in help page worked but gives error when I used it.

And since you do not provide a worksheet illustrating the problem whihc you are experiencing - there isn't much I can do to fix it.

The second worksheet (testODE2.mw) below shows some of my attempts to replicate your problem. It generates series solutions for the same ODE from the help page in several slightly different ways, then tests each one with odetest() in a couple of different ways. Every single one of these "works" - so again I cannot replicate your problem

odetest

test the explicit or implicit results from ODE-solvers

 

 

Calling Sequence

Parameters

Description

Examples

 

 

 

Calling Sequence

 

odetest(sol, ODE, y(x))

odetest(sol, ODE, series, point=x0)

Parameters

 

 

sol

-

Ordinary Differential Equation (ODE) solution being tested; can be a set or list of them

ODE

-

ODE, or a set or list of them which can also include initial or boundary conditions

y(x)

-

(optional) indeterminate function of the ODE or a set or list of them

series

-

required when testing series solutions

point=x0

-

(optional) specification of the expansion point, x0, when testing series solutions

 

 

Description

 
• 

The odetest command checks explicit and implicit solutions for ODEs by making a careful simplification of the ODE with respect to the given solution. If the solution is valid, the returned result will be 0; otherwise, the algebraic remaining expression will be returned. In the case of systems of ODEs, odetest can only test explicit solutions, given either as a set or as a list of sets. (For information on non-composed sets of solutions for nonlinear systems, see dsolve,system .)

• 

To test whether a solution satisfies one or many initial or boundary conditions, pass to odetest the ODE together with the initial or boundary conditions, enclosed as a set  or list , as second argument.

• 

If odetest returns a nonzero result, the solution being tested is not necessarily wrong; sometimes further simplifications or manipulations of odetest's output are required to obtain zero, and so verify the solution is correct. If the solution was obtained using the dsolve  command, it is recommended that you recompute the solution using one or both of the useInt and implicit options - see dsolve . This may facilitate the verification process. Also, an alternative testing technique, particularly useful with linear ODEs, is to try to recompute the ODE departing from the solution which odetest fails in testing. Examples of both types are found at the end of the next section.

• 

To test series solutions , pass the keyword series as an extra argument. Only one series solution for one ODE (can be a set with initial/boundary conditions) can be tested.

Examples

 

An ODE problem with initial conditions

ODE := [diff(y(x),x)=sin(x-y(x)), y(0) = 8];

[diff(y(x), x) = sin(x-y(x)), y(0) = 8]

(1)

sol := dsolve(ODE);

y(x) = x-2*arctan((tan(4)*x-2*tan(4)+x)/(tan(4)*x+x+2))+2*Pi

(2)

odetest( sol, ODE );    # verifies 'sol' solves the ode and satisfies y(0) = 8

[0, 0]

(3)

A second order ODE problem with boundary conditions

ODE := diff(y(x),x,x) + diff(y(x),x) + y(x)=0;

diff(diff(y(x), x), x)+diff(y(x), x)+y(x) = 0

(4)

bc := y(0) = 1, y(2*Pi) = 1;

y(0) = 1, y(2*Pi) = 1

(5)

sol := dsolve({ODE, bc});

y(x) = -(cos(3^(1/2)*Pi)*exp(-Pi)-1)*exp(-(1/2)*x)*sin((1/2)*3^(1/2)*x)/(exp(-Pi)*sin(3^(1/2)*Pi))+exp(-(1/2)*x)*cos((1/2)*3^(1/2)*x)

(6)

odetest( sol, [ODE,bc] ); # verifies 'sol' solves the ODE and satisfies the bc given

[0, 0, 0]

(7)

A series solution for a nonlinear ODE with initial conditions

ODE := [diff(y(x),x,x)+diff(y(x),x)^2=0, y(a)=0, D(y)(a)=1];

[diff(diff(y(x), x), x)+(diff(y(x), x))^2 = 0, y(a) = 0, (D(y))(a) = 1]

(8)

sol := dsolve( ODE, y(x), type='series');

y(x) = series(x-a-(1/2)*(x-a)^2+(1/3)*(x-a)^3-(1/4)*(x-a)^4+(1/5)*(x-a)^5+O((x-a)^6),x = a,6)

(9)

odetest(sol, ODE, series);

[0, 0, 0]

(10)

When testing series solutions and the initial conditions are not present in the input to odetest, an indication of the expansion point is required

ODE := diff(diff(y(x),x),x) = (3*x^2+c)*diff(y(x),x)+((3-b)*x-a)*y(x);

diff(diff(y(x), x), x) = (3*x^2+c)*(diff(y(x), x))+((3-b)*x-a)*y(x)

(11)

sol := y(x) = series(1+(-1/2*a)*x^2+(-1/6*b+1/2-1/6*c*a)*x^3+(1/24*a^2-1/24*c*b+1/8*c-1/24*c^2*a)*x^4+O(x^5),x,5);

y(x) = series(1-((1/2)*a)*x^2+(-(1/6)*b+1/2-(1/6)*c*a)*x^3+((1/24)*a^2-(1/24)*c*b+(1/8)*c-(1/24)*c^2*a)*x^4+O(x^5),x,5)

(12)

odetest(sol, ODE, series, point = 0);

0

(13)

An ODE with an arbitrary function _F1 of (x, y, dy/dx) and a solution involving nested integrals with a RootOf  in the integrand

ODE := diff(y(x),x,x) = 1/x^2*_F1(diff(y(x),x)*x/y(x))*y(x);

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

(14)

sol := dsolve(ODE);

y(x) = exp(Intat(RootOf(Intat(1/(_a-_a^2+_F1(_a)), _a = _Z)-_b+_C1), _b = ln(x))+_C2)

(15)

odetest(sol,ODE);

0

(16)

Testing ODE solutions given in implicit form, that is, not solved for the unknown (here y(x))

ODE := diff(y(x),x)=F((y(x)-x*ln(x))/x) + ln(x);

diff(y(x), x) = F((y(x)-x*ln(x))/x)+ln(x)

(17)

sol := dsolve(ODE,implicit);

ln(x)-Intat(1/(-1+F(_a)-_a), _a = -ln(x)+y(x)/x)-_C1 = 0

(18)

odetest(sol,ODE);

0

(19)

When the ODE has derivatives of other indeterminate functions and the solution is implicit, the specification of the indeterminate function of the problem is required by both dsolve  and odetest

ODE := diff(y(x),x) = x*f(x)^2*(x+2)*y(x)^3+f(x)*(x+3)*y(x)^2-diff(f(x),x)/f(x)*y(x);

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

(20)

sol := dsolve(ODE, y(x), implicit);

_C1+arctanh((f(x)*y(x))^(1/2)*x/(x*f(x)*y(x)*(2+x)+2)^(1/2))+(1/2)*(x*f(x)*y(x)*(2+x)+2)^(1/2)/(f(x)*y(x))^(1/2) = 0

(21)

odetest(sol,ODE, y(x));

0

(22)

Testing reductions of order returned by dsolve  using ODESolStructures

ODE := diff(y(x),x,x) = (diff(y(x),x)-y(x)^3-f(x)+3*x*y(x)^2*diff(y(x),x)+x*diff(f(x),x))/x;

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

(23)

sol := dsolve(ODE, y(x));

y(x) = ODESolStruc(_b(_a), [{(diff(_b(_a), _a))/_a-(_b(_a)^3-_C1*_a+f(_a))/_a = 0}, {_a = x, _b(_a) = y(x)}, {x = _a, y(x) = _b(_a)}])

(24)

odetest(sol,ODE);

0

(25)

A linear system of ODEs. The solution is a set containing x(t) and y(t) as functions of t.

sysODE := {diff(y(t),t)=-x(t),diff(x(t),t)=y(t)}, {x,y}(t);

{diff(x(t), t) = y(t), diff(y(t), t) = -x(t)}, {x(t), y(t)}

(26)

solsys := dsolve(sysODE);

{x(t) = _C1*sin(t)+_C2*cos(t), y(t) = _C1*cos(t)-_C2*sin(t)}

(27)

odetest(solsys,sysODE);

{0}

(28)

A nonlinear system of ODEs. The solution is a list of sets, the first one containing the possible answers for x(t), and the second one expressing y(t) as a function of x(t):

sysODE := {diff(y(t),t)=-x(t)^2,diff(x(t),t)=y(t)}, {x,y}(t);

{diff(x(t), t) = y(t), diff(y(t), t) = -x(t)^2}, {x(t), y(t)}

(29)

solsys := dsolve(sysODE);

[{x(t) = -6*WeierstrassP(t+_C1, 0, _C2)}, {y(t) = diff(x(t), t)}]

(30)

These answers can be tests by passing them to odetest as a list.

odetest(solsys,sysODE);

{0}

(31)

Alternatively, you can call dsolve  with the 'explicit' extra argument to directly obtain (many) composed solution sets. To test all these answers, use the map  function to apply odetest to each solution set:

solsys := dsolve(sysODE, explicit);

{x(t) = -6*WeierstrassP(t+_C1, 0, _C2), y(t) = -6*WeierstrassPPrime(t+_C1, 0, _C2)}

(32)

map(odetest, [solsys], sysODE);

[{0}]

(33)

One possible workaround for an example where odetest fails in verifying dsolve 's solution

ODE := diff(y(t),t) = ((b+2+2*t)*y(t)+1)/(1-(1+t)^2);

diff(y(t), t) = ((b+2+2*t)*y(t)+1)/(1-(1+t)^2)

(34)

sol := dsolve(ODE);

y(t) = (-(1/2)*2^(2-(1/2)*b)*t^((1/2)*b+1)*hypergeom([(1/2)*b, (1/2)*b+1], [2+(1/2)*b], -(1/2)*t)/(b+2)+_C1)*(t+2)^((1/2)*b-1)*t^(-(1/2)*b-1)

(35)

odetest(sol, ODE);            # fails in verifying this solution

(1/2)*(b+t)*((1+(1/2)*t)^((1/2)*b)*hypergeom([(1/2)*b+1, (1/2)*b+1], [2+(1/2)*b], -(1/2)*t)*b*t-2*hypergeom([(1/2)*b, (1/2)*b], [(1/2)*b+1], -(1/2)*t)*b*(1+(1/2)*t)^((1/2)*b)-4*(1+(1/2)*t)^((1/2)*b)*hypergeom([(1/2)*b, (1/2)*b], [(1/2)*b+1], -(1/2)*t)+2*b+4)*(b+2+t)/((t+2)^2*t^2*(b+2))

(36)

sol2 := dsolve(ODE, useInt);  # compute 'sol' again with 'useInt'

y(t) = (Int(-exp(Int((b+2+2*t)/(t*(t+2)), t))/(t*(t+2)), t)+_C1)*exp(Int(-(b+2+2*t)/(t*(t+2)), t))

(37)

odetest(sol2, ODE);           # this solution is easier to test

0

(38)

By evaluating the integrals appearing in sol2, the output returned by dsolve  without using the 'useInt' option can be constructed from the one obtained using the 'useInt' option, which was already verified to be correct.

An example hard to test due to the presence of radicals and Kummer  functions in the solution

ODE := diff(y(x),`$`(x,2)) = ((-a[1]*F+a[0]*E)*x+B*e*a[1])*y(x)/B^2/e^2/x/E^3;

diff(diff(y(x), x), x) = ((E*a[0]-F*a[1])*x+B*e*a[1])*y(x)/(B^2*e^2*x*E^3)

(39)

sol := dsolve(ODE, [hyper3]);             # 1F1 and KummerU solution

y(x) = _C1*exp(-(E*a[0]-F*a[1])^(1/2)*x/(B*e*E^(3/2)))*x*hypergeom([(1/2)*(2*(E*a[0]-F*a[1])^(1/2)*E^(3/2)+a[1])/((E*a[0]-F*a[1])^(1/2)*E^(3/2))], [2], 2*(E*a[0]-F*a[1])^(1/2)*x/(B*e*E^(3/2)))+_C2*exp(-(E*a[0]-F*a[1])^(1/2)*x/(B*e*E^(3/2)))*x*KummerU((1/2)*(2*(E*a[0]-F*a[1])^(1/2)*E^(3/2)+a[1])/((E*a[0]-F*a[1])^(1/2)*E^(3/2)), 2, 2*(E*a[0]-F*a[1])^(1/2)*x/(B*e*E^(3/2)))

(40)

ode := PDEtools[dpolyform](sol, no_Fn);  # the ode satisfied by sol

`casesplit/ans`([diff(diff(y(x), x), x) = (B*e*a[1]+E*x*a[0]-F*x*a[1])*y(x)/(B^2*e^2*x*E^3)], [])

(41)

normal( ODE - op([1,1],ode) );             # ode = ODE

0 = 0

(42)

Yet another alternative is to convert the special functions entering sol to other functions easier to test; in this example convert from Kummer  to Whittaker  functions:

sol_W:=convert(sol,Whittaker);

y(x) = -(1/2)*_C1*WhittakerM(-1, 1/2, -(E*a[0]-F*a[1])^(1/2)*x/(B*e*E^(3/2)))*B^2*e^2*E^3*WhittakerM(-(1/2)*a[1]/((E*a[0]-F*a[1])^(1/2)*E^(3/2)), 1/2, 2*(E*a[0]-F*a[1])^(1/2)*x/(B*e*E^(3/2)))*exp((E*a[0]-F*a[1])^(1/2)*x/(B*e*E^(3/2)))/(exp((1/2)*(E*a[0]-F*a[1])^(1/2)*x/(B*e*E^(3/2)))*(E*a[0]-F*a[1])*x)-(1/2)*_C2*WhittakerM(-1, 1/2, -(E*a[0]-F*a[1])^(1/2)*x/(B*e*E^(3/2)))*B^2*e^2*E^3*WhittakerW(-(1/2)*a[1]/((E*a[0]-F*a[1])^(1/2)*E^(3/2)), 1/2, 2*(E*a[0]-F*a[1])^(1/2)*x/(B*e*E^(3/2)))*exp((E*a[0]-F*a[1])^(1/2)*x/(B*e*E^(3/2)))/(exp((1/2)*(E*a[0]-F*a[1])^(1/2)*x/(B*e*E^(3/2)))*(E*a[0]-F*a[1])*x)

(43)

odetest( sol_W, ODE );    # this Whittaker solution is easier to test

0

(44)

 

 

See Also

DEtools

dsolve

dsolve,system

odeadvisor

pdetest

symgen

symtest

 

 

 

 

 

Download odetest.mw

 

  restart:
  interface(version);
#
# ode from help page for odetest() command
#
  ODE := diff(diff(y(x),x),x) = (3*x^2+c)*diff(y(x),x)+((3-b)*x-a)*y(x);

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

 

diff(diff(y(x), x), x) = (3*x^2+c)*(diff(y(x), x))+((3-b)*x-a)*y(x)

(1)

#
# Solution from help page for odetest() command.
#
# NB this "solution" is given, not computed, and it
# is 5-th order
#
  sol:= y(x) = series(1+(-1/2*a)*x^2+(-1/6*b+1/2-1/6*c*a)*x^3+(1/24*a^2-1/24*c*b+1/8*c-1/24*c^2*a)*x^4+O(x^5),x,5);
#
# Use dsolve to get a series solution for the above ODE
# (no boundary conditions). This will be 6-th order (by
# default)
#
  sol2_6:=  dsolve(ODE, y(x), series);
#
# Just for completeness (and comparison with sol1 above)
# generate a 5-th order solution
#
  Order:=5:
  sol2_5:=  dsolve(ODE, y(x), series);
#
# Use dsolve to get a series solution (with boundary conditions)
# at both 5-th and 6-th order
#
  sol3_5:=  dsolve([ODE, y(0)=1, D(y)(0)=0], y(x), series);
  Order:=6:
  sol3_6:=  dsolve([ODE, y(0)=1, D(y)(0)=0], y(x), series)

y(x) = series(1-((1/2)*a)*x^2+(-(1/6)*b+1/2-(1/6)*c*a)*x^3+((1/24)*a^2-(1/24)*c*b+(1/8)*c-(1/24)*c^2*a)*x^4+O(x^5),x,5)

 

y(x) = series(y(0)+(D(y))(0)*x+((1/2)*c*(D(y))(0)-(1/2)*a*y(0))*x^2+(-(1/6)*y(0)*a*c+(1/6)*(D(y))(0)*c^2-(1/6)*y(0)*b-(1/6)*a*(D(y))(0)+(1/2)*y(0))*x^3+(-(1/12)*a*c*(D(y))(0)+(1/24)*a^2*y(0)-(1/24)*y(0)*a*c^2+(1/24)*(D(y))(0)*c^3-(1/24)*c*y(0)*b+(1/8)*c*y(0)-(1/12)*(D(y))(0)*b+(1/2)*(D(y))(0))*x^4+(-(1/40)*a*c^2*(D(y))(0)+(1/60)*c*a^2*y(0)-(1/120)*y(0)*a*c^3+(1/120)*(D(y))(0)*c^4-(1/120)*c^2*y(0)*b+(1/40)*c^2*y(0)-(1/24)*c*(D(y))(0)*b+(13/40)*c*(D(y))(0)-(1/4)*a*y(0)+(1/30)*a*y(0)*b+(1/120)*a^2*(D(y))(0))*x^5+O(x^6),x,6)

 

y(x) = series(y(0)+(D(y))(0)*x+((1/2)*c*(D(y))(0)-(1/2)*a*y(0))*x^2+(-(1/6)*y(0)*a*c+(1/6)*(D(y))(0)*c^2-(1/6)*y(0)*b-(1/6)*a*(D(y))(0)+(1/2)*y(0))*x^3+(-(1/12)*a*c*(D(y))(0)+(1/24)*a^2*y(0)-(1/24)*y(0)*a*c^2+(1/24)*(D(y))(0)*c^3-(1/24)*c*y(0)*b+(1/8)*c*y(0)-(1/12)*(D(y))(0)*b+(1/2)*(D(y))(0))*x^4+O(x^5),x,5)

 

y(x) = series(1-((1/2)*a)*x^2+(-(1/6)*b+1/2-(1/6)*c*a)*x^3+((1/24)*a^2-(1/24)*c*b+(1/8)*c-(1/24)*c^2*a)*x^4+O(x^5),x,5)

 

y(x) = series(1-((1/2)*a)*x^2+(-(1/6)*b+1/2-(1/6)*c*a)*x^3+((1/24)*a^2-(1/24)*c*b+(1/8)*c-(1/24)*c^2*a)*x^4+((1/30)*a*b-(1/4)*a+(1/60)*c*a^2-(1/120)*c^3*a-(1/120)*c^2*b+(1/40)*c^2)*x^5+O(x^6),x,6)

(2)

#
# Five (slightly different) series solutions above. Check each
# of them (two ways)
#
  odetest(sol, ODE, series, point = 0); # from maple help page
  odetest(sol, ODE, 'series', point = 0);
  odetest(sol2_5, ODE, series, point = 0);
  odetest(sol2_5, ODE, 'series', point = 0);
  odetest(sol2_6, ODE, series, point = 0);
  odetest(sol2_6, ODE, 'series', point = 0);
  odetest(sol3_5, [ODE, y(0)=1, D(y)(0)=0], 'series');
  odetest(sol3_5, [ODE, y(0)=1, D(y)(0)=0], series);
  odetest(sol3_6, [ODE, y(0)=1, D(y)(0)=0], 'series');
  odetest(sol3_6, [ODE, y(0)=1, D(y)(0)=0], series);

0

 

0

 

0

 

0

 

0

 

0

 

[0, 0, 0]

 

[0, 0, 0]

 

[0, 0, 0]

 

[0, 0, 0]

(3)

 

Download testODE2.mw

if you posted a usable worksheet usingin the big green up arrow in the Mapleprimes toolbar, someone might be abke to resolve your problem

If you post something which is a mixture of Maple input/Maple output, the odds are that no-one is going to be bothered to go through your post line by line cutting out the irrelevant output, in order to obtain an executable file which they can test/examine.

The first criterion for getting a "sensible" answer is to ask a question which is simple to investigate

@Zeineb 

produces the error

Error, a constant cannot be added to a Vector; use +~ for elementwise addition instead of +

This error arises fron the line

 if  norm(F[i]-F1[i])>AC  then

because F[i] is a scalar, but F1[i] is a Vector with one element

 

the code in the procedure assembly contains one line (highlighted in red in the attached) which doesn't make much sense - what is llim[i,1..2]? (and I have trouble understanding how Maple's 2D parser is interpreting it as l*lim[i,1..2]. This is a whole new wrinkle on so-called "implicit multiplication".

NULL

restart; with(PDEtools); with(plots); with(LinearAlgebra); Digits := 10

n := 5; nn := n+1; lgth := 1; he := lgth/n; x := [seq(k*he, k = 0 .. n)]; AC := 0.1e-3; F := Vector(nn); F[1] := 1; F[nn] := evalf(exp(1))

n := 5

 

nn := 6

 

lgth := 1

 

he := 1/5

 

x := [0, 1/5, 2/5, 3/5, 4/5, 1]

 

AC := 0.1e-3

 

Vector[column](%id = 36893488148079828012)

 

1

 

2.718281828

(1)

assembly := proc (F, n, he) local nn, K, R, dS, lmm, i, lm, F1, d, S1t, f1, k11, l1, l2; nn := n+1; K := Matrix(nn, nn); R := Matrix(nn, 1); S = [1-t/he, t/he]; dS := diff(S, t); lmm := Matrix(n, 2); for i to n do lmm[i, 1] := i; lmm[i, 2] := i+1 end do; for i to n do lm := l*lmm[i, 1 .. 2]; l1 := lm[1]; l2 := lm[2]; k11 := -(int(Multiply(Tranpose(dS), S), t = 0 .. he))+(int(Multiply(Tranpose(dS), S)*S[1], t = 0 .. he))*F[l1]+(int(Multiply(Tranpose(dS), S)*S[2], t = 0 .. he))*F[l2]-(int(Multiply(Transpose(S), dS), t = 0 .. he)); S1t := Transpose(S); f1 := int(exp(2*t+2*(i-1)*he)*S1t, t = 0 .. he); K[lm, lm] := K[lm, lm]+k11; R[lm] := R[lm]+f1 end do; K[1, 1 .. nn] := 0; K[1, 1] := 1; R[1, 1] := F[1]; K[nn, 1 .. nn] := 0; K[nn, nn] := 1; R[nn, 1] := F[nn]; d := Multiply(Inverse(K), R); F1 := d end proc

NULL

NULL

c := 1; count := 0; while c > 0 do F1 := assembly(F, n, he); c := 0; for i to nn do if abs(F[i]-F1[i]) > AC then c := c+1; break end if end do; F := F1; count := count+1 end do

1

 

0

 

Error, (in assembly) bad index into Vector

 

lm := l*lmm[i, 1 .. 2]

plot([seq([x[i], F[i]], i = 1 .. n)])

 

NULL

NULL

NULL

NULL


 

Download dodgy2D.mw

 

  1. Since you state " xs and xu are functions of the variable t" and the variable of integration is 'x', then the integrand is constant wrt to the integration variable, and can be moved outside the integral itself - which makes the whole exercise a bit pointless?
  2. If I am misunderstanding something, and you do have a sensible problem, it looks as if Maple's RiemannSum() command might be useful - see the help at ?RiemannSum
  1. Different parentheses mean different things in Maple. '{}' delimit sets, '[]' delimit lists. Only '()' are allowed for the grouping of terms in an expression. You seem to be using all types of parentheses, more-or-less randomly
  2. You use ex rather than exp(x) in a few places - you probably mean the latter
  3. There are several places in this expression where I'm pretty sure that you are being confused by Maple's 2D-input rules on "implicit mulitplication". Sometimes, "whitespace" in 2-D input is interpreted as multiplication, and sometimes it isn't. I strongly recommend that you always use "explicit" multiplication
  4. As a general rule when performing a summation of a finite number of terms you should use add() rather than sum()

Given all the syntax errors in your expression, it is pretty much impossible tigure out how to fix it

@Tamour_Zubair 

on the subject of accuracy and efficiency of numeriic solution methods for ODEs (by people a lot smarter than I am!).

Solution methods can be broadly characterised, by three main criteria

  1. "Order" of the method: eg rk-2 versus rk-3. Very generally speaking, for a given "accuracy" rk-2 will require a smaller step size than rk-3, but rk-3 will require more computation time at each step. Which will be more "efficient" for any particular problem - rk-2 with (say) 100 steps, or rk-3 with (say) 50 steps?
  2. "Implicit" versus "explicit" methods: "implicit" methods require an iterative process at each step to determine the solution at that point, so will be slower than "explicit" methods. On the other hand, they are (generally) more accurate, so fewer steps are required. Which will be more "efficient" for any particular problem - an "explcit" method with (say) 100 steps or an "implicit" method with (say) 50 steps?
  3. Error control: methods such as rk-2 and rk-3 have no error control. As such it is impossible(?) to determine the "accuracy" of the results which they return! A method such as rkf45 can be thought of as running an rk-4 and an rk-5 calculation. When correctly coded, most of the calculations for rk-5 have already been performed for rk-4, so the "overhead" of the rk-5 calculation is quite small. Any discrepancy, between the two sets of results is a measure of the "accuracy" of the calculation. This allows an adaptive step size to be used. If the "error" at any step is "too big", then the step size is shortened and the calculation repeated until the "error" is within acceptable limits.

The actual ODE system also has a significant impact: if it is numerically "well behaved", eg solutions change "smoothly" and "slowly", then a low-order method (rk-2), with quite a large step size, and no error control, may give perfectly adequate results. For such a problem, a method such as rkf45 may well be "overkill"! (But do you know beforehand that the solutions are going to be "smooth" and "slowly-varying"?)

The rkf45 method is popular mainly because it "works" on many ODE systems, is reasonably efficient (more so than rkf56 or rkf67), and its adaptive step size means that its accuracy can be "tuned"

 

that you are running Maple 2015.

Some of the plot/display options I used in my original response will not work in Maple 2015 (I deveopled the original response in Maple 2022).

I have revised the offending plot/display options in the attached, which will run in Maple 2015. Note that nothing about the basic calculation has changed - just the way that options are supplied to the final plotting commands

  restart;
  interface(version);
  with(LinearAlgebra):
  with(plots):
#
# Define equations and ICS
#
  sys := [ diff(A[2](t), t) = -4/45*(-1323*A[7](t)*Pi^5 - 945*A[6](t)*Pi^4 - 630*A[5](t)*Pi^3 - 513*A[4](t)*Pi^2 - 189*A[3](t)*Pi + 3626*A[2](t))/Pi^2,
           diff(A[3](t), t) = 4/45*(-9744*A[7](t)*Pi^5 - 6960*A[6](t)*Pi^4 - 4415*A[5](t)*Pi^3 - 2784*A[4](t)*Pi^2 - 1392*A[3](t)*Pi + 14544*A[2](t))/Pi^3,
           diff(A[4](t), t) = -2/9*(-14112*A[7](t)*Pi^5 - 10215*A[6](t)*Pi^4 - 6720*A[5](t)*Pi^3 - 4032*A[4](t)*Pi^2 - 2016*A[3](t)*Pi + 12992*A[2](t))/Pi^4,
           diff(A[5](t), t) = 2/45*(-133455*A[7](t)*Pi^5 - 96000*A[6](t)*Pi^4 - 64000*A[5](t)*Pi^3 - 38400*A[4](t)*Pi^2 - 19200*A[3](t)*Pi + 81408*A[2](t))/Pi^5,
           diff(A[6](t), t) = -4096/45*(-63*A[7](t)*Pi^5 - 45*A[6](t)*Pi^4 - 30*A[5](t)*Pi^3 - 18*A[4](t)*Pi^2 - 9*A[3](t)*Pi + 26*A[2](t))/Pi^6,
           diff(A[7](t), t) = 32768/315*(-21*A[7](t)*Pi^5 - 15*A[6](t)*Pi^4 - 10*A[5](t)*Pi^3 - 6*A[4](t)*Pi^2 - 3*A[3](t)*Pi + 6*A[2](t))/Pi^7]:
  ICS := [A[2](0) = -0.001210685373, A[3](0) = -0.1636380032, A[4](0) = -0.003838287851, A[5](0) = 0.01100619795, A[6](0) = -0.001005637627, A[7](0) = -0.00002775982849]:

`Standard Worksheet Interface, Maple 2015.2, Windows 7, December 21 2015 Build ID 1097895`

(1)

#
# Convert to Matrix form and run the RK2 method for npts
# in the interval t=0..1
#
#  Rows in the results matrix are
#
#  resMat[1,..] <--> A[2](t)
#  resMat[2,..] <--> A[3](t)
#  resMat[3,..] <--> A[4](t)
#  resMat[4,..] <--> A[5](t)
#  resMat[5,..] <--> A[6](t)
#  resMat[6,..] <--> A[7](t)
#
  f, diffs:= GenerateMatrix
             ( rhs~(sys)-~lhs~(sys),
               [A[2](t), A[3](t), A[4](t), A[5](t), A[6](t), A[7](t)]
             ):
  npts:= 21:
  resMat:= Matrix(6,npts):
  resMat[1..6, 1]:= Vector(rhs~(ICS)):
  h:=1/(npts-1):
#
# The RK2 method
#
  for j from 2 to npts do
      k1:= f.resMat[..,j-1];
      k2:= f.(resMat[..,j-1]+h*k1);
      resMat[..,j]:= resMat[..,j-1]+h/2*(k1+k2);
  od:

#
# Get the solution for the system using Maple's default solvers,
# just for comparison purposes
#
  sol:=dsolve([sys[], ICS[]], numeric):

#
# Plot the solutions from the RK2 method above and Maple's
# default solvers for a couple of the independent variables
#
# I randoml picked A[2](t) and A[7](t).
#
# Solutions from Maple's default solvers are solid red lines
# Solutions from "crude" RK2 method above
#
  display( [ odeplot( sol,
                      [t, A[2](t)],
                      t=0..1,
                      color=red,
                      thickness=4,
                      legend=[ "MapleDefault"],
                      legendstyle=[font=[times, bold, 16]],
                      axesfont=[times, bold, 16]
                    ),
             pointplot( [ seq( [h*(j-1), resMat[1,j] ],
                               j=1..npts
                             )
                        ],
                        symbol=solidbox,
                        color=blue,
                        legend=["RK2"],
                        legendstyle=[font=[times, bold, 16]],
                        axesfont=[times, bold, 16]
                      )
           ],
           title= "Solutions for A[2](t)",
           titlefont=[times, bold, 20]
         );
  display( [ odeplot( sol,
                      [t, A[7](t)],
                      t=0..1,
                      color=red,
                      thickness=4,
                      legend=[ "MapleDefault"],
                      legendstyle=[font=[times, bold,16]],
                      axesfont=[times, bold, 16]
                    ),
             pointplot( [ seq( [h*(j-1),  resMat[6,j] ],
                               j=1..npts
                             )
                        ],
                        symbol=solidbox,
                        color=blue,
                        legend=["RK2"],
                        legendstyle=[font=[times, bold,16]],
                        axesfont=[times, bold, 16]
                       )
           ],
           title= "Solutions for A[7](t)",
           titlefont=[times, bold, 20]
         );

 

 

 

 

Download rk2v2.mw

 

@south 

appears to provide the answers you want (see attached) - what exactly is the problem?

  restart;
  with(plots):
  y1 := 2*x^3 - x^2 - 5*x;
  y2 := -x^2 + 3*x;
  solve(y1 = y2, x);
  plot([y1, y2], x = -4 .. 4, y = -30 .. 30, color = [orange, green]);
  shadebetween(y1, y2, x = -2 .. 2, color = purple);
  A := Int(y1 - y2, x = -2 .. 0) + Int(y2 - y1, x = 0 .. 2);
  value(%);

2*x^3-x^2-5*x

 

-x^2+3*x

 

0, 2, -2

 

 

 

Int(2*x^3-8*x, x = -2 .. 0)+Int(-2*x^3+8*x, x = 0 .. 2)

 

16

(1)

 

Download aSol.mw

@Anthrazit 

specific to the units package - consider the code in the attached

  a:=Pi:
  if   a>0
  then "success":
  else "fail";
  fi;

Error, cannot determine if this expression is true or false: 0 < Pi

 

 

Download bTest.mw

Which invites the obvious question - why did the Units package decide to convert 45 degrees to Pi/4 (radians)???

You don't even need to do it "by hand", you can do it "by eye" in negligible time, with negligible thought.

B|oth terms in the function definition are quadratic - and so are >=0. The minimum is therefor acheived when both terms are 0. A brain-dead idiot will recognise that the second term is 0 when x=1, and the first term is 0 when y=x^2, ie y=1.

So the minimum is 0 when x-1, y=1. Do you need Maple for this?

@ijuptilk 

a running argument/requirement for years. MAny "bodges" have been proposed, but I'm not going to get into it. I suggest you type

mapleprimes legend positions

into your favoured search engine and you can read through loads of possible solutions (most of whihc won't work in all cases), and all of which require a excessive amount of coding just for "aesthetics"

@harry4939 

worksheet (attached) which runs in Maple 2022. If it runs then the problem is (probably) with your worksheet. If it doesn't, save the file (with the output) and uplaod it here using the big green up-arrow in the Mapleprimes toolbar

restart

with(Student[Calculus1])

InversePlot(exp(x), -1 .. 1)

 

InversePlot(sin(x), -1 .. 1)

 

InversePlot(x^2, -1 .. 1)

 

 

Download invPlot2.mw

First 18 19 20 21 22 23 24 Last Page 20 of 207