C_R

3622 Reputation

21 Badges

6 years, 123 days

MaplePrimes Activity


These are answers submitted by C_R

https://www.maplesoft.com/demo/streaming/clickablecalculusseries4-differentialequations.aspx

If for example alpha=4 in

abs(sin(4))

you will get

as output which evaluates to a positive value.

Otherwise, please send a link to the example.

Edit:

Have you compared the output with Norm command?

help("Physics,Vectors,Norm")

On my machine the kernel disconnects for n>2000.

Since the output is significantly smaller at n=2000, I assume that the kernel reaches a capacity limit for larger n before it can report this to the GUI (aborting the evaluation attempts) and communication is lost.

For n=2001, the disconnection happens after returning output which looks like that the kernel is still doing something in the background that keeps him too busy to respond in time to the GUI.

 

crash_feb_3_2023_with_parameter_n.mw

If you use typset in the following way, letters are rendered in roman if you enclose the letters in double quotes. This is the way Maple prints strings. Without quotation marks, the letters are interpreted as symbols and displayed in italic.
Most difficult was to get the power of 3 of a roman letter without using units.

 

The y-axis label below is a variant with units that renders not as you wanted in Mapleprimes, but correctly in Maple.

plot(x, x = 0 .. 1, labels = [typeset(A, "(kg / m", ``^3, ")"), typeset(A, "(", Unit('kg'), "/", Unit('m')^3, ")")])

 

NULL

NULL

NULL

NULL

My original idea not to code in MathML was to edit the labels with Nonexecutable Math and then copy/paste into a command, hoping to preserve the underlining MathML. I could not make it work.
(Detail: in the punctuation palette there is a divison symbol / labeled "sol" that preserves the inline format kg/m^3 in Nonexecutable Math mode).

Another idea (that I did not persue) is to use a MathML editor that generates the MathML codes which could then be pasted into a typeset statement.
@all: Could this be an option for more complex labels?

Download italic_and_normal_axislabel.mw

at the start of the new input line.

Edit: In the attached, I have also put a semicolon at the end of the line of input. I forgot to mention this.  In Math2d you can delete the multiplication symbol and it still works.

total := D^2/(alpha^2*mu^2)+D^2*exp((2*(-t+t1))*alpha*mu)/(alpha^2*mu^2)+D^2*exp((2*(-t+t1))*alpha*mu)/(alpha^2*mu^2)+D1*D/((alpha*mu*tau0+1)*alpha^2*mu^2)-(-alpha*mu*tau0*exp((-t+t1)*(alpha*mu*tau0+1)/tau0)+exp((2*(-t+t1))*alpha*mu))*D*D1/(mu^2*alpha^2*(alpha^2*mu^2*tau0^2-1))+(alpha*mu*tau0*exp((-t+t1)*(alpha*mu*tau0+1)/tau0)-exp((2*(-t+t1))*alpha*mu))*D1*D/(alpha^2*mu^2*(alpha^2*mu^2*tau0^2-1))-(-alpha*mu*tau0*exp((-t+t1)*(alpha*mu*tau0+1)/tau0)+exp((2*(-t+t1))*alpha*mu))*D*D1/(mu^2*alpha^2*(alpha^2*mu^2*tau0^2-1))+(alpha*mu*tau0*exp((-t+t1)*(alpha*mu*tau0+1)/tau0)-exp((2*(-t+t1))*alpha*mu))*D1*D/(alpha^2*mu^2*(alpha^2*mu^2*tau0^2-1))+D1*D/((alpha*mu*tau0+1)*alpha^2*mu^2)+D1^2/((alpha*mu*tau0+1)^2*alpha^2*mu^2)-(alpha*mu*tau0*exp(-(-t+t1)*(alpha*mu*tau0-1)/tau0)+alpha*mu*tau0*exp((-t+t1)*(alpha*mu*tau0-1)/tau0)-alpha^2*mu^2*tau0^2-1)*D1^2/(alpha^2*mu^2*(alpha^4*mu^4*tau0^4-2*alpha^2*mu^2*tau0^2+1))-((alpha*mu*tau0*exp(-(-t+t1)*(alpha*mu*tau0-1)/tau0)+alpha*mu*tau0*exp((-t+t1)*(alpha*mu*tau0-1)/tau0)-alpha^2*mu^2*tau0^2-1)*D1^2/(alpha^2*mu^2*(alpha^4*mu^4*tau0^4-2*alpha^2*mu^2*tau0^2+1))*(D1^2))/((alpha*mu*tau0+1)^2*alpha^2*mu^2)+2*D1*D/((alpha*mu*tau0+1)*alpha^2*mu^2)+D^2/(alpha^2*mu^2); r2r2 := %; total-r2r2

0

(1)

NULL

Download auto_simplify.mw

Most of the ways described can be performed syntax free with the context pannel

https://www.maplesoft.com/support/help/Maple/view.aspx?path=worksheet%2freference%2fcontextpanel

https://www.maplesoft.com/support/help/Maple/view.aspx?path=worksheet%2fexpressions%2fmanipulatecsm

combine(factor(expand(n*x^n - 2*n*x^(n - 1) + x^n)))

As an alternative to extracting and dissembling the RootOf expression with index=real[4] its possible in this case to substitute the solution for “a” (which comes with the RootOf expression for b) into the original expression expr

expr := 36*a^3*b^3+8*a^2*b^2*(9*(a+b+1)^2+4*(a*b+a+b))*(a+b+1)+((a-b)^2-2*(a+b)+1)^2*(a+b+1)^5+a*b*((a-b)^2-2*(a+b)+1)*(17*(a+b+1)^2+4*(a*b+a+b))*(a+b+1)^2

36*a^3*b^3+8*a^2*b^2*(9*(a+b+1)^2+4*a*b+4*a+4*b)*(a+b+1)+((a-b)^2-2*a-2*b+1)^2*(a+b+1)^5+a*b*((a-b)^2-2*a-2*b+1)*(17*(a+b+1)^2+4*a*b+4*a+4*b)*(a+b+1)^2

(1)

simplify(subs(a = sqrt(3)-1, 36*a^3*b^3+8*a^2*b^2*(9*(a+b+1)^2+4*a*b+4*a+4*b)*(a+b+1)+((a-b)^2-2*a-2*b+1)^2*(a+b+1)^5+a*b*((a-b)^2-2*a-2*b+1)*(17*(a+b+1)^2+4*a*b+4*a+4*b)*(a+b+1)^2))

((b^6+11*b^5-5*b^4-144*b^3+39*b^2+981*b+873)*3^(1/2)+b^7+2*b^6-18*b^5+4*b^4+251*b^3-66*b^2-1698*b-1512)*(b-1)^2

(2)

`assuming`([solve(((b^6+11*b^5-5*b^4-144*b^3+39*b^2+981*b+873)*3^(1/2)+b^7+2*b^6-18*b^5+4*b^4+251*b^3-66*b^2-1698*b-1512)*(b-1)^2, [b], useassumptions)], [b > 0])

[[b = 1]]

(3)

NULL

Download RootOf_index_real_solution_.mw

The condition all parameters are positive is not sufficient to decide on the sign of the roots since a[1] to a[3] can become negative or positive depending on the values of the parameters.

You have to provide relations between parameters (e.g. b>r) to determine ranges for a[1] to a[3] which then might enable you to determine ranges for the roots. Even then I have little hope that you will get a simple answer.

If I add a dot to expr=0  to the first command I get the same output.

solve({0 <~ (a, b), expr = 0.}, [a, b], allsolutions);
(solve(expr = 0., [a, b], useassumptions, allsolutions) assuming (0 <~ (a, b)));
solve({0 <~ (a, b), expr = 0.}, [a, b], allsolutions);

Edit:

In the attachment you can see for the exact solutions that

  • only two solutions are identical
  • the solution s2 is clearly different from all other solutions since there is no solution with a=sqrt(3)-1=0.73. It seems that the solutions with RootOf are not displayed.
  • I am not really an expert with RootOf expressions

I hope someone more experienced can have a look at it.

solve_RootOf.mw (updated after edit)

To what I can see with printlevel:=100 simplify calls simplify,size in both cases

value remembered (in simplify): \`simplify/do\`(a*f(x)+b*f(x)+a*g(x)+1/(a*f(x)+b*f(x)+a*g(x)), size) -> a*f(x)+b*f(x)+a*g(x)+1/((a+b)*f(x)+a*g(x))

For me it looks like that simplify,size could do better on such expressions.

For your example it is possible to execute a Maple command within Flow

convert(1000*Unit('Omega'), units, Unit('`k&Omega;`'))

To preserve the value one (i.e. "1") in front of kOhm

convert(evalf(1000*Unit('Omega')), units, Unit('`k&Omega;`'))

Supported prefixes can be found here.

If you execute

expr:=(c[2]+x)^3+a; 
printlevel:=100;  
simplify(expr)

you can see that simplify/size is called nummerous times but only after simplify/normal has been called which expands expr to
x^3+3*x^2*c[2]+3*x*c[2]^2+c[2]^3+a

Then simplify/size is applied

--> enter \`simplify/size\`, args = x^3+3*x^2*c[2]+3*x*c[2]^2+c[2]^3+a

So, simplify tries to reduce the size of the above expression but not of the original.

Expanding with the normal command at the toplevel of the simpify logic seems to be a design descision.

 

f(x) = 1+c__1*g(x)+c__2*g(x)^2

f(x) = 1+c__1*g(x)+c__2*g(x)^2

(1)

g(x) = A*B/x

g(x) = A*B/x

(2)

subs(g(x) = A*B/x, f(x) = 1+c__1*g(x)+c__2*g(x)^2)

f(x) = 1+c__1*A*B/x+c__2*A^2*B^2/x^2

(3)

diff(f(x) = 1+c__1*A*B/x+c__2*A^2*B^2/x^2, x)

diff(f(x), x) = -c__1*A*B/x^2-2*c__2*A^2*B^2/x^3

(4)

subs(isolate(g(x) = A*B/x, A), diff(f(x), x) = -c__1*A*B/x^2-2*c__2*A^2*B^2/x^3)

diff(f(x), x) = -c__1*g(x)/x-2*c__2*g(x)^2/x

(5)

algsubs((rhs = lhs)(g(x) = A*B/x), diff(f(x), x) = -c__1*A*B/x^2-2*c__2*A^2*B^2/x^3)

diff(f(x), x) = (-2*c__2*g(x)^2-c__1*g(x))/x

(6)

NULL


Update: As someone who has never mastered algsubs, all I can say is that (as I read the algsubs documentation) it should have worked.  Maybe someone else can say why swapping sides was needed to make it work. I would be interested to learn.

Update2: From the algsubs help page: 

The function algsubs performs an algebraic substitution, replacing occurrences of a with b in the expression f.

I.e. lhs is replaced with rhs.

Download with_and_wo_algsubs.mw

If working with equations instead of assignments to names g and f is an option you could do

g(x) = 1+c__1/x+c__2/x^2+c__3/x^3

g(x) = 1+c__1/x+c__2/x^2+c__3/x^3

(1)

f(x) = 1-1/g(x)

f(x) = 1-1/g(x)

(2)

diff(f(x) = 1-1/g(x), x)

diff(f(x), x) = (diff(g(x), x))/g(x)^2

(3)

diff(g(x) = 1+c__1/x+c__2/x^2+c__3/x^3, x)

diff(g(x), x) = -c__1/x^2-2*c__2/x^3-3*c__3/x^4

(4)

subs(diff(g(x), x) = -c__1/x^2-2*c__2/x^3-3*c__3/x^4, diff(f(x), x) = (diff(g(x), x))/g(x)^2)

diff(f(x), x) = (-c__1/x^2-2*c__2/x^3-3*c__3/x^4)/g(x)^2

(5)

NULL

Download with_eqn.mw

First 13 14 15 16 17 18 Page 15 of 18