## 13821 Reputation

14 years, 210 days

## To be fair to the OP...

The Maple help for int() clearly states (emphasis added)

The int(expression, x) calling sequence computes an indefinite integral of the expression with respect to the variable x. Note: No constant of integration appears in the result.

but in "straightforward" Maple, something like the attached will do it.

 > restart:   s:= f->2*Pi*I*f:   V1:=1:   C:=100e-09:   L:=10.0e-03:   R:=1e03:   XL:=f-> s(f)*L:   XC:=f-> 1/(s(f)*C):   Z:= f-> XL(f)+XC(f):   T:=f-> R/(R+Z(f)):   Vout:=f-> V1*T(f);   plot( abs(Vout(f)),         f=100..100000,         axis[1]=[mode=log, gridlines=[30, color=green] ],         axis[2]=[gridlines=[3, color=green] ],         view=[100..100000, 0..1]       );
 >

## Well,...

for the example you quote, ie x=1, y=1, z=6 and w=-1, there are actually an infinite number of solutions.

Just select _Z1 to be any negative integer in the attached.

 > restart;   eq1 := a + b + c = n*x;   eq2 := a + 3*b + c = n*y;   eq3 := a + b + 5*c = n*z;   eq4 := 4*a + 8*b = n*w; # # for a givn set of integers x, y, z, and w (can # be positive or negative), can we determine a # positive integer integer n (n must be positive) # and the three integer (a, b, c) solution of previous system #   isolve(eval({eq1, eq2, eq3, eq4}, [x = 1, y = 1, z = 6, w = -1])); # # For example #   eval(%, _Z1=-1);;   eval(%%, _Z1=-10);
 (1)
 >

## Maybe...

tou want somthing like the attached? You might want to consider restricting the range of 't' to 1..20, rather than 1..100, because after t=~20, the animation gets a bit boring

 > restart;   with(plots):   M:= [ seq         ( matrixplot           ( -Matrix( 3,                      3,                      [ [ 0.2588777368e9, -0.2588777368e9,        0.     ],                        [-0.2588777368e9,  0.2588777368e9,        0.     ],                        [         0.,           0.,        0.6503118260e8]                      ]                    )*(1/t^0.9),             heights=histogram           ),           t=1..101         )       ]:   display(M, insequence=true);
 >

## When you write...

```MVals := [1.5, 2, 2.5];
for j to numelems(MVals) do
Ans[j] := dsolve(eval([OdeSys, Cond], M = MVals[j]), numeric, output = listprocedure);
end do;
```

the loop will produce A[1], A[2], A[3], and the loop variable 'j' will be 4, when the loop finishes

The next execution group, ie

```Theta_b[j]:= int( eval(U(Y), Ans[j])*eval(Theta(Y), Ans[j]), Y=0..1) / int( eval(U(Y), Ans[j]), Y=0..1):
Q_b[j]:=int( eval(U(Y), Ans[j]), Y=0..1):
```

will therefore use j=4, and so Ans[4], which of course does not exist - so this will  produce an error. In fact I can't work out what 'j' is supposed to be in thhis group

## I have trouble...

working out precisely what you want from your description, but maybe the final execution group in the attached will be of some use

 >
 >
 (1)
 >
 >
 >
 > # # The function g() returns the maximum value of the curve 'A' # in the range x=-5..0, for the supplied value of 'M' #   g:= mVal->maximize(eval(A, M = mVal), x = -5 .. 0); # # A couple of examples #   g(1.4);   g(1.3); # # The function f() computes the maximum values of the curve 'A' # in the range x=-5..0, for both supplied values of 'M', and # returns  smaller/larger, expressed as a percentage #   f:=(M1, M2)->`if`(g(M1)>g(M2), 100*g(M2)/g(M1), 100*g(M1)/g(M2)); # # A couple of exaamples   f(1.4,1.3);   f(1.3,1.4);
 (2)
 >

## Maybe the attached helps...

It constructs a graph isomorphic to the original graph 's', using only Arabic numerals, and provides a mapping between the two graphs

 > restart;   with(GraphTheory):   g1:= PathGraph(10):   g2:= CycleGraph(3):   s:= LexicographicProduct(g1,g2):   IsChordal(s,eliminationordering=true); # # Construct graph isomorphic t 's' #   G2:= Graph({seq( seq( {i, j}, j in op(4,s)[i]), i=1..30)}):   IsChordal(G2); # should be chordal   IsIsomorphic(s, G2, phi); # should be isomorphic   phi; # mapping from S to G2   DrawGraph(s);   DrawGraph(G2);
 >

## Is the attached...

what you were trying to achieve? (NB the gridlines are an aretfact of rendering on this site - they do not appear in the actual worksheet)

 >
 >
 > with(plots):
 > p1 := display       (  plot          ( data[2..-1, [1, 4]],            color=blue,            linestyle=3          ),          plot          (  data[2..-1, [1, 4]],             style=point,             color=blue,             symbol=asterisk,             symbolsize=20,             color=red          ),          axes=boxed,          labels=[y, "Absolute Error"],          labeldirections=[default, vertical]        );
 >

## A matrix is 2-D...

but in Maple you can generate arrays of exxentially arbitray dimension - see the attached for a random 4x4x4x4 example.

 > restart: # # A random 4*4*4*4 array #   Arr:=ArrayTools:-RandomArray(4,4,4,4,distribution=uniform): # # An element of the random array #   Arr[4,3,2,1]
 (1)
 >

## The simplest way...

is to use the 'legend' option.

## Not a BVP...

Since nothing in your worksheet contains a derivative, you do not have a BVP. You appear to have algebraic expressions for f(x), g(x), and h(x), together with some conditions (which you have misleadinglys assigned to bcs) for certain values of the independent variable x.
These can be solved using fsolve() - see the attached

 (1)

 (2)

 (3)

 (4)

 (5)

 (6)

 (7)

 (8)

 (9)

 (10)

 (11)

## Using subs() only...

as in the attached

 > restart;
 > with(LinearAlgebra):
 > with(DynamicSystems):
 > interface(imaginaryunit=j):
 > eq_m1 := m1 = (X__Tq*E__B*sin(delta) - R__T*E__B*cos(delta))/(R__E^2 + 2*R__a*R__E + R__a^2 + X__E^2 + X__E*L__ads*L__fd/(L__fd + L__ads) + 2*X__E*L__l + L__aqs*X__E + L__aqs*L__ads*L__fd/(L__fd + L__ads) + L__aqs*L__l + L__l*L__ads*L__fd/(L__fd + L__ads) + L__l^2);
 (1)
 > eq_m1_desired := m1 = (X__Tq*E__B*sin(delta) - R__T*E__B*cos(delta))/(R__E^2 + 2*R__a*R__E + R__a^2 + X__E^2 + X__E*L__ads_p + 2*X__E*L__l + L__aqs*X__E + L__aqs*L__ads_p + L__aqs*L__l + L__l*L__ads_p + L__l^2);
 (2)
 > ######
 (3)
 >

## Use the DirectSearch() package...

available from the Maple application centre. This "appears" to work without problems. See the attached.

 > restart:

Test code written by Dr. Venkat Subramanian at UT Austin, 05/31/2023. This code uses CVP approach (piecwise constant) to perform optimal control. NLPSolve combination with dsolve numeric parametric form is buggy and fails for some values of nvar, and works for some values of nvar. Ideally increasing nvar should show convergence with respect to the objective function.

 > restart:
 > Digits:=15;
 (1)
 > eqodes:=[diff(ca(t),t)=-(u+u^2/2)*1.0*ca(t),diff(cb(t),t)=1.0*u*ca(t)-0.1*cb(t)];
 (2)
 > soln:=dsolve({op(eqodes),ca(0)=alpha,cb(0)=beta},type=numeric,'parameters'=[alpha,beta,u],compile=true,savebinary=true):
 > ss:= proc(x)             interface(warnlevel=0):            #if  type(x[1],numeric)             if  type(x,Vector)             then local z1,n1,i,c10,c20,dt,u;                  global soln,nvar;                  dt:=evalf(1.0/nvar):                  c10:=1.0:c20:=0.0:                  for i from 1 to nvar do                      u:=x[i]:                      soln('parameters'=[c10,c20,u]):                      z1:=soln(dt):                      c10:=subs(z1,ca(t)):c20:=subs(z1,cb(t)):                  od:                  -c20;             else 'procname'(args):             end if:        end proc:   preP:= proc()               if   type( [_passed][1], numeric)               then ss( <_passed> );               else 'thisproc(_passed)'               fi;          end proc;
 (3)
 > nvar:=2;   DirectSearch:-Search( preP,                         [seq( [cat(z, j)>=0, cat(z,j)<=5][], j=1..nvar)],                         initialpoint=[0.1 \$ nvar],                         variables=[seq( cat(z, j), j=1..nvar)]                       )[1..2];
 (4)
 > nvar:=3;   DirectSearch:-Search( preP,                         [seq( [cat(z, j)>=0, cat(z,j)<=5][], j=1..nvar)],                         initialpoint=[0.1 \$ nvar],                         variables=[seq( cat(z, j), j=1..nvar)]                       )[1..2];
 (5)
 > nvar:=4;   DirectSearch:-Search( preP,                         [seq( [cat(z, j)>=0, cat(z,j)<=5][], j=1..nvar)],                         initialpoint=[0.1 \$ nvar],                         variables=[seq( cat(z, j), j=1..nvar)]                       )[1..2];
 (6)
 > nvar:=5;   DirectSearch:-Search( preP,                         [seq( [cat(z, j)>=0, cat(z,j)<=5][], j=1..nvar)],                         initialpoint=[0.1 \$ nvar],                         variables=[seq( cat(z, j), j=1..nvar)]                       )[1..2];
 (7)
 >

the attached.

 >

ERROR COMPARISON

 >
 (1)
 >
 (2)
 •
 (3)
 >
 (4)
 >
 >
 (5)
 >

 >

ERROR COMPARISON

 >
 (1)
 >
 (2)
 •
 (3)
 >
 (4)
 >
 (5)
 >