Axel Vogt

4986 Reputation

19 Badges

15 years, 195 days
Munich, Germany

MaplePrimes Activity


These are answers submitted by Axel Vogt

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

Besides 'adding' to fourier rules you may use

inttrans:-fourier(erf(x),x,k); convert(%, Int, only=fourier);
value(%); # Maple 2017

It seems you zeroes are 10*Pi*k*(1/3), 5*Pi*(2*k+1)*(1/3), k an integer

I converted to 'rational', used asymptotics to find a scaling and final get the above (find an ugly sheet attached)

MP_228037.mw

no problem in Maple 2017.3

210867-Evaluating-A-Sum.pdf

Your task has a result through the bivariate cumulative normal. Maple does not have it built in.

2*exp(1/4*tp^2*delta^2+sigma)*tp*Pi^(1/2)*
  cdfN2(-1/2*(delta*tp^2-2*tf)*2^(1/2)/tp,-1/2*delta*tp+lambda,1/2*2^(1/2))

MP227459_-_short.mws

 

PS 15-07-2019: in case of questions please post them here (I do not want privat emails if that involves gmail = Google).

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