## How to solve a heavily nonlinear system of equatio...

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.

## int method orering. What is it and why it returns ...

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);

 > int(0,x)

 > int(0,x,method=orering)

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

 > int(1,x,method=orering)

 >

## Nested SEQ to simplify textplot3d...

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])

## 3d vector addition with angles ...

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?

3d_vector.mw

## isolve does not return all solutions...

I'm trying to replicate this video: https://www.youtube.com/watch?app=desktop&v=EUVPsxYIauo

Note that the variables a, b, c are integers.

Here is my Maple worksheet:

restart;
eq1 := a*b + c = 2020;
eq1 := a b + c = 2020

eq2 := b*c + a = 2021;
eq2 := b c + a = 2021

sol1 := isolve({eq1, eq2});
sol1 := {a = 2021, b = 0, c = 2020}

However, there is another solution {a = 673, b = 2, c = 674}. Why does isolve not find the second solution? I tried 'allvalues', but it did not work.

## How to perform numerical intergration with a gamma...

Hello all,

I need to perform this numerical integration through maple. Having been a complete beginner I just wanted to ask if at all this is feasible using maple? I have done similar stuff using mathematica, but would like to try and calculate the same using maple, especially with the gamma function in the above equation.

W_{-} := M*sqrt(Pi)/(2*A*a)*(x*erf(a*x) + (1/(a*sqrt(Pi)))*exp(-a^2*x^2)) + (M/(A*a*sqrt(Pi)))*evalf(Int(exp(-epsilon^2/(4*a^2) - tau*epsilon^3)*(cos(epsilon*x) - 1)/epsilon^2, epsilon = 0..infinity)) + (2*m/Pi)*evalf(Int(exp(-tau*epsilon^3)*(cos(epsilon*x) - 1)/epsilon^2, epsilon = 0..infinity)) + (M/(A*a*sqrt(Pi)))*evalf(Int((1/(2*a^2) + 3*tau*epsilon)*exp(-epsilon^2/(4*a^2) - tau*epsilon^3), epsilon = 0..infinity)) - (2*m/Pi)*tau^(1/3)*GAMMA(2/3) -m*x;

W_{+} := M*sqrt(Pi)/(2*A*a)*(x*erf(a*x) + (1/(a*sqrt(Pi)))*exp(-a^2*x^2)) + (M/(A*a*sqrt(Pi)))*evalf(Int(exp(-epsilon^2/(4*a^2) - tau*epsilon^3)*(cos(epsilon*x) - 1)/epsilon^2, epsilon = 0..infinity)) + (2*m/Pi)*evalf(Int(exp(-tau*epsilon^3)*(cos(epsilon*x) - 1)/epsilon^2, epsilon = 0..infinity)) + (M/(A*a*sqrt(Pi)))*evalf(Int((1/(2*a^2) + 3*tau*epsilon)*exp(-epsilon^2/(4*a^2) - tau*epsilon^3), epsilon = 0..infinity)) - (2*m/Pi)*tau^(1/3)*GAMMA(2/3) + m*x;

M := 6.3*10^{17};

t := 7200;

a := 10^3 ;

m := 1;

D := 10^{-5};

Omega := 1.7*10^{23}

tau := 10^{-14}

A := tau/(D*Omega*t);

Any suggestions as how to proceed would be very helpful. Thanks.

EDIT: I would like plot the functions W_{+} and W_{-} as a function of x-axis, with both representing either side of x=0.

EDIT: for some reason I cannot reply to the comments but I have modified the question based on the comments below.

## Browse Matrix: Why is the legend formated this way...

For the legend in the image below I would have expected a black image and not a white

## why save to .m fie do not update variable in file?...

I wanted to keep a running total over a number of independent batch mode Maple scripts.

So I figured I use .m file.

Each run will read the old variable from .m file, update it, and write it again.

All what it need to do is just check if the .m file exist or not to account for the very first run.

But to my surprise, I found the variable content do not update after doing SAVE A,"TMP.m"

It seems Maple sees A variable already in TMP.m and does not save the new value of A again?. Just guessing. I was expecting that after I do  read "TMP.m" that the variable in the file will overwrite same variable value in the local proc.

After one time update, each time I read the variable, its value is same.

First time using save myself, so may be I am doing something wrong but do not see it. I was expecting to see   10,20,30,40,50,..... running total, but I see 10,20,20,20,20,...../

What Am I doing wrong? do I need to make the variable global for this to work?

Here is worksheet. Maple 2024 on windows 10.

 > restart;

 > currentdir("G:/public_html/my_notes/solving_ODE/new_version/tests/"); try  #remove TMP.m first time     FileTools:-Remove("TMP.m"); catch:     NULL; end try; #this function is called many times. foo:=proc()  local A:=0,B;  A:=A+10;  if FileTools:-Exists("TMP.m") then      print("TMP.m exists, will read its content");      B:=A; #save copy      read "TMP.m";      print("Read old value of A from file",A);      A:= A + B; #update running total      print("Now A is ",A," will now save this new value");           save A,"TMP.m";   else      print("TMP.m do not exist, first time saving to it");      save A,"TMP.m";   fi;   print("A=",A); end proc:

 > foo();

 > foo();

 > foo();

 > foo();

 > foo();

 >

## Moving tangent portion between 2 fixed tangents on...

How to show that the angle QF2P remains constant when M moves on the ellipse ? Perhaps with Explore ?
restart;
with(plots);
with(geometry);
_EnvHorizontalName := 'x';
_EnvVerticalName := 'y';
x0 := 100;
y0 := 40;
a := 7;
b := 5;
c := sqrt(a^2 - b^2);
ellipse(el, x^2/a^2 + y^2/b^2 - 1);
point(F1, -c, 0);
point(F2, c, 0);
eq := simplify((a^2 - x0^2)*(y - y0)^2 + (b^2 - y0^2)*(x - x0)^2 + 2*x0*y0*(x - x0)*(y - y0)) = 0;
sol := solve({eq}, {y});
line(tang1, op(sol[1]));
line(tang2, op(sol[2]));
sol2 := op(solve({op(sol[1]), x^2/a^2 + y^2/b^2 - 1 = 0}, {x, y}));
xM2 := rhs(sol2[1]);
yM2 := rhs(sol2[2]);
point(A, xM2, yM2);
sol3 := op(solve({op(sol[2]), x^2/a^2 + y^2/b^2 - 1 = 0}, {x, y}));
xM3 := rhs(sol3[1]);
yM3 := rhs(sol3[2]);
point(B, xM3, yM3);
line(Pol, [A, B]);
simplify(Equation(Pol));
isolate(%, y);
xM := 4;
sol := solve({subs(x = xM, x^2/a^2 + y^2/b^2 - 1 = 0)}, {y});
yM := rhs(op(sol[1]));
point(M, xM, yM);
line(Tang, x*xM/a^2 + y*yM/b^2 - 1 = 0);
intersection(P, tang1, Tang);
intersection(Q, tang2, Tang);
line(PF2, [P, F2]);
line(QF2, [Q, F2]);
alpha := FindAngle(PF2, QF2);
arctan(alpha);
evalf(%);
display(textplot([[-c, 0, "F1"], [c, 0, "F2"], [coordinates(B)[], "B"], [coordinates(A)[], "A "], [coordinates(M)[], "M "], [coordinates(P)[], "P "], [coordinates(Q)[], "Q "]], align = {"above", 'right'}), draw([el(color = red), A(color = black, symbol = solidcircle, symbolsize = 16), PF2(color = brown), QF2(color = brown), B(color = black, symbol = solidcircle, symbolsize = 16), M(color = black, symbol = solidcircle, symbolsize = 16), P(color = black, symbol = solidcircle, symbolsize = 16), tang1(color = green), tang2(color = green), Tang(color = green), F1(color = blue, symbol = solidcircle, symbolsize = 16), Q(color = blue, symbol = solidcircle, symbolsize = 16), F2(color = red, symbol = solidcircle, symbolsize = 16)]), axes = none, view = [-7 .. 15, -7 .. 12]);

## Latex command fails in command line in Maple 2024...

Just found very serious problem.

Was trying my code in command line maple (cmaple.exe) only to find latex() command fails now.

Same code works with no problem in worksheet.  Here is first the worksheet version.

 > restart;

 > interface(version);

 > ode:=diff(y(x),x)=x; try     s:=latex(ode,'output'=string):     print("Latex command worked on ode"); catch:     error lastexception; end try: the_output:=Student:-ODEs:-ODESteps(ode,y(x)): try     s:=latex(the_output,'output'=string):     print("Latex command worked"); catch:     error lastexception; end try:

 >

Now I do same thing but from command line. I put the above code in A.mpl file in some folder on windows:

ode:=diff(y(x),x)=x;
try
s:=latex(ode,'output'=string):
print("Latex command worked on ode");
catch:
error lastexception;
end try:

the_output:=Student:-ODEs:-ODESteps(ode,y(x)):
try
s:=latex(the_output,'output'=string):
print("Latex command worked");
catch:
error lastexception;
end try:

Then opened a command windows terminal and cd to the above folder and typed this command

"C:\Program Files\Maple 2024\bin.X86_64_WINDOWS\cmaple.exe"  -q A.mpl

And this is what happens. Latex works OK on generating latex for the ode, but not for the steps!It gives error

Error, latex, invalid input: %1 uses a %-2 argument, %3 (of type %4), which is missing, latex:-ModuleApply, 1, e, anything

Also I was not able to suppress the display of the odesteps on the terminal even though they do not display in worksheet, they still print in the terminal. But this is a side issue.

Why does Latex gives error in command line?

I think it is related to those funny looking characters (bullets?) signs at the start of each ODE step that show in the terminal?

But in worksheet latex has no problem converting the ODE steps to Latex. It is only in cmaple.

Is there a way to correct this? It seems to be some character encoding is causing the problem for Latex on command line vs. worksheet.

Windows 10, Maple 2024

## How does Maple solve, int(y'(x)*f(x), x) =[int(sqr...

'odeadvisor' suggests isolating y(x) from the equation as a first step, y=G(x,y'(x)), then apply the method of 'patterns'. For the first step, y(x) = (9/4)*[(y'(x))^2]/{[int(f(x),x)]^5} is what I found but, could take it no further. Nevertheless, Maple finds an intrinsic solution of the form, (3/4)*y(x)^(4/3) +(2/3)*int(sqrt(y(x)*f(x))^(-5/3) + _C1 =0, from which an explicit solution can be obtained. If anyone can supply the steps leading to the Maple solution - that would be great.

## Third party Package wkptest & ONEOptimal...

Dear all
If you have the following two maple package, kindly share it with me.
wkptest: For the symbolic computation of Painleve test for nonlinear PDEs.
ONEOptimal:-  Maple Package for obtaining Optimal System

Debendra

## How to fix 'Illegal use of a formal parameter' err...

Hello. I am trying to create a procedure that calculates the properties of a triangle (such as the sides, angles, area, and centroid) and then plots it. However, when I try to run my code, I keep getting the error:

Runtime error: Error, (in triangle) illegal use of a formal parameter

Here is the code I am using:

triangle := proc({a::numeric := 0, b::numeric := 0, c::numeric := 0, AngleA::numeric := 0, AngleB::numeric := 0, AngleC::numeric := 0})
local A, B, C, T, Tr, DegreeA, DegreeB, DegreeC, TA, TB, TC, Area, Centroid, AreaLabel, deg, rad;
uses geometry, plots;

# Function to convert degrees to radians
rad := proc(deg) evalf(deg * Pi / 180) end proc;

# Function to convert radians to degrees

# Temporary variables for calculations
local a_calc, b_calc, c_calc, AngleA_calc, AngleB_calc, AngleC_calc;

a_calc := a;
b_calc := b;
c_calc := c;
AngleA_calc := AngleA;
AngleB_calc := AngleB;
AngleC_calc := AngleC;

# Calculate missing sides or angles
if a_calc = 0 then
if AngleA_calc <> 0 and AngleB_calc <> 0 then
elif AngleA_calc <> 0 and AngleC_calc <> 0 then
end if;
elif b_calc = 0 then
if AngleB_calc <> 0 and AngleA_calc <> 0 then
elif AngleB_calc <> 0 and AngleC_calc <> 0 then
end if;
elif c_calc = 0 then
if AngleC_calc <> 0 and AngleA_calc <> 0 then
elif AngleC_calc <> 0 and AngleB_calc <> 0 then
end if;
end if;

if AngleA_calc = 0 then
AngleA_calc := deg(arccos((b_calc^2 + c_calc^2 - a_calc^2) / (2 * b_calc * c_calc)));
end if;
if AngleB_calc = 0 then
AngleB_calc := deg(arccos((a_calc^2 + c_calc^2 - b_calc^2) / (2 * a_calc * c_calc)));
end if;
if AngleC_calc = 0 then
AngleC_calc := 180 - AngleA_calc - AngleB_calc;
end if;

# Convert angles to radians for calculation

# Define points A, B, and C
geometry:-point(A, 0, 0);
geometry:-point(B, c_calc, 0);
geometry:-point(C, b_calc * cos(AngleA), b_calc * sin(AngleA));

# Calculate the area using Heron's formula
s := (a_calc + b_calc + c_calc) / 2;
Area := sqrt(s * (s - a_calc) * (s - b_calc) * (s - c_calc));
Area := evalf(Area, 4);

# Calculate the centroid of the triangle
Centroid := [(0 + c_calc + b_calc * cos(AngleA)) / 3, (0 + 0 + b_calc * sin(AngleA)) / 3];

# Text plot for side labels
T := plots:-textplot([[1/2 * c_calc, 0, cat("c = ", c_calc), align = below],
[1/2 * c_calc + 1/2 * b_calc * cos(AngleA) + 1/30 * a_calc, 1/2 * b_calc * sin(AngleA), cat("a = ", a_calc), align = right],
[1/2 * b_calc * cos(AngleA) - 1/30 * a_calc, 1/2 * b_calc * sin(AngleA), cat("b = ", b_calc), align = left]]);

# Text plot for angle labels with valid alignment options
TA := plots:-textplot([0, 0, cat(evalf(deg(AngleA)), "°"), align = right]);
TB := plots:-textplot([c_calc, 0, cat(evalf(deg(AngleB)), "°"), align = left]);
TC := plots:-textplot([b_calc * cos(AngleA), b_calc * sin(AngleA), cat(evalf(deg(AngleC)), "°"), align = above]);

# Text plot for the area of the triangle
AreaLabel := plots:-textplot([Centroid[1], Centroid[2], cat("Area= ", Area), align = above]);

# Display the triangle with labels
plots:-display([geometry:-draw([geometry:-triangle(Tr, [A, B, C])],
font = [times, roman, 18], labels = [x, y], axes = none, printtext = true), T, TA, TB, TC, AreaLabel]);
end proc:

What am I doing wrong, and how can I fix this error? Thanks!