MaplePrimes Questions

Hello everyone. after runnig this maple code i get the error :" Error, (in Optimization:-NLPSolve) non-numeric result encountered" . How can fix it?

restart;
Digits := 20;
with(LinearAlgebra);
with(linalg);
with(Optimization);
with(Student[Calculus1]);
NULL;
n := 2;
z := 1;
a := 0;
b := 1;
m := 2;
NULL;
PS1 := (j, t) -> piecewise(j = 0, 1, t^(j + s[j]));
PI1 := (j, t) -> piecewise(j = 0, 1, t^(j + q[j]));
PH1 := (j, t) -> piecewise(j = 0, 1, t^(j + h[j]));
PL1 := (j, t) -> piecewise(j = 0, 1, t^(j + l[j]));
NULL;
PS := t -> local j; Transpose(convert([seq(PS1(j, t), j = 0 .. n - 1)], Matrix));
P_I := t -> local j; Transpose(convert([seq(PI1(j, t), j = 0 .. n - 1)], Matrix));
PH := t -> local j; Transpose(convert([seq(PH1(j, t), j = 0 .. n - 1)], Matrix));
PL := t -> local j; Transpose(convert([seq(PL1(j, t), j = 0 .. n - 1)], Matrix));
Warning, (in PS) `j` is implicitly declared local
Warning, (in P_I) `j` is implicitly declared local
Warning, (in PH) `j` is implicitly declared local
Warning, (in PL) `j` is implicitly declared local


NULL;
NULL;
B1 := (i, j) -> piecewise(i = j and j = 1, 1, i = 1 and 1 < j, 0, i = j and j = 2, 1, i = 2 and 2 < j, 0, j <= i, (i + j - 2)!/(2^(j - 1)*(j - 1)!*(i - j)!));
NULL;

B := t -> Matrix(n, B1);

DS1 := (m, k) -> piecewise(m <= 1, 0, m = k, GAMMA(k + s[k - 1])/GAMMA(k + s[k - 1] - z));
DI1 := (m, k) -> piecewise(m <= 1, 0, m = k, GAMMA(k + i[k - 1])/GAMMA(k + i[k - 1] - z));
DH1 := (m, k) -> piecewise(m <= 1, 0, m = k, GAMMA(k + h[k - 1])/GAMMA(k + h[k - 1] - z));
DL1 := (m, k) -> piecewise(m <= 1, 0, m = k, GAMMA(k + l[k - 1])/GAMMA(k + l[k - 1] - z));
DS := t -> t^(-z)*Matrix(n, DS1);
DI := t -> t^(-z)*Matrix(n, DI1);
DH := t -> t^(-z)*Matrix(n, DH1);
DL := t -> t^(-z)*Matrix(n, DL1);
NULL;
NULL;

cs := i -> ps[i];
ci := j -> p[j];
ch := j -> ph[j];
cl := i -> pl[i];
CS := convert([seq(cs(i), i = 1 .. n)], Matrix);
CI := convert([seq(ci(i), i = 1 .. n)], Matrix);
CH := convert([seq(ch(i), i = 1 .. n)], Matrix);
CL := convert([seq(cl(i), i = 1 .. n)], Matrix);

NULL;
NULL;
NULL;
S := unapply(simplify(Multiply(Multiply(CS, B(t)), PS(t))[1, 1]), [t]);
I1 := unapply(simplify(Multiply(Multiply(CI, B(t)), P_I(t))[1, 1]), [t]);
H := unapply(simplify(Multiply(Multiply(CH, B(t)), PH(t))[1, 1]), [t]);
L := unapply(simplify(Multiply(Multiply(CL, B(t)), PL(t))[1, 1]), [t]);
DSS := unapply(simplify(Multiply(Multiply(Multiply(CS, B(t)), DS(t)), PS(t))[1, 1]), [t]);
DII := unapply(simplify(Multiply(Multiply(Multiply(CI, B(t)), DI(t)), P_I(t))[1, 1]), [t]);
DHH := unapply(simplify(Multiply(Multiply(Multiply(CH, B(t)), DH(t)), PH(t))[1, 1]), [t]);
DLL := unapply(simplify(Multiply(Multiply(Multiply(CL, B(t)), DL(t)), PL(t))[1, 1]), [t]);
NULL;

NULL;
RS := unapply(evalf(DSS(t) + (-0.0043217^z + 0.5944^z*Multiply(S(t), I1(t)) + (0.025^z + 0.0008^z)*S(t))), [t]);

RI := unapply(evalf(DII(t) + (-0.5944^z*Multiply(S(t), I1(t)) - 0.0056^z*Multiply(H(t), I1(t)) - 0.027^z*L(t) + (((0.025^z + 0.0008^z) + 0.025^z) + 0.5^z)*I1(t))), [t]);
RH := unapply(evalf(DHH(t) + (-0.535^z + 0.0056^z*Multiply(H(t), I1(t)) - 0.5^z*I1(t) + (0.025^z + 0.0008^z)*H(t))), [t]);
RL := unapply(evalf(DLL(t) + (-0.025^z*I1(t) + (0.025^z + 0.0008^z + 0.027^z)*L(t))), [t]);
R := unapply(evalf(RS(t)^2 + RI(t)^2 + RH(t)^2 + RL(t)^2), [t]);

NULL;

p1 := x -> (x^2 - 1)^m;
dmp1 := x -> diff(p1(x), x $ m);
NULL;
p := x -> dmp1(x)/(2^m*m!);
eq := p(x) = 0;
r := solve(eq, x);
NULL;
ss := Vector[row](m);
w := Vector[row](m);
for i to m do
    w[i] := 2/((-r[i]^2 + 1)*D(p)(r[i])^2);
    ss[i] := w[i]*evalf(R((b - a)/2*r[i] + (b + a)/2));
end do;


SS := add(ss);

Lambda := evalf((b - a)/2*SS);
;

C1 := S(0) - 43994 = 0;
C2 := I1(0) - 0.1 = 0;
C3 := H(0) = 0;
C4 := L(0) - 1 = 0;

NULL;
NLP := NLPSolve(Lambda, {C1, C2, C3, C4});
Error, (in Optimization:-NLPSolve) non-numeric result encountered

 

Hi,

It might be really trivial, but I am struggling in the algebraic manipulation of the argument of the exponential function. As an example, I want to substitute 

I*T[0]*(omega1-2*omega2) = I*omega2*T[0]-I*si*T[2]

in the expression of

exp(-I*T[0]*(omega1-2*omega2)).

However, I am only able to do so by subs command and also by exactly copying the argument in the following manner.

subs(-I*T[0]*(omega1-2*omega2) = I*omega2*T[0]-I*si*T[2], exp(-I*T[0]*(omega1-2*omega2)))

The issue is I have expressions like this all over in the main problem, and I have to copy-paste such expressions for the substitution. So I am wondering if there is a more efficient way to tackle this problem. 

Thanks in Advance,

Regards

I am trying to determine constraints for a,b,c that are real, such that the eigenvalues of my system matrix have all negative real part.

restart;
with(LinearAlgebra):
assume(a,'real');
assume(b,'real');
assume(c,'real');
A:=<c,0,0;0,-1,a;0,b,-1>
elist:=Eigenvalues(A):
map(lprint,elist):
c
-1+(b*a)^(1/2)
-1-(b*a)^(1/2)

If all eigenvalues real part must be less than 0, then clearly:

c < 0

ab < 1

However, when trying to verify these results with "is" and "coulditbe" Maple gives me blatantly false results:

additionally(c<0)
additionally(a*b<1)
is(Re(-1+sqrt(a*b))<0)
                             false

coulditbe(Re(-1+sqrt(a*b))>0)
                              true


The real part of -1+sqrt(a*b) can never be greater than 0 under the assumption that ab<1. So why is Maple giving me nonsense? Am I using the commands incorrectly?

Hi, I am completely new to Maple and I keep getting this message:

Error, invalid input: rhs received 19715.18184, which is not valid for its 1st argument, expr

my code is:

sqq:=Vector(n):
for i from 1 by 1 to n do


pom:=eval(sigma[qq],[K=0.5,Fred=0,Phi[a]=0.8,Phi[p]=0.2,camax=300000,Kmin=0.5,co=11230,c11=6120,c12=12710,c21=14.17,c22=6.61,c13=9270,c23=16.16,c14=9270,c24=16.16,g=0.745430443,R=0.00652,H=0.00081,l=2,P=Pload[i],lambda[Q]=lQres1[i], lambda[Z]=lZres1[i]]):

sqq[i]:=rhs(pom):

end do:

I am trying to get a vector sqq solving the equation sigma[qq] using the constants and vectors written there. Can anybody help me please?

While Maple itself is a pleasure to work with, the multitude and persistance of bugs in the Units package doesn't stop to surprise.

Especially as the same bugs come up again and again, after having been fixed i older versions.

In general, working with units and 0 is a pain in the ass. And this one doesn't even need a unit to compare with.

This one works in Maple 2022 - does not work in Maple 2023.

with(Units[Simple]);
min(0, 0);

Hi, 

Im trying to solve a system of 4 non-linear equations using the fsolve function. When i compute the command i seemingly dont get an answer to the system. Maple only prompts the command itself, can any of you locate my mistake or give any input on how to solve the issue. 

My code is as follows: 

restart;
r__C := 400;
r__D := 600;
r__E := 800;
a := 100;
p := 0.7;
q := Pi*a^2*p;
h__eq := 0.9*h__1*(E__1/E__2)^(1/3);
R__Ceq := sqrt(h__eq^2 + r__C^2);
R__C := sqrt(r__C^2 + h__1);
R__Deq := sqrt(h__eq^2 + r__D^2);
R__D := sqrt(r__D^2 + h__1);
R__Eeq := sqrt(h__eq^2 + r__E^2);
R__E := sqrt(r__C^2 + h__1);


eqC := 174.5*10^(-3) = q*(1 + nu)/(2*Pi*E__2*R__Ceq)*(2*(1 - nu) + h__eq^2/R__Ceq^2) + q*(1 + nu)/(2*Pi*E__1*r__C)*(2*(1 - nu) + 0) - q*(1 + nu)/(2*Pi*E__1*R__C)*(2*(1 - nu) + h__1^2/R__C^2);
eqD := 151.7*10^(-3) = q*(1 + nu)/(2*Pi*E__2*R__Deq)*(2*(1 - nu) + h__eq^2/R__Deq^2) + q*(1 + nu)/(2*Pi*E__1*r__D)*(2*(1 - nu) + 0) - q*(1 + nu)/(2*Pi*E__1*R__D)*(2*(1 - nu) + h__1^2/R__D^2);
eqE := 133.2*10^(-3) = q*(1 + nu)/(2*Pi*E__2*R__Eeq)*(2*(1 - nu) + h__eq^2/R__Eeq^2) + q*(1 + nu)/(2*Pi*E__1*r__E)*(2*(1 - nu) + 0) - q*(1 + nu)/(2*Pi*E__1*R__E)*(2*(1 - nu) + h__1^2/R__E^2);
eqA := 401.7*10^(-3) = 2*q*a*(-nu^2 + 1)*(sqrt(1 + (h__eq/a)^2) - h__eq/a)/E__2 + 2*(-nu^2 + 1)*q*a/E__1 - 2*q*a*(-nu^2 + 1)*(sqrt(1 + (h__1/a)^2) - h__1/a)/E__1;


fsolve({eqA, eqC, eqD, eqE}, {E__1, E__2, h__1, nu}, {E__1 = 0 .. 5000, E__2 = 0 .. 5000, h__1 = 0 .. 1000, nu = 0 .. 0.5});
 

 

Picture for refference: 

Hi,

I am using A:=LinearAlgebra:-RandomMatrix(10,10,generator=-10..10) to generate a random matrix. How may I specify that every row of A has at least three non-zero entries? 

Thanks!

The attached worksheet shows a simple operator to calculaute the cartesian product of a set. The code is executed in both 1D and 2D notation in the worksheet.  The code is also placed in a code edit region and in the startup code area if the worksheet.  When entered into a worksheet is either notation, it produces an error message,  Without the local designation, it executes with a warning message. When entered into a code edit region it executes without error or warning.

I assume that this behavior reflects a limitation of the 2d notation or is there a workaround to the problem?

error4.mw

For instance, given nine integer x1, x2, …, x9 satisfying x1, x2, …, x9 ≥ -5 and x13x23+…+x93=0, the goal is to maximize x1 + x2 + … + x9. However, according to Optimization/Options,  is not accepted by the Optimization:-Maximize command. A probable method is applying floor into the optimization variables; unfortunately, I can only get: Error, (in Optimization:-NLPSolve) no improved point could be found

(*restart;*)
vars := [x || (1 .. 9)]:
Optimization:-Maximize(`?()`(`+`, floor~(expr)), [add(floor~(expr) ^~ 3) = 0, expr[] >=~ -5], initialpoint = (unapply~(expr) =~ rand(-5 .. 10))()); # Alternatives to exhaustive search?
Error, (in Optimization:-NLPSolve) no improved point could be found

Is there any workaround to solve this problem? 

I am trying to find a polygon that its graph take this four points as extra point. 
I tried
f := x -> a*x^7 + b*x^6 + c*x^5 + d*x^4 + k*x^3 + l*x^2 + m*x + n;
solve([f(-2) = -5, f(5) = -6, f(6) = 1, f(-1) = 2, eval(diff(f(x), x), x = -2) = 0, eval(diff(f(x), x), x = 5) = 0, eval(diff(f(x), x), x = 6) = 0, eval(diff(f(x), x), x = -1) = 0], [a, b, c, d, k, l, m, n]);


I get. Is there a polymial with lower degree take this four point as extra points?

how I can plot phi[2] as a contour like attached figure?

tez-1.mw


 

restart

``

beta := 2.5; lambda := 0.1e-1; b := Pi; a := Pi; alpha := 1; y[1] := 1.5; y[2] := 1.5; x[1] := -1; x[2] := 1; Q[1] := 40; Q[2] := 35

2.5

 

0.1e-1

 

Pi

 

Pi

 

1

 

1.5

 

1.5

 

-1

 

1

 

40

 

35

(1)

NULL

NULL

v := (2*n-1)*Pi/(2*b)

n-1/2

(2)

Delta := exp(2*v*a)*(alpha*v+beta)*(1+lambda)-(1-lambda)*(alpha*v-beta)

1.01*exp(2*(n-1/2)*Pi)*(n+2.000000000)-.99*n+2.970000000

(3)

g[22] := ((alpha*v+beta)*((1+lambda)*exp(-v*abs(x-xi))+(-1+lambda)*exp(-v*(x+xi)))*exp(2*v*a)+(alpha*v-beta)*((1+lambda)*exp(-v*(x+xi))+(-1+lambda)*exp(-v*abs(x-xi))))/(2*v*Delta)

g[21] := ((alpha*v+beta)*exp(v*(2*a+xi))+(alpha*v-beta)*exp(-v*xi))*exp(-v*x)/(v*Delta)

NULL

u[2] := int(2*g[21]*Q[1]*Dirac(xi-x[1])*sin(n*Pi*y[1]/b)/b, xi = -a .. 0)+int(2*g[22]*Q[2]*Dirac(xi-x[2])*sin(n*Pi*y[2]/b)/b, xi = 0 .. infinity)

NULL

phi[2] := sum(u[2](x)*sin(v*y), n = 1 .. 30)

NULL

``

plot3d(phi[2], x = 0 .. 5, y = 0 .. b)

 

NULL


 

Download tez-1.mw


 

restart

``

beta := 2.5; lambda := 0.1e-1; b := Pi; a := Pi; alpha := 1; y[1] := 1.5; y[2] := 1.5; x[1] := -1; x[2] := 1; Q[1] := 40; Q[2] := 35

2.5

 

0.1e-1

 

Pi

 

Pi

 

1

 

1.5

 

1.5

 

-1

 

1

 

40

 

35

(1)

NULL

NULL

v := (2*n-1)*Pi/(2*b)

n-1/2

(2)

Delta := exp(2*v*a)*(alpha*v+beta)*(1+lambda)-(1-lambda)*(alpha*v-beta)

1.01*exp(2*(n-1/2)*Pi)*(n+2.000000000)-.99*n+2.970000000

(3)

g[22] := ((alpha*v+beta)*((1+lambda)*exp(-v*abs(x-xi))+(-1+lambda)*exp(-v*(x+xi)))*exp(2*v*a)+(alpha*v-beta)*((1+lambda)*exp(-v*(x+xi))+(-1+lambda)*exp(-v*abs(x-xi))))/(2*v*Delta)

g[21] := ((alpha*v+beta)*exp(v*(2*a+xi))+(alpha*v-beta)*exp(-v*xi))*exp(-v*x)/(v*Delta)

NULL

u[2] := int(2*g[21]*Q[1]*Dirac(xi-x[1])*sin(n*Pi*y[1]/b)/b, xi = -a .. 0)+int(2*g[22]*Q[2]*Dirac(xi-x[2])*sin(n*Pi*y[2]/b)/b, xi = 0 .. infinity)

NULL

phi[2] := sum(u[2](x)*sin(v*y), n = 1 .. 30)

NULL

``

plot3d(phi[2], x = 0 .. 5, y = 0 .. b)

 

NULL


 

Download tez-1.mw

 

 

Please, is there anyway I can solve below problem without replacing the Alpha with value? The error I got is "Error, (in fracdiff) Unable to determine ceiling of alpha"

>

>

>-fracdiff(U1, t, alpha)+U1/M-U1^2/(M*K)+diff(U1, t)-(diff(U1, t))/epsilon

>int(%, t)

Dear all
Warm Greetings.

I want to display a solution (only numerical value) of the first derivative of the function for the values of x varies from 0 to 7 with step size 0.01.

I have attached the work file. 
ODE.mw

Please do the needful.

Thanks in advance.

Hi dear Users!

I hope everyone here is fine. I have a function like

f := exp(-t)*(x^2-5*x^3+10*x^5+x+3+.5*x^4)+(1/2)*x^2*(x-1)+2*sin(x);

I have to find the value of t at which the behavior of this function is constant for 6 decimal places against x from 0..1. This is my effort

restart;
N := 20; TOL := 10^(-6); Points := 100000;
f := exp(-t)*(x^2-5*x^3+10*x^5+x+3+.5*x^4)+(1/2)*x^2*(x-1)+2*sin(x);
for j from 0 while j <= 10 do print("\nWhen x = ", j/(10.));
for i from 0 while i <= Points do
g[i, j] := evalf(eval(f, [x = (1/10)*j, t = N*i/Points]));
if `and`(i >= 1, abs(g[i, j]-g[i-1, j]) < TOL) then print("Value of t = ", evalf(N*i/Points)); print("Value of f = ", g[i, j]); break else  
end if end do end do;


The same value is then verified by making graphs

plot([eval(f, t = 1), eval(f, t = 2), eval(f, t = 3), eval(f, t = 4), eval(f, t = 5), eval(f, t = 6), eval(f, t = 7)], x = 0 .. 1, color = [red, green, blue, cyan, yellow, black, purple]);
plot(eval(f, x = .8), t = 0.1e-1 .. N);

 

Here I want to know if is there any more effective maple command to find the value of t rather than using procedures (highlighted by red) or a graphical way.

I have been trying to to get a loop to sum the elements of a list of n size, and then take a certain element of summen list (which meets) a certain condition. And then print it out. 

What I can get it to do is printing the input list, and summing the elements in a new sister list sequence. And then if I for instance want its to print the element in testseq which is less than 15. Then it instead prints all elements less than 15 in testseq. What I would like to do is to move the index, so it only prints 10 and save it to a constant? 

So what am I missing?

test := [1, 2, 3, 4, 5, 6, 7, 10];
               test := [1, 2, 3, 4, 5, 6, 7, 10]


testseq := [seq(sum(test[i], i = 1 .. j), j = 1 .. numelems(test))];
            testseq := [1, 3, 6, 10, 15, 21, 28, 38]

for i to nops(test) while testseq[i] < 15 do
    testseq[i];
end do;
                               1

                               3

                               6

                               10

First 9 10 11 12 13 14 15 Last Page 11 of 2262