tomleslie

13876 Reputation

20 Badges

15 years, 163 days

MaplePrimes Activity


These are replies submitted by tomleslie

the 'view' option, as in the code

plots:-display( [ plot( sin(t), t=-Pi..Pi, color=red),
                  plot( 2*sin(t), t=-2*Pi..2*Pi, color=blue),
                  plot( 4*sin(t), t=-4*Pi..4*Pi, color=green)
                ],
                view=[-4*Pi..4*Pi, -1..1]
              );
plots:-display( [ plot3d( x*sin(t), x=0..1, t=-Pi..Pi,     color=red, style=surface),
                  plot3d( x*sin(t), x=0..2, t=-2*Pi..2*Pi, color=blue, transparency =0.7, style=surface),
                  plot3d( x*sin(t), x=0..8, t=-4*Pi..4*Pi, color=green, transparency =0.7, style=surface)
                ],
                view=[0..1, -4*Pi..4*Pi, -1..1]
              )

which will produce the plots

 

 

 

 

 

 

Maple comes with a package called 'Finance' - see the help at ?Finance

This includes commands for AmericanOption, EuropeanOption and BermudaOption (although not AsianOption). My knowledge of financial options is restricted to European and American, so I'm not sure whther this package would be helpfiul or not - but you might want to consider it

@Carl Love 

trying to avoid assumptions about "intent"

@mclaine 

Use the icon

from the Mapleprimes toolbar. This will produce a pop-up window, and you can cut/paste from your Maple worksheet to this window. Probably best to delete all the output in your Maple worksheet first, so that you are only pasting "input" code

@mmcdara 

back to Maple 18. The nly differebce I can detect is that some point the diff() command changed. For example in Maple 18 it has to be applied elementwise to a vector

restart;
  interface(version);
  Sys:=diff~(<x1(t),x2(t)>,t)=~<-4,-2;6,3>.<x1(t),x2(t)>+<2/(exp(t)+1),-3/(exp(t)+1)>;
  ics:=<x1(0)=0, x2(0)=ln(2)>;
  dsolve([ Sys, ics]);

will produce

 

@Kitonum 

input in vector form, so the following will also work

 restart;
  Sys:=diff(<x1(t),x2(t)>,t)=~<-4,-2;6,3>.<x1(t),x2(t)>+<2/(exp(t)+1),-3/(exp(t)+1)>;
  ics:=<x1(0)=0, x2(0)=ln(2)>;
  dsolve([ Sys, ics]);

produces

 

@Carl Love 

Unfortunately, this matrix won't export to Excel - no error message, no warnings and no output file.

I was unable to export the "indexing" entry to Excel with either round ('()') or square ('[]') parentheses, without the string conversion - which I admit is a fairly ugly workaround (but it works!)

@mmcdara 

On reflection I'm happy to point out that my original answer is the *wrong* way to do it!.  If at all possible you should use "exact" arithmetic by converting all parameters to rationals - so when you talk about entities such as a*X1 + (1-a)*X2 then make sure that 'a' is a rational. Ony if this is impossible for some reason should you resort to the crude "brute force" approach of increasing the setting of Digits

@okokoabraham 

You can't find a meaningful maximum because as you have specified the problem, one of the entries in the resuts matrix is Float(undefined) So what is Float(undefined) - well infinity woud be a good guess, but if that concept bothers you then just think about  which other undefined floating-point number you want??

Now you can generate maximum values, index of maximum values and  Excel files using   , but the problem with all of these is the existence of the undefined floating point value. Maple will always report this as a maximum (after all it could be infinity).

The final execution group in the attached will return the maximum value (regrettably always Float(undefined)), the first occurrence of this value (always [2,1]) and output the whole matrix to an Excel 'xlsx' file. Excel will complain about opening any of these files because of the Float(undefined) but if you just click the *obvious* buttons when opening any of these files with Excel, you will end up with an Excel worksheet whhc just contains a lot of #NUM! entries (becuase it reaaly isn't sure what to with Float(undefined))

In the attached you will have to change the entry for the path assignment to something which exists on your machine . The attached uses

path:="C:/Users/TomLeslie/Desktop/";

which exists on my machine (basically my Desktop) but this won't exist on your machine - so change it

pdeProb4.mw

 

 

@vs140580 

If you are using the character '.' as a simple separator between matrix entries, what do you use as a decimal point when the matrix entries are floating point? In other words if python generated a 2X2  matrix with the four floating point numbers 1.1, 1.2, 1.3, 1.4 how would this be output? It can't be

A:=[ [1.1. 1.2]
       [1.3. 1.4]]

because that would be a 2X4 matrix with integer entries 1, 1, 1, 2, 1, 3, 1, 4

when you post a homework question here, answers will only be supplied if you rpovide a worksheet showing that you have at least *attempted* the problem.

As a hint, a trivial implementation of the algorithm at https://en.wikipedia.org/wiki/Bisection_method ought to give

because exactly the same question was asked (and answered) here

https://www.mapleprimes.com/questions/231944-How-To-Find-A-Quintic-Polynomial-On-Maple-

Except for the question of whether or not a cubic will also satisfy f(1) = 2, f(2) = 3, f(3) = 4, f(4) = 6, f(5) = 10. A trivial modification to the code in the above will show that the cubic

a__3*x^3 + a__2*x^2 + a__1*x + a__0

with

[a__0 = 0, a__1 = 17/6, a__2 = -1, a__3 = 1/6]

will satisy the requirement

from

animate( pointplot,  [ ['rhs(sol(t)[3])',0], symbol=solidcircle, color=red, symbolsize=20], t=0..5, frames=200, axes=boxed);

when I execute your worksheet in Maple 18 (ie ~seven years old) the returned answer for the final command, ie

Galerkin(L1, S, 0, Pi, 3)

is 0

This is also true for the current Maple release (2021). I note that you are using Maple 13  (~twelve years old), so this may just be a version issue.

Unfortunately I can't really debug anything earlier than Maple 18  :-(

pdeProb3.mw

I have (more-or-less) repeated the same code, but this time with a lot of comments, which will (hopefully) help you work out what is going on at each stage

A warning: you say that you are actually interested in the quantity w(x,t)/ (A*cos(2*t*Pi)). For obvious reasons, this quantity will be infinite whenever cos(2*t*Pi)=0, which occurs at t=1/4, 3/4, etc.

In the attached file I have added an execution group which generates matrices/plots of w(x,t)/ (A*cos(2*t*Pi)). In these plots you can see what happens at t=1/4, 3/4, etc.

  restart;
  In := 5.75*10^(-12):            
  M := 1000:
  E := 10^12:
  Vval := [seq( j, j=0..1000, 100)]:
  m := 2300:
  K := 10^9:
  A := E*In:
  B := M*V^2:
  C := 2*M*V^2:
  F := M + m:
  G := K:
  tmax := 0.05:
  xmin := 0:
  L := 1:

  pde := A*diff(w(x, t), x $ 4) + B*diff(w(x, t), x $ 2) + C*diff(w(x, t), x, t) + F*diff(w(x, t), t $ 2) + G*w(x, t);
  bc := w(0, t) = 0, w(L, t) = 0, D[1, 1](w)(0, t) = 0, D[1, 1](w)(L, t) = 0:
  ic := w(x, 0) = 0, D[2](w)(x,0)=1:
#
# Define a function which returns the value of w(x,t) for any supplied
# numeric values 'x' and 't'
#
  getVals:= (space, time)-> rhs(pdsA:-value( w(x,t) )(space,time)[3]):
#
# For any of the values in the above list of Vval
#
  for k from 1 by 1 to numelems(Vval) do
    #
    # Solve the pde for V=Vval[k]
    #
      pdsA := pdsolve( eval(pde, V=Vval[k]), {bc, ic}, numeric);
    #
    # Produce a matrix whihc populates a matrix with values of
    # w(x,t). The (i,j)-th element of the matrix corresponds to
    # the value of w(x,t) at x=(i-1)/10, t=(j-1)/10. In other
    # words it produces values w(x,t) for x, t from 0 to 1 in
    # steps of 0.1.
    #
    # The size of the matrix, ranges of x and t, spacing of
    # x, t are all arbitrary. For example if one wanted x
    # values from 0 to 1 in steps of 0.05, and t-values from
    # 0 to 5 in steps of 0.2 one would have
    #
    # Matrix(21, 26, (i,j)-> getVals( (i-1)/21, 5*(j-1)/26));
    #
    # In fact one could (should??) generalise this with
    #
    #  xmax:=1;
    #  xstep:=0.05;
    #  tmax:=5;
    #  tstep:=0.2:
    #  Matrix( xmax/xstep+1,
    #          tmax/tstep+1,
    #          (i, j) -> getVals( (i-1)*xstep,
    #                             (j-1)*tstep
    #                           )
    #        )
    #
    # Store these matrices in the table 'M', so that M[k]
    # stores the matrix of results for V=vVal[k]. May not
    # be necessary, if each matrix is to be used "immediately"
    # to calculate something else
    #
      M1[k]:= Matrix(11, 11, (i,j)-> getVals((i-1)/10, (j-1)/10));
    #
    # Generate a 3d-plot of w(x,t) for the value V=Vval[k]
    # and again store for future reference
    #
      plt1[k]:= pdsA:-plot3d( w(x,t), x=0..1, t=0..1);
  od:
#
# Example results
#
  M[3];
  plt1[3];
#
# Op seems interested in the quantity w(x,t)/(A*cos2*t*Pi),
# so repeat the above loop where the output matrices and
# plots contain these quantities (rather than just w(x,t).
#
  for k from 1 by 1 to numelems(Vval) do
      pdsA := pdsolve( eval(pde, V=Vval[k]), {bc, ic}, numeric);
      M2[k]:= Matrix(11, 11, (i,j)-> getVals((i-1)/10, (j-1)/10)/(A*cos(2*(j-1)/10*evalf(Pi))) );
      plt2[k]:= pdsA:-plot3d( w(x,t)/(A*cos(2*t*Pi)), x=0..1, t=0..1);
  od:
  
#
# Example results
#
  M2[3];
  plt2[3];

 

First 35 36 37 38 39 40 41 Last Page 37 of 207