## Simplifying bouded (link as oppose to free ) vecto...

Hi - High school teacher

I'm using the with(Physics): Setup(mathematicalnotation=true):with(Physics[Vector]): libraries which gives elegant answers to some of the questions of elementary vector algebra.

But I become stuck when I try to simplify a simple expression like

Equa[01]:=AC_ = AB_ + BC_:Equa[01];                            #AC_ = AB_ + BC_
Equa[02]:={AB_=2*DB_,BC_=2*BE_}:Equa[02];
Equa[03]:=subs(Equa[02],Equa[01]):Equa[03];
#AC_ = 2*DB_ + 2*BE_
simplify(Equa[03]);                                                              #also try combine

which gives

AC_ = 2*DB_ + 2*BE_

rather than what I was hoping for

AC_ = 2*DE_

I have define a type and build a clumsy addition procedure - with no hope of overloading '+'

###########################
# TYPE VecPos (Vecteurs liés)
#
###########################
`type/VecPos`:=proc(Exp)
local LstExp:
LstExp:=convert(Exp,string):
if length(LstExp)=3 and LstExp[-1]="_" then
true
else
false
fi:
end proc:
###########################
#
###########################
local va,vb,a,b:
if patmatch(2*Exp,a::realcons*va::VecPos+b::realcons*vb::VecPos,'Corr') then
a:=subs(Corr,a)/2:                  b:=subs(Corr,b)/2:
va:=convert(subs(Corr,va),string):  vb:=convert(subs(Corr,vb),string):
if a < 0 then
va:=convert(cat(va[2],va[1],va[3]),string);
a:= -a;
fi;
if b < 0 then
vb:=convert(cat(vb[2],vb[1],vb[3]),string);
b:= -b;
fi;
fi;

if va[2]=vb[1] then
if a > b then
return b*convert(cat(va[1],vb[2..3]),symbol)
+ (a-b)*convert(va,symbol);
elif b > a then
return a*convert(cat(va[1],vb[2..3]),symbol)
+ (b-a)*convert(vb,symbol);
else
return a*convert(cat(va[1],vb[2..3]),symbol)
fi
elif vb[2]=va[1]  then
if a > b then
return b*convert(cat(vb[1],va[2..3]),symbol)
+ (a-b)*convert(va,symbol);
elif b > a then
return a*convert(cat(vb[1],va[2..3]),symbol)
+ (b-a)*convert(vb,symbol);
else
return a*convert(cat(vb[1],va[2..3]),symbol)
fi
else
return Exp
fi
end proc:

But I am sure that their exist a better solution - which if possible should remain within the Physics[Vector] library. It is hard enough to convince high school student to use maple. Maybe adding rule in the setep... I just don't have the required time to look around.

Any help would be appreciated.

Thank

Jean-Marc Roy

Note:

patmatch(2*AB_ + 2*BC_,a::realcons*va::VecPos+b::realcons*vb::VecPos,'Corr');Corr;Corr:='Corr':

work, but neither

patmatch(AB_ + BC_,a::realcons*va::VecPos+b::realcons*vb::VecPos,'Corr');Corr;Corr:='Corr':
patmatch(AB_ + BC_,va::VecPos+vb::VecPos,'Corr');Corr;Corr:='Corr':

return results. Which explain why I mutiply 2*Exp in the addition function.

## Transfer function of some date e.g in excel...

Hello

I am new to maple. How do you create a transfer function of a time response response of e.g some data in excel, csv etc

Thank you.

Stay safe

Ian

Hi, I am trying to add some useful inverse Laplace transforms to Maple's integral tables. I am frustrated that these transforms will only be recognized  if they are entered in exactly the same format. For example, if I type:

restart;

with(inttrans):

addtable(invlaplace, 1/(s^y*sqrt(a + s^x)), Sum(a^n*sqrt(Pi)*t^(-1 + (1/2 + n)*x + y)/(GAMMA(1/2 - n)*GAMMA(1 + n)*GAMMA(1/2*x + n*x + y)), n = 0 .. infinity), s, t, {a, x, y}, y::Range(-infinity, infinity), x::Range(-infinity, infinity), a::Range(-infinity, infinity));

savetable(invlaplace, `InvlaplaceTable.m`):

Then:

restart;

with(inttrans):

invlaplace(1/(s^y*sqrt(a + s^x)), s, t);#Ok works for general

invlaplace(1/(s^3*sqrt(a + s^x)), s, t);# Dosen't WORK ?# For y = 3.

invlaplace(1/(s^3*sqrt(s^3 + a)), s, t);# Dosen't WORK ?# For y = 3. and x = 3

value(eval(invlaplace(1/(s^y*sqrt(a + s^x)), s, t), [y = 3, x = 3]))#Workaround !!!

Thanks.

## Export to LaTeX not working properly...

Does anyone here have experience with exporting Maple worksheets to LaTeX?  According to help page

?Export as latex

"You can change the Mathematics Formatting Width to align multi-line displayed formulas by modifying the option in the Export tab of the Options dialog."

That setting, however, seems to have no effect.  The image below shows the result, after setting the line width to (the extremely narrow!) 2 inches.  Long lines still overflow the left and right margins of the paper, rendering the result useless.

I see that this was pointed out in 2016 but there appears to have been no improvements since.  Does anyone know a workaround?  I am running Maple 2020 on Linux, if that matters.

This zip file z.zip contains a Maple worksheet, the exported *.tex file, and the compiled PDF.  Here is what that PDF looks like.

## How to define a set with certain properties?...

How can I define a set generated by two degree n polynomials with binary coefficients?

For example: for n=2, I want to generate the set {(a_0*x_0+a_1*x_1)* (b_0*y_0+b_1*y_1) s.t. a_0,a_1,b_0,b_1 are binary}.

## Sharing to Maple Cloud with own libraries...

I'm trying to upload a file to Maple Cloud for the first time, but I am getting an error due to the way I use libraries.

The first lines of the startup code in the sheet look like this.

```libname := "S:/Maple/NODE_Library", libname;
with(NODETreMaterial);
with(NODETreTverrsnitt);```

The libraries are on a network drive on our server.

The question is - how can I solve this? Would it be better to somehow upload those libraries to Maple Cloud (no idea how to do that by the way), or can it be solved in a different way?

## Where is the error in evalf or do?...

I want to compute a function W for certain values of x < π/2. W is a ratio of 2 positive values -they are squares-computed using dsolve and that ratio seems to be negative when evalf is applied to the answer.!!!  The true answer (without the evalf) are positive. Also, applying evalf to the correct answers does not produce those silly negative answers. Any suggestions? I would prefer uplaod my file but do not know how>

Here is the file:

This worksheet has a system of ode's ( a second order and a first order), a power series solution near 0 to use for inital conditions, and a function W of the vairables that I want to compute for certain values of x < π/2. W is a ratio of 2 positive values and that ratio seems to be negative when evalf is applied to the answer.!!! The true answer (without the evalf) are positive. Also, applying evalf to the correct answers does not produce those silly negative answers.

• >  restart;

• >  alias(B=b(x));alias(Bp=diff(b(x),x));alias(f=F(x));alias(fp=diff(F (x),x));alias(fpp=diff(F(x),x,x));

B B, Bp

B, Bp, f B, Bp, f, fp

B, Bp, f, fp, fpp

• >  eq1 := sin(x)*(1+B*cos(x)^2)*fpp-(2*((f^2-2*B)*cos(x)^2-f^2+3*B* (1/2)-1))*cos(x)*fp+2*sin(x)*((f^2-3*B*(1/2))*cos(x)^2-f^2+(1/2)* B-1/2)*f = 0;eq2 := (-B*cos(x)^6+(B-1)*cos(x)^4+cos(x)^2)*fp^2+2*f* cos(x)*sin(x)*(cos(x)-1)*(cos(x)+1)*(1+B*cos(x)^2)*fp+cos(x)*sin(x) *Bp+B*cos(x)^6*f^2-(2*(B-1/2))*f^2*cos(x)^4+B*cos(x)^2*f^2-f^2+B = 0;

eq1 sinx 1 Bcosx2fpp 2 f2 2Bcosx2 f2 3B 1cosxfp 2

2sinx f2 3B cosx2 f2 B 1 f=0 222

eq2 Bcos x 6 B 1 cos x 4 cos x 2 fp2 2fcos x sin x cos x
1 cosx 1 1 Bcosx2 fp cosx sinx Bp Bcosx6f2 2 B

1 2

(1)

f2cos x 4 Bcos x 2f2 f2 B=0 > f2p:=solve(eq1,fpp);

f2p

(2)

(3)

1 2sin x f3cos x 2 sin x 1 Bcos x 2

2cos x 3fpf2
3sinx fBcosx2 4cosx3fpB 2sinx f3 2cosx fpf2 sinx fB

3cosx fpB sinx f 2cosx fp

• >  fs:=x^8*(127/604800*C+653/17010*(C^5)+2/81*(C^7)+773/1020600*(C^3)) +x^6*(17/5670*(C^3)-4/81*(C^5)+31/15120*C)+x^4*((1/9)*C^3+7/360*C)+ (1/6)*x^2*C+C:

• >  Bs:=x^6*(20/189*(C^4)+4/315*(C^2))+4*x^4*C^2*(1/45)+2*x^2*C^2*(1/3) :

• >  Digits:=15:

• >  ic:=(c)->{F(1e-5)=subs([x=1e-5,C=c],fs),D(F)(1e-5)=subs([x=1e-5,C= c],diff(fs,x)),b(1e-5)=subs([x=1e-5,C=c],Bs)}:

> nans:=dsolve({eq1,eq2} union ic(c),{f,B},numeric,stiff=true,

(4)

> parameters=[c]);

nans proc x_rosenbrock ... end proc

(4)

(5) (6)

> W:=fp^2*cos(x)/f^2;

W fp2 cos x f2

> Wp:=simplify(subs(fpp=f2p,diff(W,x)));

cosxsinx 1 Bcosx2fp2 f27Bcosx4 f25B3cosx2fpcosxf2

1

1
Wp f3sin x 1 Bcos x 2 4fp 2 f 4

444

3B cosx2 f2 B 1 f2sinx 222

• >  k:='k': for k from 4 to 5 do nans(parameters=[k]); evalf(eval([W, Wp], nans(Pi/2-1e-10)),5); end do;

c = 4.
482.73, 1.3965 10
8

c = 5.
5.6838 10
6, 1.4948 1013

• >  k:='k': for k from 4 to 5 do nans(parameters=[k]); eval([W,Wp],

nans(Pi/2-1e-10)); end do;

c = 4. 0.0131412243081803, 1.31416436948280 108

c = 5.
154.729383663460, 1.54702786932958 10
12

• >  evalf([0.0131412243081803, -1.31416436948280*10^8],5);

0.013141, 1.3142 108

(7)

(8) (9)

## error in subs or solve!!!...

Hi, after solving an equation and inserting it in the original equation the result is not equal to zero!!

What is the problem?

in the attached file below I obtained 'q' and then I put it in the eq (3), but the result is not zero!!

555.mw

## How to find a Perpendicular Vector...

I am looking for an elegant way in which to find a vector that is perpendicular to another vector.  The attached worksheet shows one method, but this can result in a divide by zero error.  I could write a procedure to detect and avoid the divide by zero error, but this feels like a sledgehammer to crack a nut :-)

Another method might be to rotate the vector by PI/2, but I'm not sure how to do this.

Any suggestions would be gratefully received!

Perpendicular_Vectors.mw

## How to make this code more efficient?...

Hi,
I need do generate a large number of matrices (always with the same dimensions) whose each column is a random sample of a different random variable.
I wrote a rather simple procedure to do that (see below a notional example). Let T and S the time and the memory size required for a single execution of this procedure, then its execution N times needs a time N*T and a size N*S.
If time is not a problem, the increase in memory size is extremely constraining.
How should I write this procedure in order that N executions of it use a memory of the order of S and not N*S?

## datatype = float[8])) error...

upload the mw file here faq.mw

Also i have a working for lopp and want to make a procedure.
Any suggestions will be helpful as well. Thanks.

## Re: Chain rule + how to refer to a previous result...

This is a given set of equations (from a classifier problem in deep learning):

I tried to replicate the expression in Maple, but it was unsuccessful.

Q_MaplePrime20200417.mw

Would you tell me how to make it work?

Then, please let me know how to refer to a previous result (equation number) in the current expression.

The last line above (and the attached Maple document) shows my attempt, It did not work.

Thank you/Be healthy!

## Error, invalid input: subs received Data, which is...

Hello,

How to solve this error? Thank you

Sistem := diff(E[1](t), t) = subs(E[1] = E[1](t), L[1] = L[1](t), P[1] = P[1](t), M[1] = M[1](t), E[2] = E[2](t), L[2] = L[2](t), P[2] = P[2](t), M[2] = M[2](t), Data, dE1), diff(L[1](t), t) = subs(E[1] = E[1](t), L[1] = L[1](t), P[1] = P[1](t), M[1] = M[1](t), E[2] = E[2](t), L[2] = L[2](t), P[2] = P[2](t), M[2] = M[2](t), Data, dL1), diff(P[1](t), t) = subs(E[1] = E[1](t), L[1] = L[1](t), P[1] = P[1](t), M[1] = M[1](t), E[2] = E[2](t), L[2] = L[2](t), P[2] = P[2](t), M[2] = M[2](t), Data, dP1), diff(M[1](t), t) = subs(E[1] = E[1](t), L[1] = L[1](t), P[1] = P[1](t), M[1] = M[1](t), E[2] = E[2](t), L[2] = L[2](t), P[2] = P[2](t), M[2] = M[2](t), Data, dM1), diff(E[2](t), t) = subs(E[1] = E[1](t), L[1] = L[1](t), P[1] = P[1](t), M[1] = M[1](t), E[2] = E[2](t), L[2] = L[2](t), P[2] = P[2](t), M[2] = M[2](t), Data, dE2), diff(L[2](t), t) = subs(E[1] = E[1](t), L[1] = L[1](t), P[1] = P[1](t), M[1] = M[1](t), E[2] = E[2](t), L[2] = L[2](t), P[2] = P[2](t), M[2] = M[2](t), Data, dL2), diff(P[2](t), t) = subs(E[1] = E[1](t), L[1] = L[1](t), P[1] = P[1](t), M[1] = M[1](t), E[2] = E[2](t), L[2] = L[2](t), P[2] = P[2](t), M[2] = M[2](t), Data, dP2), diff(M[2](t), t) = subs(E[1] = E[1](t), L[1] = L[1](t), P[1] = P[1](t), M[1] = M[1](t), E[2] = E[2](t), L[2] = L[2](t), P[2] = P[2](t), M[2] = M[2](t), Data, dM2);
Error, invalid input: subs received Data, which is not valid for its 9-th argument