acer

32333 Reputation

29 Badges

19 years, 322 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Here is interpolation by piecewise splines. Using Maple 2019.1.

The interpolated curve is red. The first derivative of that interpolated curve is black. The orange diamonds indicate interior inflection points of that interpolated curve.

If you use a different method of curve-fitting then your interpolant (and its inflection points) may not be the same. That's a mathematical consequence, not a Maple quirk.

restart;

x := [ 7.0, 7.2, 7.4 ,7.6, 8.4, 8.8, 9.2, 9.6, 10.0,10.4,10.8,11.2]:
y := [ 0.692, 0.719, 0.723, 0.732, 0.719, 0.712,
       1.407, 1.714, 1.99,2.118, 2.305, 2.711]:

F:=Interpolation:-Interpolate(x,y,method=spline,degree=3):

plots:-display(
  plot(<<x>|<y>>,style=point,color=blue),
  plot(F,x[1]..x[-1]),
  size=[600,300]
);

pts:=Student:-Calculus1:-InflectionPoints('F'(t),t=x[1]..x[-1],numeric);

[7.349175938, 7.765875858, 8.461873414, 9.031452528, 9.511908737, 9.788460565, 10.31049449]

plots:-display(
  plot(<<x>|<y>>,style=point,color=blue),
  plot(<<pts>|<map(F,pts)>>,style=point,color="Orange",
       symbol=soliddiamond,symbolsize=20),
  plot(<<pts>|<map(D[1](F),pts)>>,style=point,color="Orange",
       symbol=diamond,symbolsize=20),
  plot(D[1](F),x[1]..x[-1],color=black),
  plot(F,x[1]..x[-1]),
  size=[600,300]
);

 

Download spline_interp.mw

Assigning values to some of the variables is not necessary for your problem. It is not really "substitution", nor does it create equations. It often just gets in the way or, in your case, leads to a circular muddle.

Equations are perfectly good expressions in Maple, and very useful. For example, step by step,

restart;

eqn := totalsalesx = 60.1 + tax + profit;

totalsalesx = 60.1+tax+profit

eval(eqn, [tax=0.3*profit]);

totalsalesx = 60.1+1.3*profit

eval(%, [profit=0.1*totalsalesx]);

totalsalesx = 60.1+.13*totalsalesx

solve({%});

{totalsalesx = 69.08045977}

eval(totalsalesx, %);

69.08045977

 

Download substitutions_eval.mw

Above, I used an equation for the solving step. And the substitutions were done using the other equations (with the eval command). None of your key variables profit, tax, or totalsalesx had to be assigned. Even the result from solve is an equation, which in turn can be used in eval.

There are lots of ways to do this. Here's another variant.

restart;

eqn1 := totalsalesx = 60.1 + tax + profit;

totalsalesx = 60.1+tax+profit

eqn2 := tax=0.3*profit;

tax = .3*profit

eqn3 := profit=0.1*totalsalesx;

profit = .1*totalsalesx

neweqn := eval(eqn1, eqn2);

totalsalesx = 60.1+1.3*profit

eval(neweqn, eqn3);

totalsalesx = 60.1+.13*totalsalesx

solve({%});

{totalsalesx = 69.08045977}

eval(totalsalesx, %);

69.08045977

 

Download substitutions_eval2.mw

This is not expert stuff. It is basic Maple praxis, worth learning.

 

If you want the same color scheme for both, and if you're willing to accept more of a density-plot style, then here is an easy way.

You could, of course, also merge the bottom 2D layer with contour lines, and also raise that to the height of the surface. (Neither of those is especially complicated -- Kitonum's shown you that way.)

restart;

lambda := 2*(1/10):

mu := -1:

beta := 10:

alpha := -25:

C := 1:

k := (1/12)*sqrt(6)/sqrt(beta*lambda*mu):

w := alpha/((10*sqrt(-lambda*mu))*beta):

A[0] := (1/2)*alpha/((10*sqrt(-lambda*mu))
                     *((1/12)*beta*sqrt(6)/sqrt(beta*lambda*mu))):

A[1] := -(1/10)*alpha/((1/12)*beta*mu*sqrt(6)
                       /sqrt(beta*lambda*mu)):

A[2] := -(12*((1/12)*sqrt(6)/sqrt(beta*lambda*mu)))
        *lambda^2*alpha/(10*sqrt(-lambda*mu)):

H := ln(sqrt(lambda/(-mu))*tanh(sqrt(-lambda*mu)*(xi+C))):

xi := k*x-t*w:

u[0] := A[0]+A[1]*exp(-H)+A[2]*exp(-H)*exp(-H):

scheme1 := ["zgradient",["Blue","Cyan","Green","Yellow","Orange","Red"]]:

P3:=plot3d(min(40,max(-40,Im(u[0]))), x=-10..10, t=-4..1,
            grid=[201,201], colorscheme=scheme1, style=surface):

plots:-display(P3,plottools:-transform((x,y,z)->[x,y,-50])(P3),
               view=-50..39, orientation=[30,75,0]);

 

Download denseasy.mw

Some other, fancier alternatives are here.

The taylor command produces the same sort of beast as the series command, and returns a special structure (which merely pretty-prints as you see it).

You can utilize the convert command to turn the result from taylor (or series) into simple sum of terms.

You can also use the series command to merge the difference into a new series structure.

restart;

E1 := taylor(ln(1+x),x=0,4);

series(x-(1/2)*x^2+(1/3)*x^3+O(x^4),x,4)

E2 := taylor(ln(1+sin(x)),x=0,4);

series(x-(1/2)*x^2+(1/6)*x^3+O(x^4),x,4)

convert(E1,polynom);

x-(1/2)*x^2+(1/3)*x^3

convert(E1,polynom)-convert(E2,polynom);

(1/6)*x^3

series(E1-E2,x);

series((1/6)*x^3+O(x^4),x,4)

 

Download seriesconvert.mw

Another way to get a simlar effect is to call   taylor(E1-E2,x) . Christian's Answer did that last call with the option 4 passed for the order. But that 3rd argument may be omitted on the comparison; you can compare the difference between E1 generated with 6 as third argument, and E2 generated with as 3rd argument).

E1 := taylor(ln(1+x),x=0,6);

series(x-(1/2)*x^2+(1/3)*x^3-(1/4)*x^4+(1/5)*x^5+O(x^6),x,6)

E2 := taylor(ln(1+sin(x)),x=0,5);

series(x-(1/2)*x^2+(1/6)*x^3-(1/12)*x^4+O(x^5),x,5)

series(E1-E2,x);

series((1/6)*x^3-(1/6)*x^4+O(x^5),x,5)

taylor(E1-E2,x);

series((1/6)*x^3-(1/6)*x^4+O(x^5),x,5)

Download seriesconvert2.mw

plots:-animate(plot, [[cos(x+2*a), cos(x-2*a)], x = 0 .. 4*Pi],
               a = 1 .. 10, frames=117);

You have used the syntax for function application, rather than multiplication.

You are missing multiplication symbols between your brackets, if your code was entered as (plaintext) 1D Maple Notation.

Even in 2D Input mode you'd still need either explicit multiplication symbols or spaces between the brackets to denote multiplication implicitly.

S := Sum(1/i(i + 1)(i + 2)(i + 3), i = 1 .. infinity);
evalf(S);

Sum(1/((i(i+1))(i+2))(i+3), i = 1 .. infinity)

Float(-infinity)

S2 := Sum(1/(i*(i + 1)*(i + 2)*(i + 3)), i = 1 .. infinity);
evalf(S2);

Sum(1/(i*(i+1)*(i+2)*(i+3)), i = 1 .. infinity)

0.5555555556e-1

sum(1/(i*(i + 1)*(i + 2)*(i + 3)), i = 1 .. infinity);

1/18

evalf(%);

0.5555555556e-1

restart

S := Sum(1/((i(i+1))(i+2))(i+3), i = 1 .. infinity); evalf(S)

Sum(1/((i(i+1))(i+2))(i+3), i = 1 .. infinity)

Float(-infinity)

restart

S := Sum(1/(i*(i+1)*(i+2)*(i+3)), i = 1 .. infinity); evalf(S)

Sum(1/(i*(i+1)*(i+2)*(i+3)), i = 1 .. infinity)

0.5555555556e-1

``

Download syntaxmult.mw

Perhaps it will help you a little to go through it a step at a time.

Notice that I'm only using the formula on the right hand side of each equation returned by solve. (There are other ways to accomplish the goal, but this might make it a little more clear.)

restart;

g := z -> (a + b*z + c*z^2)/(d + e*z + f*z^2):

eqn := y = g(z);

y = (c*z^2+b*z+a)/(f*z^2+e*z+d)

sols := solve({eqn}, {z});

{z = (1/2)*(e*y-b+(-4*d*f*y^2+e^2*y^2+4*a*f*y-2*b*e*y+4*c*d*y-4*a*c+b^2)^(1/2))/(-f*y+c)}, {z = -(1/2)*(-e*y+(-4*d*f*y^2+e^2*y^2+4*a*f*y-2*b*e*y+4*c*d*y-4*a*c+b^2)^(1/2)+b)/(-f*y+c)}

expr1 := eval(z, sols[1]);

(1/2)*(e*y-b+(-4*d*f*y^2+e^2*y^2+4*a*f*y-2*b*e*y+4*c*d*y-4*a*c+b^2)^(1/2))/(-f*y+c)

f1 := unapply(expr1, y);

proc (y) options operator, arrow; (1/2)*(e*y-b+(-4*d*f*y^2+e^2*y^2+4*a*f*y-2*b*e*y+4*c*d*y-4*a*c+b^2)^(1/2))/(-f*y+c) end proc

simplify( (g@f1)(y) );

y

expr2 := eval(z, sols[2]);

-(1/2)*(-e*y+(-4*d*f*y^2+e^2*y^2+4*a*f*y-2*b*e*y+4*c*d*y-4*a*c+b^2)^(1/2)+b)/(-f*y+c)

f2 := unapply(expr2, y);

proc (y) options operator, arrow; -(1/2)*(-e*y+(-4*d*f*y^2+e^2*y^2+4*a*f*y-2*b*e*y+4*c*d*y-4*a*c+b^2)^(1/2)+b)/(-f*y+c) end proc

simplify( (g@f2)(y) );

y

 

Download tima_inv.mw

This question is vague and underspecified, because it only gives two examples, which both happen to have 1 nonzero digit on the left of the decimal point in the input as well as the output under default display.

So about the only way that I can make sense of the request is that the OP wants 1 leading nonzero digits to the left of the decimal place, and no trailing zeros after the right-most nonzero digit.

restart;

H:=proc(x::float) local s;
  uses StringTools;
  s:=CharacterMap("0"," ",sprintf("%ld",abs(op(1,x))));
  s:=CharacterMap(" ","0",TrimRight(s));
  `if`(s="",0.,signum(op(1,x))*parse(cat(s[1],".",s[2..])));
end proc:

H( 2.55 *10^(-90) );

2.55

H( 2.22 *10^(-87) );

2.22

H( -0.0000045600060000 *10^(-87) );

-4.560006

H( 617.123789 );

6.17123789

 

Download leaddig.mw

The RiemannSum command accepts an option partition which can be used to specify the partition values as a list.

For example,

restart;

f := x^2:

P := [-1, -1/4, 1/4, 3/4, 1]:

Student:-Calculus1:-RiemannSum(f, x=-1..1,
                               method=lower, partition=P);

               0.2187500000

For this example it's easy enough to check that result,

add(minimize(f,x=P[i]..P[i+1])*(P[i+1]-P[i]), i=1..nops(P)-1);

                  7 
                  --
                  32
evalf(%);

               0.2187500000

Applying a command such as simplify may have more significant effects on the elements, so is not a really good solution. (Actually, it's a relatively poor solution. The fact that it just happens to work for the current, tivially simple example is no good justification for applying it as a universally safe course of actrion -- with least possible side-effects.)

Here are three or four reasonable ways. The 1-level evaluation might have least effects in general, but is not the briefest to type.

restart

v := `<,>`(v1, v2)

Vector[column](%id = 18446883833686440406)

v1 := 3.2; v2 := b

`~`[eval](v)

Vector[column](%id = 18446883833686435710)

`~`[eval](v, 1)

Vector[column](%id = 18446883833686437150)

rtable_eval(v)

Vector[column](%id = 18446883833686430534)

copy(v)

Vector[column](%id = 18446883833686432094)

``

Download Vector_Display_Problem_ac.mw

This code allows you to produce 2D contour plots with labels inlined.

This code allows you to produce legends easily and flexibly on 2D contour plots.

These are easily found using the Search facility of this site. Did you not try that?

 

Your claim that they have the same dimensions is false. The number of dimensions is different, which is what the error message states.

The following elementwise multiplication is done in few keystrokes:

M := Matrix([[2],[3],[4]]);

Vector(3, {(1) = 2, (2) = 3, (3) = 4})

VC := Vector([-1,1,5]);

Vector(3, {(1) = -1, (2) = 1, (3) = 5})

M *~ <VC>;

Vector(3, {(1) = -2, (2) = 3, (3) = 20})

 

Download mvelem.mw

The result from the above is a Matrix.

One might ask, should the result be a Vector or a Matrix? That is not clear, which relates to why it doesn't happen unless syntax is used to make it unambiguous.

The facility provides %, %%, and %%% for the last, second last, and third last results respectively.

There is a Help page for it, with the Topic ditto .

That Help page should also be available by searching for % in the Help system.

In the GUI you can also use Equation Labels to refer to previous output (if you like that sort of thing).

You can inform GlobalSolve which names are the variables (since it lacks a mechanism for recognizing and excluding a, the name of the dummy variable of integration).

restart;
with(GlobalOptimization):

GlobalSolve(Int(a*x-2,a=0..2), x=0..2,
            method=diffevol, variables=[x]);
                                                     -7
        [-3.99999997615814, [x = 0.119209289550781 10  ]]

Alternatively you could utilize the operator form calling sequence,

restart;
with(GlobalOptimization):                                                                    

GlobalSolve(proc(x) local a; Int(a*x-2,a=0..2); end proc,
            0..2, method=diffevol);

           [-3.99999997615814, [                    -7]]
                                [0.119209289550781 10  ]

Using Maple 2019.1, below I use the stylesheet option to the DrawGraph command.

See also the Help page for Topic GraphDrawingOptions for more description.

restart;

with(GraphTheory):

G := Graph({[[1,2], 1], [[2,3], 2], [[3,4], 3], [[4,5], 4], [[5,1], 5]}):

DrawGraph(G);

DrawGraph(G, stylesheet=[vertexpadding=20]);

DrawGraph(G, stylesheet=[vertexpadding=20,
                         vertexfontsize=20]);

 

Download graphvertexsize.mw

First 139 140 141 142 143 144 145 Last Page 141 of 336