Question: Calling procedures from another procedure

Dear Maple professionals

I have written two procedures in Maple that are run flawlessly. But when I wrote a simple third procedure that calls those two, I face an error. Can you guide me if I am missing anything? The code is attached. Thank you in advance!
 

``

restart

with(plots)

c := 1; cr := 0.3e-1*c; u := 1; sExp := 0.6e-1*c; s := .65*c

v := 3*c

NULL

FirmModelPP := proc (alpha, delta) local p0, xi0, q0, Firmpf0, G0, Recpf0, Unsold0, Environ0; option remember; xi0 := 1; p0 := min(s+sqrt((v-s)*(c-s)), delta*v+sExp); q0 := u*(v-p0)/(v-s); f(N) := 1/u; F(N) := N/u; G0 := int(F(N), N = 0 .. q0); Firmpf0 := (p0-c)*q0-(p0-s)*G0; Recpf0 := (sExp-cr)*xi0*q0; Environ0 := q0+G0; Unsold0 := G0; return p0, q0, Firmpf0, Recpf0, Unsold0, Environ0 end proc

FirmModelFC := proc (alpha, beta, delta) local p00, xi00, q00, Firmpf00, G00, Recpf00, Unsold00, Environ00, pr00; option remember; xi00 := 1; p00 := s+sqrt((v-s)*(c-s)); if p00 < delta*v+sExp then q00 := u*(v-p00)/(v-s); f(N) := 1/u; F(N) := N/u; G00 := int(F(N), N = 0 .. q00); Firmpf00 := (p00-c)*q00-(p00-s)*G00; Recpf00 := `&xi;00*q00*`(sExp-cr); Unsold00 := G00; Environ00 := q00+Unsold00 else q00 := alpha*u*(v-p00)/(v-s); f(N) := 1/u; F(N) := N/u; G00 := int(F(N), N = 0 .. q00/alpha); pr00 := p00-delta*v; Firmpf00 := (p00-c)*q00-alpha*(p00-s)*G00; Recpf00 := (beta*(pr00-sExp)+sExp-cr)*xi00*q00-(1/2)*(pr00-sExp)*beta^2*xi00^2*q00^2/(u*(1-alpha)); Unsold00 := G00; Environ00 := q00+Unsold00 end if; return p00, q00, Firmpf00, Recpf00, Unsold00, Environ00 end proc

NULL

NULL

"CurrentMetrics:= proc(alpha,beta,delta) option remember;  local  p, q, Firmpf,Recpf,Unsold,Environ; "

Error, unterminated procedure

"CurrentMetrics:= proc(alpha,beta,delta) option remember;  local p, q, Firmpf,Recpf,Unsold,Environ; "

 

"if (FirmModelFC(alpha,beta,delta)[3]>=FirmModelPP(alpha,delta)[3]) then    p:=FirmModelFC(alpha,beta,delta)[1]:  q:=FirmModelFC(alpha,beta,delta)[2]:   Firmpf:=FirmModelFC(alpha,beta,delta)[3]:  Recpf:=FirmModelFC(alpha,beta,delta)[4]:  Unsold:=FirmModelFC(alpha,beta,delta)[5]:   Environ:=FirmModelFC(alpha,beta,delta)[6]:     else   p:=FirmModelPP(alpha,delta)[1]:  q:=FirmModelPP(alpha,delta)[2]:   Firmpf:=FirmModelPP(alpha,delta)[3]:   Recpf:=FirmModelPP(alpha,delta)[4]:  Unsold:=FirmModelPP(alpha,delta)[5]:   Environ:=FirmModelPP(alpha,delta)[6]:    end if :  return p,q,Firmpf,Recpf, Unsold,Environ;  end proc: "

Error, unable to parse

"if (FirmModelFC(alpha,beta,delta)[3]>=FirmModelPP(alpha,delta)[3]) then p:=FirmModelFC(alpha,beta,delta)[1]:  q:=FirmModelFC(alpha,beta,delta)[2]:   Firmpf:=FirmModelFC(alpha,beta,delta)[3]: Recpf:=FirmModelFC(alpha,beta,delta)[4]:  Unsold:=FirmModelFC(alpha,beta,delta)[5]: Environ:=FirmModelFC(alpha,beta,delta)[6]:    else p:=FirmModelPP(alpha,delta)[1]:  q:=FirmModelPP(alpha,delta)[2]:   Firmpf:=FirmModelPP(alpha,delta)[3]: Recpf:=FirmModelPP(alpha,delta)[4]:  Unsold:=FirmModelPP(alpha,delta)[5]: Environ:=FirmModelPP(alpha,delta)[6]:   end if :  return p,q,Firmpf,Recpf, Unsold,Environ;  end proc: "

 

NULL

plot(['CurrentMetrics(alpha, .2, .2)[3]'], alpha = 0. .. 1.0, linestyle = [solid], legend = ["Firm's profit with delta=0.2"], labels = [alpha, "Firm profit"], labeldirections = ["horizontal", "vertical"], color = [blue], axes = boxed)

Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

 

 

NULL

NULL

NULL

NULL

NULL

NULL


 

Download Call_two_procedures_in_another_one.mw

 

Please Wait...