Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I have been writing a language translator. I have everything working reasonably well except that when translating abs(expr) with optimize=tryhard, the IntermediateCode converts the abs() into if...then...else statements. This would be fine except the type of the expr is generally a complex number. I need to optimize the code because there is a lot of redundant calculations otherwise.

I can't figure out how to get IntermediateCode from breaking the abs function into if...then...else statements. [My solution so far is to substitute abs with a dummy name and then use the translator to translate the dummy name into an abs statement - That's really not how things should work!]

Any suggestions?

I've included some example test cases of what is going wrong.

with(CodeGeneration)

testproc1 := proc (x) abs(x) end proc

IntermediateCode(testproc1, optimize = tryhard)

Scope( nametab,
  AssignedName(Name("testproc1"), Scope( nametab,
    Procedure(
      ParameterSequence(Declaration(Name("x"), Type(integer))),
      LocalSequence(Declaration(Name("s1"), Type(integer))),
      OptionSequence(),
      ExpressionSequence(),
      StatementSequence(
        If(
          ConditionalPair(LessEqual(Integer(0), Name("x")), StatementSequence(
            Assignment(Name("s1"), Name("x"))
          )),
          ConditionalPair(Less(Name("x"), Integer(0)), StatementSequence(
            Assignment(Name("s1"), Negation(Name("x")))
          )),
          StatementSequence(
            Assignment(Name("s1"), Integer(0))
          )
        ),
        Return(Name("s1"))
      ),
      DescriptionSequence(),
      GlobalSequence(),
      LexicalSequence(),
      Type(integer)
    )
  ))
)

 

testproc2 := proc (x::numeric) abs(x) end proc

IntermediateCode(testproc2, optimize = tryhard)

Scope( nametab,
  AssignedName(Name("testproc2"), Scope( nametab,
    Procedure(
      ParameterSequence(Declaration(Name("x"), Type(numeric))),
      LocalSequence(Declaration(Name("s1"), Type(numeric))),
      OptionSequence(),
      ExpressionSequence(),
      StatementSequence(
        If(
          ConditionalPair(LessEqual(Float(0, 0), Name("x")), StatementSequence(
            Assignment(Name("s1"), Name("x"))
          )),
          ConditionalPair(Less(Name("x"), Float(0, 0)), StatementSequence(
            Assignment(Name("s1"), Negation(Name("x")))
          )),
          StatementSequence(
            Assignment(Name("s1"), Float(0, 0))
          )
        ),
        Return(Name("s1"))
      ),
      DescriptionSequence(),
      GlobalSequence(),
      LexicalSequence(),
      Type(numeric)
    )
  ))
)

 

NULL

testproc3 := proc (x::complex) abs(x) end proc

IntermediateCode(testproc3, optimize = tryhard)

Scope( nametab,
  AssignedName(Name("testproc3"), Scope( nametab,
    Procedure(
      ParameterSequence(Declaration(Name("x"), Type(complex))),
      LocalSequence(),
      OptionSequence(),
      ExpressionSequence(),
      StatementSequence(
        Return(FunctionCall(Name("abs"), ExpressionSequence(Name("x")), unknown))
      ),
      DescriptionSequence(),
      GlobalSequence(),
      LexicalSequence(),
      Type(numeric)
    )
  ))
)

 

NULL

Download intermediate_code_abs.mw

I'm using NLPSolve to minimize a complicated function. It works great, but the answers are not returned in numerical form which I need as they are then input for the next stage of my program.

How to I extract numbers?

S2 := NLPSolve(test, phi1 = 0 .. 2*Pi, phi2 = 1.0*Pi .. 2*Pi);
     S2 := [-1.00000000011810774, 

       [phi1 = 0.773215730257661, phi2 = 5.98741001513872]]
==>The Result is a list and the solutions appear kind of string-like. 

S2[2,1] returns 'phi=0.773...' not the number I need

Dear all 

I have a system of  second order difference equation.

How, can I update the iterate solution and solve the system

System_of_equations.mw

Thank you

Dear all
I would like to verify if the proposed solution u_exact of my partial differential equation defined on \mathbb{R}^2, with zero boundary condition 
I write the  exact solution, how substitute this  to verify that the PDE is satisfied or not. I tried to substitute but I think someting missing. 
Please check ...

solution_pde_check.mwsolution_pde_check.mw

Thank you

restart:

  ra:=2: b1:=1.41: na:=0.7: we:=0.5: eta[1]:=4*0.1: d:=0.5:
  xi:=0.1: m:=na: ea:=0.5: pr:=21: gr:=0.1: R:=0.9323556933:

  PDE1:=ra*(diff(f(x,t),t))=+b1*(1+ea*cos(t))+(1/(R^2))*((diff(f(x,t),x,x))+(1/x)*diff(f(x,t),x));
  IBC:= {D[1](f)(0,t)=0,f(1,t)=0,f(x,0)=0};

2*(diff(f(x, t), t)) = 1.41+.705*cos(t)+1.150367877*(diff(diff(f(x, t), x), x))+1.150367877*(diff(f(x, t), x))/x

 

{f(1, t) = 0, f(x, 0) = 0, (D[1](f))(0, t) = 0}

(1)

sol := pdsolve({PDE1}, IBC, numeric); sol:-plot(f(x, t), t = 1.2, linestyle = "solid", title = "Velocity Profile", labels = ["r", "f"])

 

``

Download pde.mw

for different time plot of f(x,t) in single plot with different color 

acer helped me out last week with converting strings to dates which was very helpful. However now I stumble on 2 other problems:

- I do not succeed to plot DS6 (time difference versus a numeric value) and to not understand why

- in the cvs data sheet the length of the columns is not equal. The empty cells are automatical filled with "". This prevents me to use numelems as it will also take into consideration the cells filled with "". Is there a way to prevent this

As usual I would like to thank you all, power users, for your patience and help

Test.mw

we have recieved lots of great sumissions, but we want your great submission and now you have more time.

 

The deadline for submissions to the Art Gallery and Showcase for the 2023 Maple Conference is rapidly approaching. We really want to see your art! It doesn't have to be incredibly impressive or sophisticated, we just want to see what our community can create! If you've been working on something or have a great idea, you still have a few days to get it together to submit.

A penrose tiling mosaic of that famous Windows 95 background

Submission can be made by email to gallery@maplesoft.com but be sure to visit the visit our Call for Creative Works for details on the format of the submission.

 

Hi all

Let us consider the set [f1=x-y, f2=-x^2+y^2, f3=x*y+x*z, f4=-x*y*z+z^3, f5=x*y^2+y*z^2-z^3] contain homogeneous polynomials in K[x,y,z]. It has the elements of degree 1,2, and 3. Now, we start from degree 1 so we have [x-y]. Now, we go to degree 2. Now, we shall multiply f1 by the variables and add to this set f2 and f3 i.e. we have now

[x-y], [x^2-x*y, x*y-y^2, x*z-y*z, -x^2+y^2, x*y+x*z]

 We have to continue to degree 3 and multiply f1 by all monomials in degree two in k[x,y,z] and multiply f2 and f3 by any variable and add them to f4 and f5 so we have finalyas a output:

[[x-y], [x^2-x*y, x*y-y^2, x*z-y*z, -x^2+y^2, x*y+x*z], [x^3-x^2*y, x^2*y-x*y^2, x^2*z-x*y*z, x*y^2-y^3, x*y*z-y^2*z, x*z^2-y*z^2, -x^3+x*y^2, -x^2*y+y^3, -x^2*z+y^2*z, x^2*y+x^2*z, x*y^2+x*y*z, x*y*z+x*z^2, -x*y*z+z^3, x*y^2+y*z^2-z^3]]. How can I do this automatically by a simple and efficient method in Maple?

 

The Proceedings of the Maple Conference 2022 are up at mapletransactions.org and I hope that you will find the articles interesting.  There is a brief memorial to Eugenio Roanes-Lozano, whom some of you will remember from past meetings. 

The cover image was the "People's Choice" from the Art Gallery, by Paul DeMarco.

This provides a nice excuse to remind you to register at the conference page for the Maple Conference 2023 and in particular to remind you to submit your entries for the Art Gallery.  See you there!  The conference will take place October 26 and 27, and features plenary talks by our own Laurent Bernardin and by Tom Crawford (Oxford, but more widely known as "The Naked Mathematician" for his incredibly popular YouTube videos on mathematical topics). See Tom Rocks Maths for more (or less :)

The deadline for submission to the Proceedings (which will again be published in Maple Transactions) will be Nov 27, one month after the conference ends.  We have put new processes in place to ensure a more timely publication schedule, and we anticipate that the Proceedings will be published in early Spring 2024.

Maple (2023.1) opens regularly but I cannot use "open" or "save" or "save as" and after opening Maple I no longer can close it.

That is a big problem for me.

The issue is on my new laptop Lenovo L13 Yoga with Windows 11.

Any suggestion? Thanks

hi i have a problem where maple dosent have a varible theta inside cos and sin and when i give it a size it dosent solve the equtation 

The function f := x -> (x + 1)*(x^2 + (m - 5)*x - 7*m + 2) satifies
solve(discrim(f(x), x) = 0, m) has three solutions 1, -17, -1
How to find the integer numbers a, b, c, d, k, t so that the function 
f := x -> x^3 + (a*m + b)*x^2 + (c*m + d)*x + k*m+t  satifies the equation 

solve(discrim(f(x), x) = 0, m)  has three  integer numbers m?

Consider the function f:=x-> a*x^2 + b*m*x + x^3 + c*m.
I tried
restart;
f := x -> x^3 + a*x^2 + b*m*x + c*m;
solve(f(x) = 0, m);
g := x -> -x^2*(a + x)/(b*x + c);
solve(diff(g(x), x) = 0, x);

restart;
n := 0;
f := x -> -x^2*(a + x)/(b*x + c);
for a from -10 to 20 do
    for b to 20 do
for c from -10 to 20 do
mydelta := a^2*b^2 - 10*a*b*c + 9*c^2;
if 0 < mydelta and type(mydelta, integer) then
x1 := (-b*a - 3*c + sqrt(a^2*b^2 - 10*a*b*c + 9*c^2))/(4*b):
x2 := -(b*a + sqrt(a^2*b^2 - 10*a*b*c + 9*c^2) + 3*c)/(4*b):
x3 := 0:
if type(x1, integer) and type(x2, integer) and nops({0, x1, x2}) = 3 and type(f(x1), integer) and type(f(x2), integer) then n := n + 1; L[n] := [a, b, c]; end if; end if; end do; end do; end do;
L := convert(L, list);


I get
L := [[-10, 1, 6], [-10, 2, 12], [-9, 3, 5], [-8, 1, 10], [-5, 1, 3], [-4, 1, -6], [4, 1, 6], [5, 1, -3], [6, 3, 20], [7, 1, 15], [8, 1, -10], [8, 1, 12], [9, 3, -5], [10, 1, -6], [10, 1, 12], [12, 1, 18], [14, 1, -4], [15, 1, -9], [18, 1, 20], [18, 3, -10], [18, 3, 4], [20, 1, 2]]

With L[1], solve(discrim(x^3 - 10*x^2 + m*x + 6*m, x) = 0, m) ;
The equation has three integer solutions: 0, 12, -500

Dear all 
I have a PDE, with unknown u(t,x,t) ,  zero boundary condition and initial condition given

I converted the equaiton using finite difference to get a system of algebraic equation 

The system is solved at each time step 
I think i have a problem to update the solution inside the loop. 

I hope find the problem or why the numerical solution is different to exact solution at last time 

System_finite_difference.mw

Thank you for your help 

Hi Everyone; I have plotted two different expressions separately and then shown them in a single graph. From the final display, we can observe that the peak of one expression, A is larger than that of another expression B. Now, the question is, how do I calculate the decrease or increase in the percentage of both curves? This means the peak of expression A is 20%, 8%, or 7% decreases or increases as of expression A.

Help_percentage_inccrease_or_decrease.mw

more explanation, each curve has its maximum point at some value of x, need to calculate that point for each curve. Then, we combined all curves we observed that the peak of each curve is smaller than others, so I am interested to observing that difference in percentage at the maximum value of x.

for reference, I uploading a file of which idea I want to implement for my problem. This is not my problem, but I want to implement it like this.

For_reference.mw

I have written a maple-code that is visualizing cycles or periods of inverse numbers in any base in a coloured plot.

For example 1/13=0,76923 076923 ... (so period-lenght is 6, the cycle-digits are visualized)

Now I would like to run the Maple Code wich produces the plot (via display-comand) on an ipad.

The ipad will be located in a museum or galerie. In the most easily way the user just touch a button on the ipad-screen and the maple-code produces a random plot which is displayed. Later some choosable parameters for the plot are added.

I have make some tests with embedded components in Maple.

So my idea is to do this with maple-player. I read about Maple Player features:

- Interact with applications that make use of embedded components, such as sliders, buttons, and math entry boxes. Maple will perform the computations and display updated results and visualizations

Questions:

1) how do I run Maple code in Maple Player (a little example with a button- and a plot-component will help)

2) do I need to upgrade Maple 2021  to do that ?

3) What does a mapleplayer license cost for each ipad ?

Thanks for support :)

First 50 51 52 53 54 55 56 Last Page 52 of 2097