Error, (in sqrfree) argument must be a polynomial or a rational function in {zB, TBA, yB, d, xB}

Hi !

I'm getting the following error when i run my script !!!!

Error, (in sqrfree) argument must be a polynomial or a rational function in {zB, TBA, yB, d, xB}

I'm using the sqrt function for my variables but it'S returning this error

Sample of my code

CalculerH := proc (Mc) local Wc, W, vuOB, vuBA, vuBD, vW, Mow, Mowc, MoBA, eqrOB, eqrBA, eqrBD, eqSommeMoy, eqSommeMoz; Wc := 9.81*Mc; W := 9.81*(.5+.125); vuOB := Vector([(1/80)*xB, (1/80)*yB, (1/80)*zB]); vuBA := Vector([4/3-(1/60)*xB, 1/12-(1/60)*yB, 2/5-(1/60)*zB]); vuBD := Vector([-xB/d, -yB/d, (100-zB)/d]); vW := Vector([0, -W, 0]); Mow := CrossProduct(50*vuOB, vW); Mowc := CrossProduct(80*vuOB, Wc*vuBD); MoBA := CrossProduct(80*vuOB, TBA*vuBA); eqrOB := 80 = sqrt(xB^2+yB^2+zB^2); eqrBA := 60 = sqrt((80-xB)^2+(5-yB)^2+(24-zB)^2); eqrBD := d = sqrt(xB^2+yB^2+(100-zB)^2); eqSommeMoy := Mow[2]+Mowc[2]+MoBA[2] = 0; eqSommeMoz := Mow[3]+Mowc[3]+MoBA[3] = 0; fsolve({eqSommeMoz, eqrBD, eqrOB, eqrBA, eqSommeMoy}, {zB, TBA, yB, d, xB}, {xB = -100 .. 100, yB = -100 .. 100, zB = -100 .. 100, d = -100 .. 100, TBA = -10000 .. 10000}) end proc

can someone tell me where I bugged out !!!!

 

Thanks

 

 

 

acer's picture

LinearAlgebra

The calls to CrossProduct do not resolve to LinearAlgebra:-CrossProduct.

I suggest that you replace CrossProduct with LinearAlgebra:-CrossProduct.

You could also use `use`.

For example,

> CalculerH := proc(Mc)
local Wc, W, vuOB, vuBA, vuBD, vW, Mow, Mowc, MoBA, eqrOB, eqrBA, eqrBD,
eqSommeMoy, eqSommeMoz;
    Wc := 9.81*Mc;
    W := 9.81*(0.5 + 0.125);
    vuOB := Vector([xB/80, yB/80, zB/80]);
    vuBA := Vector([4/3 - xB/60, 1/12 - yB/60, 2/5 - zB/60]);
    vuBD := Vector([-xB/d, -yB/d, (100 - zB)/d]);
    vW := Vector([0, -W, 0]);
    Mow := LinearAlgebra:-CrossProduct(50*vuOB, vW);
    Mowc := LinearAlgebra:-CrossProduct(80*vuOB, Wc*vuBD);
    MoBA := LinearAlgebra:-CrossProduct(80*vuOB, TBA*vuBA);
    eqrOB := 80 = sqrt(xB^2 + yB^2 + zB^2);
    eqrBA := 60 = sqrt((80 - xB)^2 + (5 - yB)^2 + (24 - zB)^2);
    eqrBD := d = sqrt(xB^2 + yB^2 + (100 - zB)^2);
    eqSommeMoy := Mow[2] + Mowc[2] + MoBA[2] = 0;
    eqSommeMoz := Mow[3] + Mowc[3] + MoBA[3] = 0;
    fsolve({eqrOB, eqrBA, eqrBD, eqSommeMoy, eqSommeMoz},
        {xB, yB, zB, d, TBA}, {xB = -100 .. 100, yB = -100 .. 100,
        zB = -100 .. 100, d = -100 .. 100, TBA = -10000 .. 10000})
end proc:

> CalculerH(2);
{TBA = 20.64833346, d = 51.53334730, zB = 68.72157058, xB = 40.83550627,
 
    yB = -3.131639188}

Alternatively,

> CalculerH := proc(Mc)
local Wc, W, vuOB, vuBA, vuBD, vW, Mow, Mowc, MoBA, eqrOB, eqrBA, eqrBD,
eqSommeMoy, eqSommeMoz;
    Wc := 9.81*Mc;
    W := 9.81*(0.5 + 0.125);
    vuOB := Vector([xB/80, yB/80, zB/80]);
    vuBA := Vector([4/3 - xB/60, 1/12 - yB/60, 2/5 - zB/60]);
    vuBD := Vector([-xB/d, -yB/d, (100 - zB)/d]);
    vW := Vector([0, -W, 0]);
    use LinearAlgebra in
    Mow := CrossProduct(50*vuOB, vW);
    Mowc := CrossProduct(80*vuOB, Wc*vuBD);
    MoBA := CrossProduct(80*vuOB, TBA*vuBA);
    end use;
    eqrOB := 80 = sqrt(xB^2 + yB^2 + zB^2);
    eqrBA := 60 = sqrt((80 - xB)^2 + (5 - yB)^2 + (24 - zB)^2);
    eqrBD := d = sqrt(xB^2 + yB^2 + (100 - zB)^2);
    eqSommeMoy := Mow[2] + Mowc[2] + MoBA[2] = 0;
    eqSommeMoz := Mow[3] + Mowc[3] + MoBA[3] = 0;
    fsolve({eqrOB, eqrBA, eqrBD, eqSommeMoy, eqSommeMoz},
        {xB, yB, zB, d, TBA}, {xB = -100 .. 100, yB = -100 .. 100,
        zB = -100 .. 100, d = -100 .. 100, TBA = -10000 .. 10000})
end proc:

> CalculerH(2);
{TBA = 20.64833346, d = 51.53334730, xB = 40.83550627, yB = -3.131639188,
 
    zB = 68.72157058}

It is not advised to load LinearAlgebra (outside any such proc definition) and then define a procedure with bare calls like CrossProduct.

acer

Error, (in sqrfree) argument must be a polynomial or a rational

Many Thanks Acer !!!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}