tomleslie

11318 Reputation

18 Badges

12 years, 100 days

MaplePrimes Activity


These are replies submitted by tomleslie

is to always upload a worksheet which illustrates your problem!

Use the big green up-arrow in the Mapleprimes toolbar

@imparter 

to address the basic problem.

The ode you define in your worksheets as  'de1' only contains the dependent variable 'f(x)'. The ode you define in your worksheets as  'de2' contains the dependent variables 'f(x)' and 'g(x)'.

When you process the ode 'de1', to produce 'DE1', the latter contains the dependent variables

{b[0](x), b[1](x), b[2](x), b[3](x), b[4](x), b[5](x), b[6](x), b[7](x), b[8](x), b[9](x), b[10](x)}

However when you process the ode 'de2', to produce 'DE2', the latter contains the dependent variables (check the one highlighted in red)

{f(x), c[0](x), c[1](x), c[2](x), c[3](x), c[4](x), c[5](x), c[6](x), c[7](x), c[8](x), c[9](x), c[10](x)}

The mere existence of the undetermined function 'f(x)' in the definition of 'DE2' is the source of your problem.

See the attached for proof - it makes no attempt to solve anything - it just lists the indeterminates. Until you fix the existence of the indeterminate 'f(x)' in the definition of 'DE2' you are going to get precisely nowhere

  restart:

  Pr:=1:

  de1 := (1 - p)*diff(f(x), x $ 3) + p*(diff(f(x), x $ 3) + 1/2*f(x)*diff(f(x), x $ 2)):

  de2 := (1 - p)*diff(g(x), x $ 2)/Pr + p*(diff(g(x), x $ 2)/Pr + 1/2*f(x)*diff(g(x), x)):

  ibvc := f(0), D(f)(0), D(f)(5) - 1, g(0) - 1, g(5):
  n := 10:
  F := unapply(add(b[k](x)*p^k, k = 0 .. n), x):
  G := unapply(add(c[k](x)*p^k, k = 0 .. n), x):

  DE1 := series(eval(de1, f = F), p = 0, n + 1):
  indets(DE1, function(name));

{b[0](x), b[1](x), b[2](x), b[3](x), b[4](x), b[5](x), b[6](x), b[7](x), b[8](x), b[9](x), b[10](x)}

(1)

  DE2 := series(eval(de2, g = G), p = 0, n + 1):
  indets(DE2, function(name));

{f(x), c[0](x), c[1](x), c[2](x), c[3](x), c[4](x), c[5](x), c[6](x), c[7](x), c[8](x), c[9](x), c[10](x)}

(2)

``

Download indets.mw

@imparter 

actually looking at the system you are trying to solve?

The final execution group in your latest worksheet - ie this piece of code

for k from 0 to n do
    IBVC1 := select(has, CT, c[k]);
    {coeff(DE2, p, k), op(IBVC1)};
    slv1 := dsolve({coeff(DE2, p, k), op(IBVC1)});
    c[k] := unapply(rhs(slv1), x);
end do

For k=0, your code generates the ODE system

{c[0](0) - 1, diff(c[0](x), x, x), c[0](5)}

a second order ODE with two boundary conditions - which is fine, and Maple generates the solution

slv1 := c[0](x) = -x/5 + 1

 

For k=1, your code generates the ODE system

{diff(c[1](x), x, x) - f(x)/10, c[1](0), c[1](5)}

a second-order ODE with two boundary conditions, and a completely unknown function of the same independent variable f(x). What solution do you expect?

Maple returns a "formal" solution containing double integrals of the unknown function f(x)

@imparter 

you are trying to make.

  1. Your original code generates an invalid ODE system, which means that dsolve() will produce an error.
  2. This update to your code produces a valid ODE system, which means that dsolve() has a reasobale chance of coming up with a solution.

These two cases, both for loop index k=0 are illustrated in the attached. One errors, for reasons I explained previously and one doesn't.

#
# OP's original code asks for a solution of
#
  dsolve({1, diff(c[0](x), x, x)});
#
# which will produce an error
#

Error, (in dsolve) found the following equations not depending on the unknowns of the input system: {1}

 

#
# OP's new code asks for a solution of
#
  dsolve( {D(b[0])(5) - 1, diff(b[0](x), x, x, x), b[0](0), D(b[0])(0)});

b[0](x) = (1/10)*x^2

(1)

 

Download diffODEs.mw

 

 

@FDS 

as in the attached "toy" example

  restart;
  with(Statistics):
  V:=Vector[column](9, [124.0, 130.0, 130.0, 119.0, 136.0, 118.0, undefined, 130.0, 95.0]);
  Mean(V, ignore=true);

Vector(9, {(1) = 124.0, (2) = 130.0, (3) = 130.0, (4) = 119.0, (5) = 136.0, (6) = 118.0, (7) = undefined, (8) = 130.0, (9) = 95.0})

 

HFloat(122.75)

(1)

 

Download getMean.mw

@Muhammad Usman 

that you were trying to achieve what is shown in the attached? I don't think this approach can be (easily) extended beyond first differences.

  restart;
  a := 1: b := 5: h := 1: f := 1/x: N := (b-a)/h:
  for i from 0 while i <= N do
      x[i] := h*i+a;
      y[i] := eval(f, x = x[i])
  end do:
  printf("_______________________________________________________________________________\n\n\n");  
  for i from 0 by 1 while i<=2*N do:  
      if   irem(i,2)=0
      then printf("%2d%16.7f%16.7f\n",i,x[i/2],y[i/2]);
      else printf("%2d%48.7f\n",i, y[(i+1)/2]-y[(i-1)/2]);
      fi;
  od;
  printf("_______________________________________________________________________________\n")

_______________________________________________________________________________


 0       1.0000000       1.0000000
 1                                      -0.5000000
 2       2.0000000       0.5000000
 3                                      -0.1666667
 4       3.0000000       0.3333333
 5                                      -0.0833333
 6       4.0000000       0.2500000
 7                                      -0.0500000
 8       5.0000000       0.2000000
_______________________________________________________________________________

 

 

Download printStuff.mw

@ check my original comments on the typos in your equation and fix them properly before doing anything else.

I'd be surprised if an analytic solution can be found for the resulting ODE, so you may have to be satisfied with a numeric one - which means that you will need values for all parameters and a couple of initial/bondary conditions:-(

@JAMET 

the attached will show which months in a specified year have a Friday 13th. Output is in the form

[year, [list of months with Friday 13th]]

From which is pretty obvious that in 2022, the only month with a Friday 13th is month 5 - ie May!

  restart;
  with(Calendar):
  fri:= yr-> local j:seq(`if`(DayOfWeek(yr, j, 13)=6,j, NULL), j=1..12):

#
# So which months in the supplied year have a Friday 13th
#
  seq( [j, [fri(j)]], j=2000..2022);

[2000, [10]], [2001, [4, 7]], [2002, [9, 12]], [2003, [6]], [2004, [2, 8]], [2005, [5]], [2006, [1, 10]], [2007, [4, 7]], [2008, [6]], [2009, [2, 3, 11]], [2010, [8]], [2011, [5]], [2012, [1, 4, 7]], [2013, [9, 12]], [2014, [6]], [2015, [2, 3, 11]], [2016, [5]], [2017, [1, 10]], [2018, [4, 7]], [2019, [9, 12]], [2020, [3, 11]], [2021, [8]], [2022, [5]]

(1)

 

 

Download fri_2.mw

 

 

@Will_iii 

when you type

convert(360*Unit(degrees), units, radians);

in Maple Flow - it doesn't work?

Because if this is true then all you have demonstrated ist that Maple Flow is unable to execute basic Maple commands - which is somewhat scary!

@Carl Love 

If you want to restrict the range variable to integers, then not only do you need the 'sample' option, but ialso to set the adaptive=false option. If the intent is to restrict the range variable to integers, why have a 'floor(n)' command in the function definition? Isn't this a bit - well - superfluous?

@ProfG 

was that in a plot() command, the plotting variable is continuous - it does not assume integer values. Kitonum circumvented this problem by plotting only points. This has the drawback that if you draw lines between the points (say by using style=pointline), then you will not get "vertical" lines, since x-values will always differ by one

I gave a (quick+dirty) workaround for this - and you can see the effect of superimposing my plot and Kitonum's in the attached. This gives an apparent "right shift to the curve on my plot. If this is a problem it is relatively easy to fix, see the final figure in the attached

  restart;
  f:=n->ceil(sqrt(4*floor(n)))-floor(sqrt(2*floor(n)))-1:
  plot(f, 10..100, gridlines=false);

 

Points:=[[10, 2], [11, 2], [12, 2], [13, 2], [14, 2], [15, 2], [16, 2], [17, 3], [18, 2], [19, 2], [20, 2], [21, 3], [22, 3], [23, 3], [24, 3], [25, 2], [26, 3], [27, 3], [28, 3], [29, 3], [30, 3], [31, 4], [32, 3], [33, 3], [34, 3], [35, 3], [36, 3], [37, 4], [38, 4], [39, 4], [40, 4], [41, 3], [42, 3], [43, 4], [44, 4], [45, 4], [46, 4], [47, 4], [48, 4], [49, 4], [50, 4], [51, 4], [52, 4], [53, 4], [54, 4], [55, 4], [56, 4], [57, 5], [58, 5], [59, 5], [60, 5], [61, 4], [62, 4], [63, 4], [64, 4], [65, 5], [66, 5], [67, 5], [68, 5], [69, 5], [70, 5], [71, 5], [72, 4], [73, 5], [74, 5], [75, 5], [76, 5], [77, 5], [78, 5], [79, 5], [80, 5], [81, 5], [82, 6], [83, 6], [84, 6], [85, 5], [86, 5], [87, 5], [88, 5], [89, 5], [90, 5], [91, 6], [92, 6], [93, 6], [94, 6], [95, 6], [96, 6], [97, 6], [98, 5], [99, 5], [100, 5]]:
plots:-display( [ plot(Points, style=point, color=red, symbol=solidcircle),
                  plot(f, 10..100)
                ],
                gridlines=false
              );

 

  g:=n->ceil(sqrt(4*floor(n+1/2)))-floor(sqrt(2*floor(n+1/2)))-1:
  plots:-display( [ plot(Points, style=point, color=red, symbol=solidcircle),
                    plot(g, 10..100)
                  ],
                  gridlines=false
                );

 

 

Download sqPlot2.mw

@Tamour_Zubair 

at

https://en.wikipedia.org/wiki/Rouch%C3%A9%E2%80%93Capelli_theorem

which states (emphasis added)

A system of linear equations with n variables has a solution if and only if the rank of its coefficient matrix A is equal to the rank of its augmented matrix [A|b].[1] If there are solutions, they form an affine subspace of of dimension n − rank(A). In particular:

  1. if n = rank(A), the solution is unique,
  2. otherwise there are infinitely many solutions.

It is trivial to produce the coefficient matrix, the augmented matrix and their ranks, using the code

sys:=[subs(x = xmin, uhat1) = rhs(bcf1),
      subs(x = xmax, uhat1) = rhs(bcf2),
      subs(p = pmin, uhat1) = rhs(bcf3),
      subs(p = pmax, uhat1) = rhs(bcf4)]:
  vars:=[Af[0, 1](t), Af[0, 2](t), Af[0, 0](t), Af[0, 3](t)]:
  coeffMat,b:=GenerateMatrix(sys, vars):
  augMat:=GenerateMatrix(sys, vars, augmented=true):
  Rank(coeffMat);
  Rank(augMat);

which shows that the coefficient matrix has rank 3, and the augmented matrix has rank 4. Thus the sytem has no solution

@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

1 2 3 4 5 6 7 Last Page 1 of 189