tomleslie

13876 Reputation

20 Badges

15 years, 175 days

MaplePrimes Activity


These are answers submitted by tomleslie

Tried your code snipruns  in Maple 18, Maple 2015, Maple 2016, Maple 2017, and Maple 2018. No errors in any of them.

'mverbatim' is something which seems to crop up when Maple is unable to parse 2-D input.

From the above, I have only have 2 suggestions

  1. Post a more complete piece of code, beginning with a restart() command which exhibits the problem
  2. Don't use 2-D input :-)

Type

?Maple Programming Guide

at the Maple prompt. This should open a new worksheet.

In this worksheet, you want the "Advanced Connectivity" section (section 14, for current Maple installations). Then check out the subsection titled "The Maple Command Line Interface" (subsection 14.4, for current Maple installations)

I can only suggest a careful reading of the pdsolve/numeric help page. At the risk of oversimplifying this "help" page

  1. The pdsolve(...,numeric,..) command will return a 'module', comprising four "methods" for displaying/manipulating solutions. These "methods" are
    1. plot3d(). The pdsolve(.., numeric,..) command is restricted to systems of 2 (or fewer) independent variables. With 2 independent variables, plotting one or more of the dependent variables of the system requires a 3-D plot, which is what you get with this method. You can also plot (more-or-less any) function of the dependent and independent vaiables
    2. plot(): This more or less produces 'slices' through the 3-D plots produced above: ie fix one of the independent variables, then plot some function of the dependent and independent variables, whilst varying the other independent variable
    3. value() for producing numerical values
    4. animate() for producing animations (obviously)
  2. The attached merely scratches the surface of the possibilities for your specific problem.

NULL

restart;
v := 1: L := 12:
PDE := (D[2, 2](u))(x, t) = v^2*(D[1, 1](u))(x, t);
BC := u(0, t) = 0,
      u(L, t) = 0:
IC := u(x, 0) = 3*exp(-(x-6)^2)-3*exp(-36),
      (D[2](u))(x, 0) = sin(x):

(D[2, 2](u))(x, t) = (D[1, 1](u))(x, t)

(1)

sol := pdsolve( PDE, {BC, IC},
                numeric,
                spacestep = 1/200,
                timestep = 1/100
              );

_m669669728

(2)

sol[animate]( u(x, t),
              t = 0 .. 20,
              frames = 100,
              scaling = constrained,
              labels = ["x", "u(x,t)"],
              labelfont = [Arial, 14]
            );

 

#
# technically when one uses the construct
# sol|:=pdsolve(..., numeric,...) then what
# is returned is a solution "module", which
# enables several "methods", such as
#
# sol:-plot() - basically fix one variable
#               plot some function of the
#               dependent variable for the
#               given value of the fixed
#               variable while varying the
#               other
# sol:-plot3d() - basically plot some function
#                 of the independent variables
#                 and the dependent variables
# sol:-anumate() - OP seems to hve worked this
#                  one out
# sol:-value() instead of producing plots just
#              return vaues for some function of
#              the independent and dependent
#              variables, for specified values
#              of the independent variables

#
# Playing with these possibilities in no
# particular order. The most obvious(?)
# thing to plot is just the solution u(x,t)
# for all x, t - which is a 3d-plot
#
  sol:-plot3d(u(x,t), t=0..20, x=0..10);
#
# Rather than produce a plot of just the
# dependent variable, one can plot more or
# less any function of the dependent and
# and independent variables as in (the
# probably meaningless
#
  sol:-plot3d( u(x,t)*x*t,  t=0..20, x=0..10);

 

 

#
# One can use the 2D plot() to produce 'slices'
# through the above 3d-graphs, for example
#
  sol:-plot(u(x,t), t=10, x=0..10);
  sol:-plot(u(x,t), x=10, t=0..10);

 

 

#
# Many variants on the 'value' method
# but just suppose you want to know the
# value for some given pair of x,t
#
  sol:-value(u(x,t))(2,4);
#
# Or some function of the dependent and
# independent variables
#
  sol:-value(u(x,t)*sin(x)+t^2)(2,4);

[x = 2., t = 4., u(x, t) = .811862711805438231]

 

[x = 2., t = 4., u(x, t)*sin(x)+t^2 = 16.7382246747804047]

(3)

 

Download pdesol.mw

as in the attached

restart:
h:=12:base:=7.8:A:=1.12:w:=1.5:
lY:=w/sin(A):
depth:=(base/2-lY)*tan(A):
#Set notation brackets - ignores this
#solve({tan(x)=2*(h-depth-y)/w, z=w*cos(A)+w*sin(A)/tan(A+x), uY+z+depth=h},{x, y,z});
solve([tan(x)=2*(h-depth-y)/w, z=w*cos(A)+w*sin(A)/tan(A+x), uY+z+depth=h],{x, y,z});

{x = -1.120000000-1.*arctan(6750753315./(-0.3366062673e11+5000000000.*uY)), y = .7500000002*tan(1.120000000+arctan(6750753315./(-0.3366062673e11+5000000000.*uY)))+7.385649018, z = -1.*uY+7.385649016}

(1)

 

Download soleq.mws

You mean something like?


 

with(plottools):
with(plots):
l1:=line( [0,0], [0,1]):
l2:=line( [0,1], [-t,1]):
l3:=line( [0,1], [ t,1]):
l4:=line( [-t,1], [-1,2]):
l5:=line( [t,1], [1,2]):
d:=display([l1,l2,l3, l4, l5], color=red, thickness=6):
display(seq( d, t=0..1, 0.05), insequence=true, axes=none);

 

 


 

Download morph.mw

Wee I do a simple plot of your equation over a very restricted range of values for x, -0.01..0.01, and I get the figure shwn in the attached. If the *solution* fo your equation is the point at which the dependent variable is zero - then you have an awful lot of these, even in thi ting range of of the independent variable. Before I go any further, please define a lot more carefully what you mean by the statement

" How can I solve this equation?"

I mean you want all of the values where the function is zero? some of them?, any one in particular?

NULL

restart

A := 1.66123496405779610264482465216*10^48*x^12*exp(-(3.87000237787905620615465263885*I)*Pi/x)*exp(-(.321534474251124888739020720131*I)*Pi/x)+2.11374922567922298689120113111*10^50*x^12*exp(-(3.87000237787905620615465263885*I)*Pi/x)/(exp((.160767237125562444369510360066*I)*Pi/x))^2+7.16344924069934889468886048304*10^50*x^12*exp(-(.321534474251124888739020720131*I)*Pi/x)/(exp((1.93500118893952810307732631942*I)*Pi/x))^2+9.11474632627216348403905833199*10^52*x^12/((exp((1.93500118893952810307732631942*I)*Pi/x))^2*(exp((.160767237125562444369510360066*I)*Pi/x))^2)-3.86425849708968323906554386738*10^50*x^10*exp(-(3.87000237787905620615465263885*I)*Pi/x)*exp(-(.321534474251124888739020720131*I)*Pi/x)-9.49728635677626263805870840780*10^51*x^10*exp(-(.321534474251124888739020720131*I)*Pi/x)/(exp((1.93500118893952810307732631942*I)*Pi/x))^2-4.63662778304304619471230112279*10^52*x^10*exp(-(3.87000237787905620615465263885*I)*Pi/x)/(exp((.160767237125562444369510360066*I)*Pi/x))^2+4.83122406362728749484124839315*10^51*x^8*exp(-(3.87000237787905620615465263885*I)*Pi/x)*exp(-(.321534474251124888739020720131*I)*Pi/x);

0.1661234964e49*x^12*exp(-(12.15797104*I)/x)*exp(-(1.010130342*I)/x)+0.2113749226e51*x^12*exp(-(12.15797104*I)/x)/(exp((.5050651711*I)/x))^2+0.7163449241e51*x^12*exp(-(1.010130342*I)/x)/(exp((6.078985521*I)/x))^2+0.9114746326e53*x^12/((exp((6.078985521*I)/x))^2*(exp((.5050651711*I)/x))^2)-0.3864258497e51*x^10*exp(-(12.15797104*I)/x)*exp(-(1.010130342*I)/x)-0.9497286357e52*x^10*exp(-(1.010130342*I)/x)/(exp((6.078985521*I)/x))^2-0.4636627783e53*x^10*exp(-(12.15797104*I)/x)/(exp((.5050651711*I)/x))^2+0.4831224064e52*x^8*exp(-(12.15797104*I)/x)*exp(-(1.010130342*I)/x)

(1)

plots:-complexplot(A, x = -0.01 .. 0.01, numpoints=1000);

 

NULL


 

Download cplot.mw

If I just take the code you posted, and your requirement that " I can't get all of the values of r out of the loop ", then I can get all the 'r-values' out of the loop. This may not be the best way to solve your problem, but I had to make so many guesses about the intent of your code, that it's the all I'm prepared to go with right now.

Note with all the guesses and asssumtions I had to make, 'r' comes out as 8, every time: change to the value of 't' and the definition of the procedure cumprob() may change this - but since you do not define these I  just have to guess.

#
# Need some random value for 't' just to make this
# worksheet executable - so I picked t-3
#
   t:=3:
#
# Need some random procedure called cumprob() just to
# make this worksheet executable - so I picked a simple
# squaring function
#
   cumprob:= x-> x^2:
#
# Load the NumberTheory package, just to make this
# worksheet executable
#
   with(NumberTheory):
#
# Now everyth8ing at least "functions" - wtf was the OP's
# problem again?? Seems to want all the values of 'r'
# which get generated in this loop: seems not to realise
# that every time (s)he computes 'r', it will overwrite
# the previous value. So specify 'r' as NULL, which just
# initialises a sequence then for each computed value of
# 'r' , add it to the *sequence* of values in 'r'
#
  r:=NULL:
  for i from 1 to 10 do
        realchoose := rand(0.0..1.0);
        o := realchoose();
        print(o);
        for q from 1 to 2^t do # this won't execute cos 't' is undefined
              if      cumprob(q)>=o # this won't execute cos cumprob is undefined
              then printf("measurement = %d\n", q-1); break;
              end if;
        end do;
        if      q-1=0
        then q:=2^t;
        end if;
        p := ContinuedFraction((q-1)/2^t);# this won't work unless the NumberTheory package is loaded
        cf := Term(p, 1..10);
        if       cf=0
        then cf:=1;
        end if;
        print(cf);
        cfmax := max[index](cf);
        cfmax1 := max(cf);
        if      cfmax1<10
        then cfmax:=5;
        end if;
        R := Convergent( p, cfmax-1);
        r := r, denom(R); # append the current value of denom(r) to previous
                                     # values
       print(r);
   end do:
#
# Now check the sequence of values obtained for 'r'
#
  r;

Maple is quite 'polite' about writing files in certain locations - after all you woulldn't want Maple to overwrite your whole "C" drive.

You may need to run Maple with administrator privileges in order to (over)write your Maple installation. However you normally start Maple (with a left-click), use a right-click and select "Run as Administrator" - then be very, very careful.

For some of the values of rho which you specify, the argument for the second boundary condition is complex.

In general you cannot solve complex-valued BVPs in Maple. You can solve complex-valued IVPs in Maple, so a shooting method construction might be possible.  However, I thought (I might be wrong) that even Maple's IVP solver was restricted to the case where the independent valiable is real, and one or more of the dependent variables is complex

One can trick the BVP solver for cases where only the dependent variable is complex - just by redefining it as a sum of real and imaginary parts, thus generating two real equations which can be solved as a system. However, I'm pretty sure that there is no equivalent approach for when the independent variable is complex.

Note that in 100000 iterations, one gets values in ranges 0..1, all the way up to 16..17. The following counts all of these

restart;
f:=x->1-2*(1/x-trunc(1/x))+1/x;
x:=50100;
A:=Array(0..20):
for j from 1 to 100000 do
      tmp:=f(x);
      p:=floor(evalf(tmp));
      A[p]:=A[p]+1;
      x:=tmp
od:
A;

 

makes it more understandable

>  

restart;
  with(Student[Calculus1]):

#
# define the function
#

   N := t -> 10 + 2*exp(-0.3*t)*sin(t):
#
# Plot the function
#

  plot( N, 0..10);
#
# Get the criticaal points for the function
#

  crits:=[seq( [t, N(t)] ,t in CriticalPoints( N(t), t=0..10))];

 

[[1.279339532, 11.30506973], [4.420932186, 9.491465045], [7.562524839, 10.19815631]]

(1)

 

Download crits.mw

if you upload the worksheet you have using the big green up-arrow in the Mapleprimes toolbar.

You also might want to check the help for the command

VectorCalculus:-Flux()

just type ?VectorCalculus:-Flux at the Maple prompt. As the help states, this will

compute the flux of a vector field through a surface in R^3 or a curve in R^2

 

 

restart;
BigProc:= proc(H::list,T::list)
                         local Form, i;
                         Form:=NULL;
                         for i from 1 to nops(H) do
                              Form := Form,(1 + add(H[j]*T[j],j=1..i))/(1 + (add(1/(H[j]*T[j]),j=1..i)));
                         end do:
                         return [Form];
                end proc:
BigProc([1,3,5],[3,6,8])

 

 

depending on the form you want.

restart;
solution := {p[1] = 2.788944999, p[2] = 4.940143518}, { p[1] = 15.29764736, p[2] = 4.946617373};
M1:=Matrix(convert~([solution], list));
M2:=rhs~(Matrix((convert~([solution], list))));

 

 

f:=piecewise(x<1, 2*x,
                       x=1, 4,
                       x>1, 3*x
                     );
plot( f, x=0..2, discont=true);

First 137 138 139 140 141 142 143 Last Page 139 of 207