acer

32602 Reputation

29 Badges

20 years, 42 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

In Maple 2018 you could call solve without the restrictive option [lambda[1]], and get a more full picture.

This call to isolate works in Maple 16.02, and perhaps it does in your Maple 13 as well.

Calling simplify and collect on the original makes the result pretty straightforward to obtain (you wouldn't really even need isolate).

restart;

ee := lambda[2]*mu[2]^2*(lambda[2]+mu[2])*lambda[1]/(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)+lambda[2]*mu[2]*(mu[2]^2+mu[2]*lambda[2]+lambda[2]^2)*lambda[1]/(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)+mu[2]^4*lambda[2]*lambda[1]/((lambda[1]+mu[2])*(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4))+(1/2)*(mu[2]^3*lambda[1]+mu[2]^3*lambda[2]+lambda[1]*lambda[2]*mu[2]^2+mu[2]^2*lambda[2]^2+mu[2]*lambda[2]^3+mu[2]*lambda[1]*lambda[2]^2+lambda[1]*lambda[2]^3)*lambda[2]*lambda[1]/((lambda[1]+mu[2])*(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4))+3*mu[2]^4*lambda[1]/(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)+mu[1]*mu[2]^4*lambda[1]/((4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)*(lambda[2]+mu[1]))+mu[2]^4*lambda[2]*lambda[1]/((4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)*(lambda[2]+mu[1]))+mu[2]^3*lambda[2]*lambda[1]/(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)+(1/2)*(mu[2]^3*lambda[1]+mu[2]^3*lambda[2]+lambda[1]*lambda[2]*mu[2]^2+mu[2]^2*lambda[2]^2+mu[2]*lambda[2]^3+mu[2]*lambda[1]*lambda[2]^2+lambda[1]*lambda[2]^3)*lambda[2]*lambda[1]/(4*mu[2]^5+4*mu[2]^4*lambda[1]+4*mu[2]^4*lambda[2]+4*mu[2]^3*lambda[1]*lambda[2]+3*mu[2]^3*lambda[2]^2+3*lambda[1]*lambda[2]^2*mu[2]^2+2*mu[2]^2*lambda[2]^3+2*lambda[1]*lambda[2]^3*mu[2]+mu[2]*lambda[2]^4+lambda[1]*lambda[2]^4)-3*mu[1]*mu[2]^4/(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)+mu[1]*mu[2]^4*lambda[2]/((4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)*(lambda[2]+mu[1]))+mu[1]^2*mu[2]^4/((4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)*(lambda[2]+mu[1])):

isolate(ee < 0, lambda[1]);

lambda[1] < 3*mu[1]*mu[2]^4/(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)-mu[1]*mu[2]^4*lambda[2]/((4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)*(lambda[2]+mu[1]))-mu[1]^2*mu[2]^4/((4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)*(lambda[2]+mu[1]))

(1)

simplify(%);

lambda[1] < 2*mu[1]*mu[2]^4/(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)

(2)

new := collect(simplify(ee),lambda[1]);

lambda[1]-2*mu[1]*mu[2]^4/(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)

(3)

isolate(new < 0, lambda[1]);

lambda[1] < 2*mu[1]*mu[2]^4/(4*mu[2]^4+4*mu[2]^3*lambda[2]+3*mu[2]^2*lambda[2]^2+2*mu[2]*lambda[2]^3+lambda[2]^4)

(4)

 

ineq_16.02.mw

Please check that I got the Support right, for pdf and cdf being zero for x<=m.  And, well, check it all.

[edit: The option remember on the ModuleApply is not crucial. Remove if it causes any funny business related to invoking Levy with the same parameter values at different Digits -- I didn't check.]

(As usual, sigh, the plots look much nicer in Maple itself.)

restart:

plots:-setoptions(gridlines=false):

Levy := module()
  local pdf, cdf, samplingMethod, ModuleApply;
  ModuleApply := proc(m,s)
    option remember;
    Statistics:-Distribution(
      ':-PDF'=(x->pdf(m,s,x)),
      ':-CDF'= (x->cdf(m,s,x)),
      ':-RandomSample' = proc(N::nonnegint)
                           # optionally throw error if m,s not numeric
                           samplingMethod(m,s,N);
                         end proc
                            );
  end proc:
  pdf := proc(m,s,x)
    piecewise(x<=m, 0, sqrt(s/2/Pi)*exp(-s/2/(x-m))/(x-m)^(3/2));
  end proc;
  cdf := proc(m,s,x)
    piecewise(x<=m, 0, erfc(sqrt(s/2/(x-m))));
  end proc;
  samplingMethod := proc(m,s,N)
    uses ST=Statistics;
    m +~ s /~ ( ST:-Quantile~(':-Normal'(0, 1),
                              ST:-Sample(':-Uniform'(1/2, 1), N)) )^~2
  end proc;
end module:

 

Levy(0,1);

_m140015542866272

# test without loading Statistics at top level
X := Statistics:-RandomVariable(Levy(m,s)):
Statistics:-PDF(X, x);
Statistics:-CDF(X, x);
Statistics:-Sample(X, 5); # could have this throw an error, see comment in defn

piecewise(x <= m, 0, sqrt(2)*sqrt(s/Pi)*exp(-s/(2*(x-m)))/(2*(x-m)^(3/2)))

piecewise(x <= m, 0, erfc((1/2)*sqrt(2)*sqrt(s/(x-m))))

Vector[row](%id = 18446884089173118974)

# test without loading Statistics at top level
X := Statistics:-RandomVariable(Levy(0,1)):
Statistics:-PDF(X, x);
Statistics:-CDF(X, x);
Statistics:-Sample(X, 5);
Statistics:-Probability(X<40);
evalf(%), Statistics:-Probability(X<40, numeric);
plot(Statistics:-PDF(X,x), x=0..5, size=[400,200]);
plot(Statistics:-PDF(X,x), x=0..1000, axis[2]=[mode=log], size=[400,200]);
plot(Statistics:-CDF(X,x), x=0..100, size=[400,200]);
Statistics:-Histogram(Statistics:-Sample(X, 10^3),
          binbounds=[seq(j+1/2,j=0..1000)],
          axis[2]=[mode=log], size=[400,200]);

piecewise(x <= 0, 0, sqrt(2)*exp(-1/(2*x))/(2*sqrt(Pi)*x^(3/2)))

piecewise(x <= 0, 0, erfc((1/2)*sqrt(2)*sqrt(1/x)))

Vector[row](%id = 18446884089173114998)

erfc((1/20)*5^(1/2))

.8743670612, .8743670612

with(Statistics):
X := RandomVariable(Levy(0,10^(-1))):
PDF(X, x);
CDF(X, x);
Probability(X<40);
evalf(%), Probability(X<40, numeric);
plot(PDF(X,x), x=0..1, size=[400,200]);
plot(PDF(X,x), x=0..100, axis[2]=[mode=log], size=[400,200]);
plot(CDF(X,x), x=0..10, size=[400,200]);
Histogram(Sample(X, 10^3),
          binbounds=[seq(j+1/2,j=0..100)],
          axis[2]=[mode=log], size=[400,200]);

piecewise(x <= 0, 0, sqrt(5)*exp(-1/(20*x))/(10*sqrt(Pi)*x^(3/2)))

piecewise(x <= 0, 0, erfc((1/10)*5^(1/2)*(1/x)^(1/2)))

erfc((1/40)*2^(1/2))

.9601223883, .9601223883

X := RandomVariable(Levy(100,1)):
PDF(X, x);
CDF(X, x);
Probability(X<100);
Probability(X<140);
evalf(%), Probability(X<140, numeric);
plot(PDF(X,x), x=100..105, size=[400,200]);
plot(PDF(X,x), x=0..1000, axis[2]=[mode=log], size=[400,200]);
plot(CDF(X,x), x=0..1000, size=[400,200]);
Histogram(Sample(X, 10^3),
          binbounds=[seq(j+1/2,j=0..500)],
          axis[2]=[mode=log], size=[400,200]);

piecewise(x <= 100, 0, sqrt(2)*exp(-1/(2*(-100+x)))/(2*sqrt(Pi)*(-100+x)^(3/2)))

piecewise(x <= 100, 0, erfc((1/2)*2^(1/2)*(1/(-100+x))^(1/2)))

0

erfc((1/20)*5^(1/2))

.8743670612, .8743670612

Ldist := Distribution(Levy(0,1)):
PDF(Ldist, x);
CDF(Ldist, x);
Support(Ldist);

piecewise(x <= 0, 0, sqrt(2)*exp(-1/(2*x))/(2*sqrt(Pi)*x^(3/2)))

piecewise(x <= 0, 0, erfc((1/2)*2^(1/2)*(1/x)^(1/2)))

RealRange(Open(0), infinity)

Ldist := Distribution(Levy(m,s)):
PDF(Ldist, x);
CDF(Ldist, x);
Support(Ldist, output=range);

piecewise(x <= m, 0, sqrt(2)*sqrt(s/Pi)*exp(-s/(2*(x-m)))/(2*(x-m)^(3/2)))

piecewise(x <= m, 0, erfc((1/2)*2^(1/2)*(s/(x-m))^(1/2)))

m .. infinity

plot([seq(PDF(RandomVariable(Levy(0,c)),x), c=[1/2,1,2,4,8])],
     x=0..3, view=0..1, size=[500,400],
     legend=[seq('c'=c,c=[0.5,1,2,4,8])],
     legendstyle=[location=right],
     color=[red,black,cyan,blue,green]);

 

Download My-own-random-variable_ac.mw

This is an example of premature evaluation.

The argument passed to plot is evaluated up front. But that produces an error since xi does not yet have a numeric value and so the conditional test fails.

Two common ways to deal with this are:
1) delay the evalauation of the first argument to plot, using single right-quotes (unevaluation quotes).
2) use the operator form calling sequence of the plot command.

I also corrected your procedure to have its first parameter be xi rather than xih , and to return an expression instead of an operator.

restart

with(linalg):

FS := proc (xi, m0, `&xi;wp`, `&mu;v`) local f; if abs(xi) <= 1 then f := xi*m0*(1-abs(xi))^2+xi*abs(xi)*(3-2*abs(xi)) else f := signum(xi)*((`&xi;wp`-1)^2+`&mu;v`*(abs(xi)-1)^2)/((`&xi;wp`-1)^2+(abs(xi)-1)^2) end if end proc:

 

FS(xi, 1.5, 2, .8)

Error, (in FS) cannot determine if this expression is true or false: abs(xi) <= 1

 

``

plot(('FS')(xi, 1.5, 2, .8), xi = 0 .. 1.5);

 

plot(proc (xi) options operator, arrow; FS(xi, 1.5, 2, .8) end proc, 0 .. 1.5);

 

``

Download plottestac.mw

If your Maple-browser connection is set up correctly then in modern Maple you can click on the purple error message and get sent to this webpage, which happens to cover this issue with a similar example.

You can use the so-called 2-argument calling sequence of the eval command, to pick off one or more of the p[i] values.  Basically, this evaluates the first argument using the list of equations as the second argument.

And the list of equations is obtained as the second entry of the original expression (list).

Remove any of the plotting options that you don't like (gridlines, tickmarks).

restart;

ee :=  [.358700275060090779,
        [p[0] = .192413186080606, p[1] = 0.906594292940704e-1,
         p[2] = 0.677108912885780e-1, p[3] = 0.609551830556988e-1,
         p[4] = 0.589744573790909e-1, p[5] = 0.585737058072817e-1,
         p[6] = 0.589744573787748e-1, p[7] = 0.609551830550955e-1,
         p[8] = 0.677108912877626e-1, p[9] = 0.906594292931833e-1,
         p[10] = .192413186079858]]:

eval(p[4],ee[2] );

0.589744573790909e-1

L := eval([seq(p[i],i=0..10)],ee[2]);

[.192413186080606, 0.906594292940704e-1, 0.677108912885780e-1, 0.609551830556988e-1, 0.589744573790909e-1, 0.585737058072817e-1, 0.589744573787748e-1, 0.609551830550955e-1, 0.677108912877626e-1, 0.906594292931833e-1, .192413186079858]

K := [seq(i=p[i-1],i=1..11)]:
Statistics:-LineChart(L,
                      #view=0..max(L),
                      axis[2]=[gridlines=L,
                               #tickmarks=[0, seq(min(L)..max(L),(max(L)-min(L))/6)]
                               tickmarks=[0,op(L)]
                              ],
                      axis[1]=[gridlines=K, tickmarks=K]
                      );

 

Download listplot.mw

As far as I know there is no part of stock Maple other than the very limited CUDA linear-algebra package that uses the GPU for doing any (mathematical) computation other than plot rendering.

I'm not aware of any publicly available, 3rd party add-on that does so either.

[edit. I added mention of the very limited CUDA package, since Carl asked about it.]

Your main problem here is not how parse works withing a module, but rather it is that you're mixing up how you utilize uses . (You also forgot to call parse in the module, but that's not why GetProperty wasn't working.)

If you are going to utilize the syntax  uses DT=DocumentTools;   then you need to accompancy that with DT:-GetProperty(...) .

You were mixing up your usage styles.

Composition_of_Functions_Doubt_ac.mw

 

You can parse the string to obtain a math expression for the MathContainer. Ie,

SetProperty("MathContainer0","expression",parse(GetProperty("TextArea0","value")));

Download MathContainerEntry_Doubt_ac.mw

Using the DocumentTools:-Tabulate command you can get an effect something like an animation, but with the Sample and Histogram generated on the fly. You may find it a bit easier than setting up a whole "App" with Embedded Components.

Adjust to taste.

restart:

with(Statistics):

Dice1 := RandomVariable(DiscreteUniform(1, 6)):
Dice2 := RandomVariable(DiscreteUniform(1, 6)):

 

F := proc(f, minp::posint, maxp::posint, hi,
          {delay::And(numeric,nonnegative):=0.0})
  local j, meanf, N, S;
  uses DocumentTools, Statistics, Threads;
  meanf := Mean(f(Dice1,Dice2));
  for N from minp to maxp do
    S := Sample(f(Dice1,Dice2), 2^N);
    Tabulate(':-exterior'=':-none', ':-interior'=':-none',
             ':-widthmode'=':-pixels', ':-width'=800,
             [[''f(Dice1,Dice2)'' = f(''Dice1'',''Dice2''),
               ''Mean(f(Dice1,Dice2))'' = meanf],
              Histogram(S, ':-binbounds'=[seq( j+1/2, j=min(S)-1..max(S))],
                        ':-view'=0..hi/36.0,
                        ':-title'=:-typeset(`#mtext("sample size")`=2^N),
                        ':-axis[2]'=[':-tickmarks'=[0=0,
                                                    seq(i/36=sprintf("%a/36",i),i=1..hi-1)],
                                     ':-gridlines'=[seq(i/36,i=1..hi-1)]])
             ]);
    Sleep(delay);
  end do;
  NULL;
end proc:

 

f1 := (a,b) -> a + b:

F(f1, 5, 17, 7, delay=0.25);

 

 

 

 

 

f1(Dice1, Dice2) = Dice1+Dice2

Mean(f1(Dice1, Dice2)) = 7

 

 

 

 

 

K := (a,b) -> piecewise( Or(a=1, b=1), -4, abs(b-a) ):

F(K, 5, 17, 12, delay=0.25);

 

 

K(Dice1, Dice2) = piecewise(Dice1 = 1 or Dice2 = 1, -4, abs(-Dice2+Dice1))

Mean(K(Dice1, Dice2)) = -1/9

 

 

 

 

 

histo_fun.mw

Have you tried relerr=10.0^(-x-7)  ?

restart

Chargement Statistics

NULL

with(plots)

nu := 3

X := RandomVariable(ChiSquare(nu))

PDF(X, x)

f := proc (x) options operator, arrow; PDF(X, x) end proc

NULL

plot(f(x), x = 0 .. 10, thickness = 3, gridlines = true, size = [300, 300], title = Typesetting:-mrow(Typesetting:-mtext("Fonction densité de ", color = red), Typesetting:-msup(Typesetting:-mi("chi"), Typesetting:-mn("2"), mathcolor = red), Typesetting:-mtext("\navec 3. d.d.l", color = red)), font = [title, "ARIAL", 12, BOLD])

``

Download PDFColorTitle_ac.mw

You may find this kind of step useful in construction of such things:

foo := chi^2;
sprintf("%a", Typesetting:-Typeset(Typesetting:-EV(foo)));

This is fast.

restart

k := 2; M := 3

2

3

for i while i <= 2^(k-1)*M do t[i] := (i-.5)/(2^(k-1)*M); eqs[i] := [9.797958972*a[1][1]+a[1][2]*(151.7893277*t[i]-37.94733192)+9.797958972*a[2][1]+a[2][2]*(151.7893277*t[i]-113.8419958)+(.3*(1.414213562*a[1][0]+a[1][1]*(9.797958972*t[i]-2.449489743)+a[1][2]*(4.743416490*(4*t[i]-1)^2-1.581138830)+1.414213562*a[2][0]+a[2][1]*(9.797958972*t[i]-7.348469229)+a[2][2]*(4.743416490*(4*t[i]-3)^2-1.581138830)))*(1.414213562*b[1][0]+b[1][1]*(9.797958972*t[i]-2.449489743)+b[1][2]*(4.743416490*(4*t[i]-1)^2-1.581138830)+1.414213562*b[2][0]+b[2][1]*(9.797958972*t[i]-7.348469229)+b[2][2]*(4.743416490*(4*t[i]-3)^2-1.581138830))-.2828427124*e[1][0]-.2*e[1][1]*(9.797958972*t[i]-2.449489743)-.2*e[1][2]*(4.743416490*(4*t[i]-1)^2-1.581138830)-.2828427124*e[2][0]-.2*e[2][1]*(9.797958972*t[i]-7.348469229)-.2*e[2][2]*(4.743416490*(4*t[i]-3)^2-1.581138830)+.9899494934*a[1][0]+.7*a[1][1]*(9.797958972*t[i]-2.449489743)+.7*a[1][2]*(4.743416490*(4*t[i]-1)^2-1.581138830)+.9899494934*a[2][0]+.7*a[2][1]*(9.797958972*t[i]-7.348469229)+.7*a[2][2]*(4.743416490*(4*t[i]-3)^2-1.581138830) = .5, 9.797958972*b[1][1]+b[1][2]*(151.7893277*t[i]-37.94733192)+9.797958972*b[2][1]+b[2][2]*(151.7893277*t[i]-113.8419958)-(.3*(1.414213562*a[1][0]+a[1][1]*(9.797958972*t[i]-2.449489743)+a[1][2]*(4.743416490*(4*t[i]-1)^2-1.581138830)+1.414213562*a[2][0]+a[2][1]*(9.797958972*t[i]-7.348469229)+a[2][2]*(4.743416490*(4*t[i]-3)^2-1.581138830)))*(1.414213562*b[1][0]+b[1][1]*(9.797958972*t[i]-2.449489743)+b[1][2]*(4.743416490*(4*t[i]-1)^2-1.581138830)+1.414213562*b[2][0]+b[2][1]*(9.797958972*t[i]-7.348469229)+b[2][2]*(4.743416490*(4*t[i]-3)^2-1.581138830))+(.3*(1.414213562*b[1][0]+b[1][1]*(9.797958972*t[i]-2.449489743)+b[1][2]*(4.743416490*(4*t[i]-1)^2-1.581138830)+1.414213562*b[2][0]+b[2][1]*(9.797958972*t[i]-7.348469229)+b[2][2]*(4.743416490*(4*t[i]-3)^2-1.581138830)))*(1.414213562*c[1][0]+c[1][1]*(9.797958972*t[i]-2.449489743)+c[1][2]*(4.743416490*(4*t[i]-1)^2-1.581138830)+1.414213562*c[2][0]+c[2][1]*(9.797958972*t[i]-7.348469229)+c[2][2]*(4.743416490*(4*t[i]-3)^2-1.581138830))+1.414213562*b[1][0]+1.0*b[1][1]*(9.797958972*t[i]-2.449489743)+1.0*b[1][2]*(4.743416490*(4*t[i]-1)^2-1.581138830)+1.414213562*b[2][0]+1.0*b[2][1]*(9.797958972*t[i]-7.348469229)+1.0*b[2][2]*(4.743416490*(4*t[i]-3)^2-1.581138830) = 0, 9.797958972*c[1][1]+c[1][2]*(151.7893277*t[i]-37.94733192)+9.797958972*c[2][1]+c[2][2]*(151.7893277*t[i]-113.8419958)-(.3*(1.414213562*b[1][0]+b[1][1]*(9.797958972*t[i]-2.449489743)+b[1][2]*(4.743416490*(4*t[i]-1)^2-1.581138830)+1.414213562*b[2][0]+b[2][1]*(9.797958972*t[i]-7.348469229)+b[2][2]*(4.743416490*(4*t[i]-3)^2-1.581138830)))*(1.414213562*c[1][0]+c[1][1]*(9.797958972*t[i]-2.449489743)+c[1][2]*(4.743416490*(4*t[i]-1)^2-1.581138830)+1.414213562*c[2][0]+c[2][1]*(9.797958972*t[i]-7.348469229)+c[2][2]*(4.743416490*(4*t[i]-3)^2-1.581138830))+3.676955261*c[1][0]+2.6*c[1][1]*(9.797958972*t[i]-2.449489743)+2.6*c[1][2]*(4.743416490*(4*t[i]-1)^2-1.581138830)+3.676955261*c[2][0]+2.6*c[2][1]*(9.797958972*t[i]-7.348469229)+2.6*c[2][2]*(4.743416490*(4*t[i]-3)^2-1.581138830) = 0, 9.797958972*e[1][1]+e[1][2]*(151.7893277*t[i]-37.94733192)+9.797958972*e[2][1]+e[2][2]*(151.7893277*t[i]-113.8419958)-.5656854248*c[1][0]-.4*c[1][1]*(9.797958972*t[i]-2.449489743)-.4*c[1][2]*(4.743416490*(4*t[i]-1)^2-1.581138830)-.5656854248*c[2][0]-.4*c[2][1]*(9.797958972*t[i]-7.348469229)-.4*c[2][2]*(4.743416490*(4*t[i]-3)^2-1.581138830)+2.969848480*e[1][0]+2.1*e[1][1]*(9.797958972*t[i]-2.449489743)+2.1*e[1][2]*(4.743416490*(4*t[i]-1)^2-1.581138830)+2.969848480*e[2][0]+2.1*e[2][1]*(9.797958972*t[i]-7.348469229)+2.1*e[2][2]*(4.743416490*(4*t[i]-3)^2-1.581138830) = 0, 9.797958972*g[1][1]+g[1][2]*(151.7893277*t[i]-37.94733192)+9.797958972*g[2][1]+g[2][2]*(151.7893277*t[i]-113.8419958)-1.697056274*e[1][0]-1.2*e[1][1]*(9.797958972*t[i]-2.449489743)-1.2*e[1][2]*(4.743416490*(4*t[i]-1)^2-1.581138830)-1.697056274*e[2][0]-1.2*e[2][1]*(9.797958972*t[i]-7.348469229)-1.2*e[2][2]*(4.743416490*(4*t[i]-3)^2-1.581138830)+.9899494934*g[1][0]+.7*g[1][1]*(9.797958972*t[i]-2.449489743)+.7*g[1][2]*(4.743416490*(4*t[i]-1)^2-1.581138830)+.9899494934*g[2][0]+.7*g[2][1]*(9.797958972*t[i]-7.348469229)+.7*g[2][2]*(4.743416490*(4*t[i]-3)^2-1.581138830) = 0] end do

myEqs := [eqs[1][], eqs[2][], eqs[3][], eqs[4][], eqs[5][], eqs[6][]]; numelems(myEqs); numelems(indets(myEqs))

30

30

nms := indets(myEqs, And(name, Non(constant)))

{a[1][0], a[1][1], a[1][2], a[2][0], a[2][1], a[2][2], b[1][0], b[1][1], b[1][2], b[2][0], b[2][1], b[2][2], c[1][0], c[1][1], c[1][2], c[2][0], c[2][1], c[2][2], e[1][0], e[1][1], e[1][2], e[2][0], e[2][1], e[2][2], g[1][0], g[1][1], g[1][2], g[2][0], g[2][1], g[2][2]}

Q := {a[1][0], a[2][0], b[1][0], b[2][0], c[1][0], c[2][0], e[1][0], e[2][0], g[1][0], g[2][0]}

K := map(`=`, `minus`(nms, Q), 0)

{a[1][1] = 0, a[1][2] = 0, a[2][1] = 0, a[2][2] = 0, b[1][1] = 0, b[1][2] = 0, b[2][1] = 0, b[2][2] = 0, c[1][1] = 0, c[1][2] = 0, c[2][1] = 0, c[2][2] = 0, e[1][1] = 0, e[1][2] = 0, e[2][1] = 0, e[2][2] = 0, g[1][1] = 0, g[1][2] = 0, g[2][1] = 0, g[2][2] = 0}

fsol := fsolve(myEqs, `union`(nms, K), map(proc (s) options operator, arrow; s = -12 .. 12 end proc, Q))

{a[1][0] = 6.082134329, a[1][1] = 0.1857329281e-17, a[1][2] = -0.3205810176e-18, a[2][0] = -5.577058057, a[2][1] = 0.6258805490e-18, a[2][2] = 0.3205810193e-18, b[1][0] = 1.298305425, b[1][1] = 0.3738920656e-17, b[1][2] = 0.4839615888e-18, b[2][0] = -1.298305425, b[2][1] = -0.7487670954e-17, b[2][2] = -0.4839615925e-18, c[1][0] = 1.254988469, c[1][1] = -0.1644282045e-19, c[1][2] = 0.6623875451e-21, c[2][0] = -1.254988469, c[2][1] = 0.1131198859e-19, c[2][2] = -0.6623875456e-21, e[1][0] = 1.524516194, e[1][1] = 0.5330887545e-20, e[1][2] = -0.5635624424e-22, e[2][0] = -1.524516194, e[2][1] = -0.4894353953e-20, e[2][2] = 0.5635624411e-22, g[1][0] = -2.819211872, g[1][1] = 0.4869251300e-22, g[1][2] = 0., g[2][0] = 2.819211872, g[2][1] = -0.9324345846e-22, g[2][2] = 0.}

eval(map(rhs-lhs, myEqs), fsol)

[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.3548181684e-18, -0.7652104661e-18, -0.2723049339e-20, 0.1871247963e-21, 0., 0., 0., 0., 0., 0.]

``

Download for_k=2_M=3_ac.mw

restart;

kernelopts(version);

`Maple 2018.0, X86 64 LINUX, Mar 9 2018, Build ID 1298750`

conv_VerticalPlate_proc := proc (T__side, T__amb, Area, L, varepsilon, q__i)
 
  local sigma, g, T__s, `T__&infin;`, T__f, k, rho, Cp, Pr, mu, nu, alpha, beta, Ra__L, Nus__L, h, q__h, q__r, q__total;

  uses Units:-Simple, ThermophysicalData;
  
  g := 9.81*Unit('m'/'s'^2); sigma := 5.6703*Unit('W'/('m'^2*'K'^4))/10^8;

  # Return unevaluated if the first argument is not numeric or numeric*Unit(...).
  # You could also do the same for the other arguments.
  if not convert(T__side, unit_free)::numeric then return 'procname'(args); end if;
 
  if type(T__side, with_unit) then
    T__s := convert(T__side, temperature, kelvin)
  elif T__side = 0 then
    T__s := 273.15*Unit('K')
  else
    T__s := T__side*Unit('K')
  end if;
 
  if type(T__amb, with_unit) then
    `T__&infin;` := convert(T__amb, temperature, kelvin)
  elif T__amb = 0 then
    `T__&infin;` := 273.15*Unit('K')
  else
    `T__&infin;` := T__amb*Unit('K')
  end if;
 
  T__f := (1/2)*T__s+(1/2)*`T__&infin;`;
 
  k := Property(thermal_conductivity, temperature = T__f, pressure = Unit('atm'), air);
  rho := Property(density, temperature = T__f, pressure = Unit('atm'), air);
  Cp := Property(Cpmass, temperature = T__f, pressure = Unit('atm'), air);
  Pr := Property(prandtl, temperature = T__f, pressure = Unit('atm'), air);
  mu := Property(viscosity, temperature = T__f, pressure = Unit('atm'), air);
 
  if type(k, with_unit) and type(rho, with_unit) and type(Cp, with_unit) and type(mu, has_unit) then
    nu := mu/rho;
    alpha := k/(rho*Cp);
    beta := 1.0/T__f;
    Ra__L := g*beta*abs(T__s-`T__&infin;`)*L^3/(alpha*nu);
    Nus__L := (.825+.387*(Ra__L^(1/6))/(((1+(.492/Pr)^(9/16))^(8/27))))^2;
    h := Nus__L*k/L; q__h := h*(T__s-`T__&infin;`)*Area;
    q__r := varepsilon*sigma*(T__s^4-`T__&infin;`^4)*Area;
    q__total := q__h+q__r
  else
    0.1e-6*Unit('W')
  end if
 
end proc:

conv_VerticalPlate_proc(31.5*Unit('degC'), 20*Unit('degC'), Unit('m'^2), Unit('m'), .9);

100.8567010*Units:-Unit(W)

# Returns unevaluated for non-numeric x.
conv_VerticalPlate_proc(x*Unit('degC'), 20*Unit('degC'), Unit('m'^2), Unit('m'), .9);

conv_VerticalPlate_proc(x*Units:-Unit(`&deg;C`), 20*Units:-Unit(`&deg;C`), Units:-Unit(m^2), Units:-Unit(m), .9)

fsolve(100*Unit('W')-conv_VerticalPlate_proc(x, 20*Unit('degC'),
                                             Unit('m'^2), Unit('m'), .9),
       x=1*Unit('degC') .. 100*Unit('degC'));

31.41491339*Units:-Unit(`&deg;C`)

fsolve(x->(100*Unit('W')-conv_VerticalPlate_proc(x*Unit('degC'), 20*Unit('degC'),
                                                 Unit('m'^2), Unit('m'), .9))/Unit('W'),
       1 .. 100)*Unit(degC);

31.41491339*Units:-Unit(`&deg;C`)

plot(x->(100*Unit('W')-conv_VerticalPlate_proc(x*Unit('degC'), 20*Unit('degC'),
                                               Unit('m'^2), Unit('m'), .9))/Unit('W'),
     1 .. 100, labels=[Unit(degC),Unit(W)],
     adaptive=false, numpoints=30, size=[500,200], gridlines=false);

 

Download fsolve_Therm_units.mw

restart;

a:=[3,3,1,5,7,8,5,4,4,4,4,3,9];

          a := [3, 3, 1, 5, 7, 8, 5, 4, 4, 4, 4, 3, 9]

subsop(ListTools:-Search(4,a)=NULL,a);

              [3, 3, 1, 5, 7, 8, 5, 4, 4, 4, 3, 9]

Or, as a re-usable procedure,

R:=(N,A)->(NN->`if`(NN>0,subsop(NN=NULL,A),FAIL))(ListTools:-Search(N,A),A):

R(4, a);

              [3, 3, 1, 5, 7, 8, 5, 4, 4, 4, 3, 9]

R(14,a);

                              FAIL
You didn't say what you wanted to happen if the value were not present.

restart;

kernelopts(version);

`Maple 2017.2, X86 64 LINUX, Jul 19 2017, Build ID 1247392`

ee := (x-1)*(x^3-9*x^2+4);

(x-1)*(x^3-9*x^2+4)

evalc([solve(ee,x)]);

[1, 6*cos((1/3)*arctan((2/25)*26^(1/2)))+3, -3*cos((1/3)*arctan((2/25)*26^(1/2)))+3-3*3^(1/2)*sin((1/3)*arctan((2/25)*26^(1/2))), -3*cos((1/3)*arctan((2/25)*26^(1/2)))+3+3*3^(1/2)*sin((1/3)*arctan((2/25)*26^(1/2)))]

evalf(%);

[1., 8.950064702, -.6440222815, .6939575795]

[fsolve(ee,x)];

[-.6440222815, .6939575790, 1., 8.950064703]

[fsolve(ee,x,maxsols=4)];

[-.6440222815, .6939575790, 1., 8.950064703]

Student:-Calculus1:-Roots(ee,x,numeric);

[-.6440222815, .6939575790, 1., 8.950064703]

 

Download rootsqu.mw

Be careful using Calculus1:-Roots with the numeric option, since you may have to supply a range for x in order to get all the roots. (Not this example, since the default range is x=-10..10 for the numeric option.)

Notice also that applying evalf to the exact, symbolic roots can incur roundoff error (in this example, using default precision not all the last digits are correct).

Inside the procedure there is a call to procname. That means the procedure calls itself there. It's not passing itself enough arguments to match its own expected number of parameters.

The call to procname is a recursive call. But Newton's method can be implemented quite simply with an iterative approach (which you mentioned as being part of the assignment), which is what your do-loop is attempting to accomplish.

So, why did you put a call to procname there? What did you hope to accomplish with it?

First 160 161 162 163 164 165 166 Last Page 162 of 339