MaplePrimes Questions

transparent_background_in_plots.mw

Is there a better way to impletment a transparent background when genereating plots?

Here I generate a plot with a yellow background.

plot(sin(x), x = 0 .. 4*Pi, background = yellow);


I want the background to be completely transparent instead of yellow.

plot(sin(x), x = 0 .. 4*Pi, background = none);

Error, (in plot) Unable to find image file, none

none is not an accepted color, so an error is returned. Is there such a color as "clear" that is fully transparent? Is there a better way to impletment a transparent background when genereating plots?

As we know, when every Gi is normal in G, then the series is called a normal series:

cs := CompositionSeries(DihedralGroup(8))

We can draw it:

DrawSubgroupLattice(DihedralGroup(8), labels = ids, highlight = cs)

And all Gi is normal in G:

IsNormal~(cs, DihedralGroup(8))

[true, true, true, true, true]

But why type(cs, 'NormalSeries') will get false.. It is a bug or do I have a misunderstanding?

I am still struggling understanding Maple Object  inheritance due to lack of good examples and sparse documenation.

This is what I am trying to do. I have base class Person, and then make Employee class which extends Person class and adds new field.   

The constructor to the Employee class then needs to call the constructor to the Person class (its base class) in order to initialize it. The base class constuctor takes care of initialization the fields in the base class.

I do not know how to do this. Actually it is not clear to me how the proto argument gets into play in all of this. I could not find one example that explains how to use proto with inheritance.

I am trying to implement this python example. I will show the code for the Python, and my Maple translation. The part I do not know how to do, it how to call the constructor for the base class from the sub class.  If I do not do this, then the fields of the base class will remain unitilized.

Python example is from https://www.geeksforgeeks.org/python-access-parent-class-attribute/

# parent class 
class Person( object ):     
    
        # __init__ is known as the constructor          
        def __init__(self, name, idnumber):    
                self.name = name 
                self.idnumber = idnumber 
                  
        def display(self): 
                print(self.name) 
                print(self.idnumber) 
    
# child class 
class Employee( Person ):            
        def __init__(self, name, idnumber, salary): 
                self.salary = salary 
    
                # invoking the constructor of the parent class  
                #----->>>>> HOW TO DO THIS IN MAPLE?
                Person.__init__(self, name, idnumber)  
          
        def show(self):
            print(self.salary)

# creation of an object
# variable or an instance 
a = Employee('Rahul', 886012, 30000000)     
    
# calling a function of the
# class Person using Employee's
# class instance 
a.display()
a.show() 

Here is the Maple code

restart;
person:=module() 
    option object; 
    #I made these exported instead of local for ease of printing from outside while
    #debugging , that is all.. These should otherwise be local

    export idnumber::integer:=0;  
    export name::string:="";  

    export ModuleCopy::static:= proc( _self, proto, name::string, idnumber::integer, $) 
        _self:-idnumber := idnumber;
        _self:-name := name;
    end proc;
 
end module; 
#---- extend the above class 

employee:=module() 
    option object(person); 
    export salary::integer:=0;  

    ModuleCopy::static:= proc( _self, proto, name::string, idnumber::integer, salary::integer , $) 
        _self:-salary := salary;
        # invoking the constructor of the parent class  
        # How to do that in Maple?

        #I could always manually do this. But I do not want to duplicate the code
        #done by the base class constructor.
        #_self:-name := name;
        #_self:-idnumber := idnumber;
        
    end proc;
 
end module; 

 

How does one do the Python example in Maple?

Someone should write a book on programming using OOP in Maple. I'll buy a copy in advance.

Maple 2022.1

How does one compute the location of the minimum algebraically (rather than numerically) of the following expression:
F:=((z^2+(z^2+2*z+2)^(1/2)*(z^2+1)^(1/2)+z+1)^(1/2)*(-z^2+(z^2-2*z+2)^(1/2)*(z^2+1)^(1/2)+z-1)^(1/2)-(z^2+(z^2-2*z+2)^(1/2)*(z^2+1)^(1/2)-z+1)^(1/2)*(-z^2+(z^2+2*z+2)^(1/2)*(z^2+1)^(1/2)-z-1)^(1/2)+2*z)/(2*z^2+2);

Write a Maple procedures called “biggest4” and “smallest4” to find
a) the biggest
b) the smallest
of the given numbers  a = -1/3, b = 0, c = 7/3, d = -2

i guess i need to use end proc for programing but i dont understand:

I have set of graphs say with names

Graph1,Graph2,..., Graph50.

1) I want to print all these using a single for.

2) I want to check the Isomorphic property of which two are all Isomorphic pairwise using a for loop say 

Or if any other methods kind help with suitable advice.

i need to use two different methods to solve the initial value problem. I tried but didnt find the answer 

y" + 4y' + 4y = sin(x), y(0) = 1 , y'(0) = 0

y" + 4*diff(y(x), x) + 4*y(x) = sin(x)

dsys1 := {diff(y(x), x, x) + diff(y(x), x) + 4*y(x) = sin(x), y(0) = 1, D(y)(0) = 0};
dsol1 := dsolve(dsys1, numeric, method = gear);
dsol1(0);

 y = ax^3 + bx^2 + cx + d this is curve and is passing through the points (−1,−4),(1,0),(2,0),(3,−4).
1) Find the values of 𝑎,𝑏,𝑐 and 𝑑.
2) Plot the curve and the points given on the same axis.

I tried solving with derivative of the curve but i didnt find the exact values.

I need to make my base class local variable static, so that when extending the class, the subclass will share these variable and use their current values as set by the base class. If I do not make them static, then the base class when extended, will get fresh instance of these variable, losing their original values, which is not what I want.

To do this, one must make the base class variables static

This works, but now I do not know the syntax where to put the type on the variable. 

I can't write   local m::integer::static; nor local m::static::integer;

I could only write local m::static; but this means I lost the ability to have a type on the variable and lost some of the type checking which is nice to have in Maple. From Maple help:

 

Here is example

restart;

base_class:=module()
  option object;
  local n::static;  #I want this type to ::integer also. But do not know how

  export set_n::static:=proc(_self,n::integer,$)
     _self:-n := n;
  end proc;
  
  export process::static:=proc(_self,$)
    local o;
    o:=Object(sub_class);
    o:-process();
  end proc;
end module;    

sub_class:=module()
   option object(base_class);
   process:=proc(_self,$)
      print("in sub class. _self:-n = ",_self:-n);
   end proc;
end module;

o:=Object(base_class);
o:-set_n(10);
o:-process()


            "in sub class. _self:-n = ", 10

The above is all working OK. I just would like to make n in the base class of type ::integer as well as ::static

Is there a syntax for doing this?

 

Could any one please guide me how to show this solution by using Newton Raphson method. I need to show this solution step by step as shown in example.

Hi Community, I have solved the some basic expression by using built in command to get solution. Now i am interested to view the solution stp by step to show  my students of grade 10.

restart

t := x^6+2*x^5-3*x+2+(2*x^6-4*x+8)

3*x^6+2*x^5-7*x+10

(1)

p := 2*x^2-x-10

2*x^2-x-10

(2)

factor(p)

(x+2)*(2*x-5)

(3)

s := 2*x^2-x-10

2*x^2-x-10

(4)

solve(s = 0, {x})

{x = 5/2}, {x = -2}

(5)

sqrt(x-4) = 4

(x-4)^(1/2) = 4

(6)

solve(sqrt(x-4) = 4, {x})

{x = 20}

(7)

s := (x^2-9)/(x^2-2*x-15)

(x^2-9)/(x^2-2*x-15)

(8)

simplify(%)

(x-3)/(x-5)

(9)

(3*x^2-5*x)*(4*x^2+7*x+4)

(3*x^2-5*x)*(4*x^2+7*x+4)

(10)

expand(%)

12*x^4+x^3-23*x^2-20*x

(11)

``

Solving a system of equations:

x+2*y = 4

x+2*y = 4

(12)

3*x+4*y = 6

3*x+4*y = 6

(13)

solve({x+2*y = 4, 3*x+4*y = 6}, {x, y})

{x = -2, y = 3}

(14)

abs(3*x+3) = 12

3*abs(x+1) = 12

(15)

``

solve(abs(3*x+3) = 12, {x})

{x = 3}, {x = -5}

(16)

``

Download Help_to_view_solution_step_by_step.mw

Perhaps someone knows this. So I came across something recently and I can't recall if it was in this forum (which I can't find)

It was a value using some combinations of the constants e and Pi where the answer was very close to a whole number x.99939 or something.  The only thing I can remember is that it was exp(Pi)*...  I thought it was an answer written by Joe Riel where someone would use that to verify if the floating points... well I can't recall. 

Would anyone have an idea?

Do you know why increasing the number of applications of trapezoidal rule results infinity and imaginary part?

I want get result for Romberg Integration Method with 6 Applications of Trapezoidal Rule.

restart

with(Student[NumericalAnalysis]):

``

fff := (eta__1^2-1.)^2*(zeta__1^2-1.)^2*(-5.6584306313*10^(-8)*eta__1^4*zeta__1^4-1.0454641424*10^(-8)*eta__1*zeta__1^4+5.6161016651*10^(-9)*eta__1^3*zeta__1^4+1.0615594865*10^(-8)*eta__1^5*zeta__1^4+5.4851856568*10^(-9)*eta__1^3*zeta__1^2-1.4132765167*10^(-8)*eta__1^5*zeta__1^2-7.8157365683*10^(-7)*zeta__1*eta__1^4+2.9373057668*10^(-8)*eta__1^5*zeta__1^5-7.032574429*10^(-8)*eta__1^3*zeta__1^5-5.2577413654*10^(-8)*eta__1^5*zeta__1^3+2.3272955826*10^(-8)*eta__1^5*zeta__1+1.5782217112*10^(-7)*eta__1^3*zeta__1^3+2.1771522925*10^(-8)*eta__1*zeta__1^5-8.3051507888*10^(-8)*eta__1^3*zeta__1-2.2997952126*10^(-8)*eta__1*zeta__1^3+0.22608138853e-5*eta__1^4-0.53519692056e-5*eta__1^2+0.62041471332e-4+0.54946587424e-4*zeta__1^2-0.10412827312e-5*zeta__1^4-0.53422910417e-5*zeta__1^3+0.12053033309e-3*zeta__1-4.5961086182*10^(-8)*eta__1^2*zeta__1^4-1.6404108106*10^(-7)*zeta__1^2*eta__1-1.5606093643*10^(-7)*zeta__1*eta__1^2-4.168658171*10^(-7)*zeta__1*eta__1-0.5430102455e-5*eta__1^2*zeta__1^5+0.87015148204e-5*eta__1^2*zeta__1^3+0.25592467903e-5*eta__1^4*zeta__1^5-0.4071733639e-5*eta__1^4*zeta__1^3-0.44664222239e-5*eta__1^4*zeta__1^2+0.84495460425e-5*eta__1^2*zeta__1^2+7.5007400675*10^(-7)*zeta__1^5-6.6427826628*10^(-9)*eta__1^3+3.5821686059*10^(-9)*eta__1^5-2.4361928132*10^(-7)*eta__1)/(-0.32350168299e-2*eta__1^5-0.40854298828e-3*zeta__1^8-0.57170204466e-1*eta__1^8+.26989142602*zeta__1^7+.34307133883*eta__1^6+.14111119517*eta__1^4-0.48267577378e-1*zeta__1^9-1.082755589*eta__1^2-1.3163499567*zeta__1^2+0.75042415188e-3*eta__1^7-0.40463518464e-2*zeta__1^6+.66506159208*zeta__1^4+.58641863992*zeta__1^3-0.18089939414e-3*eta__1^9-.60151130424*zeta__1^5+0.49423587807e-2*eta__1^3-0.22768667085e-2*eta__1-.20653118433*zeta__1-.15635457174*eta__1^8*zeta__1+.64029273264*eta__1^8*zeta__1^3-1.8403657443*eta__1^6*zeta__1^7-0.48478855017e-1*eta__1^8*zeta__1^4-0.22007436935e-2*eta__1^2*zeta__1^8+0.56271163518e-2*eta__1^4*zeta__1^8-.22701198791*eta__1^6*zeta__1^6-0.18753531811e-2*eta__1*zeta__1^9+0.63616448215e-2*eta__1^3*zeta__1^9-0.70972300998e-2*eta__1^5*zeta__1^9+0.26109384594e-2*eta__1^7*zeta__1^9+0.37597513815e-2*eta__1^9*zeta__1^7-.81152175007*eta__1^8*zeta__1^5+.32758358916*eta__1^8*zeta__1^7+.60516338422*eta__1^6*zeta__1-2.7777061884*eta__1^6*zeta__1^3+3.8764153863*eta__1^6*zeta__1^5+0.14976271107e-3*eta__1*zeta__1^8+0.64408301026e-3*eta__1^3*zeta__1^8-0.17374541537e-2*eta__1^5*zeta__1^8+0.9436084324e-3*eta__1^7*zeta__1^8-0.95617026598e-3*eta__1*zeta__1^6-0.79980551762e-3*eta__1^3*zeta__1^6-0.43427014208e-2*eta__1^7*zeta__1^6+0.52833995188e-2*eta__1^5*zeta__1^6-0.39563328597e-2*eta__1^7*zeta__1^2-0.30978282387e-2*zeta__1*eta__1+3.4563944947*eta__1^2*zeta__1^5-2.669958003*eta__1^2*zeta__1^3-5.9197768267*eta__1^4*zeta__1^5+4.2209528188*eta__1^4*zeta__1^3+.1920464905*eta__1^4*zeta__1^2+1.9334990569*eta__1^2*zeta__1^2+0.66050016962e-2*eta__1^7*zeta__1^4+.80614880365*eta__1^6*zeta__1^4-.9191903249*eta__1^6*zeta__1^2-1.724981418*zeta__1^7*eta__1^2+2.9678721471*zeta__1^7*eta__1^4-.94779423754*zeta__1*eta__1^4+.46301464814*zeta__1^6*eta__1^4-.22761063366*zeta__1^6*eta__1^2-0.85894534062e-2*eta__1^5*zeta__1^4+0.8278524871e-2*eta__1^5*zeta__1^2+0.46097207851e-2*eta__1^3*zeta__1^4-0.93963570584e-2*eta__1^3*zeta__1^2-0.81381430978e-3*eta__1*zeta__1^4-.62093209055*eta__1^2*zeta__1^4-.80179945016*eta__1^4*zeta__1^4+.70551660939*zeta__1*eta__1^2+0.38970885732e-2*zeta__1^2*eta__1+0.10746052526e-1*eta__1*zeta__1^7-0.40389225121e-1*eta__1^3*zeta__1^7+0.52300044044e-1*eta__1^5*zeta__1^7+.10999473421*eta__1^8*zeta__1^2-0.45528793761e-1*eta__1^7*zeta__1^3+0.57167454208e-1*eta__1^7*zeta__1^5+0.11770764739e-2*eta__1^9*zeta__1^2-0.18114547653e-2*eta__1^9*zeta__1^4+0.81527768559e-3*eta__1^9*zeta__1^6+0.13191002642e-1*eta__1*zeta__1^3+0.14324735033e-1*eta__1^3*zeta__1-0.18963873748e-1*eta__1*zeta__1^5-0.56315405543e-1*eta__1^3*zeta__1^3-0.21374958034e-1*eta__1^5*zeta__1+0.7601825081e-1*eta__1^3*zeta__1^5+.65574325943+0.80855499912e-1*eta__1^5*zeta__1^3-.10468335582*eta__1^5*zeta__1^5-0.26416622831e-1*eta__1^7*zeta__1^7-0.20189726843e-2*eta__1^9*zeta__1+0.77976967502e-2*eta__1^9*zeta__1^3-0.95384754473e-2*eta__1^9*zeta__1^5+.13649316215*eta__1^6*zeta__1^9+.23302831691*eta__1^2*zeta__1^9-.32125390168*eta__1^4*zeta__1^9+0.12167023924e-1*eta__1^7*zeta__1-0.301782967e-2*eta__1^6*zeta__1^8-0.43456747248e-2*eta__1^8*zeta__1^6):

plot3d(sqrt(fff), zeta__1 = -1 .. 1, eta__1 = -1 .. 1, color = green)

 

``

Quadrature(Quadrature(sqrt(fff), zeta__1 = -1 .. 1, method = romberg[3]), eta__1 = -1 .. 1, method = romberg[3])

0.2745463666e-1+0.*I

(1)

Student:-NumericalAnalysis:-Quadrature(Student:-NumericalAnalysis:-Quadrature(sqrt(fff), zeta__1 = -1 .. 1, method = romberg[4]), eta__1 = -1 .. 1, method = romberg[4])

0.3314502549e-1+0.*I

(2)

Student:-NumericalAnalysis:-Quadrature(Student:-NumericalAnalysis:-Quadrature(sqrt(fff), zeta__1 = -1 .. 1, method = romberg[5]), eta__1 = -1 .. 1, method = romberg[5])

0.3621732017e-1+0.*I

(3)

Student:-NumericalAnalysis:-Quadrature(Student:-NumericalAnalysis:-Quadrature(sqrt(fff), zeta__1 = -1 .. 1, method = romberg[6]), eta__1 = -1 .. 1, method = romberg[6])

Float(undefined)+Float(undefined)*I

(4)

``

Download question.mw

Hi,

One of my areas of expertise is in Designer Filters EMC. Could any professional that already uses MapleFlow for EMC and Electromagnetism, help me about the main functions of this amazing software?

Thanks.

Leandro Zamaro

A small annoyance, when some code is copied from mapleprimes and pasted into Maple (the standard windows copy-paste ctrl+c   ctrl+v) and executed.  The code doesn't execute properly. 

For example

cprint:=proc(s,c)
nprintf("#mo(%A,mathcolor=\"%A\")",s,c):
end proc:

cprint("this is green",green);#prints green

cprint("this is green",red);#prints red

copying and pasting the above code in Maple and executing results in the following output

                                              

Not sure why?

First 184 185 186 187 188 189 190 Last Page 186 of 2308