tomleslie

13876 Reputation

20 Badges

15 years, 172 days

MaplePrimes Activity


These are answers submitted by tomleslie

restart:
isolate(5*x-7 = 3*x+2,x);

 

Try,

restart;
S := [seq(2..5)];
P:=combinat:-setpartition(S, 2);
map2( remove, has, P, 5);

 

When you say

I am trying to have the following display correctly....

what is your problem with

ans1:=7/9:
ans2:=1/4:
printf( "\n\t\t ans1=%a; ans2=%a\n\n", ans1, ans2);

The sort of questions one has to ask are

  1. You ask "how many days before a+b=0". Well depends on your definition: if a+b>0 on day n, and a+b<0 on day n+1 - then how many days?? Days come in integer values, but the solution to your equations does not (necessarily). So generally there is no solution fpr a+b=0, for integer n. The case a+b>0 for n, and a+b<0 for n+1, can however be determined
  2. The second problem that you have is that the answer is dependent on the values of 'a' and 'b' on day zero. In fact it is possible that there is no answer depending on initial values of 'a' and 'b'. For your specific problem, it is relatively trivial to demonatrate that if the time0 value of 'a' and 'b'  add to more than 408.1632653, then the value of 'a+b' will continue to grow, so no solution will be possible.

Given the above difficulties the attached code will generally solve your problem; you will have to supply time=0 values for 'a' and 'b'. It will trap the case when no solution is possible. It will output the integer value of days when the value of a+b becoms negative

   restart;
#
# Specify start values for a and b
#
   a[0]:=8:
   b[0]:=400:
#
# Check/trap wheter a solution is actually
# possible for these start values
#
   if   a[0]+b[0] < op( [1,2,1],
                                   solve
                                    ( 0.05*(x-0.01*(x+y))-10+0.05*(y-0.01*(x+y))-10=0 )
                                 )
#
# Soluion is possible sp generate the integer
# number of days
#
   then for n from 1 do
                  a[n]:= a[n-1]+0.05*(a[n-1]-0.01*(a[n-1]+b[n-1]))-10:
                  b[n]:= b[n-1]+0.05*(b[n-1]-0.01*(a[n-1]+b[n-1]))-10:
                  if       a[n]+b[n]<0
                 then break
                 fi
            od:
            n;
    else printf( "\t\t No solution possible")
    fi;

 

Generally midpoint methods are invoked when the BVP is singular at either of the endpoints - which occurs for your system. Use of such methods is invoked by setting the option method=bvp[midrich], or method=bvp[middefer].

When I try this I get a new error message:

Error, (in dsolve/numeric/bvp) uanble to achieve continuous solution with requested accuracy of .1 with maximum 128 point mesh (was able to get .62), consider increasing `maxmesh` or using larger `abserr`

I can get around this by setting the dsolve option abserr=1.0, and this produces output plots for all cases - see the attached.

It may be possible to reduce the value of abserr and still obtain sensible output (because 1.0 is a bit high, given the magnitude of term in the computed solution). This may require increasing the value of the option maxmesh.

odeProb.mw

 

 

Just because alternatives are good

This one hnerates all 3*3 and 4*4 matrices and stores these in lists L3 and L4 respectively. (it also outputs the first and last 10 of these matrices, and checks the total number of such matrices, which should be 512 and 65536 respectively)

   restart;
#
#  Generate all 3x3 and 4x4 binary matrices
#
   for n from 3 by 1 to 4 do
         L||n:= Matrix~( combinat:-permute
                                   ( ListTools:-Flatten
                                     ( [ combinat:-permute
                                          ( [0$n,1$n], n)$n
                                       ],
                                      1
                                    ),
                                   n
                                )
                              ):
   od:
#
# List the first five and last five of these
# binary matrices
#
   L3[1..10];
   L3[-10..-1];
   L4[1..10];
   L4[-10..-1];
#
# Check how many matrices there are - should be
# 2*9=512 an 2^16=65536
#
   numelems(L3);
   numelems(L4);

 

Maple 18.02 produces u(x, t, z) = -(diff(_F2(t, x), x)) as the solution of your first pde
Maple 2015.2 produces u(x, t, z) = -(diff(_F2(t, x), x)) as the solution of your first pde
Maple 2016.2 produces u(x, t, z) = -(D(H))((-c*t+x)/c)/c as the solution of your first pde

All three Maple versions give the same solution for your second pde - so I'm going to ignore that

I hope that it is reasonably obvoius that all of the above solutions satisfy the pde. The problem is with the boundary condition.

If (in Maple 18.02) I extend the your code somewhat to

restart;
h:= (x,t) -> H(x/c-t);
pdsolve( { diff(u(x,t,z),z)=0,
                  D[1](h)(x,t)+u(x,t,1)=0
                },
               u(x,t,z)
            );
subs( %, D[1](h)(x,t)+u(x,t,1)=0);
solve(%, u(x, t, 1));

Then it is fairly ovious that Maple18.02 agrees that u(x,t,1)= -(D(H))((-c*t+x)/c)/c. However what it fails to appriciate is that this solution is valid for all 'z', not just 'z=1'. Can't think why :-(

Can only suggest that you upgrade

 

The solution methods which you are trying will attempt to find an analytic solution for the problem - involving 9 variables. Some of these variables are raised to the power 20, and they occur in all sorts of sum/product combinations. An analytic solution may be possible(?) but I would expect it to take forever, Something you have already experienced.

So treat it as an optimization problem: I briefly tried Maple's inbult Optimization package, and iddn't get very far (although I didn't try really hard!).

On the other hand, if I use the DirectSearch package (a free add-on for Maple available from the MapleSoft Applications Centre), then I get the solution (in less than second - couldn't be bothered to time it)

Aiso = -3.16961150439891*10^(-8),
Do = 0.225559961135453e-1,
Gc = 3.15457322777402*10^(-7),
Tcr = 6.17263068490527,
a = .905862311898373,
b = .917199730481274,
c = 2.16557158762190,
mu = .931431766100372,
t = 2.41882108966471

As the attached worksheet demonstrates, Det1 with these values evaluates to 5.03615015142914*10^(-56) - whihc you have to admit is prettty close to the requred value of zero. If I played with the options ofn the DirectSearch:-SolveEquations() command then I could probaly reduce this residual error further.

My code is attached, but note that this will not run unless you have downloaded/installed the DirectSearch package from MapleSoft

optProb.mw

Analysing your ODE system, considering the number of independent variables, and their associated derivatives, I conclude that you need 28 boundary conditions. (Might be 29 depending on whether or not a value for the parameter 'omega' is given, or has to be derived from an additional boundary condition)

Analysing your boundary conditions: there are 28, which looks good. However these 28 boundary conditions contain 52 'unknowns'. Exactly how is Maple supposed to resolve a system of 28 equations in 52 unknowns?????

See the attached for confirmation oif the above argument

BCproblem.mw

Aside from a couple of warnings about implicit local variables, your code works for me as well

I would not define variables as 'global' within a module - if they are defined as 'local' at the top-level of the module, then they are available to all procedures within the module, whihc is probabl  what you want

Check out the attached for many (slight) variations on your module definition and module:-procedure calling process. I'd probably use the last of these as default

modules.mw

(and I'm not sure that I do!)

Tours2 contains 15 lists, which vary in length from1 to 4, so the obvious(?) way to organize the results of Tours_Distances calculation is to use a 4x15 matrix. Obviously some entries in this matrix "won't exist", so I have used 0 as a placeholder.

Having organised the data this way, then I think the second part of your request amounts to selecting the column indices of this matrix where all entries are <= some test value. (or maybe <, not sure precisely what you want). These indices can also be used to select the appropriate entry from the Tours2 list.

If I have understood the requirement, then the attached may be helpful

tours.mw

I could probably "tidy" this a likttle, but am reluctant to do any more work, because I may have completely misunderstood the requirement

Just because alternatives are good!

p1:=plot(sin(x), x=-Pi..Pi);
plottools:-rotate( p1, Pi/2);

 

  1. Your first system of ODEs/BCs can be solved using the inbuilt dsolve() command without reference to method (ie use of laplace transforms)
  2. Your first system of ODEs/BCs can also be solved using the inbuilt dsolve() command, whilst forcing the use of the laplace transform method. A minor manipulation of the result of this approach shows that it is equivalent that obtained in (1) above
  3. Both (1) and (2) above also apply to your second system of ODEs/BCs
  4. What are you hoping to achieve/prove by using Laplace transforms to solve these systems???

Check out the attached

solveODEs.mw

  1. Maple can actually solve your PDE explicitly
  2. The "conventional" way to check whether or not a function is a solution for a PDE is to use pdetest(sol,PDE). Trying this with your suggested solution, pdetest() fails. So I'm pretty sure that your suggested function is not a solution of the PDE

Check out the attached for more detail

pdeCheck.mw

@mschneider 

This code gnerates a single random number (in degrees) and then multiplies it by 1,2,3,4 (and produces a degrees-> radians conversion). Hardly foru random numbers!!!

A *much*  better approach would be

restart;
with(RandomTools):
randomize():                        # randomize seed for random number
                                              # generator

n:=rand(-90..90):                  # initialise random number generator

seq( [j, j*2*Pi/360],               # output generated random number (in
                                              # degrees) and in radians

         j in [ seq( n(), i=1..4)]  # generate list of 4 random numbers
                                              # uniformly distributed on -90..90

   );

 

 

First 166 167 168 169 170 171 172 Last Page 168 of 207