Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Hi every one

I'm having some plots in maple, but the layout is not pretty enough, I want export in to MATLAB. Does some one please have an idea on how I can go about it?.

I'm using Maple 16

Thank you in anticipation

Hi everyone.

I have a 2D function and I wanna after Differentiating from it with respect to tau (at any amount of sigma value) and equaling this derivative to zero solve the infinite system of equations.

P[n](tau)==LegendreP(n - 1/2, cosh(tau)) , Q[n](tau)==LegendreQ(n - 1/2, cosh(tau)) 

are Legendre function.

Thanks in advanced

FUNCTION_f.mw


 

"restart;:N:=3: f(sigma,tau):=(sqrt(cosh(tau)-cos(sigma)))*(∑)(A[n]*P[n]((tau)) -n*Q[n]((tau)) )*sin(n*sigma)"

proc (sigma, tau) options operator, arrow, function_assign; sqrt(cosh(tau)-cos(sigma))*(sum((A[n]*P[n](tau)-n*Q[n](tau))*sin(n*sigma), n = 1 .. N)) end proc

(1)

NULL

W := simplify(diff(f(sigma, tau), tau))

(1/2)*((2*A[2]*(cosh(tau)-cos(sigma))*(diff(P[2](tau), tau))+(-4*cosh(tau)+4*cos(sigma))*(diff(Q[2](tau), tau))+sinh(tau)*(A[2]*P[2](tau)-2*Q[2](tau)))*sin(2*sigma)+(2*A[3]*(cosh(tau)-cos(sigma))*(diff(P[3](tau), tau))+(-6*cosh(tau)+6*cos(sigma))*(diff(Q[3](tau), tau))+sinh(tau)*(A[3]*P[3](tau)-3*Q[3](tau)))*sin(3*sigma)+sin(sigma)*(2*A[1]*(cosh(tau)-cos(sigma))*(diff(P[1](tau), tau))+(-2*cosh(tau)+2*cos(sigma))*(diff(Q[1](tau), tau))+sinh(tau)*(A[1]*P[1](tau)-Q[1](tau))))/(cosh(tau)-cos(sigma))^(1/2)

(2)

``


 

Download FUNCTION_f.mw

 

During the computation of a series, I needed the value Psi(1/12)  of the digamma function at a rational point. 

simplify, convert/elementary or other usual convertions do not help.

But Maple knows the formula for Psi(r) when r is rational:

 

FunctionAdvisor(special_values, Psi)[24][1]: convert(%,`global`);

Psi(n+p/q) = q*(Sum(1/(k*q+p), k = 0 .. n-1))+2*(Sum(cos(2*Pi*p*k/q)*ln(sin(Pi*k/q)), k = 1 .. floor((1/2)*q+1/2)-1))-(1/2)*Pi*cot(Pi*p/q)-ln(2*q)-gamma

(1)

(simplify@value)(eval(%, [n=0, p=1, q=12]));

Psi(1/12) = ((2*3^(1/2)-6)*ln(2+3^(1/2))+(-Pi-2*gamma-6*ln(2)-3*ln(3))*3^(1/2)-Pi+2*gamma+6*ln(2)+3*ln(3))/(2*3^(1/2)-2)

(2)

evalf(%);

-12.44790533 = -12.44790533

(3)

The question is: why does not Maple use this formula when asked? Or, is there a convertion which I was missing?

 

I have written the following attached code to use Euler explicit method to solve the following IVP

diff(y(x), x) = 2*(1+x)-y(x), y(2) = 5
With Exact solution  y(x) = 2*x+exp(-x)/exp(-2)

However, I found out that my exact results are not correct while the numerical results are okay. What have I done wrong in the code? Can someone modify the code?

Thank you and kind regards.

 I recently tried using Maple 2020 to run example code for the Grid package provided in Section 15.8 of the Maple Programming Guide. Unfortunately, none of the sample code appears to work as advertised.

Firstly, when I try to run the first sequential Mandelbrot example provided, I get the following error:

Error, (in Mandelbrot:-MandelLoop) `break` outside of loop

This was easily fixed by replacing the break statement in the while with a boolean value flag, while k < iter and flag do (see attached image). With this minor change to the example provided in the manual, I was able to get the code sequential code to run in 45.743 seconds on a quad core laptop. The modifications to the sample code are highlighted in red below.

 MandelLoop := proc( X, Y, imageArray, i_low, i_high, j_low, j_high, iter, bailout )
        local flag, i, j, Xc, Yc, Xtemp, Ytemp, Xold, Yold, k, t;
        option hfloat;

        for i from i_low to i_high do
           for j from j_low to j_high do
               Xtemp := X[i];
               Ytemp := Y[j];
               Xc := Xtemp;
               Yc := Ytemp;
               k := 0;
               flag := true:
               while k < iter and flag do
                   Xold := Xtemp;
                   Yold := Ytemp;
                   Xtemp := Xold^2-Yold^2+Xc;
                   Ytemp := 2*Xold*Yold+Yc;
                   t := Xtemp^2+Ytemp^2;
                   if Xtemp^2+Ytemp^2 >= bailout then
                        imageArray[i, j, 1] := k - ln( ln( t ) )/ln(2.);
                        imageArray[i, j, 2] := imageArray[i, j, 1];
                        imageArray[i, j, 3] := imageArray[i, j, 1];
                        #break;
                        flag := false:
                  end if;
                  k := k+1;
               end do
           end do;
        end do;
    end proc:

The second, and seemingly more serious problem occurred when I tried to run the code in the last example that uses the Client/Server model to parallelise the Mandelbrot calculation. The code provided in the Programming Guide once again gives the break outside of loop error. However, after replacing the break statement in the Computeline procedure with a boolean flag as above, I found the code runs but does not enter either the Server procedure or the Computeline procedure that is actually supposed to do the work. This can be verified by including print statements in the Computeline or Server procedures. The parallelised code ran in less than one second, compared to 45 seconds for the sequential code. Unfortunately this was not due to a 45-fold speed up on my quad core laptop, but the fact that the code using the code parallelised using Grid Package did nothing whatsoever.

I have sent a number of e-mail requests to Maple Support asking them to explain these apparent errors and so far have received no response.

Any solutions to these problems from the Maple user community would be much appreciated.

Thanks.

John

Hi . Can I download Maple on my IPad Pro 12.9?

P1 := x^2+y^2-4:
P2 := y^2-2*x+2:

Original question is find CAD of (some y)[P1 <0 and P2 <0]

how to use maple 12 and maple 2015 to find Q1,Q2,Q3 which are projection of P1 and P2

my book show sample points are [-4,-1-sqrt(7),-3,-2,0,1,3/2,-1+sqrt(7),9/5,2,3]
but FindSamples result is not the same with my book, is it my book wrong or FindSamples function wrong?
I find result of my script is the same as book's quantifier position at 7,8,9 though sample points has little different

how to generalize my following script to multiple variables x, y, z, and more ?

and

I compare with maple 2015 result are different from my book solution, is maple 2015 more advanced version CAD? 

with(ListTools):

P1 := x^2+y^2-4:
P2 := y^2-2*x+2:

Q1 := x^2 + 2*x - 6;
Q2 := x^2 - 4;
Q3 := x - 1;

sourcesamples := sort(evalf([solve(Q1), solve(Q2), solve(Q3)]),`<`);

FindSamples:=proc(sourcesamples)
local N, P;
N:=nops(sourcesamples);
P:=proc(a,b)
local a1, b1, m1, n, m;
if a=b then error "Should be a<>b" fi;
a1,b1:=op(convert(sort([a,b],(x,y)->evalf(x)<evalf(y)),rational));
count := 0:
for n from 1 do
m1:=a1*n;
m:=`if`(type(m1,integer),m1+1,ceil(m1));
count := count + 1:
if is(m/n>a1) and is(m/n<b1) then return m/n fi;
od;
print("count=",count);
end proc:
[ceil(sourcesamples[1])-1, seq(op([sourcesamples[i],P(sourcesamples[i],sourcesamples[i+1])]), i=1..N-1),sourcesamples[N],floor(sourcesamples[N])+1];
end proc:

RemoveComplex := proc(yy)
local result, k:
result := []:
for k in yy do
if Im(k) = 0 then
result := [op(result), k]:
end if:
od:
if result = [] then
result := []:
end if:
return result:
end proc:

Joinsolution := proc(param1, param2group)
local result, k:
result := []:
for k in param2group do
result := [op(result), [param1, k]]:
od:
return result:
end proc:

CADsamples := FindSamples(sourcesamples):
CADresult1 := []:
for mm in CADsamples do
#print(mm):
if MakeUnique(RemoveComplex([solve(subs(x=mm, P1)), solve(subs(x=mm, P2))])) = [] then
CADresult1 := [op(CADresult1), op(Joinsolution(mm,[0]))];
else
CADresult1 := [op(CADresult1), op(Joinsolution(mm,FindSamples(sort(evalf(MakeUnique(RemoveComplex([solve(subs(x=mm, P1)), solve(subs(x=mm, P2))]))),`<`))))];
end if:
od:
CADresult1;

for mm in CADresult1 do
if subs(x=mm[1],subs(y=mm[2], P1)) < 0 and subs(x=mm[1],subs(y=mm[2], P2)) < 0 then
print("solution ", mm, SearchAll(mm[1],CADsamples), evalf(mm)):
end if:
od:

Compare with

with(RegularChains):
with(ChainTools):
with(MatrixTools):
with(ConstructibleSetTools):
with(ParametricSystemTools):
with(SemiAlgebraicSetTools):
with(FastArithmeticTools):
R := PolynomialRing([x,y]):
sys := [x^2+y^2-4,y^2-2*x+2]:
N := []:
P := []: 
H := [x]:
dec := RealTriangularize(sys,N,P,H,R):
proj := Projection(sys, N, P, H, 1, R);
Display(dec, R);

P := SamplePoints(sys, R);
Display(P, R);
cad := CylindricalAlgebraicDecompose(sys, R);
 

The following transfer function has zero/pole cancelation. I am trying to create a transfer function object, but Maple automatically simplifies the transfer function before it gets to the DynamicSystem call, which result in different output than what I expected.

I do set the cancellation=false option, even though this is the default. The problem is Maple does pole/zero cancelation before the call.

I tried to add '' around it to delay evaluation, but it did not work.  

restart;
alias(DS=DynamicSystems):
DS:-SystemOptions(cancellation=false,complexfreqvar=s):
tf:=DS:-TransferFunction('-(s - 1)/((-2 + s)*(s - 1))'):
DS:-PrintSystem(tf)

You can see it did pole/zero cancelation.

In Matlab and Mathematica, this does not happen. For example

Clear["Global`*"];
sys = TransferFunctionModel[-(s - 1)/((-2 + s) (s - 1)), s]

Same with Matlab:

>> s=tf('s');
>> sys_tf =-(s - 1)/((-2 + s)*(s - 1))

sys_tf =
 
     -s + 1
  -------------
  s^2 - 3 s + 2
 
Continuous-time transfer function.

What do I need to do in Maple to keep the transfer function without pole/zero cancelation (this affects the state space realization later on when this cancelation happens)

I am using Maple 2019 at this moment as Maple 2020 is busy.

 

As I was going over latest build using Physics:-Latex I noticed this.

The complex number I should be translated to lower case in latex.

This is what the original latex() does (and also what Mathematica TeXForm does).

It does not look good at all to have complex number I be translated to I and remain UPPER case I

Here is an example

expr:=[solve(x^2+2*x+2=0,x)];
Physics:-Latex(expr)

gives

[-1+I, -1-I]

While  latex(expr) gives the much better and more mathematical output:

[-1+i,-1-i]

 

interface(version);

`Standard Worksheet Interface, Maple 2020.1, Windows 10, July 30 2020 Build ID 1482634`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 790. The version installed in this computer is 789 created 2020, September 1.`

expr:=[solve(x^2+2*x+2=0,x)];
Physics:-Latex(expr)

[-1+I, -1-I]

[-1+I, -1-I]

latex(expr)

[-1+i,-1-i]

 


Is it possible to have Physics:-Latex translate complex numbers like latex() did?

Please see attached worksheet below.

Download latex_issue_9.mw

I'd like to suggest Physics:-Latex change its use of \textit{} and replace it with \mathit{} 

\mathit is the better Latex command to use, since the Latex generated goes into math mode and \mathit is designed to be used in math mode and hence has a better spacing for this. Making the final Latex look a little better.

Here is an example showing the difference.

restart;
ode:=diff(y(x),x) = y(x)/(x^2+1);
sol:=dsolve(ode);
Physics:-Latex(sol)

Gives

y \left(x \right) = \textit{\_C1} {\rm e}^{\arctan \left(x \right)}

It will be better to generate

y \left(x \right) = \mathit{\_C1} {\rm e}^{\arctan \left(x \right)}

Here is the difference when both are compiled using latest texlive 

Since all the Latex generated is meant to be used in math mode, \mathit would be better choice. It is considered wrong to use \textit in math mode actually, even though it does compile.

Here is the latex file used to generate the above pdf

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{maplestd2e}


\begin{document}

\[
y \left(x \right) = \textit{\_C1} {\rm e}^{\arctan \left(x \right)}
\]

\[
y \left(x \right) = \mathit{\_C1} {\rm e}^{\arctan \left(x \right)}
\]

\end{document}


 

interface(version);

`Standard Worksheet Interface, Maple 2020.1, Windows 10, July 30 2020 Build ID 1482634`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 789 and is the same as the version installed in this computer, created 2020, September 1, 23:54 hours Pacific Time.`

ode:=diff(y(x),x) = y(x)/(x^2+1);
sol:=dsolve(ode);
Physics:-Latex(sol)

diff(y(x), x) = y(x)/(x^2+1)

y(x) = _C1*exp(arctan(x))

y \left(x \right) = \textit{\_C1} {\rm e}^{\arctan \left(x \right)}

 


thank you

Download latex_issue_8.mw

I use WINDOW 10 

for j from 1 to 3 do
pout := cat("C:/Users/Eli/Documents/Animation/", "file", j, ".bmp"):
print(pout):
plotsetup(bmp, plotoutput = pout):
# plot (...)
od:

 

Hi, I have a problem related to the cancellation of the square root with a square in its argument, see the image below.

Thanks in advance,

Santiago

 

i have a task who is like this:

let h(x)=2/f(x)

and the function f meets the following criteria

 

f(-1)=4 and f '(-1)=2

 

what is h'(-1)

 

how to i solve this, i am thinking of ordinary differential equations (ODEs)

and dsolve funktion in maple. but how do i do this.

or is there another way to solve it

 

 

 Hello , I need to plot the following on the same axes of implicit plot where discrete wavenumbers k1, k2, k3 on the same set of axes (the wavenumbers are points [k1,0], [k2,0], [k3,0], ...) , where k_{n}=2*n*Pi/L and the domain [0,L] 

Could you please help , I couldn't do. Thank you

 

restart;
with(plots, implicitplot);
alpha := 0.1;
beta := 0.1;
mu := 0.5;
u := 0.5;
v := 1;
gamma = 0.1;
                          alpha := 0.1

                          beta := 0.1

                           mu := 0.5

                            u := 0.5

                             v := 1

                          gamma = 0.1

Eq := -2*sigma*alpha*beta*mu*u - sigma*alpha*beta^2*u*v - 2.0*mu*alpha*beta^2*u*v - gamma^2*k^2*alpha*beta*u + beta*sigma^2*v + sigma^3 + 2*mu*sigma^2 - alpha*beta*sigma^2*u + sigma*beta^2*u*v + gamma^2*k^2*sigma + 2.0*mu*beta*sigma*v + 2.0*mu*beta^2*u*v;
                                            2  2              2
 Eq := 0.0995 sigma + 0.004500 - 0.005 gamma  k  + 1.095 sigma 

           3        2  2      
    + sigma  + gamma  k  sigma


implicitplot(Eq, k = 0 .. 10, sigma = -0.1 .. 0.1);
 

Please can someone help me out, have been trying for a very long time now on how to differentiate the lines on the graph.......please find attachment below and correct..................................................................

 

 restart;
  with(plots):
#
# Define the ODE system
#
  odeSys:= { (diff(F(eta), eta, eta, eta))*(1+epsilon-alpha((diff(F(eta), eta, eta))^2))+F(eta)*(diff(F(eta), eta, eta))+S*(diff(F(eta), eta))-(1/2)*S*eta*(diff(F(eta), eta, eta))-(diff(F(eta), eta))^2-M*(diff(F(eta), eta)), (diff(theta(eta), eta, eta))*(1+R)-delta*(diff(F(eta), eta))^2-Pr((3/2)*S*theta(eta)+(1/2)*S*eta*(diff(theta(eta), eta))-2*(diff(F(eta), eta))*theta(eta)+F*(diff(theta(eta), eta)))};
#
# Define the first set of boundary conditions
#
  bcs1:= { F(0) = 0, (D(F))(0) = 1, (D(F))(inf) = 0, theta(0) = 1, theta(inf) = 0
         }:

  RVals:=[0.1, 0.5, 1]:
  for k from 1 by 1 to numelems(RVals) do
      pList:=[ epsilon = 0.18, M = 0.5, S = 1.5, delta = 0.3, Pr = 1.5, alpha = 0.4, R = RVals[k],inf=1
]:
      sol1[k]:= dsolve( eval
                        ( `union`( odeSys, bcs1),
                           pList
                       ),
                       numeric
                     );
     od:
  display
  ( [ seq
      ( odeplot
        ( sol1[i],
          [eta, theta(eta)],
          eta=0..2
        ),
        i=1..numelems(RVals)
      )
    ],
    color = [red, green, blue],
    title = typeset( theta(eta), " versus ", eta),
    titlefont = [times, bold, 20]
  );
 

First 10 11 12 13 14 15 16 Last Page 12 of 1731