MaplePrimes Questions

How to get the functional form of interpolation in the given example below

 

GP.mw

Hi

please help me, how could I write this? 

Hi, 

The procedure Statistics:-ChiSquareSuitableModelTest returns wrong or stupid results in some situations.
The stupid answer can easily be avoided if the user is careful enough.
The wrong answer is more serious: the standard deviation (in the second case below) is not correctly estimated.

PS: the expression "CORRECT ANSWER" is a short for "POTENTIALLY CORRECT ANSWER" given that what ChiSquareSuitableModelTest really does is not documented
 

restart:

with(Statistics):

randomize():

N := 100:
S := Sample(Normal(0, 1), N):

infolevel[Statistics] := 1:

# 0 parameter to fit from the sample S  CORRECT ANSWER

ChiSquareSuitableModelTest(S, Normal(0, 1), level = 0.5e-1):
print():

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:                    10
Degrees of freedom:      9
Distribution:            ChiSquare(9)
Computed statistic:      15.8
Computed pvalue:         0.0711774
Critical value:          16.9189774487099
Result: [Accepted]
This statistical test does not provide enough evidence to conclude that the null hypothesis is false

 

(1)

# 2 parameters (mean and standard deviation) to fit from the sample S  INCORRECT ANSWER

ChiSquareSuitableModelTest(S, Normal(a, b), level = 0.5e-1, fittedparameters = 2):


print():
# verification
m := Mean(S);
s := StandardDeviation(S);
t := sqrt(add((S-~m)^~2) / (N-1));

print():
error "the estimation of the StandardDeviation ChiSquareSuitableModelTest is not correct";
print():

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
Model specialization:    [a = -.2143e-1, b = .8489]
Bins:                    10
Degrees of freedom:      7
Distribution:            ChiSquare(7)
Computed statistic:      3.8
Computed pvalue:         0.802504
Critical value:          14.0671405764057
Result: [Accepted]
This statistical test does not provide enough evidence to conclude that the null hypothesis is false

 

 

HFloat(-0.021425681632689854)

 

HFloat(0.8531979363682092)

 

HFloat(0.8531979363682094)

 

 

Error, the estimation of the StandardDeviation ChiSquareSuitableModelTest is not correct

 

(2)

# ONLY 1 parameter (mean OR standard deviation ?) to fit from the sample S  STUPID ANSWER
#
# A stupid answer: the parameter to fit not being declared, the procedure should return
# an error of the type "don(t know what is the paramater tio fit"
ChiSquareSuitableModelTest(S, Normal(a, b), level = 0.5e-1, fittedparameters = 1):


print():
WARNING("ChiSquareSuitableModelTest should return it can't fit a single parameter");
print():

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
Model specialization:    [a = -.2143e-1, b = .8489]
Bins:                    10
Degrees of freedom:      8
Distribution:            ChiSquare(8)
Computed statistic:      3.8
Computed pvalue:         0.874702
Critical value:          15.5073130558655
Result: [Accepted]
This statistical test does not provide enough evidence to conclude that the null hypothesis is false

 

 

Warning, ChiSquareSuitableModelTest should return it can't fit a single parameter

 

(3)

ChiSquareSuitableModelTest(S, Normal(a, 1), level = 0.5e-1, fittedparameters = 1):  #CORRECT ANSWER
print():

# verification
m := Mean(S);
print():

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
Model specialization:    [a = -.2143e-1]
Bins:                    10
Degrees of freedom:      8
Distribution:            ChiSquare(8)
Computed statistic:      16.4
Computed pvalue:         0.0369999
Critical value:          15.5073130558655
Result: [Rejected]
This statistical test provides evidence that the null hypothesis is false

 

 

HFloat(-0.021425681632689854)

 

(4)

ChiSquareSuitableModelTest(S, Normal(0, b), level = 0.5e-1, fittedparameters = 1):  #CORRECT ANSWER

print():
# verification
s := sqrt((add(S^~2) - 0^2) / N);
print():

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
Model specialization:    [b = .8492]
Bins:                    10
Degrees of freedom:      8
Distribution:            ChiSquare(8)
Computed statistic:      6.4
Computed pvalue:         0.60252
Critical value:          15.5073130558655
Result: [Accepted]
This statistical test does not provide enough evidence to conclude that the null hypothesis is false

 

 

HFloat(0.8491915633531496)

 

(5)

 


 

Download ChiSquareSuitableModelTest.mw

How to get the result of this limit? I don't get the result.
 

limit(sum(1/(i*sqrt(i+1)+(i+1)*sqrt(i)), i = 1 .. n), n = infinity);

With Mathematica, I got the output is 1.

Hello. Let's say I have a list of many items. Well, let's list A:=[1,1.732,1.23,4.42,9,6.45,3.45,8.428,9.1,12]. How to get three numbers from it randomly?

In answers given in 

In https://www.mapleprimes.com/questions/227546-How-To-Make-Odetest-Verify-Dsolve

It shows that odetest() did not verify a solution to ODE becuase solution was using hypergeom special functions. If the solution to the ODE was in integral form, then odetest() will verify it OK.

But what to do if the solution I want to verify is already in hypergoem? If I try odetest() it will fail to verify now. Then I can try to convert the solution to integral form and try again.

But when  using convert(sol,Int) followed by odetest() it did not work.

The solutions I try to verify are hand solutions or book solutions, and not coming from dsolve. 

But some of them are the same solution that comes from dsolve() when not using the useInt option. 

Also, I am doing this all inside a Maple program. It is not an interactive process. So I can't do plots and look at them to decide on anything. So verification must all be implemented in code.

The question is: Why did convert(hand_solution,Int) not give the same result as dsolve(ode,useInt)? Is there another way around this? (May be I am asking for too much in this one based on answers in the above link, So that is OK if not possible. But I really like the solution given when using "useInt" option. Much more clear than otherwise).
 

restart;

ode := diff(y(x), x)*(x^3 + 1)^(2/3) + (1 + y(x)^3)^(2/3) = 0;
sol_int:=dsolve(ode,useInt);
odetest(sol_int,ode); #OK now, since solution in integral form

(diff(y(x), x))*(x^3+1)^(2/3)+(1+y(x)^3)^(2/3) = 0

Int(1/(x^3+1)^(2/3), x)+Intat(1/(_a^3+1)^(2/3), _a = y(x))+_C1 = 0

0

hand_solution:= x*hypergeom([1/3, 2/3], [4/3], -x^3) + y(x)*hypergeom([1/3, 2/3], [4/3], -y(x)^3) + _C1 = 0;
convert(hand_solution,Int); #Why this did not give same result as ABOVE?

x*hypergeom([1/3, 2/3], [4/3], -x^3)+y(x)*hypergeom([1/3, 2/3], [4/3], -y(x)^3)+_C1 = 0

(2/9)*x*Pi*3^(1/2)*(Int(1/(_t1^(1/3)*(1-_t1)^(1/3)*(x^3*_t1+1)^(1/3)), _t1 = 0 .. 1))/GAMMA(2/3)^3+(2/9)*y(x)*Pi*3^(1/2)*(Int(1/(_t1^(1/3)*(1-_t1)^(1/3)*(y(x)^3*_t1+1)^(1/3)), _t1 = 0 .. 1))/GAMMA(2/3)^3+_C1 = 0

odetest(%,ode); #does not give zero

-y(x)^3*(1+y(x)^3)^(2/3)*(Int(_t1^(2/3)/((1-_t1)^(1/3)*(y(x)^3*_t1+1)^(4/3)), _t1 = 0 .. 1))+(x^3+1)^(2/3)*(Int(_t1^(2/3)/((1-_t1)^(1/3)*(x^3*_t1+1)^(4/3)), _t1 = 0 .. 1))*x^3-(x^3+1)^(2/3)*(Int(1/(_t1^(1/3)*(1-_t1)^(1/3)*(x^3*_t1+1)^(1/3)), _t1 = 0 .. 1))+(1+y(x)^3)^(2/3)*(Int(1/(_t1^(1/3)*(1-_t1)^(1/3)*(y(x)^3*_t1+1)^(1/3)), _t1 = 0 .. 1))

 

 

Maple 2019.1

Download 072619_2.mw

 

 

 

It seems that the answer to my question is deleted!!!

So, I again repeat it.

How I can calculate this integral?

I want to calculate integral with the constants Aj]j=1,2.

The Amount of these constants  unknown this stage.

Thanks

INTEGRAL

integral.mw

I am trying to evaluate any which way the integral:

int(exp(-(sqrt(4*x^2+4*y^2+4*z^2)^3)), z = -sqrt(4-x^2-y^2).. sqrt(4-x^2-y^2),y=-sqrt(4-x^2)..sqrt(4-x^2),x=-2..2);

The program just hangs, so i click on 'stop current operation'.

Then I tried:

evalf(Int(exp(-(sqrt(4*x^2+4*y^2+4*z^2)^3)), z = -sqrt(4-x^2-y^2).. sqrt(4-x^2-y^2),y=-sqrt(4-x^2)..sqrt(4-x^2),x=-2..2));

It returns the integral back unevaluated.

It's true that I could use a change of variables, changing to spherical coordinates would be best here. But I would like to know if I did set up the original Cartesian integral correctly. Is there some workaround I can apply to get a numeric answer. I am satisfied with a decimal approximation. Then I can compare to the change of variable result. An exact answer would be even better of course.

THis is another ode which I am not able to get odetest to give zero. Any one knows of a trick to verify this solution? It might be just that the solution is too complicated for odetest to verify?


 

restart;

ode:=diff(y(x),x)*(x^3+1)^(2/3)+(1+y(x)^3)^(2/3) = 0;
sol:=dsolve(ode);

(diff(y(x), x))*(x^3+1)^(2/3)+(1+y(x)^3)^(2/3) = 0

x*hypergeom([1/3, 2/3], [4/3], -x^3)+y(x)*hypergeom([1/3, 2/3], [4/3], -y(x)^3)+_C1 = 0

odetest(sol,ode);

-9*(1+y(x)^3)^(1/3)*(x^3+1)^(2/3)*hypergeom([4/3, 5/3], [7/3], -x^3)*x^3*GAMMA(2/3)*(-y(x)^3)^(1/6)/(9*hypergeom([4/3, 5/3], [7/3], -y(x)^3)*y(x)^3*(-y(x)^3)^(1/6)*(1+y(x)^3)^(1/3)*GAMMA(2/3)-4*Pi*3^(1/2)*LegendreP(-1/3, -1/3, -y(x)^3/(1+y(x)^3)+1/(1+y(x)^3)))+9*y(x)^6*hypergeom([4/3, 5/3], [7/3], -y(x)^3)*GAMMA(2/3)*(-y(x)^3)^(1/6)/(9*hypergeom([4/3, 5/3], [7/3], -y(x)^3)*y(x)^3*(-y(x)^3)^(1/6)*(1+y(x)^3)^(1/3)*GAMMA(2/3)-4*Pi*3^(1/2)*LegendreP(-1/3, -1/3, -y(x)^3/(1+y(x)^3)+1/(1+y(x)^3)))+9*y(x)^3*hypergeom([4/3, 5/3], [7/3], -y(x)^3)*GAMMA(2/3)*(-y(x)^3)^(1/6)/(9*hypergeom([4/3, 5/3], [7/3], -y(x)^3)*y(x)^3*(-y(x)^3)^(1/6)*(1+y(x)^3)^(1/3)*GAMMA(2/3)-4*Pi*3^(1/2)*LegendreP(-1/3, -1/3, -y(x)^3/(1+y(x)^3)+1/(1+y(x)^3)))-4*(1+y(x)^3)^(2/3)*Pi*3^(1/2)*LegendreP(-1/3, -1/3, -(y(x)^3-1)/(1+y(x)^3))/(9*hypergeom([4/3, 5/3], [7/3], -y(x)^3)*y(x)^3*(-y(x)^3)^(1/6)*(1+y(x)^3)^(1/3)*GAMMA(2/3)-4*Pi*3^(1/2)*LegendreP(-1/3, -1/3, -y(x)^3/(1+y(x)^3)+1/(1+y(x)^3)))+4*(1+y(x)^3)^(1/3)*(x^3+1)^(1/3)*Pi*3^(1/2)*LegendreP(-1/3, -1/3, -(x^3-1)/(x^3+1))*(-y(x)^3)^(1/6)/((-x^3)^(1/6)*(9*hypergeom([4/3, 5/3], [7/3], -y(x)^3)*y(x)^3*(-y(x)^3)^(1/6)*(1+y(x)^3)^(1/3)*GAMMA(2/3)-4*Pi*3^(1/2)*LegendreP(-1/3, -1/3, -y(x)^3/(1+y(x)^3)+1/(1+y(x)^3))))

simplify(%);

-9*((4/9)*(1+y(x)^3)^(2/3)*Pi*3^(1/2)*LegendreP(-1/3, -1/3, (-y(x)^3+1)/(1+y(x)^3))*(-x^3)^(1/6)+(-(4/9)*(1+y(x)^3)^(1/3)*(x^3+1)^(1/3)*Pi*3^(1/2)*LegendreP(-1/3, -1/3, (-x^3+1)/(x^3+1))+(-x^3)^(1/6)*((-y(x)^6-y(x)^3)*hypergeom([4/3, 5/3], [7/3], -y(x)^3)+x^3*(1+y(x)^3)^(1/3)*hypergeom([4/3, 5/3], [7/3], -x^3)*(x^3+1)^(2/3))*GAMMA(2/3))*(-y(x)^3)^(1/6))/((-x^3)^(1/6)*(9*hypergeom([4/3, 5/3], [7/3], -y(x)^3)*y(x)^3*(-y(x)^3)^(1/6)*(1+y(x)^3)^(1/3)*GAMMA(2/3)-4*Pi*3^(1/2)*LegendreP(-1/3, -1/3, (-y(x)^3+1)/(1+y(x)^3))))

 


 

Download 072619.mw

Maple 2019.1, Physics 395

Download 072619.mw

 

 

This must be a simple question. I have a simple expression:

test := -2+exp(theta)+exp(-theta)

and want to get that factored as a polynomial in the variable exp(-theta).

That is of course easy by hand, but the same problem appears frequently, as a part in further simplifications. There must be an easy way to do it, but I cannot find it. 

            


 

 

How to draw the given data?


 

 

restart

``

0, 0.

 

0.5e-1, 0.7453559923e-1

 

.10, .1054092553

 

.15, .1290994449

 

.20, .1490711985

 

.25, .1666666667

 

.30, .1825741858

 

.35, .1972026594

 

.40, .2108185107

 

.45, .2236067977

 

.50, .2357022604

 

.55, .2472066162

 

.60, .2581988897

 

.65, .2687419249

 

.70, .2788866755

 

.75, .2886751346

 

.80, .2981423970

 

.85, .3073181486

 

.90, .3162277660

 

.95, .3248931448

 

1.00, .3333333333

 

``


 

Download aaa.mw

 

 

pde := diff(u(x, t), x $ 4) = diff(u(x, t), t $ 2);

iv:= subs(L = 100, {u(0, t) = 0, u(L, t) = 0, u(x, 0) = sin(x), D[2](u)(x, 0) = 2*x, D[1, 1](u)(0, t) = 0, D[1, 1](u)(L, t) = 0});

de := pdsolve(pde, iv, numeric):

sa1 := de:-value(output = listprocedure);

sa1:=[x=proc() ... end proc,t=proc() ... end proc,u(x,t)=proc() .. end proc]

    With the above procedure it works, but in the most compact form below it does not work.

pdsolve(pde, iv, numeric,output = listprocedure):

Error, (in pdsolve/numeric/par_hyp) invalid arguments for theta scheme: [output = listprocedure]
 

I have been using simplify() in number of places, and not really expecting it will do any harm. At worst, it will have no effect, or it will change the expression to different form, but the semantics will remain the same.

Until I noticed that odetest() fail on some of my solutions because I called simplify  on the solution before.

One example why this happens, is that Maple simplifies cos(2*x)*sqrt(1/cos(2*x)^2) to csgn(1/cos(2*x)) and this makes odetest fail. Adding assuming x::real has no effect on making odetest happy.

So now I changed simplify(sol) to simplify(sol,size) and this seems so far not to have this adverse effect. 

My main reason for calling simplify  is to make the expression smaller. In Mathematica that is what I do, In Mathematica there is no "size" option to Simplify.

So now, I am very worried about calling simplify() as is.

Could some Maple experts share some of their experience on this? Should one call simplify() only when an explicit option, like size, trig, exp, etc....is also used and not call simplify as is?

restart;

ode:= diff(y(x),x) = 2+2*sec(2*x)+2*y(x)*tan(2*x);
my_sol:= y(x) = ((2*x+sin(2*x))/(cos(2*x)*sqrt(1/cos(2*x)^2))+_C1)*sqrt(1+tan(2*x)^2);
odetest(my_sol,ode);

diff(y(x), x) = 2+2*sec(2*x)+2*y(x)*tan(2*x)

y(x) = ((2*x+sin(2*x))/(cos(2*x)*(1/cos(2*x)^2)^(1/2))+_C1)*(1+tan(2*x)^2)^(1/2)

0

#now simplify the solution first
simplify(my_sol);
odetest(%,ode);

y(x) = (_C1*csgn(1/cos(2*x))+sin(2*x)+2*x)/cos(2*x)

csgn(1, 1/cos(2*x))*_C1/cos(2*x)

simplify(my_sol) assuming x::real;
odetest(%,ode);

y(x) = (_C1*signum(cos(2*x))+sin(2*x)+2*x)/cos(2*x)

signum(1, cos(2*x))*_C1/cos(2*x)

simplify(my_sol,size);
odetest(%,ode);

y(x) = ((2*x+sin(2*x))/(cos(2*x)*(1/cos(2*x)^2)^(1/2))+_C1)*(1+tan(2*x)^2)^(1/2)

0

simplify(cos(2*x)*sqrt(1/cos(2*x)^2))

csgn(1/cos(2*x))

 

 

Download 072519.mw

 

 

Hello. Let's say I have expressions of different lengths - linear combinations of some functions with some coefficients. And there is a free member. Is there a way to get out of these expressions free member? That is func(A)=78.34

Dear Users!

I have made a code using loops. But when I exceute it I go unwanted expression please see the files and try to fix it. I shall be very thankful. 

 

Help.mw

Special request to:

@acer @Kitonum @Preben Alsholm @Carl Love

First 375 376 377 378 379 380 381 Last Page 377 of 2141