Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Hello,

Can anyone tell me why this Maple phaseportrait command returns the error below ? Thanks in advance !

 

with(DEtools);
phaseportrait(-2*x*y, [x, y], x = -1.5 .. 1.5, {[0, -2], [0, -1], [0, 0], [0, 1], [0, 2], [0, 3]}, y = -1 .. 3);
Error, (in DEtools/phaseportrait) system must have same number of dependent variables as DE's.
 

Hello

The calculation of the jacobian matrix is not working.

https://de.maplesoft.com/support/help/maple/view.aspx?path=VectorCalculus/Jacobian

Testes on windows, mac. worhksheet and document mode.

Maple 2017.

 

 

 

with(VectorCalculus)

[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, About, AddCoordinates, ArcLength, BasisFormat, Binormal, ConvertVector, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProduct, Flux, GetCoordinateParameters, GetCoordinates, GetNames, GetPVDescription, GetRootPoint, GetSpace, Gradient, Hessian, IsPositionVector, IsRootedVector, IsVectorField, Jacobian, Laplacian, LineInt, MapToBasis, Nabla, Norm, Normalize, PathInt, PlotPositionVector, PlotVector, PositionVector, PrincipalNormal, RadiusOfCurvature, RootedVector, ScalarPotential, SetCoordinateParameters, SetCoordinates, SpaceCurve, SurfaceInt, TNBFrame, TangentLine, TangentPlane, TangentVector, Torsion, Vector, VectorField, VectorPotential, VectorSpace, Wronskian, diff, eval, evalVF, int, limit, series]

(1)

Jacobian([rcos(t), rsin(t), r2t], [r, t])

Matrix(%id = 18446744078361292662)

(2)

``


 

Download DAROTIERTJACOBIANIMGRABSCHEISSEMA.mw

There seems to be patterns for sin(10^-k) for rational k;

Here we have the "floats."

n sin(10^(-n-1/2))

1 0.03161750640

2 0.003162272390

3 0.0003162277607

4 0.00003162277660

Hi!

Is it possible to create a vector, say

phi := Vector(2);
phi[1] := x[1]+2*x[2];
phi[2] := x[2]**2+x[1];

and then save it in a file that you can use in Matlab as a function handle?

I want to be able to create the phi vector in Maple but use it in Matlab.

Thanks for help!

 

You might recall this image being shared on social media some time ago.

Source: http://cvcl.mit.edu/hybrid_gallery/monroe_einstein.html

Look closely and you see Albert Einstein. However, if you move further away (or make the image smaller), you see Marilyn Monroe.

To create the image, the high spatial frequency data from an image of Albert Einstein was added to the low spatial frequency data from an image of Marilyn Monroe. This approach was pioneered by Oliva et al. (2006) and is influenced by the multiscale processing of human vision.

  • When we view objects near us, we see fine detail (that is, higher spatial frequencies dominate).

  • However, when we view objects at a distance, the broad outline has greater influence (that is, lower spatial frequencies dominate).

I thought I'd try to create a similar image in Maple (get the complete application here).

Here's an overview of the approach (as outlined in Oliva et al., 2006). I used different source images of Einstein and Monroe.

Let's start by loading some packages and defining a few procedures.

restart:
with(ImageTools):
with(SignalProcessing):

fft_shift := proc(M)
   local nRows, nCols, quad_1, quad_2, quad_3, quad_4, cRows, cCols;
   nRows, nCols := LinearAlgebra:-Dimensions(M):
   cRows, cCols := ceil(nRows/2), ceil(nCols/2):
   quad_1 := M[1..cRows,      1..cCols]:
   quad_2 := M[1..cRows,      cCols + 1..-1]:  
   quad_3 := M[cRows + 1..-1, cCols + 1..-1]:
   quad_4 := M[cRows + 1..-1, 1..cCols]:
   return <<quad_3, quad_2 |quad_4, quad_1>>:
end proc:

PowerSpectrum2D := proc(M)
   return sqrt~(abs~(M))
end proc:

gaussian_filter := (a, b, sigma) -> Matrix(2 * a, 2 * b, (i, j) -> evalf(exp(-((i - a)^2 + (j - b)^2) / (2 * sigma^2))), datatype = float[8]):

fft_shift() swaps quadrants of a 2D Fourier transform around so that the zero frequency components are in the center.

PowerSpectrum2D() returns the spectra of a 2D Fourier transform

gaussian_filter() will be used to apply a high or low-pass filter in the frequency domain (a and b are the number of rows and columns in the 2D Fourier transform, and sigma is the cut-off frequency.

Now let's import and display the original Einstein and Monroe images (both are the same size).

einstein_img := Read("einstein.png")[..,..,1]:
Embed(einstein_img)

marilyn_img  := Read("monroe.png")[..,..,1]:
Embed(monroe_img)

Let's convert both images to the spatial frequency domain (not many people know that SignalProcessing:-FFT can calculate the Fourier transform of matrices).

einstein_fourier := fft_shift(FFT(einstein_img)):
monroe_fourier   := fft_shift(FFT(monroe_img)):

Visualizing the power spectra of the unfiltered and filtered images isn't necessary, but helps illustrate what we're doing in the frequency domain.

First the spectra of the Einstein image. Lower frequency data is near the center, while higher frequency data is further away from the center.

Embed(Create(PowerSpectrum2D(einstein_fourier)))

Now the spectra of the Monroe image.

Embed(Create(PowerSpectrum2D(monroe_fourier)))

Now we need to filter the frequency content of both images.

First, define the cutoff frequencies for the high and low pass Gaussian filters.

sigma_einstein := 25:
sigma_monroe   := 10:

In the frequency domain, apply a high pass filter to the Einstein image, and a low pass filter to the Monroe image.

nRows, nCols := LinearAlgebra:-Dimension(einstein_img):

einstein_fourier_high_pass := einstein_fourier *~ (1 -~ gaussian_filter(nRows/2, nCols/2, sigma_einstein)):
monroe_fourier_low_pass    := monroe_fourier   *~ gaussian_filter(nRows/2, nCols/2, sigma_monroe):

Here's the spectra of the Einstein and Monroe images after the filtering (compare these to the pre-filtered spectra above).

Embed(Create(PowerSpectrum2D(einstein_fourier_high_pass)))

Embed(Create(PowerSpectrum2D(monroe_fourier_low_pass)))

Before combining both images in the Fourier domain, let's look the individual filtered images.

einstein_high_pass_img := Re~(InverseFFT(fft_shift(einstein_fourier_high_pass))):
monroe_low_pass_img    := Re~(InverseFFT(fft_shift(monroe_fourier_low_pass))):

We're left with sharp detail in the Einstein image.

Embed(FitIntensity(Create(einstein_high_pass_img)))

But the Monroe image is blurry, with only lower spatial frequency data.

Embed(FitIntensity(Create(monroe_low_pass_img)))

For the final image, we're simply going to add the Fourier transforms of both filtered images, and invert to the spatial domain.

hybrid_image := Create(Re~(InverseFFT(fft_shift(monroe_fourier_low_pass + einstein_fourier_high_pass)))):
Embed(hybrid_image)

So that's our final image, and has a similar property to the hybrid image at the top of this post.

  • Move close to the computer monitor and you see Albert Einstein.
  • Move to the other side of the room, and Marilyn Monroe swims into vision (if you're myopic, just take off your glasses and don't move back as much).

To simulate this, here, I've successively reduced the size of the hybrid image

And just because I can, here's a hybrid image of a cat and a dog, generated by the same worksheet.

Hi, 

Could the Maplesoft staff change the definition of the GammaDistribution in package Statistics?

In the all the papers or courses in the fiels of Probability or Statistics, the shape parameter is the first parameter of this distribution, while the scale (or "rate") parameter is the second.

From versions to versions the Maple definition of this distribution switches these parameters.
It's really a pain in the ass when you want to implement algorithms that use this distribution*

Thanks for your understanding


* for specialists, the Clayton copula uses as an ingredient a sample from Gamma(1/theta, 1) where theta is an adhoc parameter.
In Maple you must code s:=Sample(GammaDistribution(1, 1/theta)).

OK, you could reply me that once I know the trick it is the simplest thing at world to do the switch myself: nevertheless it's really boring, to say the least

1) start cmaple.exe;

2) type "proc(x, x);", and watch Maple die;

3) Request a refund from Maplesoft.

I am using command-line Maple cmaple.exe, I have been trying several hours to type the correct several characters to create a lambda function (anonymous function), but Maple's documentation is only for people using the GUI and gives no hint how to translate the right-arrow symbol into ASCII.

What is the secret, undocumented sequence of ASCII characters for defining an anonymous function via the command-line interface? (Why not document it in the user-manual, for those of who can't stand Maple's bad GUI?)

I have a maple code that has two output blocks giving a large number of numerical values for my experiment. I need these values to compare the output in both the code blocks and also to draw several figures using the data. On a single run of the program, a large number of values are obtained and then I manually copy them to excel sheet for further analysis. It takes a lot of my time to copy and paste the results on each run. I want to export the outputs of both the code blocks to a excel sheet. Any suggestion on this problem will be helpful to me. Thanks.

The link to my code is  maple-excel.mw.

I want the output in this format Book1.xlsx

Dear All,

I am having trouble with doing integration of a complex integrand with Maple 2016. The code is shown below. For simplicity, I have used a real function Psi00, but in general, it should be a complex function. Although I have assumed r to be real, in the final output, there is still an overhead bar on r^1/4. It is not recognized as real and is not multiplied on the r^5/4 factor to give r^3/2. May I ask you for help in solving this problem? Any of your help is highly appreciated!

Best,

Toby

assume(r, real); assume(phi, real);
Psi00 := exp(-(1/2)*r^2)/sqrt(Pi);
                             /  1  2\
                          exp|- - r |
                             \  2   /
                          -----------
                              (1/2)  
                            Pi       

int(int(conjugate(Psi00*r^(1/4))*Psi00*r^(1/4)*r, r = 0 .. infinity), phi = 0 .. 2*Pi);
    /   /             2 ______                          \\   
    |   |/   /  1  2\\   (1/4)  (5/4)                   ||   
    |   ||exp|- - r ||  r      r                        ||   
    |   |\   \  2   //                                  ||   
  2 |int|----------------------------, r = 0 .. infinity|| Pi
    \   \             Pi                                //   

What Maple type should I use so that test1 and test2 are always equal? (I use Maple 2017)

 

test1 := proc(x) type([op('x')], identical(['x'])) end;
MapleType := anything;
test2 := proc(x) type(x, MapleType) end;

 

Hi everyone,

I'm a beginner in maple and coding in general.

I'm making a model that need to solve a set of linear ODE in maple. Say I have model 1 and model 2.

In model 1, everything works fine and the results I get match with the experiments. However, when I modify model 1 into model 2 by adding 1 additional term multiplied by sigma (a constant) in the set of the ODE, The equations solved by maple produced complex number instead. 

May I know the reason why maple produces complex number as the result?

Please find attached the worksheet. SP1JH1B1.mw

The set of ODE are at the "longitudinal behaviour" section and the ODEs are deq2..6. When I set sigma=0 (basically back to model 1), maple gives me real number solutions again.

If I don't put "evalf" in front of value(dsolve(...)) (see sol_L), Maple produces `[Length of output exceeds limit of 1000000]`

Any help would be greatly appreciated.

Thanks in advance!

Hi,

Is it possible to write the title of a plot on two different lines with different fonts for each line?
For instance:

MyTitle := typeset("Identity function", "\n(illustration));
plot(x, x=0..1, title=MyTitle);

with the upper line  [times, bold, 14]
and the lower one   [times, roman, 12]

 

Hello all,

I am presenting some results in a small meeting tomorrow and I have a rather large symbollic matrix that I was hoping to be able to view in a more readable form (once you see my code, you will see what I mean). This should be a simple fix. Furthermore, when I use the Latex command to recieve code to import into latex, its not working properly, which makes me think I made some kind of mistake. I am really just trying to get this matrix in its full for so that it is easy for other people to read. Thanks for any help.Turns_Latex.mw
 

restart

with(LinearAlgebra)``

A := Matrix(5, 5, [0, 0, 0, 0, 0, -AXX*UU-AXY*VV-AXZ*WW, AXX, AXY, AXZ, 0, -AXY*UU-AYY*VV-AYZ*WW, AXY, AYY, AYZ, 0, -AXZ*UU-AYZ*VV-AZZ*WW, AXZ, AYZ, AZZ, 0, -AXX*UU*UU-AYY*VV*VV-AZZ*WW*WW-(AXY*UU*VV+AXZ*UU*WW+AYZ*VV*WW)*2+(-E+2*UVW)*AE, -AE*UU-VL2, -AE*VV-VL3, -AE*WW-VL4, AE])

A := subs(VL2 = -AXX*UU-AXY*VV-AXZ*WW, VL3 = -AXY*UU-AYY*VV-AYZ*WW, VL4 = -AXZ*UU-AYZ*VV-AZZ*WW, A)

A := subs(AXX = mu*(zeta__x^2+zeta__y^2+zeta__z^2+(1/3)*`#msup(mi("\`zeta__x\`"),mn("2"))`), AYY = mu*(`&zeta;__x`^2+`&zeta;__y`^2+`&zeta;__z`^2+(1/3)*`#msup(mi("\`&zeta;__y\`"),mn("2"))`), AZZ = mu*(`&zeta;__x`^2+`&zeta;__y`^2+`&zeta;__z`^2+(1/3)*`#msup(mi("\`&zeta;__z\`"),mn("2"))`), A)

A := subs(AXY = (1/3)*mu*zeta__x*zeta__y, AXZ = (1/3)*mu*zeta__x*zeta__z, AYZ = (1/3)*mu*zeta__y*zeta__z, A)

A := subs(UU = u, VV = v, WW = w, A)

A := subs(AE = mu*gamma*(`&zeta;__x`^2+`&zeta;__y`^2+`&zeta;__z`^2)/Pr, A)

Matrix(%id = 18446744078321522678)

(1)

latex(A)

 \left[ \begin {array}{ccccc} 0&0&0&0&0\\ \noalign{\medskip}-\mu\,
 \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{\tt
\#msup(mi("zeta}}_{\mbox {{\tt x"),mn("2"))}}}/3 \right) u-1/3\,\mu\,
\zeta_{x}\,\zeta_{y}\,v-1/3\,\mu\,\zeta_{x}\,\zeta_{z}\,w&\mu\,
 \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{\tt
\#msup(mi("zeta}}_{\mbox {{\tt x"),mn("2"))}}}/3 \right) &1/3\,\mu\,
\zeta_{x}\,\zeta_{y}&1/3\,\mu\,\zeta_{x}\,\zeta_{z}&0
\\ \noalign{\medskip}-1/3\,\mu\,\zeta_{x}\,\zeta_{y}\,u-\mu\, \left( {
\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{\tt
\#msup(mi("zeta}}_{\mbox {{\tt y"),mn("2"))}}}/3 \right) v-1/3\,\mu\,
\zeta_{y}\,\zeta_{z}\,w&1/3\,\mu\,\zeta_{x}\,\zeta_{y}&\mu\, \left( {
\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{\tt
\#msup(mi("zeta}}_{\mbox {{\tt y"),mn("2"))}}}/3 \right) &1/3\,\mu\,
\zeta_{y}\,\zeta_{z}&0\\ \noalign{\medskip}-1/3\,\mu\,\zeta_{x}\,\zeta
_{z}\,u-1/3\,\mu\,\zeta_{y}\,\zeta_{z}\,v-\mu\, \left( {\zeta_{x}}^{2}
+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{\tt \#msup(mi("zeta}}_{\mbox
{{\tt z"),mn("2"))}}}/3 \right) w&1/3\,\mu\,\zeta_{x}\,\zeta_{z}&1/3\,
\mu\,\zeta_{y}\,\zeta_{z}&\mu\, \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}
+{\zeta_{z}}^{2}+\mbox {{\tt \#msup(mi("zeta}}_{\mbox {{\tt
z"),mn("2"))}}}/3 \right) &0\\ \noalign{\medskip}-\mu\, \left( {\zeta_
{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{\tt \#msup(mi("zeta}}
_{\mbox {{\tt x"),mn("2"))}}}/3 \right) {u}^{2}-\mu\, \left( {\zeta_{x
}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{\tt \#msup(mi("zeta}}_{
\mbox {{\tt y"),mn("2"))}}}/3 \right) {v}^{2}-\mu\, \left( {\zeta_{x}}
^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{\tt \#msup(mi("zeta}}_{
\mbox {{\tt z"),mn("2"))}}}/3 \right) {w}^{2}-2/3\,\mu\,\zeta_{x}\,
\zeta_{y}\,uv-2/3\,\mu\,\zeta_{x}\,\zeta_{z}\,uw-2/3\,\mu\,\zeta_{y}\,
\zeta_{z}\,vw+{\frac { \left( -E+2\,{\it UVW} \right) \mu\,\gamma\,
 \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2} \right) }{\Pr}
}&-{\frac {\mu\,\gamma\, \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta
_{z}}^{2} \right) u}{\Pr}}+\mu\, \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2
}+{\zeta_{z}}^{2}+\mbox {{\tt \#msup(mi("zeta}}_{\mbox {{\tt
x"),mn("2"))}}}/3 \right) u+1/3\,\mu\,\zeta_{x}\,\zeta_{y}\,v+1/3\,\mu
\,\zeta_{x}\,\zeta_{z}\,w&-{\frac {\mu\,\gamma\, \left( {\zeta_{x}}^{2
}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2} \right) v}{\Pr}}+1/3\,\mu\,\zeta_{x}
\,\zeta_{y}\,u+\mu\, \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}
}^{2}+\mbox {{\tt \#msup(mi("zeta}}_{\mbox {{\tt y"),mn("2"))}}}/3
 \right) v+1/3\,\mu\,\zeta_{y}\,\zeta_{z}\,w&-{\frac {\mu\,\gamma\,
 \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2} \right) w}{\Pr
}}+1/3\,\mu\,\zeta_{x}\,\zeta_{z}\,u+1/3\,\mu\,\zeta_{y}\,\zeta_{z}\,v
+\mu\, \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}+\mbox {{
\tt \#msup(mi("zeta}}_{\mbox {{\tt z"),mn("2"))}}}/3 \right) w&{\frac
{\mu\,\gamma\, \left( {\zeta_{x}}^{2}+{\zeta_{y}}^{2}+{\zeta_{z}}^{2}
 \right) }{\Pr}}\end {array} \right]

 

``


 

Download Turns_Latex.mwTurns_Latex.mw

 

Set of vector mechanics exercises in the plane and space using the result technique in line (combining the key ALT + ENTER) also the unit package using the law of the triangle. It is observed that the solution is totally optimal. I leave your constructive criticism to the community's criteria. I hope that someone will raise an alternative solution using the minimum number of lines but that the students will learn. In spanish.

Ejercicios_de_Vectores_Fuerza_y_Proyecciones_2D_y_3D.mw

Lenin Araujo Castillo

Ambassador of Maple

First 643 644 645 646 647 648 649 Last Page 645 of 2097