Axel Vogt

5006 Reputation

19 Badges

15 years, 261 days
Munich, Germany

MaplePrimes Activity


These are answers submitted by Axel Vogt

Not sure if that helps for your situation - but I (always) use a pdf-printer, it works for any application (except for some odd web pages). For the example given by tomleslie for Maple 2020 the result is also complete and of size ~ 350 KB only for somewhat dated "pdfcreator"

Your AAA is linear in y, hence the integral is also linear in y.

The following works in Maple 18 (and should work in Maple 2015 as well)


 

# https://www.mapleprimes.com/questions/230226-Evaluation-Of-Double-Integral

restart; interface(version); Digits:=15;

`Standard Worksheet Interface, Maple 18.02, Windows 7, October 20 2014 Build ID 991181`

 

15

(1)

L := 1;
AAA := 3.888022*10^(-42)*p*q-4.75389*10^(-42)*y*p*q+7.4699*10^(-43)*y*p*q^2+9.1169*10^(-43)*y*p^2*q:
evalf[7](%): collect(%, y): # more easy to read and you have only 7 decimals as input
A:=%;

1

 

(-0.4753890e-41*p*q+0.7469900e-42*p*q^2+0.9116900e-42*p^2*q)*y+0.3888022e-41*p*q

(2)

A0:=remove(has, A, y);
A1:= (A - A0)/y;

'A=A0 + A1*y'; is(%);

0.3888022e-41*p*q

 

-0.4753890e-41*p*q+0.7469900e-42*p*q^2+0.9116900e-42*p^2*q

 

A = A1*y+A0

 

true

(3)

'Int(q*A0/sqrt(p^2 + q^2 + 1), [p = 0 .. L, q = 0 .. L])' +
y*'Int(q*A1/sqrt(p^2 + q^2 + 1), [p = 0 .. L, q = 0 .. L])';
evalf(%);

Int(q*A0/sqrt(p^2+q^2+1), [p = 0 .. L, q = 0 .. L])+y*(Int(q*A1/sqrt(p^2+q^2+1), [p = 0 .. L, q = 0 .. L]))

 

0.453450449270490e-42-0.421144446461726e-42*y

(4)

 


 

Download MP_230226.mw

If you integrate rationalize(expr) it works fine, seems not restricted to Reals

I guess that this may be caused by a = +-1 and Maple does not handle that *removable* singularity (limit is quite simple).

You may try

MultiSeries:-series(1/z^4/(1-z), z=0, 2);

                           -4    -3      -2
                          z   + z   + O(z  )

 

For example:

L:=[1,2,3,4,5]:
convert(L, `+`);
                                  15

But you should try to understand / learn Maple's syntax and notations, studying your lectures (or the book).

 

Product(lambda(i)-lambda(k), k=1 .. i-1)*Product(lambda(i)-lambda(k), k=i+1 .. n)

and no extra tweak if i < 1 or n < i

That is a problem of linear algebra (no polynomial division is need): both sets are a base for a linear vectorspace (polynomials of degree <= d) and you have to invert the matrix for base change.

For your case it can be done directly

myP:=x^5+x^4+2*x^2;

OrthogonalSeries:-ChangeBasis(myP,LegendreP(v, x)):
OrthogonalSeries:-ConvertToSum(%):
convert(%,polynom):
'myP'=%;
is(simplify(%));

        13   3 x   40
  myP = -- + --- + -- LegendreP(2, x) + 4/9 LegendreP(3, x)
        15    7    21

         + 8/35 LegendreP(4, x) + 8/63 LegendreP(5, x)


                                 true

For Gegenbauer you can use a tweak (find it in the attached sheet).

convert_OrthoPoly_229641.mws

 

I look at it as rolling dices with d sides, for d = 2^4 = 16 (and 100/4 = 25 rolls) the Chi^2 test rejects uniformity for B.


 

# https://www.mapleprimes.com/questions/229612-A-Probability-Riddle

restart:
with(Statistics):

A:=[0,1,0,1,0,1,1,0,1,1,1,0,0,1,1,1,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,0,0,1,0,1,0,1,0,1,1,1,1,1,0,0,1,0,1,0,1,0,1,0,1,1,1,0,1,0,1,0,0,0,1,1,1,1,0,0,0,1,0,1,0,0,0,0,0,1,1,1,0,1,0,1,0,1,0,1,0,0,0,1,1,0,1,0]:
B:=[0,1,1,0,1,1,0,1,1,1,0,1,0,0,1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,0,1,0,1,0,1,1,0,1,1,0,0,0,0,0,0,1,0,1,1,1,0,0,0,1,0,1,0,0,0,0,1,0,0,0,0,1,0,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,0,0,1,0]:

'nops(A)': '%'= ifactor(%);

nops(A) = ``(2)^2*``(5)^2

(1)

# group as 4 bits and convert them to decimals 0 ... 15
# this gives 25 dice rolls, 2^4 = 16 sided, which should be uniform

bin2dec:=q -> add(q[4-k]*2^k, k= 0 .. 3);  
#bin2dec:=q -> add(q[nops(q)-k]*2^k, k= 0 .. nops(q)-1);

[ListTools:-LengthSplit( A, 4 )]:
a:=map(bin2dec, %);

[ListTools:-LengthSplit( B, 4 )]:
b:=map(bin2dec, %);

proc (q) local k; options operator, arrow; add(q[4-k]*2^k, k = 0 .. 3) end proc

 

[5, 6, 14, 7, 10, 10, 11, 5, 1, 5, 7, 12, 10, 10, 14, 10, 3, 12, 5, 0, 7, 5, 5, 1, 10]

 

[6, 13, 13, 3, 0, 15, 0, 0, 1, 13, 1, 5, 11, 0, 2, 14, 2, 8, 4, 2, 15, 12, 7, 15, 2]

(2)

# visualize
#Histogram(a, discrete = true, thickness=10):
#Histogram(map(q -> q+0.15, b), discrete = true, thickness=10, color=grey):
#plots[display](%,%%, title="a = blue, b = grey");

ChiSquareSuitableModelTest(a, DiscreteUniform(0,15), output='hypothesis');
ChiSquareSuitableModelTest(b, DiscreteUniform(0,15), output='hypothesis');

true

 

false

(3)

# detailed report
ChiSquareSuitableModelTest(b, DiscreteUniform(0,15), summarize=true):

Chi-Square Test for Suitable Probability Model

 

----------------------------------------------

 

Null Hypothesis:
Sample was drawn from specified probability distribution

 

Alt. Hypothesis:
Sample was not drawn from specified probability distribution

 

 

 

Bins:                    5

 

Degrees of Freedom:      4

 

Distribution:            ChiSquare(4)

 

Computed Statistic:      10.6266666666667

 

Computed p-value:        .0310962037164312

 

Critical Values:         9.48772903678116

 

 

 

Result: [Rejected]
This statistical test provides evidence that the null hypothesis is false.

 

 


 

Download MP_229612.mw

For example you can convert it to a name:

"6T1": convert(%, name);
                                 6T1

 

On Windows you can call a system library

restart; interface(version);
theDLL:="C:\\WINDOWS\\SYSTEM32\\urlmon.dll";

URLDownloadToFile := define_external(
  'URLDownloadToFileA',
  pCaller::integer[4],
  szURL::string,
  szFileName::string,
  dwReserved::integer[4],
  lpfnCB::integer[4],
  'RETURN'::integer[4] ,
  LIB=theDLL):

DL:= proc() URLDownloadToFile(0, Url, Destination, 0, 0) end proc;
# return code = 0 means success

Url:="https://opendata.ecdc.europa.eu/covid19/casedistribution/csv";
Destination := "d:\\temp\\data.csv";

DL();

download_using_urlmon_on_windows.mws

Consider it as composition of the 2 functions f:= t -> sin(t)/t and g:= x -> x*sin(1/x)

If you want the numerical value only then you can just enter Int(...) - using UpperCase - and then evalf(). The numerical integrator is quite good and here cares for the "numerical singularity" in x=0

restart; Digits:=10;
Int(x^5/(exp(x)-1)/(1-exp(-x)), x= 0..1); evalf(%);
                             0.2366158792

If you think it is too slow (or want higher precision) then here use IntegrationTools:-Change(%, x=1/y,y); before evalf.

You may try the following, giving BesselI(0, r)+BesselI(1, r):

Int(g, theta = 0 .. Pi); Expand(%); value(%) assuming 0<r;

Expand the results to see that are the same

Yet another way, using "type":


 

restart;

f:=x^6-3*x-5;
L:=[solve(%)];
select(type, L, 'realcons');
evalf(%);

f := x^6-3*x-5

L := [RootOf(_Z^6-3*_Z-5, index = 1), RootOf(_Z^6-3*_Z-5, index = 2), RootOf(_Z^6-3*_Z-5, index = 3), RootOf(_Z^6-3*_Z-5, index = 4), RootOf(_Z^6-3*_Z-5, index = 5), RootOf(_Z^6-3*_Z-5, index = 6)]

[RootOf(_Z^6-3*_Z-5, index = 1), RootOf(_Z^6-3*_Z-5, index = 4)]

[1.45157146456211, -1.09429273656731]

(1)

 


 

Download MP_228473_real_roots.mws

1 2 3 4 5 6 7 Last Page 1 of 86