Ronan

1341 Reputation

15 Badges

13 years, 139 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are questions asked by Ronan

I use this type ckect elsewhere inside a package and it works. I can't get it to work in a stand alone procedure.

This was originally provided by @acer (best answer) in this question Experimental format for projective vectors - MaplePrimes

restart

 

 

test:=proc(V::{And('Vector(1)',satisfies( v->type(v[1],'Vector[:-column](3)') ) ),
               And('Vector(1)',satisfies( v->type(v[1],'Vector[:-row](3)') ) )})
print("works",V);
end proc

proc (V::{And('Vector(1)', satisfies(proc (v) options operator, arrow; type(v[1], 'Vector[:-column](3)') end proc)), And('Vector(1)', satisfies(proc (v) options operator, arrow; type(v[1], 'Vector[:-row](3)') end proc))}) print("works", V) end proc

(1)

v1:=<[<1,3,2>]>;
v2:=<[<a|b|c>]>

Vector(1, {(1) = Vector(3, {(1) = 1, (2) = 3, (3) = 2})})

 

Vector[column](%id = 36893490573309309044)

(2)

test(v1)

Error, invalid input: test expects its 1st argument, V, to be of type {And('Vector[1]',satisfies(v -> type(v[1],'Vector[:-column](3)'))), And('Vector[1]',satisfies(v -> type(v[1],'Vector[:-row](3)')))}, but received Vector(1, [Vector(3, [1,3,2])])

 

test(v2)

Error, invalid input: test expects its 1st argument, V, to be of type {And('Vector[1]',satisfies(v -> type(v[1],'Vector[:-column](3)'))), And('Vector[1]',satisfies(v -> type(v[1],'Vector[:-row](3)')))}, but received Vector(1, [Vector[row](3, [a,b,c])])

 

whattype(v1)

Vector[column]

(3)

whattype(v1[1])

Vector[column]

(4)

whattype(v2)

Vector[column]

(5)

whattype(v2[1])

Vector[row]

(6)
 

 

Download 2024-12-29_Q_Type_checking_not_working.mw

I am looking for a more eligent way to convert a Vector to a Diagonal Matrix.

restart

 

 

with(LinearAlgebra):

 

V:=Vector[column](3, [0.5863730366, 0.1171249270, 0.2965020364])

Vector(3, {(1) = .5863730366, (2) = .1171249270, (3) = .2965020364})

(1)

Vm:=Matrix(3,[[V[1],0,0],[0,V[2],0],[0,0,V[3]]])

Matrix(3, 3, {(1, 1) = .5863730366, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = .1171249270, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = .2965020364})

(2)

Vm1:=Matrix(3,3):

for i to 3 do
Vm1[i,i]:=V[i];
end do:

Vm1

Matrix(3, 3, {(1, 1) = .5863730366, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = .1171249270, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = .2965020364})

(3)
 

 

Download 2024-12-26_Q_Diagonal_Matrix_from_Vector.mw

I knowI can use a loop but I would like something neater. igcd can be applied to a list. Is there a way to map or use @ to apply gcd to a list?

lst:= [4, 2, 8, 4];
lst1 := [a^3/10, -a^2/2, a, a^4/4]
                      lst := [4, 2, 8, 4]

                        [1   3    1  2     1  4]
                lst1 := [-- a , - - a , a, - a ]
                        [10       2        4   ]


gd:=igcd(lst);



                            gd := 2

gd1=(gcd@op)(lst1);

 

It is not that this a terribly difficult to work out, but I feel I am probably missing something. I need to check if a 3D point lies on a 3D line. What is a good approach here. I started of with the idea all alpha's are equal. but there are exceptions. See P3 and P4

restart

NULL

l := `<,>`(3+2*alpha, 1+6*alpha, 4-5*alpha)

Vector[column](%id = 36893489809910741940)

(1)

NULL

P := [9, 19, -11]

[9, 19, -11]

(2)

seq(solve({l[i] = P[i]}, alpha), i = 1 .. 3)

{alpha = 3}, {alpha = 3}, {alpha = 3}

(3)

l1 := `<,>`(3+2*alpha, 1+0*alpha, 4-5*alpha)

Vector[column](%id = 36893489809910721460)

(4)

P1 := [9, 1, -11]

[9, 1, -11]

(5)

seq(solve({l1[i] = P1[i]}, alpha), i = 1 .. 3)

{alpha = 3}, {alpha = alpha}, {alpha = 3}

(6)

l2 := `<,>`(3+2*alpha, 1+0*alpha, 4-0*alpha)

Vector[column](%id = 36893489809910705556)

(7)

P2 := [9, 1, 4]

[9, 1, 4]

(8)

seq(solve({l2[i] = P2[i]}, alpha), i = 1 .. 3)

{alpha = 3}, {alpha = alpha}, {alpha = alpha}

(9)

l3 := `<,>`(3+2*alpha, 0+0*alpha, 4-0*alpha)

Vector[column](%id = 36893489809963852012)

(10)

P3 := [9, 0, 4]

[9, 0, 4]

(11)

seq(solve({l3[i] = P3[i]}, alpha), i = 1 .. 3)

{alpha = 3}, {alpha = alpha}

(12)

P4 := [9, 0, -2]

[9, 0, -2]

(13)

seq(solve({l3[i] = P4[i]}, alpha), i = 1 .. 3)

{alpha = 3}, {alpha = alpha}

(14)

 

Download 2024-12-21_Q_3D_point_lies_on_3D_line.mw

2024-12-20_Q_simplification_Question.mw
Solve the general cubic. Apply values and simplify. 

Could someone show how Maple simplifies to the value of X=3? I tried doing it manually and I could not figure it out. 

Also is there a Help assistant to see the setps?

restart

 

 

X^3+a*X=b

X^3+X*a = b

(1)

 

 

sol:=solve(X^3+a*X=b,[X])

[[X = (1/6)*(108*b+12*(12*a^3+81*b^2)^(1/2))^(1/3)-2*a/(108*b+12*(12*a^3+81*b^2)^(1/2))^(1/3)], [X = -(1/12)*(108*b+12*(12*a^3+81*b^2)^(1/2))^(1/3)+a/(108*b+12*(12*a^3+81*b^2)^(1/2))^(1/3)+((1/2)*I)*3^(1/2)*((1/6)*(108*b+12*(12*a^3+81*b^2)^(1/2))^(1/3)+2*a/(108*b+12*(12*a^3+81*b^2)^(1/2))^(1/3))], [X = -(1/12)*(108*b+12*(12*a^3+81*b^2)^(1/2))^(1/3)+a/(108*b+12*(12*a^3+81*b^2)^(1/2))^(1/3)-((1/2)*I)*3^(1/2)*((1/6)*(108*b+12*(12*a^3+81*b^2)^(1/2))^(1/3)+2*a/(108*b+12*(12*a^3+81*b^2)^(1/2))^(1/3))]]

(2)

vals:=[a=6,b=45]

[a = 6, b = 45]

(3)

Nans:=(map(eval,sol,vals))

[[X = (1/6)*(4860+12*166617^(1/2))^(1/3)-12/(4860+12*166617^(1/2))^(1/3)], [X = -(1/12)*(4860+12*166617^(1/2))^(1/3)+6/(4860+12*166617^(1/2))^(1/3)+((1/2)*I)*3^(1/2)*((1/6)*(4860+12*166617^(1/2))^(1/3)+12/(4860+12*166617^(1/2))^(1/3))], [X = -(1/12)*(4860+12*166617^(1/2))^(1/3)+6/(4860+12*166617^(1/2))^(1/3)-((1/2)*I)*3^(1/2)*((1/6)*(4860+12*166617^(1/2))^(1/3)+12/(4860+12*166617^(1/2))^(1/3))]]

(4)

simplify(Nans)

[[X = 3], [X = (1/4)*(I*3^(1/2)*(180+44*17^(1/2))^(2/3)+(8*I)*3^(1/2)-(180+44*17^(1/2))^(2/3)+8)/(180+44*17^(1/2))^(1/3)], [X = -3/2-((1/2)*I)*51^(1/2)]]

(5)
 

 

Download 2024-12-20_Q_simplification_Question.mw

1 2 3 4 5 6 7 Last Page 2 of 35