mmcdara

5989 Reputation

17 Badges

7 years, 266 days

MaplePrimes Activity


These are answers submitted by mmcdara

Instead of

y__88 := x -> rhs(dsk50):

do

y__88 := unapply(rhs(dsk50), x):
y__88(1)

Do you want to:

  1. Define a user Distribution (B1) in order to construct a RandomVariable X and to be able to Sample it?
  2. Simply generate a Sample from a ZIP (Zero-Inflated Poisson) model?
  3. Do regression?  

Consructing a Distribution with the only purpose of sampling it (point 1 above) has absolutely no point, and is a useless piece of work.
We construct a Distribution when we want to perform formal operations on a random variable whose distribution is Distribution. If only the generation of a sample matters, you just have to design a sampling algorithm.
To help you understand the futility of the construction of a Distribution, here is a simple example to draw a sample from the classical univariate ZIP model
Univariate_ZIP.mw

(Think to softwares like R, SPSS, Matlab to cite a few: they have little or no formal capabilities compared to Maple: even if they do not contain any abstract construction of random variables, they are nevertheless capable  to generate samples, even for functions of several random variables.)

So I believe that the first question you must answer to is "What do I want to do in fine, and do I need everything I've written to achieve it?"
If you just want to generate a sample of a bivariate ZIP model things are quite simple.
If you want to construct the bivariate random variable of this ZIP model things can become very touchy.
_____________________________________________________

For the moment, assuming that you really want to construct the distribution of a bivariate ZIP random variable, your code contains several errors and undefined quantities.
Look here a partial correction of your code:
(Stochastic representations of ZIP models generally use Bernoulli random variables. I can't see any in your code, but it contains two Binomial random variables oughtn't they not to be Bernoulli random variables?)

restart:  

with(Statistics):  

randomize():  

N    := 100;

`x__01` := Vector[row](N, [1$N]):  

`x__11` := Sample(Binomial(N, 0.4), N):

`x__22` := Sample(Normal(0, 1), N):  

`z__02` := Vector[row](N, [1$N]):

`z__12` := Sample(Binomial(N, 0.4), N):  

`z__22` := Sample(Normal(0, 1), N):  

100

 

P

(1)

gamma__01 *~ `z__01`

gamma__01*z__01

(2)

# As you operate on vectors use +~ instead of +, *~instead od *, exp~instead of exp and so on
# undefined quantities in red

aux1 := ((1 +~ exp~(-(gamma__01 *~ `z__01` +~  gamma__11 *~ `z__11` +~ gamma__21 *~ `z__21`)))):
aux2 := ((1 +~ exp~(-(gamma__02 *~ `z__02` +~ gamma__12 *~ `z__12` +~ gamma__22 *~ `z__22`)))):

phi__1 := 1 /~ aux1 ;     

phi__2 := 1/~ aux2;  

lambda__1 := exp~(beta__01 *~ `x__01` +beta__11 *~ `x__11` + beta__21 *~ `x__21`) *~ aux1;

lambda__2 := exp~(beta__02 *~ `x__02` +~ beta__12 *~ `x__12` +~ beta__22 *~ `x__22`) *~ aux2;

`#msub(mi("φ",fontstyle = "normal"),mi("1"))` := 1/(1+exp(-`#msub(mi("z"),mi("01"))`*`#msub(mi("γ",fontstyle = "normal"),mi("01"))`-`#msub(mi("z"),mi("11"))`*`#msub(mi("γ",fontstyle = "normal"),mi("11"))`-`#msub(mi("z"),mi("21"))`*`#msub(mi("γ",fontstyle = "normal"),mi("21"))`))

 

`#msub(mi("φ",fontstyle = "normal"),mi("2"))` := Vector(4, {(1) = ` 1 .. 100 `*Vector[row], (2) = `Data Type: `*anything, (3) = `Storage: `*rectangular, (4) = `Order: `*Fortran_order})

 

`#msub(mi("λ",fontstyle = "normal"),mi("1"))` := exp(`#msub(mi("β",fontstyle = "normal"),mi("21"))`*`#msub(mi("x"),mi("21"))`+(Vector(4, {(1) = ` 1 .. 100 `*Vector[row], (2) = `Data Type: `*anything, (3) = `Storage: `*rectangular, (4) = `Order: `*Fortran_order})))*(1+exp(-`#msub(mi("z"),mi("01"))`*`#msub(mi("γ",fontstyle = "normal"),mi("01"))`-`#msub(mi("z"),mi("11"))`*`#msub(mi("γ",fontstyle = "normal"),mi("11"))`-`#msub(mi("z"),mi("21"))`*`#msub(mi("γ",fontstyle = "normal"),mi("21"))`))

 

Vector[row](%id = 18446744078400074326)

(3)


Fix the issues above (undefined variables) and let me know when it's done.

 

Download mmcdara_step_1.mw

The next command in your file is

B:= (y[1],  y[2])->([[phi +(1-phi)*((e)^(-lambda[1]- lambda[2])*(1+ alpha*(1-(e)^(-(1-(e)^(-1))*lambda[1]))*(1-(e)^(-(1-(e)^(-1))*lambda[2])))),],[(1-phi)*((e)^(-lambda[1]- lambda[2])*((lambda[1])^(y[1]) *  (lambda[2])^(y[2]))/(y[1]!* y[2]!)*((1+ alpha)*((e)^(-y[1])-(e)^(-(1-(e)^(-1))*lambda[1]))*((e)^(-y[2])-(e)^(-(1-(e)^(-1))*lambda[2])))),]]):  

It contains a lot of misplaced commas and a lot of (e)^(something). This latter is a common error many newbies do instead of writting  exp(something): in Maple "e" is just a name and e^(-1) is not 1/exp(1).
After corrections it seems you should have been written (it's likely I used too many "~" but I do not know what quantities are scalars and whar are vectors or matrices).

B:= y -> (
[
  [
    phi +(1-phi)*(exp~(-lambda[1]-lambda[2])*~(1+alpha*~(1-~exp~(-(1-~exp(-1))*lambda[1]))*(1-exp~(-(1-exp~(-1))*lambda[2]))))
  ],
  [
    (1-phi)*(exp~(-lambda[1]-lambda[2])*((lambda[1])^(y[1]) *  (lambda[2])^(y[2]))/(y[1]!* y[2]!)*((1+ alpha)*(exp~(-y[1])-exp~(-(1-exp(-1))*lambda[1]))*(exp~(-y[2])-exp~(-(1-exp(-1))*lambda[2]))))
  ]
]
):

Note the expression of B contains phi which appears later to be a scalar value and has nothing to do with previously defined phi__1 and phi__2.
So my question: What is the purpose of defining  phi__1 and phi__2 given they are never used.

Had you expressed your problem in a more synthetic form, with simple words, it would have been simpler to understand what you want to achieve and, maybe, to help you.

that can be found using solve

Please: could you write correctly the left hand sides ot all the odes?

restart:

kernelopts(version)

`Maple 2015.2, APPLE UNIVERSAL OSX, Dec 20 2015, Build ID 1097895`

(1)

deqs := {
diff(Cb(t), t) = beta1*Cb(t)*Va(t)-(delta+psi1+varsigma1)*Cb(t),
diff(Df(t), t) = beta4*Df(t)*Va(t)-(delta+psi4+varsigma4)*Df(t),
diff(Fn(t), t) = beta3*Fn(t)*Va(t)-(delta+psi3+varsigma3)*Fn(t),
diff(Rs(t), t) = psi1*Cb(t)+psi2*Sc(t)+psi3*Fn(t)+psi4*Df(t)-delta*Rs(t)-varsigma1*Cb(t)-varsigma2*Sc(t)-varsigma3*Fn(t)-varsigma4*Df(t),
diff(Sc(t), t) = beta2*Sc(t)*Va(t)-(delta+psi2+varsigma2)*Sc(t),
diff(Va(t), t) = Phi-(beta1*Cb(t)+beta2*Sc(t)+beta3*Fn(t)+beta4*Df(t))*Va(t)-delta*Va(t)
}:
print~(deqs):

diff(Cb(t), t) = beta1*Cb(t)*Va(t)-(delta+psi1+varsigma1)*Cb(t)

 

diff(Df(t), t) = beta4*Df(t)*Va(t)-(delta+psi4+varsigma4)*Df(t)

 

diff(Fn(t), t) = beta3*Fn(t)*Va(t)-(delta+psi3+varsigma3)*Fn(t)

 

diff(Rs(t), t) = psi1*Cb(t)+psi2*Sc(t)+psi3*Fn(t)+psi4*Df(t)-delta*Rs(t)-varsigma1*Cb(t)-varsigma2*Sc(t)-varsigma3*Fn(t)-varsigma4*Df(t)

 

diff(Sc(t), t) = beta2*Sc(t)*Va(t)-(delta+psi2+varsigma2)*Sc(t)

 

diff(Va(t), t) = Phi-(beta1*Cb(t)+beta2*Sc(t)+beta3*Fn(t)+beta4*Df(t))*Va(t)-delta*Va(t)

(2)

ind := [indets(rhs~(deqs), function)[]];
unknowns := map2(op, 0, ind);

[Cb(t), Df(t), Fn(t), Rs(t), Sc(t), Va(t)]

 

[Cb, Df, Fn, Rs, Sc, Va]

(3)

eval(rhs~(deqs), ind =~ unknowns):

print~(solve(%, unknowns)):

[Cb = (Phi*beta1-delta^2-delta*psi1-delta*varsigma1)/(beta1*(delta+psi1+varsigma1)), Df = 0, Fn = 0, Rs = (Phi*beta1-delta^2-delta*psi1-delta*varsigma1)*(psi1-varsigma1)/(beta1*(delta+psi1+varsigma1)*delta), Sc = 0, Va = (delta+psi1+varsigma1)/beta1]

 

[Cb = 0, Df = (Phi*beta4-delta^2-delta*psi4-delta*varsigma4)/(beta4*(delta+psi4+varsigma4)), Fn = 0, Rs = (Phi*beta4-delta^2-delta*psi4-delta*varsigma4)*(psi4-varsigma4)/(beta4*(delta+psi4+varsigma4)*delta), Sc = 0, Va = (delta+psi4+varsigma4)/beta4]

 

[Cb = 0, Df = 0, Fn = (Phi*beta3-delta^2-delta*psi3-delta*varsigma3)/(beta3*(delta+psi3+varsigma3)), Rs = (Phi*beta3-delta^2-delta*psi3-delta*varsigma3)*(psi3-varsigma3)/(beta3*(delta+psi3+varsigma3)*delta), Sc = 0, Va = (delta+psi3+varsigma3)/beta3]

 

[Cb = 0, Df = 0, Fn = 0, Rs = 0, Sc = 0, Va = Phi/delta]

 

[Cb = 0, Df = 0, Fn = 0, Rs = (Phi*beta2-delta^2-delta*psi2-delta*varsigma2)*(psi2-varsigma2)/(beta2*(delta+psi2+varsigma2)*delta), Sc = (Phi*beta2-delta^2-delta*psi2-delta*varsigma2)/(beta2*(delta+psi2+varsigma2)), Va = (delta+psi2+varsigma2)/beta2]

(4)

# No infection... does it mean Va = 0?

subsystem := eval(remove(has, deqs, diff(Va(t), t)), Va(t) = 0):
print~(subsystem):

diff(Cb(t), t) = -(delta+psi1+varsigma1)*Cb(t)

 

diff(Df(t), t) = -(delta+psi4+varsigma4)*Df(t)

 

diff(Fn(t), t) = -(delta+psi3+varsigma3)*Fn(t)

 

diff(Rs(t), t) = psi1*Cb(t)+psi2*Sc(t)+psi3*Fn(t)+psi4*Df(t)-delta*Rs(t)-varsigma1*Cb(t)-varsigma2*Sc(t)-varsigma3*Fn(t)-varsigma4*Df(t)

 

diff(Sc(t), t) = -(delta+psi2+varsigma2)*Sc(t)

(5)

ind := [indets(rhs~(subsystem), function)[]]:
unknowns := map2(op, 0, ind);

[Cb, Df, Fn, Rs, Sc]

(6)

eval(rhs~(subsystem), ind =~ unknowns);

{-(delta+psi1+varsigma1)*Cb, -(delta+psi2+varsigma2)*Sc, -(delta+psi3+varsigma3)*Fn, -(delta+psi4+varsigma4)*Df, Cb*psi1-Cb*varsigma1+Df*psi4-Df*varsigma4+Fn*psi3-Fn*varsigma3-Rs*delta+Sc*psi2-Sc*varsigma2}

(7)

print~(solve(%, unknowns)):

[Cb = 0, Df = 0, Fn = 0, Rs = 0, Sc = 0]

(8)

 

Download Five_stationnary_states.mw

(As your stationary state without infection doesn't contain Va(t) I suspected that Va(t) was the "infection" (???) in which case the the solution is given (thin black text) in the attached file.

Two questions:

  1. What does "absence of infection" mean ?
  2. What is "Q" ?
    You claim it is the statiobary value of Cb in case of no infection, but "Q" doesn't appear in your equations.

Hi,

The attached file contains the construction of the Inverse-ChiSquare(n) distribution (first part of the file) and of a Generalized-Inverse-ChiSquare(a, b, n) distribution (the distribution of Y = a + b*X where X ~ Inverse-ChiSquare(n) ).

restart;
st:=time():

with(Statistics):

 

Inverse-ChiSquare distribution

 

InvChi2 := proc(n)
  # source = https://en.wikipedia.org/wiki/Inverse-chi-squared_distribution
  description "inverse chisquare distribution with n=degrees of freedom";

  Distribution(
    PDF = unapply( 2^(-n/2)/GAMMA(n/2)*t^(-n/2-1)*exp(-1/2/t)/abs(b), t)

    , CDF = unapply(GAMMA(n/2, 1/2/t)/GAMMA(n/2), t)

    , Mean = 1/(n-2)

    , Median = 1/(n*(1-2/9/n)^3)

    , Mode = 1/(n+2)

    , Variance = piecewise(n > 4, 2/(n-2)^2/(n-4), undefined)

    , Skewness = piecewise(n > 6, 4/(n-6)*sqrt(2*(n-4)), undefined)

    , Kurtosis = piecewise(n > 8, 12*(5*n-22)/(n-6)/(n-8), undefined)

    , Conditions = [n > 2]

    , RandomSample = proc(N::nonnegint)
        1 /~ Sample(GammaDistribution(2/n, n/2), N)
      end proc
  );
end proc:

IC2:= RandomVariable(InvChi2(n));


pdf      = PDF(IC2, t);
cdf      = CDF(IC2, t);
mean     = Mean(IC2);
median   = Median(IC2);
variance = Variance(IC2);
skewness = Skewness(IC2);
kurtosis = Kurtosis(IC2);

IC2 := _R14

 

pdf = 2^(-(1/2)*n)*t^(-(1/2)*n-1)*exp(-1/(2*t))/(GAMMA((1/2)*n)*abs(b))

 

cdf = GAMMA((1/2)*n, 1/(2*t))/GAMMA((1/2)*n)

 

mean = 1/(n-2)

 

median = 1/(n*(1-2/(9*n))^3)

 

variance = piecewise(4 < n, 2/((n-2)^2*(n-4)), undefined)

 

skewness = piecewise(6 < n, 4*sqrt(2*n-8)/(n-6), undefined)

 

kurtosis = piecewise(8 < n, 12*(5*n-22)/((n-6)*(n-8)), undefined)

(1)

IC2:= RandomVariable(InvChi2(5));


pdf      = PDF(IC2, t);
cdf      = CDF(IC2, t);
mean     = Mean(IC2);
median   = Median(IC2);
mode     = Mode(IC2);
variance = Variance(IC2);
skewness = Skewness(IC2);
kurtosis = Kurtosis(IC2);

S := Sample(IC2, 10^4):
Histogram(log[10]~(S), title=typeset(log__10('S')));

_R19

 

pdf = (1/6)*2^(1/2)*exp(-(1/2)/t)/(Pi^(1/2)*t^(7/2)*abs(b))

 

cdf = (4/3)*((1/4)*2^(1/2)*(1/t)^(3/2)*exp(-(1/2)/t)+(3/4)*2^(1/2)*(1/t)^(1/2)*exp(-(1/2)/t)+(3/4)*Pi^(1/2)*erfc((1/2)*2^(1/2)*(1/t)^(1/2)))/Pi^(1/2)

 

mean = 1/3

 

median = 18225/79507

 

mode = 1/7

 

variance = 2/9

 

skewness = undefined

 

kurtosis = undefined

 

 

 

Generalized-Inverse-ChiSquare distribution

(aka scaled and translated Inverse-ChiSquare distribution)

 

 

GenInvChi2 := proc(a, b, n)
  # source = https://en.wikipedia.org/wiki/Inverse-chi-squared_distribution
  description "inverse chisquare distribution with a=location, b=scale, n=degrees of freedom";


  local IC2      := RandomVariable(InvChi2(n));
  local pdf      := unapply(PDF(IC2, t), t);
  local cdf      := unapply(CDF(IC2, t), t);
  Distribution(
    
    PDF = unapply( pdf((t-a)/b), t)

    , CDF = unapply( cdf((t-a)/b), t)

    , Mean = a + b*Mean(IC2)

    , Median = a + b*Median(IC2)

    , Mode = a + b*Mode(IC2)

    , Variance = b^2*Variance(IC2)

    , Skewness = Skewness(IC2)

    , Kurtosis = Kurtosis(IC2)

    , Conditions = [n > 2, b > 0]

    , RandomSample = proc(N::nonnegint)
        a +~ b /~ Sample(GammaDistribution(2/n, n/2), N)
      end proc
  );
end proc:

GIC2 := RandomVariable(GenInvChi2(a, b, n));


pdf      = PDF(GIC2, t);
cdf      = CDF(GIC2, t);
mean     = Mean(GIC2);
median   = Median(GIC2);
mode     = Mode(GIC2);
variance = Variance(GIC2);
skewness = Skewness(GIC2);
kurtosis = Kurtosis(GIC2);

GIC2 := _R27

 

pdf = 2^(-(1/2)*n)*((t-a)/b)^(-(1/2)*n-1)*exp(-(1/2)*b/(t-a))/(GAMMA((1/2)*n)*b)

 

cdf = GAMMA((1/2)*n, (1/2)*b/(t-a))/GAMMA((1/2)*n)

 

mean = a+b/(n-2)

 

median = a+b/(n*(1-2/(9*n))^3)

 

mode = a+b/(n+2)

 

variance = b^2*piecewise(4 < n, 2/((n-2)^2*(n-4)), undefined)

 

skewness = piecewise(6 < n, 4*sqrt(2*n-8)/(n-6), undefined)

 

kurtosis = piecewise(8 < n, 12*(5*n-22)/((n-6)*(n-8)), undefined)

(2)

GIC2 := RandomVariable(GenInvChi2(2, 4.32, 3));


pdf      = PDF(GIC2, t);
cdf      = CDF(GIC2, t);
mean     = Mean(GIC2);
median   = Median(GIC2);
mode     = Mode(GIC2);
variance = Variance(GIC2);
skewness = Skewness(GIC2);
kurtosis = Kurtosis(GIC2);

S := Sample(GIC2, 10^4):
Histogram(log[10]~(S), title=typeset(log__10('S')));

_R29

 

pdf = (1/2)*2^(1/2)*exp(-(1/2)/(.2314814815*t-.4629629630))/(Pi^(1/2)*(.2314814815*t-.4629629630)^(5/2)*abs(b))

 

cdf = 2*((1/2)*2^(1/2)*(1/(.2314814815*t-.4629629630))^(1/2)*exp(-(1/2)/(.2314814815*t-.4629629630))+(1/2)*Pi^(1/2)*erfc((1/2)*2^(1/2)*(1/(.2314814815*t-.4629629630))^(1/2)))/Pi^(1/2)

 

mean = 6.32

 

median = 3.813985280

 

mode = 2.864000000

 

variance = Float(undefined)

 

skewness = undefined

 

kurtosis = undefined

 

 

 

Download InverseChi2_and_GeneralizedInverseChi2.mw

Maybe you wonder why I used an a priori so complex construction for InverseChi2 ?
Given that  Y ~ Inverse-ChiSquare(n) iif  X~ ChiSquare(n) and Y=1/X, another possibility would have been to write :

InvChi2 := proc(n)
  # source = https://en.wikipedia.org/wiki/Inverse-chi-squared_distribution
  description "inverse chisquare distribution with n=degrees of freedom";

  local X := RandomVariable(ChiSquare(n)):
  local Y := 1/X:
  Distribution(
    PDF = unapply(PDF(Y, t), t)
    , CDF = unapply(CDF(Y, t), t)
  );
end proc:

But the problem is that Maple meets difficulties to compute some ot these statistics if not returning wrong results (I'm almost sure of that but I need to check it one more time).
InverseChi2_Why_explicit_expresions.mw

LAST POINT: I didn't check if the definitions of the skewness and kurtosis I used here and I got on Wikipedia (reference within the procedures) are the one used in Maple (which are normalized, and quite common, expressions).

First remark:
Does the matrix you want to build have some particular type?
For instance are its elements integer, real, complex; is it symmetrix (diagonal would be perfect :-) )

Second remark:
Let's suppose that you build this matrix by modifying some initial matrix in an adhoc way.
Let M

N := ...;
M := LinearAlgebra:-RandomMatrix(N$2, generator=a..b)

this matrix.
One can easily build a transformation F (in fact an infinity of them) applied to M such Determinant(F(M)) = some given value. But this implies that the elements of  F(M) will no longer be able to be considered as samples from "generator=a..b"
(
using "generator=a..b" means that the elements of the random matrix are realizations of N^2 mutually indepenent and identically distributed random variables... but forcing the determinant to some value introduces constraints which break the independency
).

Final remark:
In case of random matrices of integers, only integers value can be a determinant of such matrices.
Reciprocally: Prob(determinant(M)::integer | a::real, b::real) = 0.

The only way to preserve the statistics of the random matrices while forcing their determinant, is to generate a (potentially) large number of such matrices ank the one whose determinant is closer to the desired one.
But it is an highly inefficient method.

Here are a few transformations of a an arbitrary random matrix to another one whose determinant has a given value.

ManySolutions.mw

restart

eq_27 := diff(u[n](t), t$2) = alpha*(- exp(-beta*u[n-1](t)) + 2*exp(-beta*u[n](t)) - exp(-beta*u[n+1](t)))

diff(diff(u[n](t), t), t) = alpha*(-exp(-beta*u[n-1](t))+2*exp(-beta*u[n](t))-exp(-beta*u[n+1](t)))

(1)

eq_28 := n -> exp(-beta*u[n](t)) = 1+v[n](t)/alpha

proc (n) options operator, arrow; exp(-beta*u[n](t)) = 1+v[n](t)/alpha end proc

(2)

aux_1 := isolate(eq_28(n), u[n](t));

u[n](t) = -ln((v[n](t)+alpha)/alpha)/beta

(3)

eq_29 := eval(convert(lhs(eq_27), Diff), aux_1)
         =
         simplify(eval(rhs(eq_27), {seq(eq_28(n+k), k=-1..1)}));

Diff(Diff(-ln((v[n](t)+alpha)/alpha)/beta, t), t) = -v[n-1](t)+2*v[n](t)-v[n+1](t)

(4)

lhs_27 := eval(lhs(eq_27), u[n]=(t -> u[n](xi[n](t)))):
d      := [select(has, indets(%), diff)[]]:
lhs_27 := eval(lhs_27, d =~ eval(d, xi[n](t) = d__1*n + c__1*t + zeta__1)):
lhs_27 := convert(eval(lhs_27, xi[n](t)=xi[n]), diff);

(diff(diff(u[n](xi[n]), xi[n]), xi[n]))*c__1^2

(5)

aux_2 := select(has, indets(rhs(aux_1), function), ln)[] = H(t);

ln((v[n](t)+alpha)/alpha) = H(t)

(6)

eq_29_a := simplify(isolate(convert(eval(eq_29, aux_2), diff), diff(H(t), t$2)));

diff(diff(H(t), t), t) = (v[n-1](t)-2*v[n](t)+v[n+1](t))*beta

(7)

eq_30_1 := lhs_27=rhs(eq_29_a)

(diff(diff(u[n](xi[n]), xi[n]), xi[n]))*c__1^2 = (v[n-1](t)-2*v[n](t)+v[n+1](t))*beta

(8)

eq_30 := eval(convert(eq_30_1, Diff), u[n](xi[n])=lhs(aux_2))

(Diff(Diff(ln((v[n](t)+alpha)/alpha), xi[n]), xi[n]))*c__1^2 = (v[n-1](t)-2*v[n](t)+v[n+1](t))*beta

(9)


Download From_27_to_30.mw

There are still a lot of informations you did not provide:

  • What are the ranges of the parameters you want to adjust?
  • At least can you tell which ones are potive and which ones are negative?
  • Do you have some prior guess, I mean an a priori reasonable initial point to give to the optimization procedure?
  • What are your initial condiitons?
  • At some point you will have to minimize the discrepancy between experimental data and data generated by your model: how do you "measure" this discrepancy?
    Stated otherwise, what is the expression of the function you want to minimize?
  • ... and maybe some other stuff I do not have in mind.

Whatever, here is a file where you will find how to fit the 8 parameters (I hope I didn't miss some).
The strategy used is quite raw. It is likely that we could do something more subtle which accounts to the specific structure ot your model (in de1 only A(t) appears and it's parameters could then be adjusted independently of the others, leading to a "two shots fitting method").

In case of A(t), l(t) and S(t) have different orders of magnitude, as it seems to be the case in the experimental data you provide, it's likely that normalizing them (and the simulation data too) will be a good way to preprocess the data.
Weighing the discrepancy is also often a good practice.

restart;

with(plots):with(CurveFitting);

[ArrayInterpolation, BSpline, BSplineCurve, Interactive, LeastSquares, Lowess, PolynomialInterpolation, RationalInterpolation, Spline, ThieleInterpolation]

(1)

with(DEtools):with(linalg):
with(LinearAlgebra):
with(plots):
#with(Student[VectorCalculus]);
with(plots, implicitplot):
with(Student[Calculus1]):

The vector field:

rhs1 := (A,l,S) -> alpha__AP*A - mu__A*A;
rhs2 := (A,l,S) -> alpha__lS*l*S - mu__l*l - beta__Al*l*A;
rhs3 := (A,l,S) -> alpha__S*S - beta__lS*l*S - beta__AS*A*S;

proc (A, l, S) options operator, arrow; alpha__AP*A-mu__A*A end proc

 

proc (A, l, S) options operator, arrow; alpha__lS*l*S-mu__l*l-beta__Al*l*A end proc

 

proc (A, l, S) options operator, arrow; alpha__S*S-beta__lS*l*S-beta__AS*A*S end proc

(2)

Equilibria:

equilibria := solve([rhs1(A,l,S), rhs2(A,l,S), rhs3(A,l,S)], [A,l,S]);

[[A = 0, l = 0, S = 0], [A = 0, l = alpha__S/beta__lS, S = mu__l/alpha__lS]]

(3)

The differential equations:

de1 := diff(A(t), t) = rhs1(A(t),l(t),S(t));
de2 := diff(l(t), t) = rhs2(A(t),l(t),S(t));
de3 := diff(S(t), t) = rhs3(A(t),l(t),S(t));

diff(A(t), t) = alpha__AP*A(t)-mu__A*A(t)

 

diff(l(t), t) = alpha__lS*l(t)*S(t)-mu__l*l(t)-beta__Al*l(t)*A(t)

 

diff(S(t), t) = alpha__S*S(t)-beta__lS*l(t)*S(t)-beta__AS*A(t)*S(t)

(4)

# To dsolve numericaly all the parameters must be given numerical value, or,
# you must use the option "parameter":

sys := {de1, de2, de3, A(0)=A__0, l(0)=l__0, S(0)=S__0}:

params := convert(indets(sys, name) minus {t}, list);

[A__0, S__0, l__0, mu__A, mu__l, alpha__AP, alpha__S, alpha__lS, beta__AS, beta__Al, beta__lS]

(5)

NP := numelems(params):
P := [seq(rand(0. .. 1.)(), n=1..NP)]

[.8953600369, .2617341097, .7780122500, 0.6587642124e-1, .7235311453, .3157837057, 0.5872123377e-1, .5108327385, 0.8517118248e-1, .1791765017, .5849452936]

(6)

# Solution procedure


Simulator := proc(P, times)
  dsolve(eval(sys, params=~P), numeric, output=Array(times)):
end proc:
 

sys    := {de1, de2, de3, A(0)=A__0, l(0)=l__0, S(0)=S__0}:
params := convert(indets(sys, name) minus {t}, list);
NP     := numelems(params):

# A set of parameters I will consider as the set which generates the experimental data

P_exp := [seq(rand(0. .. 1.)(), n=1..NP)]:
T_exp := [$1..4]:
print~(params=~P_exp):


# Given P_exp and T_ext, here are the experimental data you would get, provided:
#
#  (1) Times T_ext are free of measurement errors.
#
#  (2) A, l and S values are free of measurement errors.
#
#  (3) The model itself (set of odes) has no modeling bias (meaning it represents
#      perfectly he same reality which is observed during the experiments).
#
# Given the way "Experiences" are generated here these three conditions are verified.
# But you must be aware of them when you will deal with true experimental data.
#
# I choosed this strtegy because you did not provide any unformation on the prior
# knowledge about the parameters to fit.


Experiences := Simulator(P_exp, T_exp)[2][1]

params := [`#msub(mi("A"),mi("0"))`, `#msub(mi("S"),mi("0"))`, `#msub(mi("l"),mi("0"))`, `#msub(mi("&mu;",fontstyle = "normal"),mi("A"))`, `#msub(mi("&mu;",fontstyle = "normal"),mi("l"))`, `#msub(mi("&alpha;",fontstyle = "normal"),mi("AP"))`, `#msub(mi("&alpha;",fontstyle = "normal"),mi("S"))`, `#msub(mi("&alpha;",fontstyle = "normal"),mi("lS"))`, `#msub(mi("&beta;",fontstyle = "normal"),mi("AS"))`, `#msub(mi("&beta;",fontstyle = "normal"),mi("Al"))`, `#msub(mi("&beta;",fontstyle = "normal"),mi("lS"))`]

 

A__0 = .9756863545

 

S__0 = .5463328867

 

l__0 = .6001239943

 

mu__A = .9519402194

 

mu__l = .4530054535

 

alpha__AP = .6130574612

 

alpha__S = .1454385066

 

alpha__lS = .8465880241

 

beta__AS = .1252254115

 

beta__Al = .1275408863

 

beta__lS = .9722223978

 

Experiences := Matrix(4, 4, {(1, 1) = HFloat(1.0), (1, 2) = HFloat(0.6952409042863898), (1, 3) = HFloat(0.3333866523291111), (1, 4) = HFloat(0.4924164247433441), (2, 1) = HFloat(2.0), (2, 2) = HFloat(0.49540500863778375), (2, 3) = HFloat(0.2360059030718795), (2, 4) = HFloat(0.3675519323868015), (3, 1) = HFloat(3.0), (3, 2) = HFloat(0.35300875610521093), (3, 3) = HFloat(0.19086549082483467), (3, 4) = HFloat(0.26468114350941063), (4, 1) = HFloat(4.0), (4, 2) = HFloat(0.25154202406112974), (4, 3) = HFloat(0.1709249488613265), (4, 4) = HFloat(0.18852318573763832)})

(7)

# Define an objective function aimed to measure the discrepancy between experiences and
# simulations.
#
# I suppose that your initial conditions A__0, l__0 and S__0 (parameters 1 to 3) have
# KNOWN values that can be isolate form your 11 parameters (8 UNKNOWN value parameters remain).
#
# Here I choosed something very simple.

Discrepancy := proc(p4, p5, p6, p7, p8, p9, p10, p11)
  local P := [IC[], _passed]:
  local Sim := Simulator(P, T_exp)[2][1]:
  add((Experiences[.., 2..4] - Sim[.., 2..4])^~2)
end proc:

# Example of use.
#
# I suppose that your initial conditions A__0, l__0 and S__0 are KNOWN values that can
# be isolate form your 111 parameters.

IC     := P_exp[1..3];
P_exp;
P_test := P_exp[4..NP] +~ [seq(rand(-0.1..0.1)(), n=4..NP)];

Discrepancy(P_test[])

[.9756863545, .5463328867, .6001239943]

 

[.9756863545, .5463328867, .6001239943, .9519402194, .4530054535, .6130574612, .1454385066, .8465880241, .1252254115, .1275408863, .9722223978]

 

[1.044186899, .3624709889, .6029853327, .1862928981, .8314071466, 0.286473626e-1, .1309445020, .9688395126]

 

HFloat(0.06798948400015192)

(8)

# Find the set of parameter values which minimizes the discrepancy


ParamRanges := seq(0.5*P_exp[n]..2*P_exp[n], n=4..NP):

opt := Optimization:-Minimize(Discrepancy, ParamRanges):

MinimalDiscrepancy := opt[1];

interface(rtablesize=NP+1):

`<,>`(
  Vector[row](3, ["Parameter", "Exp. value", "Best Fit"]),
  evalf[6](Matrix(NP-3, 3, (i, j) -> `if`(j=1, params[i+3], `if`(j=2, P_exp[i], opt[2][i]))))
)

MinimalDiscrepancy := 7.84084529035125120*10^(-20)

 

Matrix([["Parameter", "Exp. value", "Best Fit"], [mu__A, .975686, 1.14756], [mu__l, .546333, .453005], [alpha__AP, .600124, .808682], [alpha__S, .951940, .145439], [alpha__lS, .453005, .846588], [beta__AS, .613057, .125225], [beta__Al, .145439, .127541], [beta__lS, .846588, .972222]])

(9)

# Another rum from a different initial point.
#
# Find the set of parameter values which minimizes the discrepancy


StartFrom := [seq(rand(0. .. 1.)(), n=4..NP)]:

opt := Optimization:-Minimize(Discrepancy, ParamRanges, initialpoint=StartFrom):

MinimalDiscrepancy := opt[1];

interface(rtablesize=NP+1):

`<,>`(
  Vector[row](3, ["Parameter", "Exp. value", "Best Fit"]),
  evalf[6](Matrix(NP-3, 3, (i, j) -> `if`(j=1, params[i+3], `if`(j=2, P_exp[i], opt[2][i]))))
)

MinimalDiscrepancy := 2.68781058384918034*10^(-18)

 

Matrix([["Parameter", "Exp. value", "Best Fit"], [mu__A, .975686, 1.19135], [mu__l, .546333, .453005], [alpha__AP, .600124, .852463], [alpha__S, .951940, .145438], [alpha__lS, .453005, .846588], [beta__AS, .613057, .125226], [beta__Al, .145439, .127541], [beta__lS, .846588, .972222]])

(10)

# FUZZY EXPERIMENTAL DATA

ErrorFreeExperiences := copy(Experiences):
FuzzyExperiences     := Experiences + `<|>`(Vector(4, 0), Statistics:-Sample(Normal(0, 0.1), [4, 3])):
Experiences          := copy(FuzzyExperiences);
 

Experiences := Matrix(4, 4, {(1, 1) = 1.0, (1, 2) = .5934828473168638, (1, 3) = .28536754958932503, (1, 4) = .5332094602563157, (2, 1) = 2.0, (2, 2) = .5511335763494679, (2, 3) = .20641874046665082, (2, 4) = .46628805805390544, (3, 1) = 3.0, (3, 2) = .45675534088981706, (3, 3) = 0.7778873764426907e-1, (3, 4) = .13359722472835653, (4, 1) = 4.0, (4, 2) = .21793233819484376, (4, 3) = .1742774293269861, (4, 4) = .2327436674189362}, datatype = float[8])

(11)

# Run 1

opt := Optimization:-Minimize(Discrepancy, ParamRanges, initialpoint=StartFrom):

MinimalDiscrepancy := opt[1];

interface(rtablesize=NP+1):

Res_1 :=
`<,>`(
  Vector[row](3, ["Parameter", "Exp. value", "Best Fit"]),
  evalf[6](Matrix(NP-3, 3, (i, j) -> `if`(j=1, params[i+3], `if`(j=2, P_exp[i], opt[2][i]))))
):



# Run 2 with another initial point


StartFrom := [seq(rand(0. .. 1.)(), n=4..NP)]:

opt := Optimization:-Minimize(Discrepancy, ParamRanges, initialpoint=StartFrom):

MinimalDiscrepancy := opt[1];

interface(rtablesize=NP+1):

Res_2 :=
`<,>`(
  Vector[row](3, ["Parameter", "Exp. value", "Best Fit"]),
  evalf[6](Matrix(NP-3, 3, (i, j) -> `if`(j=1, params[i+3], `if`(j=2, P_exp[i], opt[2][i]))))
):


# Comparison:

Res_12 := `<|>`(Res_1, Res_2[.., -1])

MinimalDiscrepancy := 0.561832022428544742e-1

 

MinimalDiscrepancy := 0.561832022428555566e-1

 

Res_12 := Matrix(9, 4, {(1, 1) = "Parameter", (1, 2) = "Exp. value", (1, 3) = "Best Fit", (1, 4) = "Best Fit", (2, 1) = `#msub(mi("&mu;",fontstyle = "normal"),mi("A"))`, (2, 2) = .975686, (2, 3) = 1.18747, (2, 4) = 1.03445, (3, 1) = `#msub(mi("&mu;",fontstyle = "normal"),mi("l"))`, (3, 2) = .546333, (3, 3) = .645788, (3, 4) = .645788, (4, 1) = `#msub(mi("&alpha;",fontstyle = "normal"),mi("AP"))`, (4, 2) = .600124, (4, 3) = .865335, (4, 4) = .712315, (5, 1) = `#msub(mi("&alpha;",fontstyle = "normal"),mi("S"))`, (5, 2) = .951940, (5, 3) = .290877, (5, 4) = .290877, (6, 1) = `#msub(mi("&alpha;",fontstyle = "normal"),mi("lS"))`, (6, 2) = .453005, (6, 3) = 1.69318, (6, 4) = 1.69318, (7, 1) = `#msub(mi("&beta;",fontstyle = "normal"),mi("AS"))`, (7, 2) = .613057, (7, 3) = 0.626127e-1, (7, 4) = 0.626127e-1, (8, 1) = `#msub(mi("&beta;",fontstyle = "normal"),mi("Al"))`, (8, 2) = .145439, (8, 3) = .128320, (8, 4) = .128320, (9, 1) = `#msub(mi("&beta;",fontstyle = "normal"),mi("lS"))`, (9, 2) = .846588, (9, 3) = 1.49787, (9, 4) = 1.49787})

(12)

 

IMPORTANT REMARK

It could be surprising that 4 triples (A, l, S) (thus 12 data) cannot enable to determine in a unique way the 8 parameters.
The two runs above give significantly different values (see for instance mu__A).

The reason is that the experimental data are NOT INDEPENDENT.

Indeed A(t), l(t), S(t) are not independent and thus the experimental observation of, let's say S(t) at some time, is not
independent of the observation of, let's say l(t), at this same time.
This why the two runs above give different "best fit" og royghly the same quality (both discrepancies are arpinrd 3e-8).

The dependency of A(t), l(t) and S(s) explains the lack of unicity of the "best fit".
Among the 8 parameters it's likely that a subset of them is of main importance, while the remaining subset is only
responsible of "small adjustments" (this is a thumb of rule in real multi-parameter problems).

Solutions of almost equal quality are spead on a variety of R^11 whose dimension is the cardinal of the subset of
"important" parameters

Collecting the value of A, l and S at only 4 times is not enough is not enough.
Increasing the number of time observations could help reducing the dimension of the previousvariety, which is
notat alla certainty, but it's main interest would be to assess the quality and the robustness of the "best fit" through
some training-and-validation strategy.
 

 


HOW TO HANDLE YOUR REAL PROBLEM?

# (0) Provide initial conditions
#     For simplicity keep the shown above and write

IC := "a list of 3 values";


`something like` =  P_exp[1..3];

"a list of 3 values"

 

`something like` = [.9756863545, .5463328867, .6001239943]

(13)

# (1) Define your real experiments

Experiences := Matrix(4, 4, [1,201.8,89.3,7, 2,257.27,113,13, 3,432.82,150.8,20, 4,730.909,169.8,27])

Experiences := Matrix(4, 4, {(1, 1) = 1, (1, 2) = 201.8, (1, 3) = 89.3, (1, 4) = 7, (2, 1) = 2, (2, 2) = 257.27, (2, 3) = 113, (2, 4) = 13, (3, 1) = 3, (3, 2) = 432.82, (3, 3) = 150.8, (3, 4) = 20, (4, 1) = 4, (4, 2) = 730.909, (4, 3) = 169.8, (4, 4) = 27})

(14)

# (2) Define the ranges of eaxh parameter

ParamRanges := "a sequence of 8 ranges";

`something like` =  seq(0.5*P_exp[n]..2*P_exp[n], n=4..NP)

"a sequence of 8 ranges"

 

`something like` = (.4759701097 .. 1.903880439, .2265027268 .. .9060109070, .3065287306 .. 1.226114922, 0.7271925330e-1 .. .2908770132, .4232940120 .. 1.693176048, 0.6261270575e-1 .. .2504508230, 0.6377044315e-1 .. .2550817726, .4861111989 .. 1.944444796)

(15)

# (3) Suitable while not necessary, define a good initial guess

StartFrom := "a list of 8 values, each in the corresponding ParamRange";

`something like` = [seq(rand(0. .. 1.)(), n=1..NP)];

"a list of 8 values, each in the corresponding ParamRange"

 

`something like` = [.3799209845, .7995366322, 0.2064667791e-1, .1277668084, .6328373412, .5759628388, .4963360952, .6559863541, .4005500613, .3565024675, .6504128478]

(16)

# (4) Run this command


# opt := Optimization:-Minimize(Discrepancy, ParamRanges, initialpoint=StartFrom):

 

Download data_fitting_2_mmcdara.mw

is to reparameterize fun by writting y=a*x and z=b*x,which gives an expression (K) which only depends on a and b.
Then Maximizing K for a reasonable initial point, gives (sometimes but not always) a maximum value close to 3.

I think that working of fun before maximizing it could be useful.

restart:

fun := ((2*(x+y+z))*(sqrt(y*z*(z+x)*(x+y))/(z+2*x+y)+sqrt(z*x*(x+y)*(y+z))/(x+2*y+z)+sqrt(x*y*(y+z)*(z+x))/(y+2*z+x))-9*x*y*z/(x+y+z)-2*(x*y+x*z+y*z))/(sqrt(x*y*z/(x+y+z))*(x+y+z-sqrt(27*x*y*z/(x+y+z))))

(2*(x+y+z)*((y*z*(z+x)*(x+y))^(1/2)/(z+2*x+y)+(z*x*(x+y)*(y+z))^(1/2)/(x+2*y+z)+(x*y*(y+z)*(z+x))^(1/2)/(y+2*z+x))-9*x*y*z/(x+y+z)-2*x*y-2*x*z-2*y*z)/((x*y*z/(x+y+z))^(1/2)*(x+y+z-3*3^(1/2)*(x*y*z/(x+y+z))^(1/2)))

(1)

J := eval(fun, [y=a*x, z=b*x]):
J := normal(J) assuming x > 0:

indets(%, name);

K := simplify(J, size)

{a, b}

 

-4*(-(a+b+1)^2*(a+(1/2)*b+1/2)*(a+2*b+1)*(a*b*(b+1)*(a+1))^(1/2)+(-(a+b+1)^2*(a+(1/2)*b+1/2)*(a*(a+b)*(b+1))^(1/2)+(-(1/2)*(a+b+1)^2*(b*(a+1)*(a+b))^(1/2)+(a+(1/2)*b+1/2)*((b+1)*a^2+(b^2+(15/2)*b+1)*a+b^2+b))*(a+2*b+1))*(a+b+2))/((a*b/(a+b+1))^(1/2)*(a+b+2)*(2*a+b+1)*(a+2*b+1)*(a+b+1)*(-3*(a*b/(a+b+1))^(1/2)*3^(1/2)+a+b+1))

(2)

opt := Optimization['Maximize'](K, assume = nonnegative, initialpoint = ({seq})(w = (evalf(rand(0. .. 10.)())), w in [a, b]))

[2.99997521027645897, [a = HFloat(5.919443231768365e-10), b = HFloat(3257954.1358281113)]]

(3)

# Ok, I was lucky, because changing the initial point doesn't always lead to a solution :-(

limit(fun, x=+infinity)

(-2*y-2*z+(y*z)^(1/2)+2*(y*z+z^2)^(1/2)+2*(y^2+y*z)^(1/2))/(y*z)^(1/2)

(4)

J := eval(fun, [x=a*y, z=b*y]):
J := normal(J) assuming y > 0:

indets(%, name);

K := simplify(J, size):

opt := Optimization['Maximize'](K, assume = nonnegative, initialpoint = ({seq})(w = (evalf(rand(0. .. 10.)())), w in [a, b]))

{a, b}

 

[2.99998920784625689, [a = HFloat(1.0686746169023969e-10), b = HFloat(3299620.511784931)]]

(5)

J := eval(fun, [x=a*z, y=b*z]):
J := normal(J) assuming z > 0:

indets(%, name);

K := simplify(J, size):

opt := Optimization['Maximize'](K, assume = nonnegative, initialpoint = ({seq})(w = (evalf(rand(0. .. 10.)())), w in [a, b]), iterationlimit=10^4)

{a, b}

 

[2.99986781035996186, [a = HFloat(1.5734336356888115e8), b = HFloat(4.496344944631562e12)]]

(6)

 


Download 2D_parameters.mw

Your code contains the name gamma, which is by default the Euler constant (0.5772156649): is this the value of gamma you want to use, or did you forget to do this

local gamma:
....
gamma := some_numeric_vaue;
...
dsolve(...)

?

About the error you get: odeplot the solution for the range t=0..0.6e-5 to see what happens.
The solutions seem to go to infinity when t tends to 0.6e-5... thus the "singulatity" Maple suspects.

This "singularity" is the result of the values you choosed for the parameters.
I advice you to check them, particularly their signs.

If this may help you understand where the problem could be, the attached file also contains a formal solution through serie expansions.
Could_help.mw


Does this suit you?
 

-> 

restart:

with(plots):
with(LinearAlgebra):

relaxG__xy := -(Matrix(3, 3, {(1, 1) = 258877736.8, (1, 2) = -258877736.8, (1, 3) = 0., (2, 1) = -258877736.8, (2, 2) = 258877736.8, (2, 3) = 0., (3, 1) = 0., (3, 2) = 0., (3, 3) = 65031182.60})) . (1/t^.9):


A := proc(M, T)
  local tau := max(1, T):
  matrixplot(eval(M, t=tau), heights=histogram, axes=boxed, title=typeset('t'=tau));
end proc:
animate(A, [relaxG__xy, 10*t], t=0..10, frames=11, paraminfo=false );

 


 

Download F.mw

 

  • For a safer code declare D as local (D is a symbol for differentiation).
  • In the definition of TPP: replace the square brackets by parenthesis (square brackets have other purposes).
  • A few packages are useless (linalg is an obsolete package replaced by LinearAlgebra for instance), others can be needed for futher purposes you do not mention.

Then 

diff(TPpm(Q, Qr), Q);
g1 := isolate(%, Q);

works correctly.
Just keep in mind that the last line above is a short for 

g1 := isolate(%=0, Q);

Here is your file corrected
q1_mmcdara.mw

``

restart:

f := b -> 47.965-(-(3.08*0.2*b^(1-0.7))/(GAMMA(3-0.7)))

proc (b) options operator, arrow; 47.965+3.08*.2*b^(1-.7)/GAMMA(3-.7) end proc

(1)

t := [seq(i, i = 1 .. 100, 10)]:
a := f~(t):  #type help(elementwise) to understand the syntax

dataplot(t, a)

 

# Or

plot(f(z), z=1..100)

 

 

Download ThisWay.mw

The distribution you want to build cannot have 3 parameters, 5 are needed:

  • 2 couples (probability, quantile), thus 4 parameters,
  • 1 more parameter for the mode.

Here is a the building of a 5-parameter Triangular distribution of type II:

restart:

with(Statistics):

TriangularTypeII := proc(Q, P, c)
   # Q = list of 2 quantiles
   # P = list of the associated probabilities
   # c  = mode


   local F   := unapply(CDF(Triangular(a, b, c), t), t):
   local eqs := {F(Q[1])=P[1], F(Q[2])=P[2]}:
   local AB  := solve(eqs, {a, b}):
   local T   := RandomVariable(Triangular(op(eval([a, b], AB)), c)):
   printf("According to Maple help pages : %a\n", eval(["a", "b", "c"]=~[a, b, c], AB));

   Distribution(
      PDF = unapply(PDF(T, t), t),
     
      CDF = unapply(CDF(T, t), t),

      Mean = Mean(T),

      Variance = Variance(T),

      Mode = c,

      Skewness = Skewness(T),
      Kurtosis = Kurtosis(T),

      #Conditions = [Q > P],

      RandomSample = proc(N::nonnegint)
                       Sample(T, N)
                     end proc
   )
end proc:

T := RandomVariable(TriangularTypeII([3, 5], [1/4, 3/4], 4))

According to Maple help pages : ["a" = 2-2^(1/2), "b" = 6+2^(1/2), "c" = 4]

 

_R1

(1)

f := PDF(T, x);
F := unapply(CDF(T, x), x):
'F(x)' = F(x);

omega := Support(T, output='range');

f := piecewise(x < 2-sqrt(2), 0, x <= 4, (2*(-2+sqrt(2)+x))/((4+2*sqrt(2))*(2+sqrt(2))), x <= 6+sqrt(2), (2*(6+sqrt(2)-x))/((4+2*sqrt(2))*(2+sqrt(2))), 0)

 

F(x) = piecewise(x < 2-2^(1/2), 0, x <= 4, (-2+2^(1/2)+x)^2/((4+2*2^(1/2))*(2+2^(1/2))), x <= 6+2^(1/2), 1-(6+2^(1/2)-x)^2/((4+2*2^(1/2))*(2+2^(1/2))), 1)

 

2-2^(1/2) .. 6+2^(1/2)

(2)

N := 10^3:
S := Sample(T, N):


plots:-display(
  Histogram(S),
  plot(f, x=omega, color=red, thickness=2)
);

plots:-display(
  ScatterPlot(sort(S), Vector(N, i -> i/N), symbol=point)
  , plot(F(x), x=omega, color=red, thickness=2)
  , gridlines=true
  , plot([[3, 0], [3, F(3)]], color=green)
  , plot([[5, 0], [5, F(5)]], color=green)
  , plot([[op(1, omega), F(3)], [3, F(3)]], color=green)
  , plot([[op(1, omega), F(5)], [5, F(5)]], color=green)
);

 

 

'Mean'          = evalf(Mean(T));
'EmpiricalMean' = Mean(S);
 print():

'Variance'          = evalf(Variance(T));
'EmpiricalVariance' = Variance(S);
 print():
'Skewness'          = evalf(Skewness(T));
'EmpiricalSkewness' = Skewness(S);
 print():

'Kurtosis'          = evalf(Kurtosis(T));
'EmpiricalKurtosis' = Kurtosis(S);
 print():

'Mode'          = evalf(Mode(T));
'EmpiricalMode' = Mode(S);
 print():

Statistics:-Mean = 4.

 

EmpiricalMean = HFloat(3.9457549090842075)

 

 

Statistics:-Variance = 1.942809041

 

EmpiricalVariance = HFloat(1.8109903462754544)

 

 

Statistics:-Skewness = 0.

 

EmpiricalSkewness = HFloat(0.06301060196838523)

 

 

Statistics:-Kurtosis = 2.400000000

 

EmpiricalKurtosis = HFloat(2.402054736302438)

 

 

Statistics:-Mode = 4.

 

EmpiricalMode = HFloat(3.9610709790716934)

(3)

'FirstQuartile'          = Quantile(T, 1/4);
'EmpiricalFirstQuartile' = Quantile(S, 1/4);
 print():
'ThirdQuartile'          = Quantile(T, 3/4);
'EmpiricalThirdQuartile' = Quantile(S, 3/4);
 print():

FirstQuartile = 3

 

EmpiricalFirstQuartile = HFloat(2.928500595626717)

 

 

ThirdQuartile = 5

 

EmpiricalThirdQuartile = HFloat(4.905483406168978)

 

(4)

 

Download TriangularDistribution.mw

One could improve this by:

  • defining the support of the distribution within TriangularTypeII,
  • checking the type of the arguments (Q::list, P::list),
  • verifying that the components of P are in [0, 1] (the order doesn't matter provided it is consistent with those of Q),
  • checking that min(Q) < c < max(Q),
  • ...

WATCH OUT:
Contrary to the SubjectiveBeta distribution of your previous thread, you cannot define a TriangularTypeII distribution with parameters ( [q1, q2], [p1, p2], c).
The reason is that there are too many conditions about these 5 parameters for solve being capable 
to solve equations eqs formally (eqs depends on 7 quantities q1, q2, p1, p2, c, a, b).
To give you an idea of the complexity of this problem, consider this

Tref := RandomVariable(Triangular(a, b, c))
                              _R3
Quantile(Tref, p) assuming p >=0, p <=1:
quant := unapply(%, p):

# In the case the first quantile is less than c and the second is larger than c,
# here are the solutions (a, b):

q__1 := op(2, quant(p__1)):
q__2 := op(3, quant(p__2)):

eqs := {q__1=Q__1, q__2=Q__2};

solve(eqs, {a, b}):  # uncomment to display
        /                          (1/2)         
       { a + (p__1 (b - a) (c - a))      = Q__1, 
        \                                        

                                           (1/2)       \ 
         b - ((-p__2 + 1) (b - a) (-c + b))      = Q__2 }
                                                       / 

@vv @minhthien2016

I was preparing "my proof" as you beat me to the punch.

My demonstration relies upon the fact that, under an ad hoc transformation, the original equation is of the form x^4 + p*x^2 + q = 0.
I hadn't seen the factorization of the initial equation.

restart

eq := (x-a)^4 + (x-b)^4 - c

(x-a)^4+(x-b)^4-c

(1)

# Rewrite eq by setting b=a+u and c=a+v

rew := collect(expand(eval(eq, [b=a+u, c=a+v])), x):

# Proceed as if you want to compute the formal solutions of this
# equation "by hand".
#
# As said in math books the first step is to apply the transformation
# x -> x - coeff(x^3) / coeff(x^4) / 4 to get a 3rd degree equation.


shift := coeff(rew, x^3)/coeff(rew, x^4) / 4;

eq_X  := simplify(eval(rew, x=X-shift));

-a-(1/2)*u

 

-a-v+3*X^2*u^2+(1/8)*u^4+2*X^4

(2)

# As we see we did more than this because the resulting equation is of 2nd degree
# wrt the auxiliary variable U=X^2.

eq_U  := eval(eq_X, X=surd(U, 2));

-a-v+3*U*u^2+(1/8)*u^4+2*U^2

(3)

# Solve this equation wrt U

sol_U := [solve(eq_U, U)]

[-(3/4)*u^2+(1/2)*(2*u^4+2*a+2*v)^(1/2), -(3/4)*u^2-(1/2)*(2*u^4+2*a+2*v)^(1/2)]

(4)

# Compute the solutions of equation "eq".
#
# Given the solution "sol_U" this could be done by hand, but I use
# Maple directly for simplicity.

sol_x := [solve(eval(eq, [b=a+u, c=a+v]), x)]:
print~(sol_x):

a+(1/2)*u+(1/2)*(-3*u^2+2*(2*u^4+2*a+2*v)^(1/2))^(1/2)

 

a+(1/2)*u-(1/2)*(-3*u^2+2*(2*u^4+2*a+2*v)^(1/2))^(1/2)

 

a+(1/2)*u+(1/2)*(-3*u^2-2*(2*u^4+2*a+2*v)^(1/2))^(1/2)

 

a+(1/2)*u-(1/2)*(-3*u^2-2*(2*u^4+2*a+2*v)^(1/2))^(1/2)

(5)

#                           Discussion
#
# (1/2)*u + (1/2)*sqrt(-3*u^2+2*sqrt(2*u^4+2*a+2*v)) must be an integer,
# thus u + sqrt(-3*u^2+2*sqrt(2*u^4+2*a+2*v)) is a multiple of 2.
#
# As u is an integer, so sqrt(-3*u^2+2*sqrt(2*u^4+2*a+2*v)) must be.
# then -3*u^2+2*sqrt(2*u^4+2*a+2*v) is a pefect square noted K^2.
#
# Which implies in return that 2*u^4+2*a+2*v is too a perfect square L^2.
#
# 2*u^4+2*a+2*v being a perfect square L^2 implies u^4+a+v is divided by 2.
# Thus u^4+a+v writes 2*L^2 (not the same L as before).
#
# So either a, u, v are both even, or only one of them is;
#
#                         Different cases
# [1] u is even
#   then u/2 is an integer and sqrt(-3*u^2 + 2*sqrt(2*u^4+2*a+2*v)) must be
#   an even integer.
#   Thus -3*u^2 + 2*sqrt(2*u^4+2*a+2*v) (Rel.1) is of the form 4*K^2.
#
#   On the same way sqrt(-3*u^2 - 2*sqrt(2*u^4+2*a+2*v)) is also an even
#   integer; and thus -3*u^2 - 2*sqrt(2*u^4+2*a+2*v) is of the form 4*L^2
#   (Rel.2).
#
#   Summing Rel.1 and Rel.2 gives -6*a^2 = 4*(K^2 + L^2).
#   Which is impossible.
#   Then u cannot be even.
#
#
# [2] u is odd
#   then u/2 is of the form P+1/2 and sqrt(-3*u^2 + 2*sqrt(2*u^4+2*a+2*v)) must be
#   an odd integer.
#   Thus -3*u^2 + 2*sqrt(2*u^4+2*a+2*v) (Rel.1) is of the form (2*K+1)^2.
#
#   On the same way sqrt(-3*u^2 - 2*sqrt(2*u^4+2*a+2*v)) is also an odd
#   integer; and thus -3*u^2 - 2*sqrt(2*u^4+2*a+2*v) is of the form (2*L+1)^2
#   (Rel.2).
#
#   Summing Rel.1 and Rel.2 gives -6*a^2 = (2*K+1)^2 + (2*L+1)^2.
#   Which is impossible.
#   Then u cannot be even odd.
#
#
# [3] u = 0 (particular case which implies b=a)
#   then u/2 = 0 and sqrt(-3*u^2 - 2*sqrt(2*u^4+2*a+2*v)) = sqrt(-2*sqrt(2*a+2*v)),
#   which is imaginary.
#
# Then there is no triple (a, b, c) such that the equation
#        (x-a)^4 + (x-b)^4 - c = 0
# possesses 4 distinct integer roots
 

 

Download a-b-c.mw

Here is way to make your procedure ALG to work for non countable sets (see mainly after the PROPOSAL text)

Basically ALG doens't work on thngs like [1, 2) which are intervals and not sets (as  @vv pointed it out).

So the idea is to start converting each interval, for instance [1, 2), into a set (here { 1 <= z < 2 }).
Once done your algorithm produces a set of sets, let's say A1, ..., An which are not in a reduced form in the following sense:

  • If A1 = {p < z < q, z=q} its reduced form should be {p < z <= q}
  • If A1 = {p < z < q, z=p} its reduced form should be {p <= z < q}
  • If A1 = {p < z <= q,  q <= z < r} its reduced form should be {p < z < r}
  • and so on

The attached file shows hot to convert intervals and not sets and get the reduced  forms of each A1, ..., An
This file doesn't contain a new pocedure to do this, because It's better that you check the result on the example I provide (and some others)  before writting another version of ALG.

 

Typesetting:-mrow(Typesetting:-mi("restart", italic = "true", mathvariant = "italic"), Typesetting:-mo(":", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mi("ALG", italic = "true", mathvariant = "italic"), Typesetting:-mo("&coloneq;", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mo("proc", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("X", italic = "true", mathvariant = "italic"), Typesetting:-mo("&Proportion;", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mi("set", italic = "true", mathvariant = "italic"), Typesetting:-mo(",", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.3333333em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("C", italic = "true", background = "[255,255,0]", opaque = "true", mathvariant = "italic"), Typesetting:-mo("&Proportion;", background = "[255,255,0]", opaque = "true", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mi("set", italic = "true", background = "[255,255,0]", opaque = "true", mathvariant = "italic")), mathvariant = "normal"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("#", background = "[255,255,0]", opaque = "true", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi(" see below the reason of this change", italic = "true", background = "[255,255,0]", opaque = "true", mathvariant = "italic"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("local", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("A", italic = "true", mathvariant = "italic"), Typesetting:-mo(",", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.3333333em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("c", italic = "true", mathvariant = "italic"), Typesetting:-mo(",", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.3333333em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("S", italic = "true", mathvariant = "italic"), Typesetting:-mo(",", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.3333333em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("T", italic = "true", mathvariant = "italic"), Typesetting:-mo(",", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.3333333em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("ok", italic = "true", mathvariant = "italic"), Typesetting:-mo("&coloneq;", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mi("false", italic = "true", mathvariant = "italic"), Typesetting:-mo(";", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.2777778em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mi("A", italic = "true", mathvariant = "italic"), Typesetting:-mo("&coloneq;", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mi("C", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("union", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("")), mathvariant = "normal", open = "{", close = "}")), mathvariant = "normal", open = "{", close = "}"), Typesetting:-mo(":", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("for", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("c", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("in", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("C", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("do", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("end", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("do", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(":", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo("if", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("not", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("`union`", italic = "true", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("C", italic = "true", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("")), mathvariant = "normal", open = "[", close = "]")), mathvariant = "normal"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("subset", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("X", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("then", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("error", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-ms("C must contain subsets of X"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("fi", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(";", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.2777778em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo("while", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("not", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("ok", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("do", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("ok", italic = "true", mathvariant = "italic"), Typesetting:-mo("&coloneq;", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mi("true", italic = "true", mathvariant = "italic"), Typesetting:-mo(";", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.2777778em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("for", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("S", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("in", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("A", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("do", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("if", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("not", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("X", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("minus", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("S", italic = "true", mathvariant = "italic")), mathvariant = "normal"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("in", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("A", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("then", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("A", italic = "true", mathvariant = "italic"), Typesetting:-mo("&coloneq;", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("A", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("union", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("X", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("minus", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("S", italic = "true", mathvariant = "italic")), mathvariant = "normal", open = "{", close = "}"), Typesetting:-mo(";", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.2777778em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("ok", italic = "true", mathvariant = "italic"), Typesetting:-mo("&coloneq;", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mi("false", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("fi", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(";", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.2777778em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("for", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("T", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("in", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("A", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("do", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("if", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("not", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("S", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("union", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("T", italic = "true", mathvariant = "italic")), mathvariant = "normal"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("in", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("A", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("then", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("A", italic = "true", mathvariant = "italic"), Typesetting:-mo("&coloneq;", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("A", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("union", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("S", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("union", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("T", italic = "true", mathvariant = "italic")), mathvariant = "normal", open = "{", close = "}"), Typesetting:-mo(";", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.2777778em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("ok", italic = "true", mathvariant = "italic"), Typesetting:-mo("&coloneq;", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mi("false", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("fi", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(";", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.2777778em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("od", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("od", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo("od", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(";", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.2777778em"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mi("A", italic = "true", mathvariant = "italic"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "newline"), Typesetting:-mspace(height = "0.0ex", width = "0.0em", depth = "0.0ex", linebreak = "auto"), Typesetting:-mo("end", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("proc", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(":", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"))

ALG({1, 2, 3}, {{1}, {2}});

{{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}

 

8

(1)

``

ALG({0, 2}, {RealRange(0, Open(1)), RealRange(Open(1), 2), {1}}); nops(%)

Error, (in ALG) cannot determine if this expression is true or false: not `subset`(`union`(RealRange(0, Open(1)), RealRange(Open(1), 2), {1}), {0, 2})

 

1

(2)


PROPOSAL

kernelopts(version)

`Maple 2015.2, APPLE UNIVERSAL OSX, Dec 20 2015, Build ID 1097895`

(3)

WATCHOUT: the code below couldn't work with Maple 2023
(see here  https://www.mapleprimes.com/questions/236556-Solve-Equation-With-Parameter-Using-Maple#comment295355)

As I do not have Maple 2023 I cannot assure you the following code will work correctly.


Why do you get the previous error?
The reason is that neither RealRange(0, Open(1))nor RealRange(Open(1), 2) are sets NULL

NULL

# Here is what C looks like with Maple 2015.2
#
# The point is that C is not of type set(set), which is why I modified the declaration
# of the arguments in procedure ALG.

C := {RealRange(0, Open(1)), RealRange(Open(1), 2), {1}}

{RealRange(0, Open(1)), RealRange(Open(1), 2), {1}}

(4)

type(C[1], set);
type(C[2], set);

false

 

false

(5)

# How to build A := `union`(C, {{}}) when not all C elements are sets?

Cs, Cns := selectremove(type, C, set);

{{1}}, {RealRange(0, Open(1)), RealRange(Open(1), 2)}

(6)

# Initialize A

A := `union`(Cs, {{}})

{{}, {1}}

(7)

# Complete A with Cns elements.
#
# Step 1: build the sets corresponding to each Cns component

ContinuousSets := `or`(map(c -> {convert(z in c, relation)}, Cns));

# Step 2: assemble

A := A union ContinuousSets

{{And(0 <= z, z < 1)}, {And(1 < z, z <= 2)}}

 

{{}, {1}, {And(0 <= z, z < 1)}, {And(1 < z, z <= 2)}}

(8)

# Check manually your algorithm

X := {0, 2};

ok := false:
while not ok do
  ok := true:
  for S in A do
    if `not`(`minus`(X, S) in A) then
      A := `union`(A, {`minus`(X, S)});
      ok := false
    end if;
    for T in A do
      if `not`(`union`(S, T) in A) then
        A := `union`(A, {`union`(S, T)});
        ok := false
      end if
    end do
  end do
end do:

{0, 2}

(9)

A

{{}, {1}, {And(0 <= z, z < 1)}, {And(1 < z, z <= 2)}, {0, 2}, {1, And(0 <= z, z < 1)}, {1, And(1 < z, z <= 2)}, {And(0 <= z, z < 1), And(1 < z, z <= 2)}, {0, 1, 2}, {0, 2, And(0 <= z, z < 1)}, {0, 2, And(1 < z, z <= 2)}, {1, And(0 <= z, z < 1), And(1 < z, z <= 2)}, {0, 1, 2, And(0 <= z, z < 1)}, {0, 1, 2, And(1 < z, z <= 2)}, {0, 2, And(0 <= z, z < 1), And(1 < z, z <= 2)}, {0, 1, 2, And(0 <= z, z < 1), And(1 < z, z <= 2)}}

(10)

# Reduce all the sets in A.
#
# For instance:
#    {1, 1 < z <= 2)}   should be written {And(1 <= z <= 2)}
#    {1 < z <= 2, 0, 2} should be written {1 < z <= 2), z=0}
#                                      or {Or(1 < z <= 2, z=0)}
#
# Remark: only sets which contains z have to be possibly reduced   

Az := select(has, A, z);

{{And(0 <= z, z < 1)}, {And(1 < z, z <= 2)}, {1, And(0 <= z, z < 1)}, {1, And(1 < z, z <= 2)}, {And(0 <= z, z < 1), And(1 < z, z <= 2)}, {0, 2, And(0 <= z, z < 1)}, {0, 2, And(1 < z, z <= 2)}, {1, And(0 <= z, z < 1), And(1 < z, z <= 2)}, {0, 1, 2, And(0 <= z, z < 1)}, {0, 1, 2, And(1 < z, z <= 2)}, {0, 2, And(0 <= z, z < 1), And(1 < z, z <= 2)}, {0, 1, 2, And(0 <= z, z < 1), And(1 < z, z <= 2)}}

(11)

Areduc := NULL:
for a in Az do
  s, r := selectremove(has, a, z):
  ri   := map(_r -> And(_r <= z , z <= _r), r):
  sol  := solve({Or((s union ri)[])});
  map(i -> if i[]::`=` then i[] else i end if, {sol});
  map(i -> if i::set then And(op(i)) else i end if, %);
  Areduc := Areduc union {`if`(numelems(%)=1, %, {Or(%[])})};
end do:

Ar := remove(has, A, z) minus {{}}:
map(i -> if numelems(i)=1 then {z=i[]} else {Or((z=~i)[])} end if, Ar):

FinalA := {{}} union % union Areduc:
print~(FinalA):

{}

 

{And(0 <= z, z <= 1)}

 

{And(0 <= z, z <= 2)}

 

{And(0 <= z, z < 1)}

 

{And(1 <= z, z <= 2)}

 

{And(z <= 2, 1 < z)}

 

{Or(And(0 <= z, z <= 1), z = 2)}

 

{Or(And(0 <= z, z < 1), And(z <= 2, 1 < z))}

 

{Or(And(0 <= z, z < 1), z = 2)}

 

{Or(And(1 <= z, z <= 2), z = 0)}

 

{Or(And(z <= 2, 1 < z), z = 0)}

 

{Or(z = 0, z = 2)}

 

{Or(z = 0, z = 1, z = 2)}

 

{z = 1}

(12)

 

Download SigmaAlg_mmcdara.mw

5 6 7 8 9 10 11 Last Page 7 of 51