C_R

3412 Reputation

21 Badges

5 years, 312 days

MaplePrimes Activity


These are answers submitted by C_R

Works for sums

2*A*B/(A*m+m)+C^2+D^2;

convert([op(%)],Vector);
expand~(numer~(%)/A);
collect((x->1/x)~(expand~(denom~(%%)/A)),m);
(%.%%)assuming real;

By coincidence, I found what you were looking for in the layout palette.

Simply select whatever is selectable with the mouse and click on one of the layout brakets.

Your can make them your favorites for easier access as I have done here

Carl Love has provided an answer for a=b=c=d here.

inrt := `%*`(a*b);
inrt2 := subs(a = `%*`(2*Unit('m')), b = `%*`(3*Unit('m')), inrt);
MultiEquation(((A = inrt) = inrt2) = value(inrt2));

I could not find a way to remove the brackets in the output

We get closer (still one pair of brackets left) to what you are looking for by modifing an answer from acer (same link above)

p := proc(A,B,C,CC) # modified a=b=c proc form acer
  uses Typesetting;
  mrow(Typeset(A),mo("="),
       Typeset(B),mo("="),
       Typeset(C),mo("="),
       Typeset(CC));
end proc:

ee := p(a,b,c,d);

Typesetting:-mrow(Typesetting:-mi("a"), Typesetting:-mo("="), Typesetting:-mi("b"), Typesetting:-mo("="), Typesetting:-mi("c"), Typesetting:-mo("="), Typesetting:-mi("d"))

(1)

ee;

a = b and b = c and c = d

(2)

inrt := `%*`(a*b);
inrt2 := subs(a = `%*`(2*Unit('m')), b = `%*`(3*Unit('m')), inrt);

`%*`(a*b)

 

`%*`(`%*`(2*Units:-Unit(m))*`%*`(3*Units:-Unit(m)))

(3)

p(A,inrt,inrt2,value(inrt2))

0, "%1 is not a command in the %2 package", _Hold, Typesetting

(4)

NULL

Maybe someone has an idea how to remove the brackets.

I cannot see a way to write from the above a proc with only one parameter. A, a and b must somehow be given. Or at least a and b if A is fixed.

Download abc_modif.mw

@Carl Love 

Your explantion makes sense: only curved arrows are affeted (curve and comet).  Each time either the head or the tail of a curve extends into the complex domain an error is thrown (the curves midpoints are centered on the grid).

Algorithmwise I see only two simple options. Clipping of the curves or suppression of arrows in case of boundary extension. The later case is implemented and works for straight arrows and for curved arrows if the inital point for arrow calculation matches the singularity.

For curved boundaries (or boundaries not parallel to the axes) clipping of arrows might be better looking since the plot will stay complete and the boundary of the domain can be better guessed and is not jagged. Or the opposite ... we have to see how it looks like

A slight reduction of the plotrange helps in this case without changing the grid and the labels.

restart;
ode:=diff(y(x),x)-1/(-x^2+1)^(1/2) = 0;
x_range:=-0.98 .. 0.98;
DEtools:-DEplot(ode,y(x),x =x_range,y = -1.6 .. 1.6,[y(0) = 0],arrows = 'curve')

Or a larger range and clipping the view

restart;
ode := diff(y(x), x) - 1/(-x^2 + 1)^(1/2) = 0;
x_range := -1.1 .. 1.1;
DEtools:-DEplot(ode, y(x), x = x_range, y = -1.6 .. 1.6, [y(0) = 0], arrows = 'curve', iterations = 1, view = [-1 .. 1, -1.6 .. 1.6]);

This is only works for odes with simple singularities on the x-axis.

By the way: dfieldplot (probably used by DEplot) throws the same error

restart;
ode := diff(y(x), x) - 1/(-x^2 + 1)^(1/2) = 0;
x_range := -0.99 .. 0.99;
DEtools:-dfieldplot(ode, y(x), x = x_range, y = -1.6 .. 1.6, [y(0) = 0], arrows = 'curve');

Entering solve with 6 equations in 3 variables:

     This can be explained by solve interpreting the assumptions on the variables lambda as 3 new equations.
     These assumptions alone trigger the Solutions lost message.

There a quite some assumptions in the document. I feel a bit uneasy about which assumptions solve uses when called with useassumptions.

I also feel a bit uneasy about the indexed subscripts because of typos that may not be visible.

I have to stop here but attach my attempts. Maybe this gives you some ideas.

061123_solving_with_assumptions-1_reply.mw

To add the example in your own worksheet, place the cursor where you want to add the task.

Then goto the task an insert the content and replace the integrand and boundaries by yours if you want

 

See the attached. Is that what you are looking for?

task_example.mw

If you mean by coordinat node the points where the three curves intersect

you can can define a procedure and use fsolve. Here is a code snippet for one point that you can paste at the end of you worksheet and see how ist works

dd:=proc(tt) 
    rhs(Solusi5(tt)[2])- rhs(Solusi5(tt)[3])
end;
A5x:=fsolve(dd,0..5);
A5y:=rhs(Solusi5(A5x)[2]);
plots:-pointplot([[A5x,A5y]]);
display(PlotA5, PlotI5, PlotS5,%)

Try
 

with(Statistics):
L1 := [2, 4, 6]:
ColumnGraph(L1, axis[1] = [tickmarks = [[0.4 = "abe", 1.4 = "banan", 2.4 = "palme"], rotation = Pi/2]]);

 

Your general solution Sol1 should also simplify to an expression with signum(xc1-xc2) without the need to restrict the domain to real

sqrt((xc1 - xc2)^2)/(xc1 - xc2);
simplify(%);
                                    (1/2)
                      /           2\     
                      \(xc1 - xc2) /     
                      -------------------
                           xc1 - xc2     

                       signum(xc1 - xc2)
                      

Perhaps the radical is too complex and Maple overlooks this simplifcation or there is no simplification possible in the complex domain (for a reason I can't see at the moment).

Anyway, your substitution is equivalent to the assumption xc1 > xc2. You could use
 

simplify~(solve({eq1, eq2}, [x, y], explicit), radical) assuming (xc2 < xc1)

to avoid a call to realdomain and the substitution step. It's just a little bit neater.

 

Edit:

No simplification to an expression with signum possible in the complex domain without assumptions because the expression bellow is in general not zero

 

To change a style, navigate to style under format and modify 2d input this way



See https://www.maplesoft.com/support/help/maple/view.aspx?path=worksheet%2Fdocumenting%2Fstyles

to make it permanet for all worksheets

Without the model it is difficult to help.

In general:

What you have to do is to constrain the end effector position using parameters. There are several ways to do this.

https://fr.maplesoft.com/products/maplesim/modelgallery/detail.aspx?id=38

for example constrains the position a radar points to.

There are videos describing the whole process. Here is one

https://www.youtube.com/watch?v=7IKFqRkKqI0

Once constrained, MapelSim can generate and export algebraic constraints that you need to calulate the inverse kinematics.

The tricky part is to preserve the pulley coordinates in the algebraic constraints. For that you might find the following helpfull

https://www.mapleprimes.com/posts/217390-Equation-Extraction-For-Kinematics

Attached you will find a way in Maple. Since the problem is nonlinear there can be more minima (local or global). That's most likely the reason why the result from Maple and Mathcad do not agree in a first attempt.

NLPsolve (and the Optimization package in general) has a bunch of options Minerr in a solve block does not seem to have. If you want to reproduce whatever Minerr does you have to go through all the options and their combinations. I would start with methods first.

 

 

restart

H := Vector(9, {(1) = 210.84, (2) = 218.19, (3) = 219.17, (4) = 222.27, (5) = 226.35, (6) = 228.45, (7) = 230.44, (8) = 234.65, (9) = 239.75})

Vector[column](%id = 36893491118738273692)

(1)

Q := Vector(9, {(1) = 1800, (2) = 1750, (3) = 1730, (4) = 1700, (5) = 1650, (6) = 1635, (7) = 1600, (8) = 1570, (9) = 1500})

Vector[column](%id = 36893491118738263564)

(2)

A := 330.156

330.156

(3)

In Mathcad I used solve by using a solve block:

 

 

But what is the most efficient way to do this in Maple?

 

NULL

Supposing

Q^2in Mathcad is equivalent to `~`[`*`](Q, Q) in Maple

NULL

And in the same way

could be written using element wise operators

H = A*`~`[`-`](1, Q/Q0)-`~`[`*`](kf*Q, Q)-`~`[`*`](kl*`~`[`-`](Q, Qs), `~`[`-`](Q, Qs))

Vector[column](%id = 36893491118738273692) = Vector[column](%id = 36893491118738251396)

(4)

"res_v:=(lhs-rhs)(?);#` vector of residuals`"

Vector[column](%id = 36893491118738227316)

(5)

initial_points := {Q0 = 6413, Qs = 1416, kf = 10^(-5), kl = 10^(-5)}

{Q0 = 6413, Qs = 1416, kf = 1/100000, kl = 1/100000}

(6)

with(Optimization)

[ImportMPS, Interactive, LPSolve, LSSolve, Maximize, Minimize, NLPSolve, QPSolve]

(7)

res_l := convert(res_v, list)

[-119.316+594280.800/Q0+3240000*kf+kl*(1800-Qs)^2, -111.966+577773.000/Q0+3062500*kf+kl*(1750-Qs)^2, -110.986+571169.880/Q0+2992900*kf+kl*(1730-Qs)^2, -107.886+561265.200/Q0+2890000*kf+kl*(1700-Qs)^2, -103.806+544757.400/Q0+2722500*kf+kl*(1650-Qs)^2, -101.706+539805.060/Q0+2673225*kf+kl*(1635-Qs)^2, -99.716+528249.600/Q0+2560000*kf+kl*(1600-Qs)^2, -95.506+518344.920/Q0+2464900*kf+kl*(1570-Qs)^2, -90.406+495234.000/Q0+2250000*kf+kl*(1500-Qs)^2]

(8)

LSSolve(res_l, initial_points)

[378.523243101364528, [Q0 = HFloat(6413.0), Qs = HFloat(1416.0), kf = HFloat(9.99999999995449e-6), kl = HFloat(9.99999999995449e-6)]]

(9)

Same as initial points  

NLPSolve(add(map(`^`, res_l, 2)), initialpoint = initial_points)

[3.80383862075732582, [Q0 = HFloat(6411.783489433508), Qs = HFloat(1431.553974929293), kf = HFloat(5.797829593736934e-6), kl = HFloat(5.21635358612149e-5)]]

(10)

NULL

NLPSolve does not give Minerr output as I would have expected from the description
https://support.ptc.com/help/mathcad/r9.0/en/PTC_Mathcad_Help/example_using_minerr_for_nonlinear_least_squares_fitting.html

 

 

Download SolveBlockQuestion-reply.mw

 

For comparision:
The best I could do with substitutions. What makes it tricky is the coefficient R1*R2 of s.

I spare out the sorting detail since its already twice as long as acers solution.

V = V1*R2/(C*R1*R2*s+R1+R2)

V = V1*R2/(C*R1*R2*s+R1+R2)

(1)

R1*R2 = R12

R2*R1 = R12

(2)

RS = R1+R2

RS = R1+R2

(3)

algsubs(RS = R1+R2, algsubs(R1*R2 = R12, V = V1*R2/(C*R1*R2*s+R1+R2)))

V = V1*R2/(C*R12*s+RS)

(4)

(`@`(numer, rhs))(V = V1*R2/(C*R12*s+RS))/RS

V1*R2/RS

(5)

expand((`@`(denom, rhs))(V = V1*R2/(C*R12*s+RS))/RS)

C*s*R12/RS+1

(6)

V = V1*R2/(RS*(C*s*R12/RS+1))

V = V1*R2/(RS*(C*s*R12/RS+1))

(7)

subs(RS = R1+R2, isolate(R1*R2 = R12, R12), V = V1*R2/(RS*(C*s*R12/RS+1)))

V = V1*R2/((R1+R2)*(C*s*R2*R1/(R1+R2)+1))

(8)

NULL

Download subsway.mw

Your parameters still do not match. In the following I have tried to show how the substitution should be done and what needs to be changed.

NULLOriginal expression

((D@@2)(theta))(eta) = -(-D[t]*epsilon*(-gamma+beta)*(D(theta))(eta)+beta*(D[B]*epsilon*(mu-lambda)*(D(phi))(eta)+(1/2)*nu*(f(eta)*sin(alpha)+eta*cos(alpha))))*(D(theta))(eta)/(beta*sigma)

((D@@2)(theta))(eta) = -(-D[t]*epsilon*(-gamma+beta)*(D(theta))(eta)+beta*(D[B]*epsilon*(mu-lambda)*(D(phi))(eta)+(1/2)*nu*(f(eta)*sin(alpha)+eta*cos(alpha))))*(D(theta))(eta)/(beta*sigma)

(1)

with the following indeterminates

indets(((D@@2)(theta))(eta) = -(-D[t]*epsilon*(-gamma+beta)*(D(theta))(eta)+beta*(D[B]*epsilon*(mu-lambda)*(D(phi))(eta)+(1/2)*nu*(f(eta)*sin(alpha)+eta*cos(alpha))))*(D(theta))(eta)/(beta*sigma))

{alpha, beta, epsilon, eta, lambda, mu, nu, sigma, D[B], D[t], cos(alpha), f(eta), sin(alpha), (D(phi))(eta), (D(theta))(eta), ((D@@2)(theta))(eta)}

(2)

Expressions to substitute (in the form of an equation. Do not use the assignment operator :=     )

Pr = nu/sigma

Pr = nu/sigma

(3)

Isolate an indeterminate you want to replace

isolate(Pr = nu/sigma, sigma)

sigma = nu/Pr

(4)

Substitute it into (1)

subs(sigma = nu/Pr, ((D@@2)(theta))(eta) = -(-D[t]*epsilon*(-gamma+beta)*(D(theta))(eta)+beta*(D[B]*epsilon*(mu-lambda)*(D(phi))(eta)+(1/2)*nu*(f(eta)*sin(alpha)+eta*cos(alpha))))*(D(theta))(eta)/(beta*sigma))

((D@@2)(theta))(eta) = -(-D[t]*epsilon*(-gamma+beta)*(D(theta))(eta)+beta*(D[B]*epsilon*(mu-lambda)*(D(phi))(eta)+(1/2)*nu*(f(eta)*sin(alpha)+eta*cos(alpha))))*(D(theta))(eta)*Pr/(beta*nu)

(5)

Now you have Pr appearing which gets you closer to the result you are looking for.

Similarly you have to proceed for the other parameters with  the goal to remove all indeterminates you do not wantfrom your original expression . To get an overview what indeterminates are used in a expression use the indets command.

For your target expression

((D@@2)(theta))(eta) = -(1/2)*Pr*(D(theta))(eta)*eta*cos(alpha)-(1/2)*Pr*(D(theta))(eta)*sin(alpha)*f(eta)-N[b]*(D(theta))(eta)*(D(phi))(eta)-N[t]*(D(theta))(eta)

((D@@2)(theta))(eta) = -(1/2)*Pr*(D(theta))(eta)*eta*cos(alpha)-(1/2)*Pr*(D(theta))(eta)*sin(alpha)*f(eta)-N[b]*(D(theta))(eta)*(D(phi))(eta)-N[t]*(D(theta))(eta)

(6)

you get

indets(((D@@2)(theta))(eta) = -(1/2)*Pr*(D(theta))(eta)*eta*cos(alpha)-(1/2)*Pr*(D(theta))(eta)*sin(alpha)*f(eta)-N[b]*(D(theta))(eta)*(D(phi))(eta)-N[t]*(D(theta))(eta))

{Pr, alpha, eta, N[b], N[t], cos(alpha), f(eta), sin(alpha), (D(phi))(eta), (D(theta))(eta), ((D@@2)(theta))(eta)}

(7)

You can compare which indeterminates are used in the original and the target to determine what has to be removed from the original

`minus`({alpha, beta, epsilon, eta, lambda, mu, nu, sigma, D[B], D[t], cos(alpha), f(eta), sin(alpha), (D(phi))(eta), (D(theta))(eta), ((D@@2)(theta))(eta)}, {Pr, alpha, eta, N[b], N[t], cos(alpha), f(eta), sin(alpha), (D(phi))(eta), (D(theta))(eta), ((D@@2)(theta))(eta)})

{beta, epsilon, lambda, mu, nu, sigma, D[B], D[t]}

(8)

The indeterminates above have to be removed from the original and(!) these ones should appear in the target

`minus`({Pr, alpha, eta, N[b], N[t], cos(alpha), f(eta), sin(alpha), (D(phi))(eta), (D(theta))(eta), ((D@@2)(theta))(eta)}, {alpha, beta, epsilon, eta, lambda, mu, nu, sigma, D[B], D[t], cos(alpha), f(eta), sin(alpha), (D(phi))(eta), (D(theta))(eta), ((D@@2)(theta))(eta)})

{Pr, N[b], N[t]}

(9)

You have to do this with additional relations, which are your parameter expressions.

Pr = nu/sigma, N[b] = epsilon*D[B](mu-lambda)/sigma, N[t] = epsilon*D[t](gamma-beta)/(gamma*sigma), Le = nu/D[B]

Pr = nu/sigma, N[b] = epsilon*(D[B](mu)-D[B](lambda))/sigma, N[t] = epsilon*(D[t](gamma)-D[t](beta))/(gamma*sigma), Le = nu/D[B]

(10)

indets({Le = nu/D[B], Pr = nu/sigma, N[b] = epsilon*(D[B](mu)-D[B](lambda))/sigma, N[t] = epsilon*(D[t](gamma)-D[t](beta))/(gamma*sigma)})

{Le, Pr, beta, epsilon, lambda, mu, nu, sigma, D[B], N[b], N[t], D[B](lambda), D[B](mu), D[t](beta)}

(11)

{Le, Pr, beta, lambda, mu, nu, sigma, `&epsilon;`, D[B], N[b], N[t], D[B](lambda), D[B](mu), D[t](beta)}and D[t](gamma)

The parameters highlighted in red are neither in the original nor in the target. Substituting your parameter expressions (somehow rearranged -> see isolate above) in the original will introduce them in to the result.
That is what I called mismatch.

NULL

Further observations:

• 

Make clear whether the D in D[B](lambda), D[B](mu), D[t](beta), D[t](gamma) is meant to be the differential operator  or used to name variables or parameters.

• 

If the subscripts in D[B](lambda), D[B](mu), D[t](beta), D[t](gamma)are meant to be subscripts and not elements of an indexed object rather use two under scores __ to enter the subscript.

• 

gamma (i.e. gamma) in D[t](gamma)is a constant in Maple that evaluates to a number. It is dangerous to use it as a name.

NULL

Download parameter_mismatch.mw

First 8 9 10 11 12 13 14 Page 10 of 17