MaplePrimes Questions

Sq := proc(n::integer)
local aS, oS, aC, oC, s, dr, pc, u;
aS := -i/n;
oS := sum(1/s, s = 1 .. n);
aC := 1/2*aS;
oC := oS - 1/2*1/((n + 1)*n);
point(S, aS, oS); point(C, aC, oC);
MakeSquare(K, [S, 'center' = C]);
u := (x, i) -> sum(exp(-x*k)/k, k = 1 .. i);
pc := plot(u(x, n), x = 0 .. 4, color = green);
dr := draw([K]);
display({dr, pc});
end ;Sq(1);
Error, (in geometry:-draw) non-numeric coordinate encountered, cannot determine plot view
How to correct this procedure ?

I have used alias for various reasons inside a pagkage. It is useful for coupling old command names to modern ones.

I am trying now to get this to work inside a sub package but no success. Can this be done?

restart

 

pkg:=module()
option package;
export   Sqr, UHG;
alias(XX=Sqr);
#alias(eparm=CirclePramUHG);
Sqr:=proc(x)
   return x^2;
end proc;

 UHG:=module()
          option package;
         
          export
               CircleParmUHG;

alias(eparm=CirclePramUHG);

     CircleParmUHG := proc(T::algebraic, U::algebraic)
       local t, u, P, cp;
         #  P := point;
             t := T*denom(T)*denom(U);
             u := U*denom(T)*denom(U);
         # if P <> NullPoint then
         #   P := 'NullLine';
         #end if;
        if t::numeric and u::numeric and t<>0 and u<>0 then
             cp:=  <u^2 - t^2| 2*u*t| u^2 + t^2>/gcd(gcd(u^2 - t^2, 2*u*t), u^2 + t^2);
          else
             cp:=  <u^2 - t^2| 2*u*t| u^2 + t^2>;
        end if;
        return cp
      end proc;
    end module;
end module;

_m2044017012448

(1)

with(pkg)

[Sqr, UHG]

(2)

Sqr(4)

16

(3)

UHG:-CircleParmUHG(t,u)

[`?`]

(4)

UHG:-eparm(t,u)

Error, eparm is not a command in the pkg:-UHG package

 

with(UHG)

[CircleParmUHG]

(5)

CircleParmUHG(2,7)

Vector[row]([45, 28, 53])

(6)

eparm(2,7)

eparm(2, 7)

(7)

 

XX(3)

9

(8)
 

 

Download 2024-06-29_use_alias_in_a_Sub_Package.mw

Maple formats output depending on typesetting options "extened" and "standard" for the GUI (or interface). An example taken from

restart;
ts_standard:=proc(k::anything)
     interface(typesetting=standard):
     print(k);
     interface(typesetting=extended): 
     NULL;
end proc:
k:=3/8*ln(55/52)+sin(x)+3/4*exp(x);
                    3   /55\            3       
               k := - ln|--| + sin(x) + - exp(x)
                    8   \52/            4       

ts_standard(k);
                               

Why is the input two times returned and why one time as a list?
Somehow the first interface statement is responsible for that.

I am only interested in the reformated input inside the list.
Is it possible to fix the code?

Other observation with typesetting=standard:

restart;
interface(typesetting=standard);
expr:=cos(x)^2;
((x->x)=combine[trig])(expr);
                      

((x->x)=combine[trig])(expr);#subsequent call
                          2   1            1
                    cos(x)  = - cos(2 x) + -
                              2            2

(with Maple 2024.1 this only accurs in Math-1D)
but

restart;
expr:=cos(x)^2;
interface(typesetting=standard);
((x->x)=combine[trig])(expr);
                                      2
                        expr := cos(x) 

                            extended

                          2   1            1
                    cos(x)  = - cos(2 x) + -
                              2            2

I need to check inside typeset to see is something evaluates to 1. I can find if something contains 1 and have been using that. But got caught out last night because I forgot my work around. e.g. 1+H contains 1 and my work around is `1+H` so the check doesn't see the 1. The typeset is always the first item in the list.

restart

 

 

foo:=proc(a,{S::list:=[]})
local i,perp::boolean;
if S<>NULL then
  if (S[1])=1 or S[1]::function and has(`or`(seq (op(S[1]),i=1..nops([op(S[1])]))),1)  then
   #if (S[1])=1 or S[1]::function and `or`(seq (is(op(S[1][i]),1),i=1..nops([op(S[1])])))  then  ;#  not working
   
     perp:=true;print(perp);
    else
     perp:=false;print(perp);
  end if;
end if;
end proc:

foo(6,S=["cat"]);

 

false

(1)

foo(6,S=[1]);

true

(2)

foo(6,S=[typeset("cat=",H/H),align={above,left},color=green]); #good

true

(3)

foo(6,S=[typeset("cat=",H),align={above,left}])

false

(4)

foo(6,S=[typeset("cat=",1+H)],align={above,left},color=green);#want to fix this

 

 

true

(5)

foo(6,S=[typeset("cat=",`1+H`)]); #work around

false

(6)

foo(6,S=[typeset("cat=",`B/(H+1)`)]); #work around

false

(7)

foo(6,S=[typeset("cat=",`B/(H+1)`,"  height =",1)]); #correct

true

(8)

foo(6,S=[typeset("cat=",H^2/((2*H-H)*H),"  height =",`B/(H+1)`)]); #correct

true

(9)

op(typeset("cat=",B/(H+1)));# this would be false

 

"cat=", B/(1+H)

(10)

op(typeset("cat=",H^2/((2*H-H)*H),"  height =",`B/(H+1)`)) ;  # this would be true

 

 

"cat=", 1, "  height =", `B/(H+1)`

(11)
 

 

Download 2024-06-27_Q_check_inside_typeset.mw

When the limit approaches from left, the result must be zero. What cause the wrong? Will introducing an extra parameter M affect the result in W1?

W := -1/2+(1/2)*tanh(3.6*(tan(Pi*(r-2.1)/(2*7.9))-.6^2/tan(Pi*(r-2.1)/(2*7.9)))/Pi)

-1/2+(1/2)*tanh(1.145915590*tan(.1988349781*r-.4175534540)-.4125296124/tan(.1988349781*r-.4175534540))

(1)

limit(W, r = 10, left)

-1.000000000

(2)

W1 := -1/2+(1/2)*tanh(3.6*(tan(Pi*(r-2.1*M)/((2*7.9)*M))-.6^2/tan(Pi*(r-2.1*M)/((2*7.9)*M)))/Pi)

-1/2+(1/2)*tanh(1.145915590*tan(.1988349781*(r-2.1*M)/M)-.4125296124/tan(.1988349781*(r-2.1*M)/M))

(3)

limit(W1, r = 10*M, left)

-1.000000000

(4)

NULL

Download limit.mwlimit.mw

I want to write  in maple using summation notation for symbolic calculation. The output should come as 

 

W_1exp(k_1.q)+W_2exp(k_2.q)+W_3exp(k_3.q)

where k_j.q are the dot product of the vectors k_j and q. 

mp.mw

How to do this. Please help. The summation is not working for me, only suffix k is coming  

Is there a way to define tensor components without addressing each component individually? Suppose I define a tensor A[a, mu], where Latin letters are space coordinates and Greek letters are space-time coordinates. Is there an easy way to define multiple components without having to define each component separately. For example, A[a,0] = 0 and A[a,i] = LeviCevita[a,i,j].

restart;
with(Physics);
Setup(spaceindices = lowercaselatin_ah)
g_[]
Define(A[a, mu])
A[a, 1] := 0
A[a, b] := LeviCivita[a, b, c]
TensorArray(A[a, mu]) 
A[1, 2] := 0
A[2, 3] := LeviCivita[2, 3, c]
TensorArray(A[a, mu])

The general writing method does not seem to change the tensor components, but the writing method in which I address the components individually does. What exactly am I doing wrong? 

I use convert~([points1], list) command but the outcome is not I want. The code of shortscreen is attached. I wanna change the outermost curly braces of the sequence "points1" into square brackets. Thank you all guys to answer!

The below is I want.

This is not I want cause the outermost has three square brackets! I just wanna two.

GUI state after interupting with :

After switching to untitled 17 and back to test_timeout:

Sometimes it is necessary to switch back and forth twice.

Does this mean that the kernel did not receive the interupt?

eqn := B(n) = -sum(binomial(n + 1, k)*B(k), k = 0 .. n - 1)/(n + 1);
init := B(0) = 1, B(1) = -1/2;
sol := rsolve({eqn, init}, B(n));
Why doesn’t this give me any solution ? Thank you.

How to add x,y,z axis in plotsetup command? I need to enhance the quality of figure, so I use plotsetup command width=5000,height=5000. But in this case, the range of x,y,z axis vanish like this. The related code is attached.

Hi all,

I'm new to this software, I've started using it to build myself a spacemouse, and figuring out the "inverse kinematics" involved in its working. I've done a little research on how Maple works, I'm fortunate enough to have a student license, but maybe this problem is above my capacity.

Essentially, I want to control a 6-DOF platform by measuring six distances (with magnetic sensors, but that's not relevant, I believe), from three points forming an equiliateral triangle on the top platform, to six points on the bottom platform. So far I've been able to calculate the effect that each of the degrees of freedom has on the platform and on each of this distances that I want to measure.

But that's where the problem lies. Now I have a system of six equations with six variables and a few parameters, a system that's heavily nonlinear, involving a lot of trig functions and multiplications between them. I've tried to "brute force" a symbolic solution by simply typing in: solve(equations, variables) (note that both equations and variables were properly defined) but Maple just ran for a couple of hours without providing an answer. I don't know if this particular application reaches this software's limits, or if it's me who is doing something wrong.
I'll try to provide the maple Worksheet, I'm still not familiar with this site's formatting, sorry in advance:


restart;
L := Matrix(3, 3, [[cos(theta)*cos(psi), cos(theta)*sin(psi), -sin(theta)], [sin(phi)*sin(theta)*cos(psi) - cos(phi)*sin(psi), sin(phi)*sin(theta)*sin(psi) + cos(phi)*cos(psi), sin(phi)*cos(theta)], [cos(phi)*sin(theta)*cos(psi) + sin(psi)*sin(phi), cos(phi)*sin(theta)*sin(psi) - sin(phi)*cos(psi), cos(phi)*cos(theta)]]);
T := Matrix(3, 3, [[1, psi, -theta], [phi*theta - psi, phi*psi*theta + 1, phi], [phi*psi + theta, psi*theta - phi, 1]]);
p[ni] := Typesetting[delayDotProduct](R, Vector[column](3, [cos(theta[n]), -sin(theta[n]), 0]), true)

p__n := (T . (p[ni])) + Vector[column](3, [u, v, w])

m[m] := R*Vector[column](3, [cos(phi__m), -sin(phi__m), h/R])

`&Delta;p` := p__n - m[m]

with(VectorCalculus)

s[n] := sqrt(`&Delta;p` . `&Delta;p`)

theta[1] := -Pi/12;
theta[2] := Pi/12;
theta[3] := (2*Pi)/3 - Pi/12;
theta[4] := Pi/12 + (2*Pi)/3;
theta[5] := (4*Pi)/3 - Pi/12;
theta[6] := (4*Pi)/3 + Pi/12;

phi[1] := 0;
phi[2] := (2*Pi)/3;
phi[3] := (4*Pi)/3;

s[1] := eval(s[n], {phi__m = phi[1], theta[n] = theta[1]})

s[2] := eval(s[n], {phi__m = phi[1], theta[n] = theta[2]})

s[3] := eval(s[n], {phi__m = phi[2], theta[n] = theta[3]})

s[4] := eval(s[n], {phi__m = phi[2], theta[n] = theta[4]})

s[5] := eval(s[n], {phi__m = phi[3], theta[n] = theta[5]})

s[6] := eval(s[n], {phi__m = phi[3], theta[n] = theta[6]})

 

equations := [-d[1]^2 + s[1]^2 = 0, -d[2]^2 + s[2]^2 = 0, -d[3]^2 + s[3]^2 = 0, -d[4]^2 + s[4]^2 = 0, -d[5]^2 + s[5]^2 = 0, -d[6]^2 + s[6]^2 = 0]

variables := [u, v, w, psi, theta, phi]

solve(equations, variables)

 

So far this is what I've got, thanks in advance for the help.

EDIT: In the beginning of the worksheet two rotation matrices are declared, L and T. T is a "linearized" version of L, assuming small angles, and I'm using it to simplify the expressions. Still there is no luck.

There is an integration method called orering in Maple. But see no mention on it at help page 

It shows up when using option 

method=_RETURNVERBOSE

And that is how I knew about it.

It gives division by zero when asked to integrate zero !

Any one knows what is this method? Will send bug email to Maplesoft suport just in case also.
 

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

int(0,x)

0

int(0,x,method=orering)

Error, (in IntegrationTools:-Indefinite) numeric exception: division by zero

int(1,x,method=orering)

x

 


 

Download division_by_zero_int_orering_method.mw

 

 

Dear all, how can I simplify the following command by using nested SEQ?

tagsCornersPlot := textplot3d([[seq(cornerPoints[1 .. dim, 1]), cornerPoints[1 .. dim, 1]], [seq(cornerPoints[1 .. dim, 2]), cornerPoints[1 .. dim, 2]], [seq(cornerPoints[1 .. dim, 3]), cornerPoints[1 .. dim, 3]], [seq(cornerPoints[1 .. dim, 4]), cornerPoints[1 .. dim, 3]]], align = {above, right}, font = [Courier, bold, 20])

Hello Everyone 

I created a file to sum up 5 vectors and display them in 3d space. (see below)

I would like to optimize my input so that I input the total length of the vector and the angle in the x-y plane and the angle in the x-z plane. 

At the top of the document there is an idea from a different pots how to do it with 2d vectors but I can't get it to work with 3d vectors. 

Any ideas?

Thanks in advance!

3d_vector.mw

First 93 94 95 96 97 98 99 Last Page 95 of 2426