tomleslie

13876 Reputation

20 Badges

15 years, 178 days

MaplePrimes Activity


These are answers submitted by tomleslie

By default the LinearAlgebra package in Maple will use "hardware floats" (also known as hfloats). These are numbers which range from (roughly) 10^(-316) to 10^(316), with about 15-16 digits of precision. By setting the value of Digits to higher values, Maple will start to use "software floats", increasing both the precision and the numeric range - but there are still limits.

The maximum and minimum exponents which can be used are obtained from the Maple_floats() command as

restart;
Maple_floats(MIN_EXP);
Maple_floats(MAX_EXP);

which returns   -9223372036854775806, 9223372036854775806 - in other words, compared with the hardware floats range above (roughly 10^(-316) to 10^(316)), you can now use numbers in the range 10^(-9223372036854775806) to 10^(-9223372036854775806).

Consider now a couple of the entries in your matrix 'b1', namely exp(-1.34467182513784*10^26) and exp(9.70144630827073*10^26).

Just how small/big are these numbers? You can get some idea by evaluating exp(-1.0*10^j) and exp(1.0*10^j) for increasing values of the integer 'j', using

restart;
seq( exp(-1.0*10^j), j=1..26);
seq( exp(1.0*10^j), j=1..26);

The "smallest" value which the first of these can express. occurs for j=19, where one gets the answer

3.08113559210^(-4342944819032518277)

and the largest value which the second can express is

3.245556614*10^(4342944819032518276)

Note the size of those exponents!

Beyond j=19, Maple will return either zero or infinity. So for the two examples from your matrix 'b1' which I quoted above (corresponding to j=26), one would expect Maple to "evaluate" these to '0' and 'infinity' respectively.

So not only can you not perform this calculation using "hardware floats", you cannot perform it using "software floats" either:-(

 

 

print() does two things

  1. prints the argument to the screen
  2. returns NULL

so

a:=print("hello");

will put "hello" on the screen, and also make the assignment a:=NULL, which is why you also get 'a:=    ' as output (which you can of course suppress by terminating the command with a colon rather than a semicolon).

For me, using 1-D input, this works identically in Maple2016 and Maple2017

As in the execution group I added to your worksheet - see the attached

matPlots.mw

Didn't really understand Maxim's comment. Probably another *mysterious* artefact arising from the use of 2D-input. The attached *seems* to provide the solution curves which you want

pdeSol.mw

Just because alternatives are good

Use the select[flatten]() command

   restart;
#
# generate an arbitrary matrix of any
# size you want given by nR (number
# of rows) and nC (number of columns),
# with integer entries between -99 and
# +99
#
   nR:=10:
   nC:=20:
   R:=LinearAlgebra:-RandomMatrix(nR,nC);
#
# Select all entries from this matrix which
# are >=0, and convert to a list
#
   L:=convert(select[flatten](x->x>0, R),list);

  1. Your system need six bounday condtions
  2. Even if I "guess" two additional boundary conditions, I cannot obtain an analytic solution. However I can obtain a numerical solution
  3. See the attached

pdeProb.mw

Because the typesetting level is set to 'extended' by default, then x->(f@g)(x) is displayed as x->(f@g)(x)

Highlighting issues, which have already been fixed, seems a bit pointless

plot( x^2,
         x=-2.5..2.5,
         tickmarks=[spacing(0.5), default]
       );

Basically Kitonum's first suggestion. If this doesn't work for you in Maple 18, then something weird is happening, so post your complete code using the big green up-arrow in the Mapleprimes toolbar

Don't know where your plotting ranges for L,C came from - but they are not helping.

If I play around with these ranges a little, I can focus on a region where a solution curve does occur, then plot it with implicitplot(), extract data from this plot, and print out a table of C, L, abs(zIT) - where the last of these is always 50.

See the attached

LCprob.mw

In the definition of the parameter 'W', you somehow managed to include the name 'e'. Note this is not the well-known exponential function, just a letter which comes between 'd' and 'f' and has no particular mathematical meaning. It is (just about) detectable in 2D math input, because it appears as an italic 'e' rather than a normal 'e', Compare your definition of the parameter 'W' with the subsequent definition of the parameter 's' in the followwing ewxecution group. The latter shows a normal 'e' in the input line while the former shows an italic 'e'.

If I make the required change then the rest of your worksheet now executes in pretty much negligible time - although whether or not it gives the answers you desire - I have no idea.

Anyhow check out the fix in the attached

fixParasitic.mw

then the solution is pretty trivial - see the attached

intProb.mw

If this assumption is invalid - then things get a lot trickier!

Assuming that this is a "reasonably smooth" surface, then the "solution" for 'abs(zIT)-50=0' will probably be a smooth curve (or a even family of smooth curves). Awkward to try to obtain such smooth curves from a simple 'plot3d()'

An alternative would be to use 'implicitplot', to generate only these solution curves

p1:=plots:-implicitplot( abs(zIT)=50, C=20.28e-15..951.6e-15, L=208.9e-12..3.87e-9);

One could then use

plottools:-getdata(p1);

which (amongst other thngs) will return one or more matrices, which will points on each of these solution curves.

A caveat: if the function abs(zIT) is "nasty", ie contains discontinuities or singularities, then the above process may have to refined a little

Before we get into the precision argument, let us establish some ground rules

You specify a value for the variable 'K', and then compute the two quantities

a := K+sqrt(K^2-1) and

b := K-sqrt(K^2-1)

Notice that if one forms the product a*b, ie ( K+sqrt(K^2-1))*(K-sqrt(K^2-1)), then simple algebra suggests that one should get

K^2-sqrt(K^2-1)^2

ie

K^2-(K^2-1)

for which the answer is (obviously and trivially) 1. This final value of '1' is a useful measure of calculation precision

##############################################################################

Now let us perform these calculations in Matlab and Maple.

In Matlab2017b, if I use

version
format long
format compact
K=25888158.4218766
a=K+sqrt(K^2-1)
b=K-sqrt(K^2-1)
a*b

I get as output

ans =  '9.3.0.713579 (R2017b)'
K =2.588815842187660e+07
a =5.177631684375317e+07
b =1.862645149230957e-08
ans =0.964409054140619

Notice that the final answer (which should be 1) is *off* by about 3.5% - so in terms of precision this is crap. This is a consequence of the fact that Matlab is "hardwired" to use double precision arithmetic (somewhere between 15 and 17 significant digits, depending on how you define 'double precision')

Now if I try the same calculation in Maple, I first of all have to consider that (by default) Maple will use 10-digit precision. I freely admit that I have no idea why this is the Maple default, but I can change this precision to any value I want by setting the value for the 'Digits' environment variable. So, to make this very roughtly equivalent to a "double precision" calculation, just set Digits=16, as in the following

Digits := 16;
 K := 25888158.4218766;
 a := K+sqrt(K^2-1);
 b := K-sqrt(K^2-1);
 a*b

which produces

Digits := 16;
K := 2.58881584218766*10^7
a := 5.177631684375318*10^7
b := 2.*10^(-8)
1.035526336875064

Notice that the final answer is still *off*  by about 3.5% so in terms of precision, this (like Matlab) is pretty crap.

Fortunately, unlike Matlab, I can easily resolve this problem in Maple just by setting the value of 'Digits' high enough. Consider setting Digits:=50 in the above code example, which generates the output

Digits := 50
K := 2.58881584218766*10^7
a := 5.1776316843753180686150329739993292995901941992172*10^7
b := 1.9313849670260006707004098058007828*10^(-8)
.99999999999999999999999999999999997795416307975823

The final answer is now *off* by about 0.000000000000000000000000000000001%. Notice that this far more accurate than anything you can get from Matlab - that's the comparison between "hardwired double precision" as used by Matlab, and software floats (arbitrary precision) as used by Maple

From someone who uses both, I offer the free advice: don't ever claim that Matlab is more accurate than Maple - that's just wrong on so many levels

restart;
f:=(x,y)->exp(-0.96374054*x)*sin(2*Pi*y)/(2*Pi*(-0.96374054^2-4*Pi^2));
plots:-contourplot(f(x,y), x=-0.5..1.5, y=-0.5..1.5);

The reason I use the word 'probably' is that the original code you posted contains mutlple, superfluous(?) parentheses, and muliple missing operators (usually multiplication signs) Hence I have no idea whether my interpretation of your expression is actually the expression which you want to be plotted

 

the following

  restart;
  with(LinearAlgebra):
  M:= RandomMatrix(10, 10);
  colors:= [ red,   blue, green, black,  orange,
                   olive, pink, brown, yellow, cyan
                ]:
#
# Plot row values versus column index
#
  plots:-display
              ( [ seq
                   ( plots:-listplot
                                ( M[j,..],
                                  color=colors[j]
                                ),
                     j = 1..op([1,1],M)
                  )
                ]
            );
#
# Plot column values versus row index
#
  plots:-display
               ( [ seq
                    ( plots:-listplot
                                 ( M[..,j],
                                    color=colors[j]
                                 ),
                      j = 1..op([1,2],M)
                   )
                ]
             );

 

First 149 150 151 152 153 154 155 Last Page 151 of 207