Kitonum

21530 Reputation

26 Badges

17 years, 86 days

MaplePrimes Activity


These are answers submitted by Kitonum

Do

f:=x->x^2+6*x+12:

g:=x-> f(x)*exp(x):

f(2);

g(2);


                                          28

                                   28 exp(2)

 

or more automatically

restart;

sol:=dsolve({diff(f(x), x) = 2*x+6, f(0) = 12});

f:=unapply(eval(f(x), sol), x);

g:=x-> f(x)*exp(x):

f(2);

g(2);

 

Edited.

MUKUNDS 

1) Many sub-expressions in your system are repeated. For a more compact notation, I gave them the names A, B, C

2) Variables  omega  and  a are squared, so it is enough to solve the system only for  omega>=0  and  a>=0 .

3) First, we plot both equations, from which find the ranges for each root.

4) Using  fsolve  command we find these roots.

 

restart; r := 0.5e-1; A := sqrt(a^2+r^2/(1+r)^2); B := sqrt(a^2/(a^2+r^2/(1+r)^2)); C := A*EllipticE(B)-r^2*EllipticK(B)/((1+r)^2*A); Sys := [0.4e-3*a^2*omega^2+(-a*(1+r)+a*omega^2+4*r*C/(a*Pi))^2-0.1e-3 = 0, 0.1e-1^2+(1/4)*(-a*(1+r)+a*omega^2+4*r*C/(a*Pi))*(omega^2-r-1-4*r*C/(a^2*Pi)+4*r*(EllipticE(B)*a/A+(1/2)*A*(2*a/A^2-2*a^3/A^4)*(EllipticE(B)/B-EllipticK(B)/B)/B-(1/2)*r^2*(2*a/A^2-2*a^3/A^4)*(EllipticE(B)/((-B^2+1)*B)-EllipticK(B)/B)/((1+r)^2*B*A)+r^2*EllipticK(B)*a/((1+r)^2*A^3))/(a*Pi))/(a*omega^2) = 0]
``

plots[implicitplot](Sys, omega = 0 .. 1, a = 0 .. .7, color = [red, blue], gridrefine = 5);

 

 

  

NULL

fsolve(Sys, {a = 0 .. 0.1, omega = 0.6 .. 0.8});

fsolve(Sys, {a = 0.5 .. 1, omega = 0.8 .. 1});

                                

The other 6 solutions easy to find by all changes of signs of found 2 solutions.

Download Syst.mw

See some other ways to solve the problem here

I've fixed several additional errors and inaccuracies in your procedure. Now it is working properly both in Standard and in Classic worksheets.

Euler := proc(f::procedure, a, b, alpha, n::integer)

local w, h, i, xN, yN;

w := Matrix(2, n+1);  h := (b-a)/n;  i := 1;  xN := a; yN := alpha;

while i <= n+1 do

w[1, i] := evalf(xN); w[2, i] := evalf(yN);

yN := evalf(yN+h*f(xN, yN)); xN := evalf(xN+h);

i := i+1

end do;

interface(rtablesize = infinity);

w;

end proc:

 

Example of use with a visualization:

Data := Euler((x, y)->exp(x), 0, 2, 1, 10);

A := plot(Data[1], Data[2], color = blue, legend = "Approximate solution"):

B := plot(exp(x), x = 0 .. 2, 0 .. 8, color = red, legend = "Exact solution"):

plots[display](A, B);

Here is a simple example:

with(plots):

A:=listplot3d([[1,2],[3,4],[5,6],[7,8]], color=red):

B:=listplot3d([[1,3],[3,5],[5,7],[7,9]], color=yellow):

C:=listplot3d([[1,4],[3,6],[5,8],[7,10]], color=blue):

display(A,B,C, axes=normal);

For a better visual perception of the plot the font for tickmarks and labels can also be changed. Compare:

A := plot(x^2, x = 0 .. 1, color = red, labels = [x, y]):

B := plot(x^2, x = 0 .. 1, thickness = 3, color = red, axis = [thickness = 2, tickmarks = [thickness = 2]], axesfont = [times, bold, 13], labelfont = [times, bold, 14], labels = [x, y]):

plots[display](<A | B>, scaling = constrained);

 

 

 

 

An example:

solve((x-1)*(x+1)*(x^2+1)=0, useassumptions) assuming real, positive;

                                                     1

This means extraction the sequence of expressions from a list  or a set. [...][]  or  {...}[]  are equivalent to  op([...])  or  op({...})

 

Addition: see help on  set  or  list

The procedure  Sort  solves the problem. In  Sort procedure  the procedure  OrderOfDerivative , which returns the order of derivatives, was used.

restart;

OrderOfDerivative:=proc(A)

local n, A1;

n:=0;

A1:=A;

while op(0,A1)=diff do

A1:=op(A1)[1]; n:=n+1;

od;

n;

end proc:

 

Example of use:

OrderOfDerivative(diff(x(t),t,t));

                               2

 

The code of the basic procedure  Sort :

Sort:=proc(Expr)

local  L;

L:=sort([op(Expr)], (a,b)->OrderOfDerivative(indets(a, `function`)[1])>=OrderOfDerivative(indets(b, `function`)[1]) );  # The sorted list of op(Expr)

``(add(select(s->has(s,diff), L)))+add(select(s->not has(s,diff), L));  # Conversation  L  into  sum

end proc:

 

 

Example of use:

Expr:=a*diff(x(t),t)+b*x(t)+r*diff(x(t),t,t)+a*diff(y(t),t)+b*diff(y(t),t,t)+c*y(t): # The initial expression

Sort(Expr);

             

 

 

Unfortunately we have to "freeze" the terms with derivatives by the construction ``(...), or in the process of summing elements of the list  L  Maple randomly rearranges the list of terms.


  

The simple procedure  Hist  builds a histogram for any lists  X  and  P  and the width  h . The options are:  C  is the color of filling (by default  blue) and  V is the view of the plot.

Hist := proc (X::list, P::list, h::numeric, C::{string, symbol} := blue, V::list := [X[1]-0.6*h .. X[-1]+0.6*h, 0 .. max(P)])

local n, S, A, B;

n := nops(X);

S := seq(piecewise(X[i]-(1/2)*h <= x and x <= X[i]+(1/2)*h, P[i]), i = 1 .. n);

A := plot([S], x = X[1]-(1/2)*h .. X[n]+(1/2)*h, color = C, filled);

B := plot([S], x = X[1]-0.51*h .. X[n]+0.51*h, tickmarks = [default, [seq(P[i] = P[i], i = 1 .. n)]], color = black, thickness = 2);

plots:-display(A, B, view = V);

end proc:

 

The initial example:

Hist([1, 3, 5, 7], [1/8, 1/4, 1/2, 1/8], 1.8);

                              

 

The second example with 2 used options:

Hist([1, 2, 3, 4], [1/8, 1/4, 1/2, 1/8], 0.8, cyan, [-0.5 .. 5.2, -0.05 .. 0.6]);

                               

 

 

 

In order that the surface was more like your picture I did:

1) Removed the plane  x=0.

2) Changed the sign in front of  z -term.

3) Changed the scaling along the  y-axis.

3) Added the plotting of the Bifurcation Set (op(eliminate({f, implicitdiff(f, y, x)}, x)[2]) = 0  is the projecting surface onto x=-7):

 

f := x^3-x*z+(1/3)*y:

A := plots[implicitplot3d](f, x = -7 .. 5, y = -50 .. 50, z = -5 .. 7, axes = boxed, grid = [60, 60, 60], style = surface, color = khaki, orientation = [175, -20, 15], lightmodel = light1):

B := plots[intersectplot](x+7 = 0, op(eliminate({f, implicitdiff(f, y, x)}, x)[2]) = 0, x = -7 .. 5, y = -50 .. 50, z = -5 .. 7, color = red, thickness = 4, linestyle = solid):  #  Bifurcation Set

C := plots[implicitplot3d](x = -7, x = -7 .. 5, y = -50 .. 50, z = -5 .. 7, style = surface, color = "LightGrey"):  # The plane  x=-7

plots[display](A, B, C); 

                              

 

 

 Edited.

 

 

Here's an example of another way to solve this problem. This universal method allows you  from a list of certain objects to select objects that satisfy certain properties. I believe that all beginners must master this method:

restart;

A:=[2,4,6,8,10,12,8,6]:

select(i->A[i]=6, [$ 1..nops(A)]);

                                   [3, 8]

Procedure  SM  solves your problem:

SM:=proc(n)

local L;

uses combinat;

L:=permute([(-1)$n,1$n],n);

interface(rtablesize=infinity);

Matrix(L);

end proc:

 

Example of use:

SM(4);

                                     

 

 

 

Period  procedure finds the least positive period for all expressions of the form a linear combination of  {sin(a*t+a0), cos(b*t+b0), exp((c*t+c0)*I)}  with rational coefficients  a, b, c  and  a0, b0, c0  are any real constants.

Period:=proc(Expr)

local Expr1, S, T, T1, d;

Expr1:=evalc(subs(op(indets(Expr,symbol))=t, Expr));

S:=indets(Expr1,'trig') minus indets(Expr1,'realcons');

T:=map(s->coeff(op(1,s),t), S);

T1:=map(t->2/t,T);

d:=ilcm(op(denom~(T1)));

ilcm(op(d*~(T1)))/d*Pi;

end proc:

 

Examples of use:

Period(sin(t/2+sqrt(2))-4*cos(2*t/3-5));

                            12*Pi

Period(2+sin(3*x)+cos(2*x)-sin(x/2)+exp(7/2*I*x));

                             4*Pi

 

Edited.

Estimation  N=62/eps  is universal, but very overpriced. A direct calculation gives us the exact value of  integer positive  N  for each epsilon.

restart;

x:=n->n^2/(n^2+31*n+228);

x0:=limit(x(n), n=infinity);

N:=epsilon->max(1, floor(op(1, solve(abs(x(n)-x0)<=epsilon, n)[-1]))+1):

 

Example:

N(10^(-3));

                                  30977

Check:

evalf(abs(x(30977)-x0));

evalf(abs(x(30976)-x0));

                       0.0009999791325

                        0.001000011390

Edited. 

First 193 194 195 196 197 198 199 Last Page 195 of 290