C_R

3412 Reputation

21 Badges

5 years, 314 days

MaplePrimes Activity


These are replies submitted by C_R

@tomleslie 

Actually, I was looking for an identity operator. A command that repeats an expression without further manipulation. I would have searched differently if I had guessed the appropriate search term “identity” in Acers response beforehand. Eval (in this may be too simplified example) was the first command that worked to illustrate a use case.

Instead of a better requirement I can at least give some motivating background:  

By personal preference I try to avoid the assignment operator wherever possible. This is mainly for better readability of Maple Documents for non Maple users. An equation is easier to understand than several lines of code. So, if it was only for the output in my example the input (1)=value((1)) would have been equally compact. What I like about the ()() construct is that it separates commands grouped in the first pair of parathesis from the expression in the second pair of parenthesis. Reuse of such a construct on other expressions is easier: Only one instance of the expression must be exchanged.  As in this example:

NULL

-(2*(x^3+2))/(x*(x+1)*(I*sqrt(3)+2*x-1)*(I*sqrt(3)-2*x+1))

-2*(x^3+2)/(x*(x+1)*(I*3^(1/2)+2*x-1)*(I*3^(1/2)-2*x+1))

(1)

Three instances of (1)

-2*(x^3+2)/(x*(x+1)*(I*3^(1/2)+2*x-1)*(I*3^(1/2)-2*x+1)) = simplify(expand(numer(-2*(x^3+2)/(x*(x+1)*(I*3^(1/2)+2*x-1)*(I*3^(1/2)-2*x+1))))/expand(denom(-2*(x^3+2)/(x*(x+1)*(I*3^(1/2)+2*x-1)*(I*3^(1/2)-2*x+1)))))

-2*(x^3+2)/(x*(x+1)*(I*3^(1/2)+2*x-1)*(I*3^(1/2)-2*x+1)) = (x^3+2)/(2*x^4+2*x)

(2)

One instance of (1)

` `

(3)

((proc (x) options operator, arrow; x end proc) = `@`(simplify, (`@`(expand, numer))/(`@`(expand, denom))))(-2*(x^3+2)/(x*(x+1)*(I*3^(1/2)+2*x-1)*(I*3^(1/2)-2*x+1)))

-2*(x^3+2)/(x*(x+1)*(I*3^(1/2)+2*x-1)*(I*3^(1/2)-2*x+1)) = (x^3+2)/(2*x^4+2*x)

(4)

Function to display equality of an expression to the simplified version of the expression (without the need to involve proc statement).

simplify_expanded := proc (x) options operator, arrow; ((proc (x) options operator, arrow; x end proc) = `@`(simplify, (`@`(expand, numer))/(`@`(expand, denom))))(x) end proc

proc (x) options operator, arrow; ((proc (x) options operator, arrow; x end proc) = `@`(simplify, (`@`(expand, numer))/(`@`(expand, denom))))(x) end proc

(5)

simplify_expanded(-2*(x^3+2)/(x*(x+1)*(I*3^(1/2)+2*x-1)*(I*3^(1/2)-2*x+1)))

-2*(x^3+2)/(x*(x+1)*(I*3^(1/2)+2*x-1)*(I*3^(1/2)-2*x+1)) = (x^3+2)/(2*x^4+2*x)

(6)

NULL

Download simplify_expanded.mw

@acer Thank you very much for the detailed explanations. Very much appreciated!

@acer I remembered that there is this handwriting pallet

However, the output is not so nice as yours since it puts brackets arround the left and right hand side (see attached). Can these brackets be removed?

Your solution surprised me because it contains a comment symbol (#) and a statement separator (;) a within left quotes. The pallet symbol I found uses a neutral operator (&). It is not clear to me what they exactly do. Is there a help page explaining the function of such characters within left single quotes?  

Thank you!

mover_ex_with_palett.mw

(updated comment)

…I did not know (and was looking for years)! Very interesting solutions without decomposing and reassembling of expressions, which is error prone and not elegant.
Also good: no assumptions required.
Not so good: Intuitively I would not have looked for an expansion option to make an expression shorter. As in the example, I would have tried (and abandoned) it the same way.

Two questions remain:

Why can’t simplify/size shorten such expressions?

And to make the numer/denom operation dispensable: Why does expand only work on polynomials but not on ratios of polynomials?

I think there is potential for improvement.

@ousshajjaj You got feedback form an expert!

I would be interested to see your finshed model here.

One hint on the Stuart platform: if you want to inspect the full model in 3d worksspace you have to disable the visualisation components in the Subsystem Leg. Otherwise you will only see only leg. With one leg the modeling approach is less obvious.

With the approach from Orang you probably don't need to consult the 3d workspace. With my proposal you most likely have to.

Good look with your project!

Key to solve your problem will be the creation of 3d assemblies for the elements “couland” and “noix” in your drawing. These elements will define the 8 kinematic loops (!) of your problem.

Thinking about this I have no idea how this can be done best. This would be the perfect moment for an experienced user or MapleSim support to jump in with some advice.

Or, maybe someone knows a model in the model gallery where you can learn from. Straight away I can only suggest the Stewart platform https://de.maplesoft.com/products/maplesim/modelgallery/detail.aspx?id=34

This example does not use 3d assemblies as I have proposed above. The orientation of the legs is done implicitly withinin the legs. This is an extremely smart and efficient way of doing it but requires expert knowledge and allot of experience.  That’s why I was proposing an engineering approach using 3d subassemblies (of ridig body frames).

Please take my advice as an educated guess from someone how has been in the same situation looking for training material on building 3d assemblies (planar is simple) or some general good practice on building 3d assemblies (or at least things you should not do). I hope my approach is a not a "solution looking for problems".

So again: Can someone come up with some better advice?

you might have access to the Dynamic System Package. The package provides commands and plot options which are of particular interest for engineers.

Try: help("DynamicSystems")

Alternatively, you might consult help pages designed for scientist and engineers for examples.

https://de.maplesoft.com/support/help/category.aspx?cid=892

@acer found a way “forcing” Maple to produce one of the exact expressions proposed by @Christian Wolinski.

With that knowledge at hand, I reinvestigated my initial attempts of defining assumptions to compute the inverse. I finally found two ways to do so (see attached). Without the knowledge that exact solutions exist and that Maple has all it needs on board I would have abandoned with the wrong conclusion off Maple being incapable.  

Summing up all the efforts, I ask myself how Maple can help other users having the right intuition finding the corresponding command with less effort.

No compromises needed any more. Thank you again!

inverse_function_with_fsolve_and_assumptions.mw

@acer  Good to know that plot can deal with 0.*I, which I have learned now is an important design feature.

Therefore, the not responding plot command that I observed in some instances is probably related to evaluation efficiency of the integral and its inverse (or equivalent expressions).

Thank you for indicating how expressions using Maple functions can be derived from the integral. I will comment on that in the other post.

@Thomas Richard 
Your hint (?fnormal) is in line with a solution I got from another user: i.e. limiting the digits of the numeric evaluation of an integral.

Limiting digits most likely removed such terms.

I can see now fsolve having to deal with information on directions pointing away from the real valued solution...

Thanks for the quick clarification!

@Christian Wolinski This completes my picture. 

All your expressions are better than evaluation of the integral within fsolve (which I still think should work).

Your first expression is still the best in terms of a) computation efficiency and b) no restrictions on the search interval. I am using a squared form which removes the s shape of the function in the search interval.

g := alpha -> fsolve(alpha = EllipticF(sqrt(sin(x__0))/sqrt(sin(x__0) + 1), sqrt(-sin(x__0)^2 + 1)*I/(sin(x__0) - 1))^2/(1 - sin(x__0)),x__0)

In the meantime I have found another simple looking expression with the help of Maples Functionadvisor. Pretty cool (the advisor).

Int(1/sqrt(sin(x0) - sin(x)), x = 0 .. x0) = sqrt(2)*InverseJacobiCN(cos(x0)/(sin(x0) + 1), sqrt(2)*sqrt(sin(x0) + 1)/2).

Thanks again! Without your help I would have to live with numerical compromises.

@Carl Love
It works fine now

I can even access the output component wise! If it was for a Maple functionality I would suggest an access via indices where each index corresponds to either an operand or an operator (i.e. 1..9 for the example above). 

However, for the moment I am fine with the solutions as they are. Thank you all!

@Carl Love. I tried it but the output still contains the unwanted parenthesis.

Apart from that I like the extension to more than 3 operators and the inclusion of other operator types.

If I could later on refer in an easy way to components of the output, this would be perfect.
I vote up since it is close to a solution that I consider worth implementing in Maple.

Multiequation.mw

@acer  Thank you for your very detailed answer!

I have attached an example how I would use your solution 1). The input is hidden.

In case someone from MapleSoft reads this: Please take the attachment as a suggestion to improve Maple in the field of

- professional looking documents

- integration (computing the inverse with fsolve, simplifying integrals to expressions containing Maple functions)

From the following expression x__0 as a function of alpha has to be derived

2*sqrt(alpha) = int(1/sqrt(sin(x__0)-sin(x)), x = 0 .. x__0)

2*alpha^(1/2) = int(1/(sin(x__0)-sin(x))^(1/2), x = 0 .. x__0)

(1)

Using fsolve on the expression required manipulation of the precision the integral is evaluated to. However knowing
from @Christian Wolinski that

EF := 2*EllipticF(sqrt(sin(x__0))/sqrt(sin(x__0)+1), I*sqrt(-sin(x__0)^2+1)/(-1+sin(x__0)))/sqrt(1-sin(x__0))

p := proc (A, B, C) Typesetting:-mrow(Typesetting:-Typeset(A), Typesetting:-mo("="), Typesetting:-Typeset(B), Typesetting:-mo("="), Typesetting:-Typeset(C)) end proc

ff := p(lhs(2*alpha^(1/2) = int(1/(sin(x__0)-sin(x))^(1/2), x = 0 .. x__0)), rhs(2*alpha^(1/2) = int(1/(sin(x__0)-sin(x))^(1/2), x = 0 .. x__0)), EF); ff

2*sqrt(alpha) = int(1/sqrt(sin(x__0)-sin(x)), x = 0 .. x__0) and int(1/sqrt(sin(x__0)-sin(x)), x = 0 .. x__0) = 2*EllipticF(sqrt(sin(x__0))/sqrt(sin(x__0)+1), I*sqrt(-sin(x__0)^2+1)/(-1+sin(x__0)))/sqrt(1-sin(x__0))

(2)

we can plot the inverse using the expression on the righthandside of (2) instead of the integral

g := proc (alpha) options operator, arrow; fsolve(lhs(2*alpha^(1/2) = int(1/(sin(x__0)-sin(x))^(1/2), x = 0 .. x__0)) = EF, x__0 = 0 .. (1/2)*Pi) end proc

plot(g, 0 .. (1/2)*Pi, labels = [alpha, x__0])

 

The big question now remains: How we can force Maple to convert/simplify the integral to an expression that contains functions known by Maple?

NULL

Download inverse_function_with_fsolve_with_EllipticF.mw

@Christian Wolinski Thank you! Where did you get the expressions from? I was acutally expecting Maple to return such expressions.
I am interested, since I work in the meatime with the square of the expression (see my second attachment above). I guess that simliar expressions can be obtained.

Update: The simple formulas work much better. No reduced prescsision is required.

First 62 63 64 65 66 67 Page 64 of 67