mmcdara

6568 Reputation

18 Badges

8 years, 103 days

MaplePrimes Activity


These are answers submitted by mmcdara

it's because you "..used the "``" things ..":

A correct writing is given -below for the first memmer of abCaseTest.
Below there is a conversion of abCaseTest into this correct writting

abCaseSet := {[`0<a<1`, `0<b<1`], [`0<a<1`, `b=-1`], [`0<a<1`, `b=0`], [`0<a<1`, `b=1`], [`0<a<1`, `1<b<&infin;`], [`0<a<1`, -`1<b<0`], [`0<a<1`, -`&infin;<b<-1`], [`a=-1`, `0<b<1`], [`a=-1`, `b=-1`], [`a=-1`, `b=0`], [`a=-1`, `b=1`], [`a=-1`, `1<b<&infin;`], [`a=-1`, -`1<b<0`], [`a=-1`, -`&infin;<b<-1`], [`a=0`, `0<b<1`], [`a=0`, `b=-1`], [`a=0`, `b=0`], [`a=0`, `b=1`], [`a=0`, `1<b<&infin;`], [`a=0`, -`1<b<0`], [`a=0`, -`&infin;<b<-1`], [`a=1`, `0<b<1`], [`a=1`, `b=-1`], [`a=1`, `b=0`], [`a=1`, `b=1`], [`a=1`, `1<b<&infin;`], [`a=1`, -`1<b<0`], [`a=1`, -`&infin;<b<-1`], [`1<a<&infin;`, `0<b<1`], [`1<a<&infin;`, `b=-1`], [`1<a<&infin;`, `b=0`], [`1<a<&infin;`, `b=1`], [`1<a<&infin;`, `1<b<&infin;`], [`1<a<&infin;`, -`1<b<0`], [`1<a<&infin;`, -`&infin;<b<-1`], [-`1<a<0`, `0<b<1`], [-`1<a<0`, `b=-1`], [-`1<a<0`, `b=0`], [-`1<a<0`, `b=1`], [-`1<a<0`, `1<b<&infin;`], [-`1<a<0`, -`1<b<0`], [-`1<a<0`, -`&infin;<b<-1`], [-`&infin;<a<-1`, `0<b<1`], [-`&infin;<a<-1`, `b=-1`], [-`&infin;<a<-1`, `b=0`], [-`&infin;<a<-1`, `b=1`], [-`&infin;<a<-1`, `1<b<&infin;`], [-`&infin;<a<-1`, -`1<b<0`], [-`&infin;<a<-1`, -`&infin;<b<-1`]}; map(subs, abCaseSet, a = A)

Error, invalid input: subs received [`0<a<1`, `0<b<1`], which is not valid for its 1st argument

 

 

lprint(abCaseSet[1])

[`0<a<1`, `0<b<1`]

 

X := {[-1 < a and a < 0, -1 < b and b < 0]};

{[-1 < A and A < 0, -1 < b and b < 0]}

(1)

V := NULL:

{[a = -1, b = -1], [a = -1, b = 0], [a = -1, b = 1], [a = -1, -1 < b and b < 0], [a = -1, 0 < b and b < 1], [a = -1, 1 < b and b < infinity], [a = -1, -infinity < b and b < -1], [a = 0, b = -1], [a = 0, b = 0], [a = 0, b = 1], [a = 0, -1 < b and b < 0], [a = 0, 0 < b and b < 1], [a = 0, 1 < b and b < infinity], [a = 0, -infinity < b and b < -1], [a = 1, b = -1], [a = 1, b = 0], [a = 1, b = 1], [a = 1, -1 < b and b < 0], [a = 1, 0 < b and b < 1], [a = 1, 1 < b and b < infinity], [a = 1, -infinity < b and b < -1], [-1 < a and a < 0, b = -1], [-1 < a and a < 0, b = 0], [-1 < a and a < 0, b = 1], [-1 < a and a < 0, -1 < b and b < 0], [-1 < a and a < 0, 0 < b and b < 1], [-1 < a and a < 0, 1 < b and b < infinity], [-1 < a and a < 0, -infinity < b and b < -1], [0 < a and a < 1, b = -1], [0 < a and a < 1, b = 0], [0 < a and a < 1, b = 1], [0 < a and a < 1, -1 < b and b < 0], [0 < a and a < 1, 0 < b and b < 1], [0 < a and a < 1, 1 < b and b < infinity], [0 < a and a < 1, -infinity < b and b < -1], [1 < a and a < infinity, b = -1], [1 < a and a < infinity, b = 0], [1 < a and a < infinity, b = 1], [1 < a and a < infinity, -1 < b and b < 0], [1 < a and a < infinity, 0 < b and b < 1], [1 < a and a < infinity, 1 < b and b < infinity], [1 < a and a < infinity, -infinity < b and b < -1], [-infinity < a and a < -1, b = -1], [-infinity < a and a < -1, b = 0], [-infinity < a and a < -1, b = 1], [-infinity < a and a < -1, -1 < b and b < 0], [-infinity < a and a < -1, 0 < b and b < 1], [-infinity < a and a < -1, 1 < b and b < infinity], [-infinity < a and a < -1, -infinity < b and b < -1]}

(2)

``

 

(3)

subs(a = A, %);

{[A = -1, b = -1], [A = -1, b = 0], [A = -1, b = 1], [A = -1, -1 < b and b < 0], [A = -1, 0 < b and b < 1], [A = -1, 1 < b and b < infinity], [A = -1, -infinity < b and b < -1], [A = 0, b = -1], [A = 0, b = 0], [A = 0, b = 1], [A = 0, -1 < b and b < 0], [A = 0, 0 < b and b < 1], [A = 0, 1 < b and b < infinity], [A = 0, -infinity < b and b < -1], [A = 1, b = -1], [A = 1, b = 0], [A = 1, b = 1], [A = 1, -1 < b and b < 0], [A = 1, 0 < b and b < 1], [A = 1, 1 < b and b < infinity], [A = 1, -infinity < b and b < -1], [-1 < A and A < 0, b = -1], [-1 < A and A < 0, b = 0], [-1 < A and A < 0, b = 1], [-1 < A and A < 0, -1 < b and b < 0], [-1 < A and A < 0, 0 < b and b < 1], [-1 < A and A < 0, 1 < b and b < infinity], [-1 < A and A < 0, -infinity < b and b < -1], [0 < A and A < 1, b = -1], [0 < A and A < 1, b = 0], [0 < A and A < 1, b = 1], [0 < A and A < 1, -1 < b and b < 0], [0 < A and A < 1, 0 < b and b < 1], [0 < A and A < 1, 1 < b and b < infinity], [0 < A and A < 1, -infinity < b and b < -1], [1 < A and A < infinity, b = -1], [1 < A and A < infinity, b = 0], [1 < A and A < infinity, b = 1], [1 < A and A < infinity, -1 < b and b < 0], [1 < A and A < infinity, 0 < b and b < 1], [1 < A and A < infinity, 1 < b and b < infinity], [1 < A and A < infinity, -infinity < b and b < -1], [-infinity < A and A < -1, b = -1], [-infinity < A and A < -1, b = 0], [-infinity < A and A < -1, b = 1], [-infinity < A and A < -1, -1 < b and b < 0], [-infinity < A and A < -1, 0 < b and b < 1], [-infinity < A and A < -1, 1 < b and b < infinity], [-infinity < A and A < -1, -infinity < b and b < -1]}

(4)

``


 

Download subs.mwsubs.mw

Here is a solution among many others

Remark: You said nothing about the random character of the number of non null elements. So I arbitrary considered this number was a discrete uniform random variable between 3 and the dimension of the matrix.
 

restart;

Seed := randomize()

156676907126580

(1)

# Matrix dimension

N := 10:

# One needs at least 3 non zeros elements per row

NZ := 3:

# define a discrete uniform random variable
# with values in [NZ..N]

rnz := rand(NZ..N):

# There are different ways to generate the matrix
# Here is one of them

M := NULL:

for n from 1 to N do

  # build a random vector

  R    := LinearAlgebra:-RandomVector(10, generator=-10..10);
  
  # randomly choose the rank of null elements

  Keep := sort(combinat:-randperm([$1..N])[1..rnz()]);
  
  # generate a vector V with some zeroes

  V    := Vector[row](N, i -> `if`(i in Keep, R[i], 0));
  
  # concatenate the Vs to form the matrix

  M    := < M, V >:
end do:

M;

Matrix([[0, 0, 0, -8, 9, 0, -6, 0, 0, 0], [-8, 0, 10, -4, 5, -7, 0, 9, 0, 0], [0, -7, -1, 0, 7, 0, 0, 0, 0, 0], [0, -7, 0, 6, 0, -8, 9, 0, 8, 0], [10, -9, -7, -8, 0, -10, 1, 3, -1, 4], [7, -8, -7, 8, 7, -5, -9, -4, -7, 4], [8, -4, -2, 0, 4, 4, -9, -2, -1, 0], [5, -6, 0, 2, -10, 3, 4, 9, 5, 8], [-5, 0, 10, 3, -5, 0, -8, 0, 8, -6], [-3, 0, 0, 0, -3, 0, 0, 7, 4, 4]])

(2)

 


 

Download AtLeast3NonNull.mw

Hi, it seems you need some additional constraints about a, x and y (> 0 or < 0?)


 

restart:

Coneq1:=x=-a/surd((1+c^2)^3, 2);
eq2:=y=a*c^3/surd((1+c^2)^3, 2)

x = -a/((c^2+1)^3)^(1/2)

 

y = a*c^3/((c^2+1)^3)^(1/2)

(1)

eq11 := expand(map(u -> surd(u^2, 3), eq1));
eq21 := expand(map(u -> surd(u^2, 3), eq2));

surd(x^2, 3) = surd(a^2/(c^2+1)^3, 3)

 

surd(y^2, 3) = surd(a^2*c^6/(c^2+1)^3, 3)

(2)

c2sol := expand(solve(subs(c^2=c2, eq11), c2));

a^(2/3)/surd(x^2, 3)-1

(3)

simplify(subs(c^2=c2sol, eq21));

EQ1 := normal(subs(c^6=c2sol^3, %));

surd(y^2, 3) = surd(c^6*surd(x^2, 3)^3, 3)

 

surd(y^2, 3) = surd(-(-a^(2/3)+surd(x^2, 3))^3, 3)

(4)

simplify(EQ1) assuming a > 0, x > 0, y > 0;
simplify(EQ1) assuming a < 0, x > 0, y > 0;
simplify(EQ1) assuming a > 0, x < 0, y > 0;
simplify(EQ1) assuming a < 0, x < 0, y > 0;
simplify(EQ1) assuming a > 0, x > 0, y < 0;
simplify(EQ1) assuming a < 0, x > 0, y < 0;
simplify(EQ1) assuming a > 0, x < 0, y < 0;
simplify(EQ1) assuming a < 0, x < 0, y < 0;

y^(2/3) = a^(2/3)-x^(2/3)

 

y^(2/3) = surd((a^(2/3)-x^(2/3))^3, 3)

 

y^(2/3) = a^(2/3)-(-x)^(2/3)

 

y^(2/3) = surd((a^(2/3)-(-x)^(2/3))^3, 3)

 

(-y)^(2/3) = a^(2/3)-x^(2/3)

 

(-y)^(2/3) = surd((a^(2/3)-x^(2/3))^3, 3)

 

(-y)^(2/3) = a^(2/3)-(-x)^(2/3)

 

(-y)^(2/3) = surd((a^(2/3)-(-x)^(2/3))^3, 3)

(5)

 


 

Download NeedSomeAdditionalConstraints.mw

I believe that the first thing to do is to simplify your equations...
You could take inspiration from this:
 

NULL

restart:

# do not use with(CodeGeneration) but instead :
#  1/ with(CodeGeneration, Matlab)
#  2: at the end of your worksheet CodeGeneration:-Matlab(...)

# first simplification of dM1

dM1 := subs(sqrt(b^2+z^2)=R,  diff(M1(z), z) = (eval(((2*I)*exp(-sqrt(t^2*v^2+b^2)+(1/2*I)*v^2*t)/sqrt(t^2*v^2+b^2)-(2*I)*exp(-sqrt(t^2*v^2+b^2)-(1/2*I)*v^2*t)/sqrt(t^2*v^2+b^2))*t^2+2*h[1](z)*t+((-(4*I)*t/sqrt(t^2*v^2+b^2)-2)*exp(-sqrt(t^2*v^2+b^2)+(1/2*I)*v^2*t)+(-2+(4*I)*t/sqrt(t^2*v^2+b^2))*exp(-sqrt(t^2*v^2+b^2)-(1/2*I)*v^2*t))*t+h[2](z)+(2*t+(2*I)*t^2/sqrt(t^2*v^2+b^2))*exp(-sqrt(t^2*v^2+b^2)+(1/2*I)*v^2*t)+(2*t-(2*I)*t^2/sqrt(t^2*v^2+b^2))*exp(-sqrt(t^2*v^2+b^2)-(1/2*I)*v^2*t), t = z/v))/v):

print():

# an even more simplified expression

dM1 := diff(M1(z), z) = simplify(expand(rhs(dM1)));

 

diff(M1(z), z) = (2*h[1](z)*z+h[2](z)*v)/v^2

(1)

``


 

Download 1.mw

 

To understand where the abs(1, ...) comes from and to handle correctly the discontinuity of the dervative when 
(.9*sqrt(-c^2+1)-.4358898944*c)/(-.9*sqrt(-c^2+1)-.4358898944*c)) = 0, please look this


 

restart:

diff(log(abs(c)), c)

abs(1, c)/abs(c)

(1)

f := piecewise(c < 0, log(-c), c > 0, log(c))

f := piecewise(c < 0, ln(-c), 0 < c, ln(c))

(2)

diff(f, c)

piecewise(c = 0, undefined, 1/c)

(3)

In your case:

I3 := -sqrt(-c^2+1)*piecewise(F(c) < 0, log(-F(c)), F(c) > 0, log(F(c)), undefined)

I3 := -sqrt(-c^2+1)*piecewise(F(c) < 0, ln(-F(c)), 0 < F(c), ln(F(c)), undefined)

(4)

diff(I3, c)

piecewise(F(c) < 0, ln(-F(c)), 0 < F(c), ln(F(c)), undefined)*c/sqrt(-c^2+1)-sqrt(-c^2+1)*piecewise(F(c) < 0, (diff(F(c), c))/F(c), 0 < F(c), (diff(F(c), c))/F(c), undefined)

(5)

eval(%, F(c) = (.9*sqrt(-c^2+1)-.4358898944*c)/(-.9*sqrt(-c^2+1)-.4358898944*c)):

 

(6)

 


 

Download hint.mw

Unless I'm mistaken, the limit is +infinity if x > 1 and has a finite value if x < 1 (undefined for x=1):

 

restart:

J := Int(Int(exp(-(y-beta[0]-beta[1]*x-b0-b1*x)^2/(2*sigma^2))*exp(-b0)*exp(-b1),b0=0..infinity),b1=0..infinity)

Int(Int(exp(-(1/2)*(-b1*x-x*beta[1]-b0+y-beta[0])^2/sigma^2)*exp(-b0)*exp(-b1), b0 = 0 .. infinity), b1 = 0 .. infinity)

(1)

J0 := op(1,J)

Int(exp(-(1/2)*(-b1*x-x*beta[1]-b0+y-beta[0])^2/sigma^2)*exp(-b0)*exp(-b1), b0 = 0 .. infinity)

(2)

combine(op(1, J0), exp);
T := Student:-Precalculus:-CompleteSquare(%, b0)

exp(-(1/2)*(-b1*x-x*beta[1]-b0+y-beta[0])^2/sigma^2-b0-b1)

 

exp(-(1/2)*(b0-(-(1/2)*(2*b1*x+2*x*beta[1]-2*y+2*beta[0])/sigma^2-1)*sigma^2)^2/sigma^2-(1/2)*(-b1*x-x*beta[1]+y-beta[0])^2/sigma^2-b1+(1/2)*(-(1/2)*(2*b1*x+2*x*beta[1]-2*y+2*beta[0])/sigma^2-1)^2*sigma^2)

(3)

T_e := op(T);

-(1/2)*(b0-(-(1/2)*(2*b1*x+2*x*beta[1]-2*y+2*beta[0])/sigma^2-1)*sigma^2)^2/sigma^2-(1/2)*(-b1*x-x*beta[1]+y-beta[0])^2/sigma^2-b1+(1/2)*(-(1/2)*(2*b1*x+2*x*beta[1]-2*y+2*beta[0])/sigma^2-1)^2*sigma^2

(4)

Remainder := add(op(2..-1, T_e)):
Gauss := op(1, T_e):

J0 := exp(Remainder)*Int(exp(Gauss), b0=0..infinity);

exp(-(1/2)*(-b1*x-x*beta[1]+y-beta[0])^2/sigma^2-b1+(1/2)*(-(1/2)*(2*b1*x+2*x*beta[1]-2*y+2*beta[0])/sigma^2-1)^2*sigma^2)*(Int(exp(-(1/2)*(b0-(-(1/2)*(2*b1*x+2*x*beta[1]-2*y+2*beta[0])/sigma^2-1)*sigma^2)^2/sigma^2), b0 = 0 .. infinity))

(5)

# the integral is obviously equal to 1/(2*sigma*sqrt(2*Pi))

J0_sol := exp(Remainder)/(2*sigma*sqrt(2*Pi))

(1/4)*exp(-(1/2)*(-b1*x-x*beta[1]+y-beta[0])^2/sigma^2-b1+(1/2)*(-(1/2)*(2*b1*x+2*x*beta[1]-2*y+2*beta[0])/sigma^2-1)^2*sigma^2)*2^(1/2)/(sigma*Pi^(1/2))

(6)

J1 := Int(J0_sol, b1=0..+infinity)

Int((1/4)*exp(-(1/2)*(-b1*x-x*beta[1]+y-beta[0])^2/sigma^2-b1+(1/2)*(-(1/2)*(2*b1*x+2*x*beta[1]-2*y+2*beta[0])/sigma^2-1)^2*sigma^2)*2^(1/2)/(sigma*Pi^(1/2)), b1 = 0 .. infinity)

(7)

J1 := expand(combine(J1, exp));

(1/4)*2^(1/2)*exp((1/2)*sigma^2)*exp(beta[0])*exp(beta[1]*x)*(Int(exp(b1*x)/exp(b1), b1 = 0 .. infinity))/(sigma*Pi^(1/2)*exp(y))

(8)

J := value(%);

(1/4)*2^(1/2)*exp((1/2)*sigma^2)*exp(beta[0])*exp(beta[1]*x)*(limit((exp(b1*x-b1)-1)/(-1+x), b1 = infinity))/(sigma*Pi^(1/2)*exp(y))

(9)

eval(J) assuming x < 1

-(1/4)*2^(1/2)*exp((1/2)*sigma^2)*exp(beta[0])*exp(beta[1]*x)/(sigma*Pi^(1/2)*exp(y)*(-1+x))

(10)

eval(J) assuming x > 1

2^(1/2)*exp((1/2)*sigma^2)*exp(beta[0])*exp(beta[1]*x)*infinity/(sigma*Pi^(1/2)*exp(y))

(11)

 


 

Download error_function.mw

Replace ; by : at the end of the command

  1. https://www.maplesoft.com/support/help/Maple/view.aspx?path=ProgrammingGuide/Chapter15
    next choose Multithread programming and/or Parallel programming (it depends on what type of "parallelization" you are interested in).
  2.  I'm sure there is a little two parts course on the Posts section of Mapleprimes (it was pretty well done... author dohashi ??? ).
    Unfortunately iI couldn't retrieve it.
  3. on Mapleprimes site :
    Parallel Programming Contents Page
    The Current Limitations of Parallel Programming In Maple

     

@radaar 
"Will Grid:-Map use a lot of memory? " : It depends on the way you have coded.
From experience, reducing the computation time with Grid is very easy, but avoiding used memory inflation can be a hard task.

The first thing to do is:

  1. Run your code on a single proc and catch the memory used from the task monitor (if you use Wondows).
    Look also to the runing process dubbed "mserver" and rnote the memory it uses ; let's notoe it S.
     
  2. Do the same by using Grid on P processors. You will have P+1 mserver processes: look to the memory size they use (depending on your programming you could have P processors with size S and one "the parent one" with size P*S: this means you will have to search in your code why it consumes so many memory when run on P processors).
     
  3. I don't have Windows right now to give you the correct command I use to use, but you can catch programmatically the total memory used (the command can be run with ssystem("command"))


More generally, if you are interested to use Grid, here are a few advices (from experience):

  1. Avoid using convert(blablabla, X) where X is a set, list, array, matrix, ...; from experience this can dramatically inflate the memory. So think first to the good structure blablabla must have.
     
  2. Avoid solve and prefer fsolve. I do not understand why solve tends to increase memory (maybe a point related to the remember table solve uses?) , but it seems to be the fact.
     
  3. grid:-Run and Grid:-Launch seem to do the same thing, but it's not true and a code optimized for one of them can give poor results when run with the other one.
     
  4. Forget garbage collector gc: it doesn't work on multiple processors
     

So, no real answers here, just be very careful: a code that requires a small amount of memory on a single processor can be very greedy on multiple processors (i already crashed my 64 Gb machine with "raw" coding when a good coding used less than 1Gb)

Here are two ways to do this. 
 


 

restart:

with(Statistics):

C := RandomVariable(Cauchy(0, 1)):

# The easiest way

N := 10^4:
C_sample := Sample(C, N, method=[envelope, range=-1..1]):
Histogram(C_sample);

[Mean, Variance](C_sample);

CodeTools:-Usage( Sample(C, N, method=[envelope, range=-1..1]) ):

 

[HFloat(-3.747279823038963e-4), HFloat(0.28029046512049793)]

 

memory used=507.56KiB, alloc change=0 bytes, cpu time=7.00ms, real time=7.00ms, gc time=0ns

 

# A lengthy way

p := Probability(C < -1, numeric);
q := 1-Probability(C > 1, numeric);

U_sample := Sample(Uniform(p, q), N):

C_cdf  := unapply(CDF(C, z), z):
C_icdf := unapply(solve(C_cdf(u)=z, u), z);

C_sample := C_icdf~(U_sample):
Histogram(C_sample);

[Mean, Variance](C_sample);

CodeTools:-Usage( C_icdf~(U_sample) ):

HFloat(0.25)

 

HFloat(0.75)

 

proc (z) options operator, arrow; -cot(z*Pi) end proc

 

 

[HFloat(-0.008152438124121577), HFloat(0.2737286335656307)]

 

memory used=2.21MiB, alloc change=0 bytes, cpu time=30.00ms, real time=30.00ms, gc time=0ns

 

 


 

Download CauchySampling.mw

Completing Carl Love's reply: if you want to pick "without replacement" and "without order constraints" (that is the nth picked number is not necessarily greater than the previous one) P numbers from a list L you must use combinat:-randperm
 

restart

L := [$1..100]:

P:= 3:
combinat:-randperm(L)[1..P]

[13, 71, 67]

(1)

# compare this

for k from 1 to 10 do
  combinat:-randcomb([$1..5], 5)
end do;

[1, 2, 3, 4, 5]

 

[1, 2, 3, 4, 5]

 

[1, 2, 3, 4, 5]

 

[1, 2, 3, 4, 5]

 

[1, 2, 3, 4, 5]

 

[1, 2, 3, 4, 5]

 

[1, 2, 3, 4, 5]

 

[1, 2, 3, 4, 5]

 

[1, 2, 3, 4, 5]

 

[1, 2, 3, 4, 5]

(2)

# to this

for k from 1 to 10 do
  combinat:-randperm([$1..5], 5)
end do;

[2, 4, 5, 1, 3]

 

[5, 2, 1, 4, 3]

 

[5, 1, 2, 3, 4]

 

[5, 1, 3, 4, 2]

 

[2, 4, 1, 3, 5]

 

[2, 4, 5, 1, 3]

 

[5, 4, 2, 3, 1]

 

[1, 5, 2, 3, 4]

 

[1, 2, 3, 4, 5]

 

[1, 3, 2, 5, 4]

(3)

 


 

Download pick.mw

If you really want to use colorscheme you can use this (the key point is style=point)

N  := numelems(x1):
xy := convert(Matrix(2, N, [x1, y1])^+,listlist):

plot(xy, style=point, colorscheme=["zgradient", ["Orange", "Red", "NavyBlue"]]);  # for instance


Another way to blavk/Blue coloring:

with(plots):
display(seq(pointplot([x1[k], y1[k]], color=piecewise(z1[k]<0.5, "Black", "RoyalBlue")), k=1..N))

 


 

restart

fe := Int(sqrt(1+(-5.557990765*sin(5.557990765*x)-7.3*cos(5.557990765*x)-5.6*sinh(5.557990765*x)+7.3*cosh(5.557990765*x))^2), x = 0 .. al)

Int((1+(-5.557990765*sin(5.557990765*x)-7.3*cos(5.557990765*x)-5.6*sinh(5.557990765*x)+7.3*cosh(5.557990765*x))^2)^(1/2), x = 0 .. al)

(1)

# this to have a broad idea of a search interval

plot(evalf(subs(al=a, fe)), a=0..1, gridlines=true)

 

g := proc(a)
  evalf(subs(al=a, fe))-0.5
end proc;

proc (a) evalf(subs(al = a, fe))-.5 end proc

(2)

fsolve(g(al), al=0..1);

.1550088024

(3)

evalf(subs(al=%, fe))

.5000000002

(4)

 


 

Download int.mw

@radaar   
@Carl Love

What do you mean by "surrogate optimization built in function"?
A surrogate can be as simple as the linear model Statistics:-LinearFit returns, or as complex as a neural network (Maple 2018 and later) with, in between GPE (gaussian process emulation such as kriging for instance).
Surrogate-based optimization generally uses GPE

As Carl wrote you could use the Kriging interpolation (I think this requires Maple 2018 or later).
But this implementation of the kriging method is more related to geostatistics than to surrogate modeling of an expensive code (mainly: correlation functions not well adpated).

There also exists a (commercial) toolbox dubbed "GlobalOptimization" which  is supposed to implement the EGO (Efficient Global Optimization method based on kriging surrogates).... unfortunately it gives poor results and doesn't work as claimed (in particular it can't be parameterized as described in the help pages; I posted a question about it a few weeks ago).

My personal (and thus questionable) opinion is that Maple is not yet adpated to do Surrogate-based optimization.

I can't picture out what your problem really is...

  1. Were did you find this procedure "print", is it one you wrote somewhere else?
  2. Use Matrix instead of matrix with strng type elements.
  3. Maybe read the help pages about Matrix and print?

 


 

restart:

problems := Matrix(5, 1, [M1, M2, M3, M4, M5])

problems := Matrix(5, 1, {(1, 1) = M1, (2, 1) = M2, (3, 1) = M3, (4, 1) = M4, (5, 1) = M5})

(1)

# g := "negative effect on the health of the consumer"

PA := "probability occurrence of each problems"

"probability occurrence of each problems"

(2)

g := Matrix(1, 3, [1, 2, 3])

g := Matrix(1, 3, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 3})

(3)

Criteria := Matrix(1,3,[ "not serious",  "moderately serious", "very serious"]);

#` For each value of g we print the corresponding adjective from the matrix Criteria `

for i from 1 by 1 to 3 do
  if  g(i)=i  then   
    print(Criteria(i));  
  end if   
end do    
 

Criteria := Matrix(1, 3, {(1, 1) = "not serious", (1, 2) = "moderately serious", (1, 3) = "very serious"})

 

"not serious"

 

"moderately serious"

 

"very serious"

(4)

IN := Matrix(1, 3, [1, 2, 3])

IN := Matrix(1, 3, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 3})

(5)

A := Matrix(1, 3, ["without risk", "occasional dange", "very common danger"])

A := Matrix(1, 3, {(1, 1) = "without risk", (1, 2) = "occasional dange", (1, 3) = "very common danger"})

(6)

for i to 3 do
  if IN(i) = i then
    print(A(i))
  end if
end do

"without risk"

 

"occasional dange"

 

"very common danger"

(7)

 


 

Download DontUnderstandYourProblem.mw

PS: if my answer is completely out of line, please forget it 

First 45 46 47 48 49 50 51 Last Page 47 of 56