gulliet

241 Reputation

6 Badges

16 years, 238 days

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by gulliet

Let assume that the entries are a list of lists that denotes the height z, i.e. [[3, 2, 1, 1], [2, 2, 1], [1, 1]]. Then, we transform it (manually in the example below) in a list of x-, y-, z-coordinates (for a given point, the x-coordinate is equal to its row index, and, similarly, the y-coordinate is equal to its column index). Finally, we plot the diagram thanks to the function polyhedraplot. > with(plots); > polyhedraplot([[1, 1, 3], [1, 2, 2], [1, 3, 1], [1, 4, 1], [2, 1, 2], [2, 2, 2], [2, 3, 1], [3, 1, 1], [3, 2, 1]], polyscale = .5, polytype = hexahedron, scaling = CONSTRAINED, orientation = [20, 70]); 97_FerrersDiagram.jpg HTH, -- Jean-Marc
One possible way, which uses functional programming, is as follows:
restart;

myInt := proc(fun, var, n)
  foldl((f, v) -> int(f, v), fun, seq(var, i = 1..n));
end proc:

myInt(sin(x)*exp(x), x, 2);

                                1              
                              - - cos(x) exp(x)
                                2              

seq(myInt(sin(x)*exp(x), x, i), i = 1..4);

            1                 1                  1                
          - - cos(x) exp(x) + - sin(x) exp(x), - - cos(x) exp(x), 
            2                 2                  2                

              1                 1                  1              
            - - cos(x) exp(x) - - sin(x) exp(x), - - sin(x) exp(x)
              4                 4                  4              
Regards, -- Jean-Marc
Also, you may want to convert the abs() into piecewise() and set discont = true in the graphs.
convert(abs(x^2-6*x+5), piecewise);

                         /  2                       
                         | x  - 6 x + 5       x <= 1
                         |                          
                         |   2                      
                        <  -x  + 6 x - 5      x < 5 
                         |                          
                         |  2                       
                         | x  - 6 x + 5       5 <= x
                         \                          

f := unapply(%, x);
Df := unapply(diff(f(x), x), x);
DDf := unapply(diff(Df(x), x), x);

                     /         2                     2                    
  f := x -> piecewise\x <= 1, x  - 6 x + 5, x < 5, -x  + 6 x - 5, 5 <= x, 

     2          \
    x  - 6 x + 5/
Df := x -> piecewise(x < 1, 2 x - 6, x = 1, undefined, x < 5, -2 x + 6, x = 5, 

  undefined, 5 < x, 2 x - 6)
DDf := x -> piecewise(x < 1, 2, x = 1, undefined, x < 5, -2, x = 5, undefined, 

  5 < x, 2)

a := plot(f(x), x = -2 .. 7, y = -10 .. 10):
b := plot(Df(x), x = -2 .. 7, y = -10 .. 10, 
    discont = true, linestyle = 2):
c := plot(DDf(x), x = -2 .. 7, y = -10 .. 10, 
    discont = true, linestyle = 3):
display([a, b, c], title = 
    `function in solid, 1st deriv in dotted, 2nd deriv dashed`);
97_multipleplotfirstsecondderivdiscont.jpeg Regards, -- Jean-Marc
restart; with(plots):
f := proc (x) options operator, arrow; sin(x^2-7*x+3) end proc; 
Df := unapply(diff(f(x), x), x); 
_EnvAllSolutions := true; 
critpts := solve(Df(x) = 0, x); 
indets(critpts[1]);
                                      / 2          \
                         f := x -> sin\x  - 7 x + 3/
                                 / 2          \          
                   Df := x -> cos\x  - 7 x + 3/ (2 x - 7)
                          _EnvAllSolutions := true
                          7   1                       (1/2)  
               critpts := - + - (37 + 4 Pi _Z1 + 2 Pi)     , 
                          2   2                              

                 7   1                       (1/2)  7
                 - - - (37 + 4 Pi _Z1 + 2 Pi)     , -
                 2   2                              2
                     /                           (1/2)\ 
                    { _Z1, (37 + 4 Pi _Z1 + 2 Pi)      }
                     \                                / 

a := plot(f(x), x = 0 .. 6); 
b := plot(Df(x), x = 0 .. 6, linestyle = 2); 
c1 := plot([subs({_Z1 = -3}, critpts[1]), t, t = -6 .. 6], color = green); 
c2 := plot([subs({_Z1 = -3}, critpts[2]), t, t = -6 .. 6], color = green); 
c3 := plot([critpts[3], t, t = -6 .. 6], color = green); 
c4 := plot([subs({_Z1 = -2}, critpts[2]), t, t = -6 .. 6], color = green); 
c5 := plot([subs({_Z1 = -1}, critpts[2]), t, t = -6 .. 6], color = green); 
c6 := plot([subs({_Z1 = 0}, critpts[2]), t, t = -6 .. 6], color = green); 
c7 := plot([subs({_Z1 = -2}, critpts[1]), t, t = -6 .. 6], color = green); 
display([a, b, c1, c2, c3, c4, c5, c6, c7], 
title = `function in solid, derivative in dotted`);
97_multipleplotfirstsecondderiv.jpeg Regards, -- Jean-Marc
Before going any further, could you check that the expressions below are actually what you intend to work with. (Note that I have fixed several syntax errors and assumed that "nt" stands for "int".) By the way, what are "c" and "t"? Also, my understanding is that you do not have any equation but an integral that must be computed and then plotted, perhaps thanks to the function plot3d(), am I right?
restart;
g := wp*sqrt((w^2-wp^2)/wh^2-w^2)/c; 
varphi := (1/2)*w*t; 
Phi0 := sin((1/2)*w*t)/((1/2)*w*t);

                                               (1/2)
                                / 2     2     \     
                                |w  - wp     2|     
                             wp |-------- - w |     
                                |    2        |     
                                \  wh         /     
                        g := -----------------------
                                        c           
                                         1    
                               varphi := - w t
                                         2    
                                         /1    \
                                    2 sin|- w t|
                                         \2    /
                            Phi0 := ------------
                                        w t     

A := int((exp(-(1/4)*g^2*l^2)/g*((w^2+c^2*g^2)/(wh^2-
w^2)))*Phi0*(sin(w*y-x+varphi)+sin(w*y+x+varphi)), w = wp .. wh);
        /                                       /     /  
        |                                       |     |  
        |                                       |     |  
        |                                       |     |  
        |                  1                    |     |  
A := int|-------------------------------------- |2 exp|- 
        |                  (1/2)                |     |  
        |   / 2     2     \                     \     \  
        |   |w  - wp     2|      /  2    2\              
        |wp |-------- - w |      \wh  - w / w t          
        |   |    2        |                              
        \   \  wh         /                              

      / 2     2     \   \                                                     
    2 |w  - wp     2|  2|                                                     
  wp  |-------- - w | l |                                                     
      |    2        |   |   /         / 2     2     \\                        
      \  wh         /   |   | 2     2 |w  - wp     2||    /1    \ /   /       
  ----------------------| c |w  + wp  |-------- - w || sin|- w t| |sin|w y - x
              2         |   |         |    2        ||    \2    / \   \       
           4 c          /   \         \  wh         //                        

                                   \              \
                                   |              |
                                   |              |
                                   |              |
     1    \      /          1    \\|              |
   + - w t| + sin|w y + x + - w t|||, w = wp .. wh|
     2    /      \          2    //|              |
                                   /              |
                                                  |
                                                  |
                                                  |
                                                  /
Regards, -- Jean-Marc
The constant Pi is written Pi, whereas pi is just the greek letter pi without any numeric value associated to it.
> evalf(Pi);

                                 3.141592654
> evalf(pi);

                                     pi
Regards, -- Jean-Marc
Use Pi (with a capital P) instead of pi (which is just the greek letter without any specific meaning).
> evalf(Pi);

                                 3.141592654
> evalf(pi);

                                     pi

Regards, -- Jean-Marc
You should have a look at the function msolve(). See help("msolve") for more info and examples. [EDITED] One possible way:
> sols := msolve(x^i = 4, 12);

  sols := {i = 1, x = 4}, {i = 2, x = 2}, {i = 2, x = 4}, {i = 2, x = 8}, 

    {i = 2, x = 10}, {i = 3, x = 4}, {i = 3, x = 10}, {i = 4, x = 2}, 

    {i = 4, x = 4}, {i = 4, x = 8}, {i = 4, x = 10}, {i = 5, x = 4}, 

    {i = 5, x = 10}, {i = 6, x = 2}, {i = 6, x = 4}, {i = 6, x = 8}, 

    {i = 6, x = 10}, {i = 7, x = 4}, {i = 7, x = 10}, {i = 8, x = 2}, 

    {i = 8, x = 4}, {i = 8, x = 8}, {i = 8, x = 10}, {i = 9, x = 4}, 

    {i = 9, x = 10}, {i = 10, x = 2}, {i = 10, x = 4}, {i = 10, x = 8}, 

    {i = 10, x = 10}, {i = 11, x = 4}, {i = 11, x = 10}

> map(proc (s) options operator, arrow; subs(s, x^i) end proc, {sols});

{4, 16, 64, 100, 256, 1000, 1024, 4096, 10000, 16384, 65536, 100000, 262144, 

  1000000, 1048576, 4194304, 10000000, 16777216, 100000000, 1000000000, 

  1073741824, 10000000000, 100000000000}

Regards, -- Jean-Marc
Assuming you want you to use the piecewise command (see help("piecewise") for more info), defining a multivariate function can be done as follows:
f := (x, y) -> piecewise(x <> 0 and y > 0, sin(x*y)/x, 0);
For instance, 97_definingmultivariatepiecewisefun.jpg Regards, -- Jean-Marc
> restart; with(Optimization); 
datax := [10, 15, 20, 25, 30, 45, 60, 90, 120, 150, 180]; 
datay := [428, 334.1, 280.7, 262.7, 242.4, 212.9, 182.2, 151, 130.5, 116.9, 109.5]; 
tau := 1; 
model := N1*exp(lambda1*(t-tau))+N2*exp(lambda2*(t-tau)); 
residuals := [sum((datay[i]-(eval(model, t = datax[i])))^2, i = 1 .. nops(datax))]; 
NLPSolve((428-N1*exp(9*lambda1)-N2*exp(9*lambda2))^2+
(334.1-N1*exp(14*lambda1)-N2*exp(14*lambda2))^2+
(280.7-N1*exp(19*lambda1)-N2*exp(19*lambda2))^2+
(262.7-N1*exp(24*lambda1)-N2*exp(24*lambda2))^2+
(242.4-N1*exp(29*lambda1)-N2*exp(29*lambda2))^2+
(212.9-N1*exp(44*lambda1)-N2*exp(44*lambda2))^2+
(182.2-N1*exp(59*lambda1)-N2*exp(59*lambda2))^2+
(151-N1*exp(89*lambda1)-N2*exp(89*lambda2))^2+
(130.5-N1*exp(119*lambda1)-N2*exp(119*lambda2))^2+
(116.9-N1*exp(149*lambda1)-N2*exp(149*lambda2))^2+
(109.5-N1*exp(179*lambda1)-N2*exp(179*lambda2))^2, 
initialpoint = {N1 = 1.122*10^3, N2 = 1.2830*10^3, 
lambda1 = -0.39e-1, lambda2 = -.326}, method = sqp);


 [439.485735349365996, 
    [N1 = 257.198668654980509, 
    N2 = 531.115292604514593, 
    lambda1 = -0.00532918849969983306, 
    lambda2 = -0.119870376119667749]]


Regards, -- Jean-Marc
restart;
pol:=(-1)^n/(2^n*n!)*(1 - x)^(-a) * (1 + x)^(-b) *diff((1 - x)^(a+n)* 
(1 + x)^(b+n),x$n):
Lx:=unapply(pol,n,a,b):
theta1(2) := Lx(2,0,0):
convert(theta1(2),sum);

              1        2   1                        1        2
              - (1 - x)  + - (-2 + 2 x) (2 x + 2) + - (1 + x) 
              4            4                        4         

Regards, -- Jean-Marc
If I have made no mistake in translating from Maple to Mathematica, here is what is returned by Mathematica 6.0.3: 97_doubleintefrommathemarica603.jpg Regards, -- Jean-Marc
Not exactly the form you are looking for but here is a possible method. You can pass side assumptions to simplify(), for instance, {alpha+beta = 1} and use assuming for the rest of the constraints.
simplify(simplify((beta*p-beta-p)*alpha/(p*(beta-1)),{alpha+beta = 1}))
assuming 0 < alpha, alpha < 1, 0 < beta, beta < 1;

                             1 + alpha p - alpha
                             -------------------
                                      p         
HTH, -- Jean-Marc
You are missing a parenthesis in the definition of PDE: write D((diff(u(t, z), `$`(z, 2*z)))*z) rather than D*(diff(u(t, z), `$`(z, 2*z)))*z).
PDE := diff(u(t, z), t)-v*(diff(u(t, z), z)) = 
D((diff(u(t, z), `$`(z, 2*z)))*z)-k*u(t, z)
Regards, -- Jean-Marc
> restart;
> f := proc (x, d) options operator, arrow; sin(x^2+d^2) end proc;

                                           / 2    2\
                         f := (x, d) -> sin\x  + d /

> mtaylor(f(x, d), [x = 0, d = 0], 4);

                                    2    2
                                   x  + d 
> help("mtaylor");
Regards, -- Jean-Marc
1 2 3 4 5 6 7 Last Page 2 of 10