tomleslie

13876 Reputation

20 Badges

15 years, 165 days

MaplePrimes Activity


These are answers submitted by tomleslie

using the big green up-arrow in the Mapleprimes toolbar.

The attached worksheet shows a "toy" example, with exact values, approximate values, absolute errors and relative errors combined into a single matrix

errTab.mw

in  processXL.mw will read xlip.xlsx and output xlop.xlsx

Note that you will have to change the string 'dir' in the Maple worksheet to something valid for your machine/installation

that using the same name for indexed and unindexed variables *may* be a problem, so I fixed this. However you do have other issues, mainly related to the fact that your "zeroth" equation is actually an ODE, whilst subsequent equations are PDEs. This i getting Maple a bit confused.

The attached *seems* to work

odeProb.mw

You are integrating with respect to a named variable 's'. In simple kinematics problems,  the variable name 's' often represents a distance, and therefore has units of length (say, for example, metres). Now this might get a little confusing because there will be two quantities 's' in the solution: one will be the representation of the unit 'seconds' and one will be the (quantity of) distance with unit 'metres'. Maple will distinguish between these, by representing the variable name 's' in italic font, and the unit 's' in upright font.

If you find this confusing, you can change the integration variable to a different name - for example if it is a distance, then 'd' might be an appropriate choice. Either way it doesn't make a real difference to the answer, as will be shown by the following code

  restart:
  with(Units[Standard]):
  integ:=10*Unit(metre/second^2);
  int(integ, s*Unit(metre));
  int(integ, d*Unit(metre));

because the answers are 10*s(metre^2/second^2) and  10*d(metre^2/second^2), respectively

as far as I can tell

pars := [K = 2/(3*R*sqrt(h__0)), tau = (2*p*A)/(3*R*sqrt(h__0))]

see the attached worksheet

tf.mw

By the way in your original worksheet you somehow(?) managed to enter the character '1' as an atomic variable, rather than the simple integer 1. I have no idea how you managed to achieve this - some obscure 'feature' of 2D math input maybe.

It is why the numerator of the expression posted in your original worksheet looks like 1.000000000*1

 

 

as it was the last time you asked it.

If I just ignore your description of the problem (and your worksheet), the following code appears(?) to generate the matrix you want

restart;
interface(rtablesize=30):
M1:=3:M2:=3:M3:=3:
M:= Matrix( [ [ 0$(M1*M2*M3) ] $ (M1*M2*M3-3),
              seq
              ( [ seq
                  ( seq
                    ( seq
                      ( (t^p)*((1/2)^q)*((1/2)^r)/p,
                        p=1..M1
                      ),
                      q=0..M2-1
                    ),
                    r=0..M3-1
                  )
                ],
                t=0..1,1/2
              )
            ]
          );

genMat.mw

(on my machine), the two operations return

memory used=332.26MiB, alloc change=40.00MiB, cpu time=2.93s, real time=2.93s, gc time=109.20ms

and

memory used=315.82MiB, alloc change=0 bytes, cpu time=3.15s, real time=3.15s, gc time=343.20ms

So the discrepancy in cputime (3.15s-2.93s=0.22s) appears to correspond (more or less) to the "extra " garbage collection time (343.20ms-109.20ms=234.00ms)

 

 

construct the data to be tabulated as a "simple" matrix, as in the attached code

datMat.mw

which will produce

As vv suggests, the inline assignment feature is probably your best bet. According to the help, this feature was actually introduced in Maple 2018

You can achieve the same effect using the assign() command using the code below

  restart;
  str:= "A";
  x:= 10;
  str:= cat
        ( str,
          `if`
          ( x=10,
            [ assign('x', 11), " it was 10"][] ,
            [ assign('x', 9),  "it was not 10"][]
          )
        );
  x;

This works all the way back to Maple 18. (Maybe(?) earlier, but Maple 18 is the earliest version I happen to have installled.)

 

 

and the one seem to be most interested in is described comprehensively here

https://en.wikipedia.org/wiki/Matrix_representation_of_conic_sections.

However (just for fun!) it is also possible to do this operation (more intuitively?) using Maple's geometry() package with the code below

  restart;
#
# Initialise
#
  with(geometry):
  _EnvHorizontalName := 'x':
  _EnvVerticalName := 'y':
  point(oo, [0,0]):
#
# Define the conic
#
  conic( C1, 5*x^2+4*y*x+8*y^2+16*x-8*y-16):  
#
# Center the conic at the origin
#
  translation( C2, C1, dsegment( d1, point( p1, coordinates( center(C1) ) ), oo )):
#
# Rotate so that the foci lie along the x-axis
#
  cc:= map(coordinates, foci(C2))[1]:
  rotation(C3, C2, arctan(cc[2]/cc[1]), `if`(cc[2]<0, clockwise, counterclockwise)):
#
# Draw the three ellipses produced above
#
  draw( [C1, C2, C3],
        color=[red, green ,blue],
        axes=normal,
        legend=["original", "translated", "rotated"],
        legendstyle=[font=[times, bold, 20]]
      );
#
# Equation of translated/rotated conic (and
# its "canonical" form).
#
  eq1:=Equation(C3);
  t1:=select(type, lhs(eq1),numeric):
  (eq1-t1)/abs(t1);

ellCan.mw
 

but a quick web search suggests that you can 'export' data from this application in three different formats which Maple cal read - namely CSV, TSV and Excel.

So export from Apple:-Numbers in one of these formats, then use either Import(), or ExcelTools:-Import(), depending on which format you pick

as shown in the attached

odeSol.mw

which produces

[t = 1.0, x(t) = 1.15363937245946]

and

 

 

 

 

the code below

V:=Vector[row]([ 2,3,1,9]);
W:=V^~2;
U:=sin~(V);

 

that the attached worksheet fixes all your problems. As a general rule you should use the eval() command rather than the subs() command, whem yoi just want to evaluate an expression for a given list of parameters. You should also avoid using assign(), when the desried operation can be achieved by judicious use of an eval() statement

Your implementaion of the spline algorithm with "natural" endpoints appears to agree with results given by the built-in version.

splineProb.mw

why do the string entries exist at all? The code

  restart;
  B:=[ [601,1201,2401,4801,9601],    [2.87E-19,7.94E-21,7.94E-23,1.03E-24,5.91E-26],
       [2001,4001,8001,16001,32001], [3.30E-2,5.37E-4,8.47E-6,1.33E-7,2.08E-9],
       [183,365,728,1476,2910],      [4.58E0,7.54E-8,2.20E-11,4.95E-14,9.15E-15],
       [1621,3020,6166,12022],       [2.95E-3,8.51E-6,3.39E-8,2.51E-10]
     ]:
  plots:-display(  seq( plot(log[10]~(B[j]), log[10]~(B[j+1])), j=1..7,2),
                   legend = ["BFFM", "BNM", "BHM", "ARKN"],
                   color= [ red, gold, blue, black],
                   symbolsize = 15,
                   axes = framed, 
                   symbol = [box, circle, solidbox, solidcircle],
                   style = "pointline",
                   symbolsize = 15,
                   labels = [typeset(log__10(`NFE`)), typeset(log__10(`Max Err`))]
                );

produces the figure below

First 55 56 57 58 59 60 61 Last Page 57 of 207