Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

How to find sgn on maple?

signum.mw

I am trying to generate all non-isomorphic graphs of a certain order and size that have the same degree sequence (not necessarily regular). I assume I would have to use the select option in GraphTheory[NonIsomorphicGraphs] command, however, there are no examples (that I could find) of how to use the option. Any idea how this could be done?

I have an n x n matrix. I am trying to write a procedure that will randomly choose a row (column) in the matrix, and replace another row (column) with the entries of the chosen row (column). So, the end result will be another n x n matrix that has two identical rows (columns). How could one do this?

Hello there, 

Would you please tell me how to get the 'Desired' expression from the 'Sec_Z2prim' expression?

My 'Attempt' did not work. 


 

restart;

TR_turns_ratio := N = n2 / n1;

N = n2/n1

(1)

Sec_Z2prim := Z1 = Z2*n1^2/n2^2;

Z1 = Z2*n1^2/n2^2

(2)

Attempt := subs(TR_turns_ratio, Sec_Z2prim) assuming (n1 > 0, n2 > 0);

Z1 = Z2*n1^2/n2^2

(3)

Desired := Z1 = Z2*(1/N)^2;

Z1 = Z2/N^2

(4)

 

 

Thank you, 
 

Download Q20201014.mw

I usually piecewise functions in my maple codes. I want to export  the my maple code to a Matlab code in order to utilize advantages of plots of Matlab.

What methods would you recommend me?

 

For example:

Suppose that I have a piecewise u function.

restart:
u:=1/(1. + exp(x))^2 + 1/(1. + exp(-5.*t))^2 - 0.2500000000 + x*(1/(1. + exp(1 - 5*t))^2 - 1./((1. + exp(-5*t))^2) + 0.1776705118 + 0.0415431679756514*piecewise(0. <= t and t <= 0.5000000000, 1.732050808, 0.) + 0.00922094377856479*piecewise(0. <= t and t <= 0.5000000000, 30.98386677*t - 7.745966692, 0.) + 0.0603742508215732*piecewise(0.5000000000 <= t and t <= 1., 1.732050808, 0.) - 0.00399645630498528*piecewise(0.5000000000 <= t and t <= 1., 30.98386677*t - 23.23790008, 0.)) + (-0.00243051684581302*piecewise(0. <= x and x <= 0.5000000000, 1.732050808, 0.) - 0.000809061198761621*piecewise(0. <= x and x <= 0.5000000000, 30.98386677*x - 7.745966692, 0.) - 0.0152377552205917*piecewise(0.5000000000 <= x and x <= 1., 1.732050808, 0.) - 0.00195593427342862*piecewise(0.5000000000 <= x and x <= 1., 30.98386677*x - 23.23790008, 0.))*piecewise(0. <= t and t <= 0.5000000000, 1.732050808, 0.) + (-0.000433590063316381*piecewise(0. <= x and x <= 0.5000000000, 1.732050808, 0.) - 0.000146112803263678*piecewise(0. <= x and x <= 0.5000000000, 30.98386677*x - 7.745966692, 0.) - 0.00319022339097685*piecewise(0.5000000000 <= x and x <= 1., 1.732050808, 0.) - 0.000477063086307787*piecewise(0.5000000000 <= x and x <= 1., 30.98386677*x - 23.23790008, 0.))*piecewise(0. <= t and t <= 0.5000000000, 30.98386677*t - 7.745966692, 0.) + (-0.00276114805649180*piecewise(0. <= x and x <= 0.5000000000, 1.732050808, 0.) - 0.000933166016624500*piecewise(0. <= x and x <= 0.5000000000, 30.98386677*x - 7.745966692, 0.) - 0.0207984584912892*piecewise(0.5000000000 <= x and x <= 1., 1.732050808, 0.) - 0.00314360556336114*piecewise(0.5000000000 <= x and x <= 1., 30.98386677*x - 23.23790008, 0.))*piecewise(0.5000000000 <= t and t <= 1., 1.732050808, 0.) + (0.000172746997599710*piecewise(0. <= x and x <= 0.5000000000, 1.732050808, 0.) + 0.0000586775450031145*piecewise(0. <= x and x <= 0.5000000000, 30.98386677*x - 7.745966692, 0.) + 0.00136190009033518*piecewise(0.5000000000 <= x and x <= 1., 1.732050808, 0.) + 0.000211410172315387*piecewise(0.5000000000 <= x and x <= 1., 30.98386677*x - 23.23790008, 0.))*piecewise(0.5000000000 <= t and t <= 1., 30.98386677*t - 23.23790008, 0.);

 

 

I use the following code to transform a Matlab code, but the output is not working in Matlab.

 

with(CodeGeneration):
 	
Matlab(u,resultname="w");

 

Using solve on this example:

restart;
eq:=x^3 - 3*x^2 + 3*x - 1=0;
solve(eq,x);

gives solution x=1, with multiplicty 3

              1, 1, 1

When using PDEtools:-Solve

restart;
eq:=x^3 - 3*x^2 + 3*x - 1=0;
solve(eq,x);
PDEtools:-Solve(eq,x);

it gives

         x = 1

How can one make it show x=1, x=1, x=1 ?

Found that only when using PDEtools:-Solve(eq,x,numeric) it gives 

           x = 1., x = 1., x = 1.

How to make it do the same without using numeric?

Maple 2020.1.1

 

What is the reason that error accepts its arguments without being inside paranthesis? This is different from all other Maple functions I've seen. For example, both these below work the same

f := proc (x) 
     if x<0 then 
        error "invalid x: %1", x; 
     else 
        x^(1/2); 
     end if 
end proc:

And

g := proc (x) 
     if x<0 then 
        error("invalid x: %1", x); 
     else 
        x^(1/2)
     end if 
end proc:

One can't do for other Maple functions. For example sin x  gives an error. It must be sin(x)

Looked at help page for error and did not see something about this difference.

I have been having difficulty with plotting these graphs from Cartesian to Polar. I know that with double integrals there is an inclusion of r when you go from Cartesian to Polar. I think my graph of the function being integrated is correct. I am having difficulty with the command for the shaded region. I know with Cartesian, I can use inequal command to get the right shaded area. Will this command work with polar coordinates? 

I attached the Maple worksheet.

Thank you all for help in advance!

eqell := expand((x+(1/2)*R1-(1/2)*R)^2/a^2+y^2/b^2-1); geometry:-ellipse(ell, eqell, [x, y]); detail(ell); ellipse: hint: unable to determine if 1/(1/2*R+1/2*R1)^2*(1/(-8*R^3*R1+14*R^2*R1^2-3*R*R1^3)*R^2+2/(-8*R^3*R1+14*R^2*R1^2-3*R*R1^3)*R1*R+1/(-8*R^3*R1+14*R^2*R1^2-3*R*R1^3)*R1^2) is zero Error, (in geometry:-ellipse) the given polynomial/equation is not an algebraic representation of a ellipse. How to manage this error ? Thank you.

The expressions f(1), f(1,2,3), or f with any number of arguments, all match the type specfunc(f), while the expression f(g(1), 2 ,3) matches the type f(g(anything), anything, anything). However, is there a type which is matched by expressions like f(g(1), 2, 3 ...), with an arbitrary number of arguments after g(something)?

 

The command Typesetting:-Settings(prime=x,typesetprime=true):  makes diff(y(x),x) gives the latex as y'(x) which is what I wanted.

But I'd like to also be able to turn this off.  The reason is that in my program, I could have different variables in different places, and need to be able to turn this off/on as the program runs.

I know I can change the setting, by calling the above command again, with different variable. But I was looking for a way to turn it off as well. 

Similar to Typesetting:-Suppress  

Is there a way to do that? Actually the best solution would be, is to have the effect of Typesetting:-Settings(prime=x,typesetprime=true): be local to the proc. So if this command is used inside a proc, when leaving the proc, its effect will be automatically removed, as if this command was never issued.

Only when it is issued in global context, it will remain in effect until one does a restart.   Right now, the effect of Typesetting:-Settings(prime=x,typesetprime=true): is global. Even when called from inside a proc.  But this might be hard to implement. Therefore, being just able to turn it off is good for now.

Here is an example

restart;
foo:=proc(expr,x,y)
   Typesetting:-Settings(prime=x,typesetprime=true):
   print(Physics:-Latex(expr));

   #How to turn off the effect of above Typesetting command now?
   #so the following command works as the default setting?

   print(Physics:-Latex(expr));
end proc;


expr:=diff(y(x),x)=3:
foo(expr,x,y);

 

Hi

I am trying to implement a recursive algorithm for matrix inverses, its a seventh-order method

for n to 7 do
    new := (1/16*old) . (120*I + ((A . old) . (735*I + ((A . old) . (-861.*I + ((A . old) . (651*I + ((A . old) . (93*I + (A . (old(-15*I + (A . old)))))))))))));
    old := new;
    print(n);
end do

However I get a error informing me that this is a recursive statment. Which it is, but maple thinks this is a bad thing.

So it is clear that I am doing somthing wrong, Can anyone help me by explaining what I am doing wrong?

Mvh

Eric Ragnarsson

 

Examples of mathematical models for the formation of spline curves based on polynomials of various orders that simulate certain trajectories are given.
Mathematical models of the formation of a spline-curve are presented, taking into account the extreme derivatives of the initial orders. The construction of spline curves of Hermite and Bezier of various orders, consisting of different segments, is considered. The presented models are systematic and universal, i.e. can be used to generate any polynomial spline curves with specified extreme derivatives of vectors.Example_1.mwExample_2.mwExample_3.mwExample_4.mwExample_5.mwExample_7.mwExample_6.mw

Hi,

I have questions about linestyle in maple, how to change solid and Dash whatever  to line with cross or line with plus 

Please see a plot attached.

Look forward to hearing from you as soon as possible.

Regards,

Mathastr

plots.pdf

I am new to Maple. I attempted to write a procedure that takes another procedure as input. It is not working correctly. As you can see from the output of a call to procedure A that something went wrong.
How do I do this correctly?
 

H := proc (n::integer)::real; local s, i; s := 0; for i by 2 to n do if i <= n-1 then s := s+1./((i*(i+1))) else s := s+1./i end if end do; return s end proc

A := proc (n::integer, T::procedure)::real; local d1, d2, s; d1 = T(n+1)-T(n); d2 = T(n+2)-T(n); s := T(n+1)-d1*d2/(d2-d1); return s end proc

proc (n::integer, T::procedure)::real; local d1, d2, s; d1 = T(n+1)-T(n); d2 = T(n+2)-T(n); s := T(n+1)-d1*d2/(d2-d1); return s end proc

(1)

H(11)

.7365440115

(2)

A(10, H)

.7365440115-d1*d2/(d2-d1)

(3)

``


 

Download st.mw

1 2 3 4 5 6 7 Last Page 2 of 1737