6672 Reputation

17 Badges

10 years, 174 days

MaplePrimes Activity

These are answers submitted by tomleslie

In Maple 2015, either of the following produces a plausible answer

f1 := t -> sin(t);
f2 := t -> cos(t);
dsys := {diff(x(t), t) = x(t)*f1(t)+f2(t), x(0) = 3};
solution_procedure := dsolve(dsys, type = numeric, output = listprocedure);
f1 := t -> sin(t);
f2 := t -> cos(t);
dsys := {diff(x(t), t) = x(t)*f1(t)+f2(t), x(0) = f1(3)};
solution_procedure := dsolve(dsys, type = numeric, output = listprocedure);

Please post 'failing' code

Well apart from the arbitrary constant (which int() never provides), the following works for me

eqn1:=diff(u(xi), xi,xi)=a__0+a__1*u(xi)+a__2*u(xi)^2;
eqn2:=diff(u(xi), xi)*eqn1:
eqn3:=map(int, eqn2, xi):
isolate(eqn3, diff(u(xi), xi)^2);

It also follows the OP's 'manual' method

If you want to do it the "long" way, you will need to know the difference between an equation ('=') and an assignment (':='). The following will work


fsolve really does not like the term ln(-m0) - whihc is complex, and things go downhill from there.

This can be avoided with a little maniplation

# Define equation
# Mnipulate to combine ln() terms
  eqn:=combine(collect(eqn, vs), ln, 'symbolic');
# Assign parameters
  r:= 13100:
  g:= 9.81:
  m0:= 2.8e6:
# Solve for case where eqn=300
# specifying that solution  ar in the range 0..100
  fsolve(eqn=300, t, 1..100);
# Solve for case where eqn=300
# specifying that solution  are in the range -300..0
  fsolve(eqn=300, t, -300..0);
# Plot over the range -300..100
  plot(eqn, t=-300..100);





In the second, only solutions in the range 0..Pi/2 will be returned

Use one of the following

# Valid in Maple 2016
# Works in previous versions (but is
# 'deprecated' in Maple 2016

As well as the problems with 'implied multiplication'

  1. The first argument to plots:-sphereplot() is meaningless
  2. plots:-sphereplot() is deprecated. You should be using plot3d() with the option coords=spherical. (Unless you have a very old Maple)
  3. You cannot use plots:-fieldplot to plot a 3-D vector field, you need to use plots:fieldplot3d()

See the attached for more detailed explanations/examples

I (occasionally) share your confusion with the correct way to apply the output of a dsolve/numeric command as the input of a subsequent command. However the code in the following (if a little clumsy), seems to provide the answers for your pde.

I have incuded a couple of extra plot() commands at the end, to give some idea of the 'scope' of output information which is available

  1. I am somewhat surprised that no convolve function exists outside the AudioTools and SignalProcessing packages, both of which only accept 'numeric' values. If I had 'numeric' values I would tend to use the latter, if only becuase it accepts simple Arrays as input
  2. It is not too difficult to write your own convolution function, as in the attached. A caveat: convolution is one of these functions which can be calculated "efficiently" - or not. The code in the attached is as simple-minded as possible, and as the examples show, works for most "sensible" 1-D data types. Compared with either AudioTools:-Convolution(), or SignalProcessing:-Convolution() it is probably very inefficient. But it does work with (1-D) structures containing symbolic data
  3. If you are interested in 2-D convolution, then I suggest you check ImageTools:-Convolution()

The followng is just one possibility. Note that you will have to change the filePath to something appropriate for your installation

# Use a sequential formatted print statement
# to write to simple text file
  fname1:="C:/Users/TomLeslie/Desktop/txtop1.txt": #OP needs to change this
  ( fprintf
    ( fname1,
      "%12.8f, %12.8f\n",
        x, fy(x)
    x=0..1, 0.1

If I check your worksheets with

  1. A loop with 'J' running from 15 to 16
  2. A single value of J=16

then the plots for J=16 differ - not by much - but they are different!

So it seems that any time your loop executes for a single 'J-value', the answer is different from the corresponding 'J-value', with the loop performing multiple times.

I traced this behaviour to the fact that you are reusing the value 'k'.

  1. It is assigned to 0.524 prior to loop execution
  2. So first time through the loop, the above value of 'k' will be used in the computation of omega_e and all subsequent dependent quantities (I assume that this is deliberate)
  3. However also first time through the loop, the value of 'k' is reassigned to 1.25, apparently purely for use in plot generation???
  4. This means that second time through the loop, the value of 'k' being used in the computation of omega_e wil be 1.25, not 0.524
  5. So if you run the loop once with J=16, your answer will be calculated using k=0.524. If you run the loop twice, with J=15..16, then the answer for J=16 will be calculated using k=1.25 - and these are different.
  6. I fixed this problem by changing the name of the variable to 'kk' in all of the plot setup stuff. See the attached worksheet

If I now double check, by running your example of J=15..18 versus running the loop once at J=18 then the plots for J=18 seem to be the same.

There is a lot of other stuff in this worksheet which is a bit untidy/inefficient, but this is not worth doing anything about until/unless you confirm that the basic problem has been solved.

I think the following code is OK: at least it clears up the problem with 'epsilon'.

You do have to be pretty careful when simulataneously using change of variables, and compact display (so you can't see what the variables are!) - so I inserted a couple of 'show' commands so that I could keep track

In your declaration of 'chi' and 'cont', you use both the symbol 'k', and the function 'k(s)' - is this deliberate?

  ( u(x, n, q, t),
    v(x, n, q, t),
    w(x, n, q, t),
    p(x, n, q, t)
  chi := 1/(1-n*k(x));
# OP uses 'k' in the following and 'k(x)' in the
# above - is this deliberate?
  cont := chi*diff(u(x, n, q, t), x)+diff(v(x, n, q, t), n)+diff(w(x, n, q, t), z)-v(x, n, q, t)*k*chi;
  ( u(s, Y, z, t),
    v(s, Y, z, t),
    w(s, Y, z, t),
    p(s, Y, z, t)
  contTrans := dchange
                       ( { n = Y+h(s),
                             q = z,
                             x = s
                         [s, Y, z]
# Check variable setup in contTrans in "standard"
# notation
  ( u0(s, Y, z, t),
    v0(s, Y, z, t),
    w0(s, Y, z, t),
    p0(s, Y, z, t),
    u1(s, Y, z, t),
    v1(s, Y, z, t),
    w1(s, Y, z, t),
    p1(s, Y, z, t)
  contLinearised := subs
                               ( { p(s, Y, z, t) = p0(s, Y, z, t)+epsilon*p1(s, Y, z, t),
                                    u(s, Y, z, t) = u0(s, Y, z, t)+epsilon*u1(s, Y, z, t),
                                    v(s, Y, z, t) = v0(s, Y, z, t)+epsilon*v1(s, Y, z, t),
                                    w(s, Y, z, t) = w0(s, Y, z, t)+epsilon*w1(s, Y, z, t)
  contExpand := expand(contLinearised);

whether you just want

a simple plot of the trajectories of the moving disks, or

to draw the two trajectories as animations?

I have added code to your worksheet which does both of the above. See below


In your first example _C1 is arbitrary, so

is a 'general" solution for your original ODE.

With y(x)=0, the above merely reduces to _C1=0, and since _C1 is arbitrary, _C1=0 is allowed and so the possibility y(x)=0 is "contained" within this "general" solution

In your second example y(x)=0 is an acceptable solution (provided that _C1=0), but there is also a further solution y(x)=-1/x, which works irrespective of the constant of integration

In both cases I think that Maple has provided the most general solution(s) possible - you just have to know how to interpret them

Try the code

expr:=(x-y)^2+(x-z)^2+(z-x)^2 = 3;
plots:-implicitplot3d(expr, x=-1..1, y=-1..1, z=-1..1);

which will produce a plot.

One thing I doubt about your originally posted expression is the existence of the (x-z)^2 and (z-x)^2 terms. For real x,z, these two terms are identical - did you mean that?

First 111 112 113 114 115 116 117 Last Page 113 of 138