## 6279 Reputation

7 years, 325 days

## Workaround...

 > restart
 > kernelopts(version)
 (1)
 > with(ScientificConstants): with(Units):
 > g := evalf(Constant(g, units))
 (2)
 > int(g, t*Unit('s'));
 > # Workaround intat(g, tau=t*Unit('s')); simplify(%, 'Unit');
 (3)
 > # The vector case with(VectorCalculus): SetCoordinates('cartesian[x, y, z]'):
 > a := `<,>`(0, 1, 0) *~ g
 (4)
 > v[0] := `<,>`(v__0, 0, 0) *~Unit('m'/'s')
 (5)
 > V := simplify(intat~(a, tau=t*Unit('s')));
 (6)

If you want to integrate twice to get the position X do this (remember that v__0 and t are dimensionless velocity and time) :

X := intat~(intat~(a, tau=t*Unit('s')), tau=t*Unit('s'))
+
intat~(v[0], tau=t*Unit('s')):

simplify(X);

v__0*t*Unit('m')*e[x] + 9.80665*t^2*Unit('m')*e[y] + 0.*e[z]

## Contribution to the final answer...

I was capable to derive a surprisingly simple expression based on the hypergeometric function but not the one you want (or more precisely I got a LaguerreL based expression but the result is not correct).
In the route to the proof I have used two properties of the HermiteH polynomials (physical form) that Maple "doesn't know" and I did some transformations by hand (for instance commuting the operators Int and Sum. I don't know if this is something that can be done using directly Maple?

Maybe someone will  reuse the material presented in the attached file and finalize the demonstration?
Goog luck.

 > restart;
 > with(IntegrationTools):
 > L := (m, n) -> exp(a^2)*a^(abs(n-m))*sqrt(2^(abs(n-m))*min(n, m)!/max(n, m)!)*LaguerreL(min(n, m), abs(n-m), -2*a^2);
 (1)
 > H := 2^(-m/2-n/2)*exp(lambda^2*sigma^2/4)/sqrt(n!)/sqrt(m!*Pi)*Int(HermiteH(m,s+lambda*sigma/2)*HermiteH(n,s+lambda*sigma/2)*exp(-s^2), s=-infinity..infinity); # Set a = lambda*sigma/2 H := unapply(eval(H, lambda=a*2/sigma), (m, n));
 (2)
 > # I think this is the key property to use # # Basic Property 1: BP1m := HermiteH(m, s+a) = Sum(binomial(m, i)*HermiteH(i, s)*(2*a)^(m-i), i=0..m); BP1n := HermiteH(n, s+a) = Sum(binomial(n, j)*HermiteH(j, s)*(2*a)^(n-j), j=0..n);
 (3)
 > # So: SBP1 := eval(H(m, n), [BP1m, BP1n]);
 (4)
 > #  Commute Sum operators and the Int operator OutInt   := mul(remove(has, [op(SBP1)], Int)[]); GetI     := GetIntegrand(SBP1): SumTerms := op([1, 1], GetI)*op([2, 1], GetI): S, R := selectremove(has, [op(%)], HermiteH): SBP1 := OutInt * Sum(Sum(mul(R[]) * Int(mul(S[])*exp(-s^2), s=-infinity..+infinity), op([1, 2], GetI)), op([2, 2], GetI));
 (5)
 > # If we expand SSum we will get (m+1)*(n+1) terms of the form # T[i, j] = int(C[i, j]*HermiteH(i, x)*Hermite(j, x)*exp(-x^2), x=-infinity..+infinity). # # But we know that #     1)  T[i, j<>i] = 0 #     2)  T[i, j=i] = sqrt(Pi)*2^i*i! # # It is easy to see that all terms of the form T[i, i] are got for i = 0.. min(m, n) # Then the product of the two dpuble sums reduces to # Basic Property 2: BP2 := Int(HermiteH(i, s)*HermiteH(j, s)*exp(-s^2), s = -infinity .. infinity) = piecewise(j=i, sqrt(Pi)*2^i*i!, 0);
 (6)
 > # Use basic property 2 into SBP1 SBP2 := eval(SBP1, BP2); # Symplify by hand SBP2 := OutInt * Sum(binomial(m, i)*binomial(n, i)*(2*a)^(m-i)*(2*a)^(n-i)*sqrt(Pi)*2^i*i!, i=0..min(m, n));
 (7)
 > # Ask a little help (a huge one in fact) to Maple: eval(SBP2, Sum=sum);
 (8)
 > # Two a priori cases... which appear to give the same result mLEn := eval(SBP2, Sum=sum) assuming m <= n; mGTn := eval(SBP2, Sum=sum) assuming m > n; simplify(mLEn - mGTn);
 (9)
 > # Define the expression of H(m, n) this way Hermite2Hypergeom := mLEn
 (10)
 > # Check case m < n simplify(L(1, 3), 'LaguerreL'); simplify(eval(H(1, 3), Int=int)); simplify(eval(Hermite2Hypergeom, [m=1, n=3]))
 (11)
 > # Check case m = n normal(simplify(L(3, 3), 'LaguerreL')); simplify(eval(H(3, 3), Int=int)); simplify(eval(Hermite2Hypergeom, [m=3, n=3]))
 (12)
 > # Check case m > n simplify(L(3, 1), 'LaguerreL'); simplify(eval(H(3, 1), Int=int)); simplify(eval(Hermite2Hypergeom, [m=3, n=1]))
 (13)
 > # Now let's start from Hermite2Hypergeom and try to convert it as LaguerreL. # # Roughly: convert(Hermite2Hypergeom, `1F1`) assuming m::posint, n::posint: convert~(%, LaguerreL): Hermite2Laguerre := convert~(%, factorial);
 (14)
 > # That seems pretty, but there is a main problem: (-n-1)! = 0 for any positive integer n. # # (Note that the above expression does not account for the sign of m-n, which seems already # quite suspect... but Hermite2Hypergeom did not neither andtheresults where correct.) eval(Hermite2Laguerre, m=3); eval(%, n=1);
 > # I have spent a lot of time to try and understand how to get rid of this problem without any success. # # So I feel that the formula L(m, n) is not that far but I am not capable to get it. # I hope someone will and that and my work will help.

## Semantic correction and solution...

Writting "In the above integral, r and sigma are the random variables" is incorrect: R and Sigma are txo random variables whose realizations noted r and sigma.
Assuming that this is what you wanted to say, here is the solution

 > restart:
 > with(Statistics):
 > R    := RandomVariable(Normal(k*sigma, sigma)): f__R := unapply(PDF(R, r), r);
 (1)
 > Sigma     := RandomVariable(LogNormal(m__Sigma, s__Sigma)): f__Sigma := unapply( (PDF(Sigma, sigma) assuming sigma > 0), sigma);
 (2)
 > # Compute the inner integral (it could be done head-on) InnerIntegral := Int(r*f__R(r), r=-infinity..+infinity); InnerIntegral := Mean(R);
 (3)
 > OuterIntegral := upperbound -> Int(sigma*f__Sigma(sigma)*InnerIntegral, sigma=0..upperbound); value(OuterIntegral(+infinity)); eval(%) assuming s__Sigma > 0;
 (4)
 > # A simpler way to get the previous result: Moment(Sigma, 2)*coeff(InnerIntegral, sigma): simplify(%); # (here the call to Statistics:-Moment automatically accounts for the conditions # on the parameters of Sigma:) print(): (attributes(Sigma)[3]):-Conditions;
 (5)
 > # What happens if the integration is done for upperbound U < +infinity? value(OuterIntegral(U)): solution := simplify( (eval(%) assuming s__Sigma > 0, U > 0) )
 (6)
 > # Now give to these parameters the values you want indets(solution, name) minus {Pi}
 (7)
 >

Now, why is this semantic point important?

• If r and sigma were INDEED  random variables, then the inner integral (and even the outer) would make  no sense. Even the simpler int(r, r=-infinity..+infinity) makes no sense.

• If Sigma (I prefer using a capital do refer to a random variable) was a random variable, then
R, defined by PDF(R, r) = Normal(k*sigma, sigma) where sigma is a realization of Sigma, would not be a random variable but a random process.
A (1D) random proces is a (finite or not) collection of random variables indexed by a number (which can be itself the realization of a random variable).
Thus, "R conditionned by Sigma=sigma", which I am going to note R[sigma] is a random variable (a gaussian one with mean k*sigma and standard deviation sigma), but not R which is an infinite collection of random variables R[sigma] with sigma=0..+infinity.

## Classic problems related to use 2D input...

To acoid them be EXTREMELY careful when using 2D input mode in document style ... or avoid it (my advice) and use 1D input mode and worksheet instead.

The explanation is in bold brown courier font in the attached file:
(I changed the construction of U, V and Upsilon for my Maple 2015 doesn't support yours... but this is anecdotal).

 > restart
 >
 (1)
 >
 (2)

 >
 (3)
 >
 (4)

 >
 (5)
 >
 (6)
 >
 (7)
 > # WHAT DID YOU DEFINE? # # To see really what the variables you defined are do this lprint(anames(user)); # Observe there are 3 "Q's": # #   on one side Q__11, Q__55 #   on the other one Q # # This means that what appears as Q subscriped 110, 550, 113, 553, 556, ... are the same variable Q # with indices 110, 550, 113, 553, 556, .... # # To see this: indices(Q); # Q is a table: eval(Q);
 G, h, l, Phi, rho, Q__55, W, Upsilon, U, E, m, nu, Q, L, R, mu, Q__11
 (8)
 > # Note that neither [11] nor [55] indices of Q
 >
 (9)
 >
 (10)
 >
 (11)
 >
 (12)
 >
 (13)
 >
 (14)
 >

 (15)
 > # WHAT ARE THE INDETERMINATES OF eq1? lprint~(indets(eq1, name));
 Q__110 Q__111 Q__113 U0 W0 beta__1 beta__2 beta__4 beta__7 omega t x `#mi("\`Q__551\`")` `#mi("\`Q__556\`")` Upsilon0 `#mrow(mi("\`Q__550\`"),mo("⋅"),mi("U"),mfenced(mrow(mi("x"),mo(","),mi("t"))))` `#mrow(mi("\`Q__553\`"),mo("⋅"),mi("ϒ",fontstyle = "normal"),mfenced(mrow(mi("x"),mo(","),mi("t"))))`
 (16)
 > # Compare to the table Q whose indices are remembered here {indices(Q, nolist)}
 (17)
 > # So the answer to your question is obvious: # # You defined Q[110] and use Q__110 in eq1 (same thing for the other quantities) # # And the remedy is simple: be more carefull when you se 2D mode # And a good advice (IMO), let's drop it and use 1D input mode instead to avoid this kind of issues.

Note that your problem does not limit tho the Qs but extends to the betas.

The problem with the 2D inputs is that what you see is not what you get.
Here you falsely believed that the variables in eq1 where those you previously defined.

## The error message is perfectly clear...

You provide initial conditions for g[s] (equation (3)), one of them involving D(g[s]](1), but you solve an ODE which does not contain any derivative of g[s].

If g[s] must respect a differential eqution, write it and solve a 2-by-2 differential system instead of a single differential equation.

If g[s] is not governed by a differential equation, specify the expression of g[s](x) and remove all references to g[s] in the boundary conditions.
Here is an illustration of the "Known g[s] case":  Known_gs_mmcdara.mw

## What do you feel about...

this proposal.mw ?

 >

# Parameters always positive

 > assume(0 < sigma__d, 0 < sigma__v): interface(showassumed=0):
 > Diff('lambda__1', sigma__v) = sqrt(5)/(5*sigma__d): f__1 := rhs(%): Diff('lambda__1', sigma__d) = -sqrt(5)*sigma__v/(5*sigma__d^2): f__2 := abs(rhs(%)):
 > use plots in   display(     inequal(       f__1-f__2 > 0       , sigma__v=0.001..10, sigma__d=0.001..10       , color="Chartreuse"       , optionsexcluded=[color="Niagara DarkOrchid"]     )     ,     # For a more complex case than yours     # (here a simple plot(solve(f__1=f__2, sigma__d), sigma__d=0.001..10)     # would be enough)     implicitplot(       f__1=f__2       , sigma__v=0.001..10, sigma__d=0.001..10       , color=blue       , thickness=5       , grid=[100, 100]       , legend=typeset('f__1' = 'f__2')     )     , textplot([3, 7, typeset('f__1' > 'f__2')], font=[Times, bold, 14])     , textplot([7, 3, typeset('f__1' < 'f__2')], font=[Times, bold, 14], color=white)     , labels=[typeset(sigma__v), typeset(sigma__d)]   ) end use;

(customize it as you want)

## I hope this will enlighten you enough to...

@jalal

To get this histogram you present:

• Given the nature of your data I suppose they are already consist in a serie of elements of the type [C[k], N[k]] where
• C[k] is the range of the kth class,
• N[k] is the number of elements C[k] contains.

This is what I call synthetic data by opposition to raw data (see below).

• If it is so you have two possibilities:
1. To build an Statistics:-Histogram you must have raw data, not synthetic data.
So either you have these raw data or you don't.
• If you have them, let R the list/vector of incomes, just use Statistics:-Histogram with the ad hoc customization (first plot in the attached file).

• If you do not have them, you can recreate fake raw data from synthetic data so that their histogram is the one you want (second plot in the attached file).

2. If you only have synthetic data and bo not necessarily want to use Statistics:-Histogram, then you can proceed as explaine in the third plot in the attached file.

 > restart

CASE 1: YOU HAVE RAW DATA

Simulation of hypothetic raw data

 > R := Statistics:-Sample(Triangular(6, 97, 53), 10^3):

Raw data histogram

 > C := [seq(0..100, 10)]: Statistics:-Histogram(   R   , frequencyscale=absolute   , binbounds=C   , axis[1]=[tickmarks=C]   , view=[-1..101, default]   , color="Pink"   , transparency=0.5   , labels=["Salaires (milliers de \\$)", "Nombre d'employés"]   , labeldirections=[default, vertical]   , labelfont=[Tahoma, 10]   , size=[700, 400] )

CASE 2: YOU DO NOT HAVE RAW DATA BUT SYNTHETIC DATA ONLY

... AND YOU WANT TO USE  Statistics:-Histogram

Here are the synthetic data which correspond to the raw data R above

 > Classes       := [seq(C[k]..C[k+1], k=1..numelems(C)-1)]: SyntheticData := Statistics:-TallyInto(R, Classes): SyntheticData := Matrix(numelems(Classes), 2, (i, j) -> `if`(j=1, lhs(SyntheticData[i]), rhs(SyntheticData[i])));
 (1)

If you want to use Statistics:-Histogram you must create hypothetic raw data in a correct way.
The reconstruction below produces raw data that have the same histogram as above.

 > S := [seq((add(op(SyntheticData[k, 1]))/2)\$(SyntheticData[k, 2]), k=1..numelems(Classes))]: Statistics:-Histogram(   S   , frequencyscale=absolute   , binbounds=C   , axis[1]=[tickmarks=C]   , view=[-1..101, default]   , color="Pink"   , transparency=0.5   , labels=["Salaires (milliers de \\$)", "Nombre d'employés"]   , labeldirections=[default, vertical]   , labelfont=[Tahoma, 10]   , size=[700, 400] )

CASE 3: YOU DO NOT HAVE RAW DATA BUT SYNTHETIC DATA ONLY

... AND YOU DO NOT NECESSARILLY WANT TO USE  Statistics:-Histogram

 > bars := [           seq(             plottools:-rectangle(               [op(1, SyntheticData[k, 1]), 0]               , [op(2, SyntheticData[k, 1]), SyntheticData[k, 2]]               , color="Pink"               , transparency=0.5             )             , k=1..numelems(Classes)           )         ]: plots:-display(   bars   , labels=["Salaires (milliers de \\$)", "Nombre d'employés"]   , labeldirections=[default, vertical]   , labelfont=[Tahoma, 10]   , size=[700, 400] )
 >

## Be careful when using 2D mode...

It's likely that some typo or hidden character appeared in ode2 (bold red text).
As I never use  the document mode with 2D inputs, the attached file displays two types of fonts: so correct your own file the way I did if this annoys you.

 > restart
 > kernelopts(version)
 (1)
 >
 >
 >
 >
 >
 (2)
 >
 >
 (3)
 >
 >
 (4)
 >
 (5)
 > b1 := eval(ode2, a1); b2 := eval(ode2, a2); b3 := eval(ode2, a3);
 (6)
 > c1 := dsolve({bcs1, eval(b1, f(x) = x)}, numeric); c1(0); c2 := dsolve({bcs1, eval(b2, f(x) = x)}, numeric); c2(0); c3 := dsolve({bcs1, eval(b3, f(x) = x)}, numeric); c3(0);
 (7)
 > :
 >
 >
 >

PS 1: using PDETools:-declare doesn't ease the task of finding where the error is and you must be doubly careful using it.
PS 2: be consistent and declare u[e] too if you consider it as a function of x (which u[e]' seems to mean, even if u[e] is later defined as a constant function).

## Use orthogonality condition of Hermite p...

As explained in the attached file your code does not work with my Maple 2015?
So I copy-pasted your expression of eq5 and used it as the starting point to get eq6.

Your code is in grey, mine on bold brown; the successive transformations of F (the integral term in your eq6) enableobtaoining a standard form from which it clearly appears that the orthogonality condition of Hermite polynomials (Maple uses their physical form) can be used to simplify the expression of F:

Final remark: as _C2 intervenes through its square, there are two real and opposite values of _C2 such that F(n)=1.

 > restart;
 > kernelopts(version)
 (1)

Here is your file NOT EXECUTED in Maple 2015 for PDEtools:-dchange(...) generates an error with Maple 2015

 > with(PDEtools): #with(Maplets[Elements]):
 > eq0:= E1 = (n+1/2)*_h; param := m1 =_h*sigma^2;
 (2)
 > os := expand(isolate((-_h^2/(2*m1))*diff(psi(x),x,x)+(m1*x^2/2)*psi(x)-E1*psi(x)=0,diff(psi(x),x,x)));
 (3)
 > eq1 := PDEtools:-dchange([x=sqrt(_h/m1)*zeta,psi(x)=f(zeta)*exp(-zeta^2/2)],os,[zeta,f(zeta)],params={m1,_h,E1}); eq2 := expand(isolate(eq1,diff(f(zeta),zeta\$2))); eq3 := simplify(eval(remove(has,convert(rhs(dsolve(eq2,f(zeta))),Hermite),KummerM),eq0)*exp(-zeta^2/2),radical)       assuming zeta::positive; eq4 := subs(param,simplify(subs(zeta=sqrt(_h/m1)*x,eq3))) ; eq5 := unapply(eq4,n,x,sigma); eq6 := solve(int(eq5(n,x,sigma)^2, x=-infinity...infinity)=1,_C2,useassumptions) assuming _C2 :: real, sigma::positive,n::posint;
 (4)

From now on: I copy-paste the expression of "your" (that I cannot obtain with Maple 2015)

 > eq5 := proc (n, x, sigma) options operator, arrow; _C2*HermiteH(n, sqrt(1/sigma^2)*x)*2^(-n)*exp(-(1/2)*x^2/sigma^2) end proc
 (5)

Here is the integral contained in your relation "eq6"

After some elementary algebra I get the last relation above

 > F := Int(eq5(n,x,sigma)^2, x=-infinity...infinity) assuming n::posint; F := combine(F, exp); F := eval(F, sqrt(1/sigma^2) = 1/sigma); F := simplify(IntegrationTools:-Expand(F)); F := IntegrationTools:-Change(F, x/sigma=z, z) assuming sigma > 0; F := simplify(IntegrationTools:-Expand(F));
 (6)

From orthogonality of Hermite polynomials (Physical form used in Maple)
(see Wiki)

 > select(has, indets(F, function), Int)[]; OrthogonalityCondition := % = (2^n*n!*sqrt(Pi))
 (7)
 > F := unapply(eval(F, OrthogonalityCondition), n)
 (8)

Thus the expression of _C2 for any n

 > eq6 := unapply( [solve(F(n)=1, _C2)], n)
 (9)
 >

## The two derivatives give exactly the sam...

The two derivatives give exactly the same thing a.

Nevertheless here is a way to do what you want derivatives.mw

## Personally...

I_would_do_that.mw

I declared prnt and clr as optional parameters (first one is boolean initialized to true, second one is string initialized to blue), I introduced a control of the color you pass, and I simplified your code a little bit.
Here are the modifications (complete code in the attached file)

....
{clr::string:="Blue"},
{prnt::boolean:=true}
)
....
local col := substring(StringTools:-Capitalize(clr), 1..1);
local COL := `if`(col="R", "Red", `if`(col="G", "Green", "Blue"))
....
if `not`(member(col, {"R", "G", "B"})) then
error cat("allowed colors are red, green or blue, received ", clr)
end if:

if prnt then
print(cat("Spread 2 [x,y] Points/Vectors wrt origin ",  COL));
end if:

if col = "B" then
return ....

elif col="G" then
return ....

elif col="R" then
return ....
end if;
end proc:

More controls could be necessary for a safer code (what if the denominators in the green and red cases are null?)

## A way...

 > restart:
 > expr := h(arctan(y/x))+arctan(a/b)^2
 (1)
 > eval(expr, arctan = (u -> arctan((numer, denom)(u))))
 (2)
 >

## Unfortunately I gave only Maple 2015 and...

Unfortunately I gave only Maple 2015 and WeibullPlot is not avaliable.

Look to this file and tell me if the plot I draw corresponds or not to what you would like to get?
I'm afraid I did not corerctly understood what is the issue you refer to.
Here axis 1 is given 4 subticks and axis 2  3 subricks, you can see that the plot is correct.

 >
 >
 >
 >
 >
 (1)
 > kernelopts(version)
 (2)
 > F  := unapply(CDF(Weibull(1, 0.6), z), z): AA := sort(AA): N  := numelems(AA): interface(warnlevel=0): WB := map(n -> [AA[n], solve(F(z)=n/N)], [\$1..N-1]): plots:-display(   plot(     WB     , color="NavyBlue"     , gridlines=true     , axis[1]=[mode=log, color="DarkGreen", tickmarks=[subticks=3]]     , axis[2]=[mode=log, color="DarkGreen", tickmarks=[subticks=4]]     , size=[700, 500]     , axes=boxed   )   , plot(Mean(Weibull(1, 0.6)), z=(min..max)(AA), color=red, linestyle=3)   , plot([[Mean(AA), WB[1][2]], [Mean(AA), WB[-1][2]]], z=(min..max)(AA), color=red, linestyle=3) )
 > Sample_data    := log[10]~(map2(op, 1, WB)): Reference_data := log[10]~(map2(op, 2, WB)): FIT := LinearFit([1, x], Reference_data, Sample_data, [x], output=solutionmodule): print~(FIT:-Results()):
 (3)
 > p := plots:-display(   plot([seq([Reference_data[n], Sample_data[n]], n=1..numelems(Sample_data))], color="NavyBlue")   , plot(       FIT:-Results("leastsquaresfunction"), x=(min..max)(Reference_data), color="NavyBlue", linestyle=3     )   , gridlines=true ): p := plottools:-transform((x, y) -> [y, x])(p): plots:-display(   p   , axis[1]=[tickmarks=[seq(k=10.0^k, k=-3..1)], color="DarkGreen"]   , axis[2]=[tickmarks=[seq(k=10.0^k, k=-3..1)], color="DarkGreen"]   , view=[(min..max)(Sample_data), (min..max)(Reference_data)]   , size=[700, 500]   , axes=boxed )
 >

## The limit is not a number...

but an interval.

Just do this to see what happens for a given y as x goes to 0.

limit(f(x, y), x=0)
/1\             /1\
-1 + sin| - | .. 1 + sin| - |
\y/             \y/

limit(f(1/x, 1/y), x=+infinity)
-1 + sin(y) .. 1 + sin(y)
limit(sin(x), x=+infinity)
-1 .. 1

You can also compute a directional limit

limit(f(x, lambda*x), x=0)
-2 .. 2

In the attached file you will find an exploration of f(x,y) as you get closer and closer to the point (0, 0) (the value h of the slider means the neighborhood of (0, 0) has size 10-h).
limit.mw

## A quick slution...

A quick workaround is

plots:-implicitplot(g=1e-8, x = 0 .. 80, y = 0 .. 60, scaling = constrained, grid=[400, 400])

Nevertheless do not gorget that g=0 on the domain  33 <= x <= 58,  0, <= y <= 49.99226668
gnull.mw

 1 2 3 4 5 6 7 Last Page 3 of 53
﻿