acer

32333 Reputation

29 Badges

19 years, 321 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Are you trying to say that you want it substituted by sigma literally, or that you just want a factor of Ls pulled out of the particular subterm?

restart;

LD := Lambda_ds = (-Lm^2/Lr + Ls)*i_ds + Lm*Lambda_dr/Lr;

Lambda_ds = (-Lm^2/Lr+Ls)*i_ds+Lm*Lambda_dr/Lr

sigma := (1-Lm^2/(Ls*Lr));

1-Lm^2/(Ls*Lr)

new := subs(ss=Ls*sigma, algsubs(Ls*sigma=ss,LD));

Lambda_ds = i_ds*Ls*(1-Lm^2/(Ls*Lr))+Lm*Lambda_dr/Lr

simplify(new - LD);

0 = 0

restart;

LD := Lambda_ds = (-Lm^2/Lr + Ls)*i_ds + Lm*Lambda_dr/Lr;

Lambda_ds = (-Lm^2/Lr+Ls)*i_ds+Lm*Lambda_dr/Lr

new := subs(ss=Ls*sigma, algsubs(Ls*(1-Lm^2/(Ls*Lr))=ss,LD));

Lambda_ds = i_ds*Ls*sigma+Lm*Lambda_dr/Lr

simplify(eval(new, sigma=(1-Lm^2/(Ls*Lr))) - LD);

0 = 0

 

Download question20200618_ac.mw

The dsolve parameter list is wrong in several places, and contains hidden 2D Input characters. That problem might also occur for the A in the initialvalues list passed to Minimize, and possibly also for the parameter sequence in the definition of procedure sse. You may be able to correct it in 2D Input by deleting the A character insteances and typing it in again. You'd likely be better off not using 2D Input mode, as it's clearly problematic for you.

You seem to be missing initial conditions, because the input line which assigns to ic has several statements broken by colons. You very likely should change those to a comma-separated sequence of equations instead.

The add call inside your sse procedure is not set up to handle the case that the result from select is an empty list. (In that case, it would pass NULL to rhs and throw an error.) It looks as if your select call might be an attempt to extract just one of the dsolve results solution procedures, is that right? Iso, then which one? Is it C(T)?

You may need to specifiy ranges for the parameters, in the call to Minimize.

You may need to adjust procedure sse so that it handles the case of a singularity in the numeric solution. (try..catch and return a large value? Something else?)

Your worksheet has a colon terminating the line with the call to Minimize. You likely would be better off not supressing that output, to see how it does.

You could apply this command.

restart;

expr := sqrt(abs(w[1]^2-2*w[1]*w[2]+w[2]^2
                 +x[1]^2-2*x[1]*x[2]+x[2]^2
                 +y[1]^2-2*y[1]*y[2]+y[2]^2
                 +(z[1]-z[2])^2));

abs(w[1]^2-2*w[1]*w[2]+w[2]^2+x[1]^2-2*x[1]*x[2]+x[2]^2+y[1]^2-2*y[1]*y[2]+y[2]^2+(z[1]-z[2])^2)^(1/2)

Student:-Precalculus:-CompleteSquare(expr);

abs((z[2]-z[1])^2+(y[2]-y[1])^2+(x[2]-x[1])^2+(w[2]-w[1])^2)^(1/2)

 

Download SPCSq.mw

Look at the computations and figure out what purpose they might serve in addressing any of the questions.

restart;

f := 19*(5*x/2+x*y-5*y-y^3+y^2/8-x^2/4+exp(y-20));

(95/2)*x+19*x*y-95*y-19*y^3+(19/8)*y^2-(19/4)*x^2+19*exp(y-20)

plot3d(f, x=-10..15, y=-3..3, view=-100..800.0);

S1 := fsolve({diff(f,x),diff(f,y)},{x=-10..15, y=-3..3});

{x = 6.500000004, y = .7500000019}

S2 := fsolve({diff(f,x),diff(f,y)},{x=-10..15, y=-3..3}, avoid={S1});

{x = 4.999999998, y = -0.9182986828e-9}

# fsolve does not find any more in this range
fsolve({diff(f,x),diff(f,y)},{x=-10..15, y=-3..3}, avoid={S1, S2});

fsolve({95/2+19*y-(19/2)*x, 19*x-95-57*y^2+(19/4)*y+19*exp(y-20)}, {x, y}, {x = -10 .. 15, y = -3 .. 3}, avoid = {{x = 4.999999998, y = -0.9182986828e-9}, {x = 6.500000004, y = .7500000019}})

Student:-MultivariateCalculus:-SecondDerivativeTest(f, [x,y]=eval([x,y],S1));

LocalMin = [], LocalMax = [[6.500000004, .7500000019]], Saddle = []

Student:-MultivariateCalculus:-SecondDerivativeTest(f, [x,y]=eval([x,y],S2));

LocalMin = [], LocalMax = [], Saddle = [[4.999999998, -0.9182986828e-9]]

H := :-VectorCalculus:-Hessian(f,[x,y]);

Matrix(2, 2, {(1, 1) = -19/2, (1, 2) = 19, (2, 1) = 19, (2, 2) = -114*y+19/4+19*exp(y-20)})

#
# These are all strictly negative
#
LinearAlgebra:-Eigenvalues( Matrix(eval(H, S1), shape=symmetric) );

Vector(2, {(1) = -85.5000001317647, (2) = -4.750000008235295})

#
# These include both positive and negative values
#
LinearAlgebra:-Eigenvalues( Matrix(eval(H, S2), shape=symmetric) );

Vector(2, {(1) = -22.667008848410028, (2) = 17.91700899241002})

 

Download saddle_extr.mw

See the Help page for Topic object,function_mechanism which discusses some special situations of invoking methods.

Your process example in particular (a collision with another module in the namespace) can also be handled via the function syntax.

This might also assist you with a releated case which you have not yet covered in your Questions, involving mapping the same name (of method functions) across multiple objects. (See examples in the page.) In that case you might specifically want to not refer to the name as the export of any particular one of the objects.

restart;

module car_class()
      option object;
      local name::string:="";

      export process::static := proc(o::car_class)
             print("process method");             
      end proc:   

      export set_name::static := proc(o::car_class,_name::string)
             print("inside set name");
             o:-name := _name:
      end proc:     
end module:

my_car:=Object(car_class):  #make object

set_name(my_car,"toyota"):

"inside set name"

function:-process(my_car):

"process method"

set_name(my_car,"toyota"):

"inside set name"

 

Download object_function.mw

You could adjust the datatype to also include a specified default fill value.

Or you could specify a dummy instance of your object as a default fill value -- even if the fill value never gets used explicitly.

As an example of the former idea:

restart;
module solution_class()
      option object;
      local sol::anything;
end module:

sol:=Object(solution_class):

A := Array(datatype={solution_class,identical(NULL)}, fill=NULL):

A(1) := sol;

Vector(1, {(1) = module solution_class () local sol::anything; option object; end module})

 

Download Array_dt_fill.mw

The former idea looks a little uglier when set up, and interferes a little as it relaxes the strictures that usually come for free from a proscriptive datatype. But the latter idea could be unsatisfactory if you really didn't want any instance to exist strictly outside of when instances were stored. (Such a circumstance could be contrived, albeit artificial.)

Also, the awkwardness is not specific to object types.

Array(datatype=prime);
Error, unable to store '0' when datatype=prime

A:=Array(datatype=prime, fill=2):  # distasteful
A(3):=7;  # ugh
             A := [2, 2, 7]

A:=Array(datatype=prime, storage=sparse):
A(3):=7;  # sigh
Error, unable to store '0' when datatype=prime

A:=Array(datatype={prime,identical(0)}, storage=sparse):
A(3):=7;
             A := [0, 0, 7]

@nm You wrote,

   "It would be much more natural to do something like
     my_car[set_name]("toyota") or my_car:-set_name("toyota")

    And then my_car:-get_name() since in these, the object itself
    is upfront, instead of being passed as an argument."

You can do this:

restart;

module car_class()
      option object;
      local name::static;  #private
      export set_name::static:=proc(nname::string)
          name := nname;
      end proc;
      export get_name::static:=proc()
          return name;
      end proc;      
end module:

my_car:=Object(car_class); #make an object of class car

module car_class () option object; end module

my_car:-set_name("toyota"):

my_car:-get_name();

"toyota"

 

Download car_class.mw

Of the 8 root formulas (in v[c]) there are two that are real-valued for all real b[2].

You could plot them using the implicitplot command. Or you could plot the explicit formulations of just those two. Or you could plot the real and imaginarty parts of the explicit forumulations. You could investigate the discriminant, if you so wish.

What makes you think that you are missing out on some details? I see no evidence that you're missing out of some regions of b[2] for which there are additional nontrivial purely real solutions. Did I miss it?

note. I don't advise trying to think of matching up the explicit formulas (or their real and imaginary components) with particular connect curves, unless you want to wade into deeper water. (This relates to the blue vertical noice connecting curves in two of the plots.)

note. I have not tried to do anything along the lines of RootFinding:-Parametric, even with an approximation for Pi.

restart;

expr:=(-6*v^8*b[1]+(36*b[1]^2-12*b[2])*v^6-24*v^4*b[1]*b[2]+56*Pi*v^2+240*Pi*b[1])/(Pi*v^10*(v^2+6*b[1]));

(-6*v^8*b[1]+(36*b[1]^2-12*b[2])*v^6-24*v^4*b[1]*b[2]+56*Pi*v^2+240*Pi*b[1])/(Pi*v^10*(v^2+6*b[1]))

# I need to solve this polynomial and look at how the solutions behave over different values of b[2]

P:=eval(-numer(expr),[b[1]=1]);

6*v^8+12*v^6*b[2]-36*v^6+24*v^4*b[2]-56*Pi*v^2-240*Pi

discrim(P, v); factor(%);
[solve(%<0)];
evalf(%);

-72138957898383360*Pi^3*(-2744*Pi^2*b[2]^3+49632*Pi*b[2]^4-4320*b[2]^5+28224*Pi^2*b[2]^2-952800*Pi*b[2]^3+43200*b[2]^4+21609*Pi^3-451332*Pi^2*b[2]+5694948*Pi*b[2]^2-38880*b[2]^3+3537108*Pi^2-10760040*Pi*b[2]+5904900*Pi)^2

-72138957898383360*Pi^3*(-18*b[2]+162+Pi)^2*(-2744*Pi*b[2]^3+240*b[2]^4+28224*Pi*b[2]^2-240*b[2]^3+21609*Pi^2-62370*Pi*b[2]+36450*Pi)^2

[RealRange(-infinity, Open(9+(1/18)*Pi)), RealRange(Open(9+(1/18)*Pi), Open(RootOf(240*_Z^4+(-2744*Pi-240)*_Z^3+28224*Pi*_Z^2-62370*Pi*_Z+21609*Pi^2+36450*Pi, index = 1))), RealRange(Open(RootOf(240*_Z^4+(-2744*Pi-240)*_Z^3+28224*Pi*_Z^2-62370*Pi*_Z+21609*Pi^2+36450*Pi, index = 1)), Open(RootOf(240*_Z^4+(-2744*Pi-240)*_Z^3+28224*Pi*_Z^2-62370*Pi*_Z+21609*Pi^2+36450*Pi, index = 2))), RealRange(Open(RootOf(240*_Z^4+(-2744*Pi-240)*_Z^3+28224*Pi*_Z^2-62370*Pi*_Z+21609*Pi^2+36450*Pi, index = 2)), infinity)]

[RealRange(-infinity, Open(9.174532925)), RealRange(Open(9.174532925), Open(13.54833498)), RealRange(Open(13.54833498), Open(21.09299752)), RealRange(Open(21.09299752), infinity)]

plots:-implicitplot(P, b[2]=-15..22, v=-10..10, gridrefine=3);

HHH := simplify([solve(P,v,explicit)]):
nops(HHH);

8

plots:-display(
  seq(plot([Re,Im](HHH[i]), b[2]=-15..22), i=1..2)
);

plots:-display(
  seq(plot([Re,Im](HHH[i]), b[2]=-15..22), i=1..8)
);

HH := [solve(P,v)]:

HH1 := [allvalues(HH[1])]:
HH2 := [allvalues(HH[2])]:

plots:-display(
  plot(HH1[1], b[2]=-15..22),
  plot(HH2[1], b[2]=-15..22)
);

seq( print(evalf[20](eval(simplify(HH1[i]), b[2]=10))), i=1..4 );

1.2758485664478996255+0.97939797510404682722e-21*I

0.70362672524111679003e-20+1.4345487083972181802*I

0.28516187852517728599e-20-1.9661192724546546340*I

0.18415764139723627810e-20-3.1151620462225417219*I

plots:-display(
  seq(plot([Re,Im](HH1[i]), b[2]=-15..22), i=1..4),
  seq(plot([Re,Im](HH2[i]), b[2]=-15..22), i=1..4)
);

 

Download ComplexPlotQuestion_ac.mw

restart

with(plots); with(plottools)

interface(imaginaryunit = I)

L := `~`[[Re, Im]](sort([fsolve(x^8-1-I, x, complex)], key = argument))

display(pointplot(L, symbol = solidcircle, symbolsize = 20, color = red), polygon(L, style = line, thickness = 2, color = blue), gridlines)

NULL

Download ComplexQuestion_ac.mw

There are other ways to accomplish this kind of thing.

I'm not sure which you would consider as best, in part because I know little details about your actual examples or requirements. (Are they all numeric, are float results ok, is it supposed to be highly efficient or just easy, etc.)

with(LinearAlgebra):

A,b := <<0,1>|<0,0>>, <0,0>;

A, b := Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 1, (2, 2) = 0}), Vector(2, {(1) = 0, (2) = 0})

S := LinearSolve(A, b);

Vector(2, {(1) = 0, (2) = _t10[2]})

evalindets(S,name,()->1);

Vector(2, {(1) = 0, (2) = 1})

evalindets(S,name,()->0);

Vector(2, {(1) = 0, (2) = 0})

LinearSolve(evalf(A), b, method=QR);

Vector(2, {(1) = 0., (2) = 0.})

LeastSquares(A, b, optimize);

Vector(2, {(1) = 0, (2) = 0})

LeastSquares(A, b, method=SVD);

Vector(2, {(1) = 0., (2) = 0.})

 

Download LSunder.mw

If your results have additional symbolic names in them (ie. that are present in the input, and are not just the introduced free parameters) then it is easy to adjust the evalindets 2nd argument (the type) to match only the introduced names. (With the base of the introduced parameter names under one's control there is no need to check also with a set intersection.)

with(LinearAlgebra):

A,b := <<0,u>|<0,v>>, <0,v>;

A, b := Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = u, (2, 2) = v}), Vector(2, {(1) = 0, (2) = v})

S := LinearSolve(A, b, free=_t);

Vector(2, {(1) = -v*(_t[2]-1)/u, (2) = _t[2]})

evalindets(S,indets(S,'specindex'(nonnegint,_t)),()->0);

Vector(2, {(1) = v/u, (2) = 0})

Download LSunder2.mw

You can access data structures directly using OpenMaple. You could go via a C extension to python.

Using the cmaple interface is not the really the right interface for the kind of interprocess memeory interaction you're describing.

I am not sure how you got in that bind, but here are a few adjustments (still using Equation Labels, etc), but with eval and unapply.

I used Maple 2018.2, to match your major version.

restart

with(Units)

Automatically loading the Units[Simple] subpackage

 

UseSystem('FPS')

UsingSystem()

FPS

(1)

Fin := 2*Unit('gal')/Unit('min')

(77/17280)*Units:-Unit(ft^3/s)

(2)

Cin := Unit('lb')/(2*Unit('gal'))

(288/77)*Units:-Unit(lb/ft^3)

(3)

Qin := Fin*Cin

(1/60)*Units:-Unit(lb/s)

(4)

Fout := 2*Unit('gal')/Unit('min')

(77/17280)*Units:-Unit(ft^3/s)

(5)

Cout := Q/(100*Unit('gal'))

(1/100)*Q*Units:-Unit(1/gal)

(6)

Qout := Fout*Cout

(1/3000)*Q*Units:-Unit(1/s)

(7)

``

Qin

(1/60)*Units:-Unit(lb/s)

(8)

theEq := diff(Q(t), t) = Qin-2*Q(t)*(1/100)

diff(Q(t), t) = (1/60)*Units:-Unit(lb/s)-(1/50)*Q(t)

(9)

dsolve(theEq)

Q(t) = (5/6)*Units:-Unit(lb/s)+exp(-(1/50)*t)*_C1

(10)

simplify(eval(Q(t) = (5/6)*Units[Unit](lb/s)+exp(-(1/50)*t)*_C1, _C1 = Unit(lb/min)))

Q(t) = (1/60)*(50+exp(-(1/50)*t))*Units:-Unit(lb/s)

(11)

q := unapply(rhs(Q(t) = (1/60)*(50+exp(-(1/50)*t))*Units[Unit](lb/s)), t)

proc (t) options operator, arrow; (1/60)*(50+exp(-(1/50)*t))*Units:-Unit(lb/s) end proc

(12)

q(10)

(1/60)*(50+exp(-1/5))*Units:-Unit(lb/s)

(13)

q(30)

(1/60)*(50+exp(-3/5))*Units:-Unit(lb/s)

(14)

``

evalf((1/60)*(50+exp(-3/5))*Units[Unit](lb/s))

.8424801942*Units:-Unit(lb/s)

(15)

``

Download units_issue_ac.mw

Do either of the attempts in this attachment work in your Maple 13?

Clutch_Modell_ac.mw

It's a little difficult for us, since the odeplot that seems problematic in your Maple 13 works in later versions (eg. Maple 16, Maple 2020).

I see that you've ignored my comment in your earlier duplicate of this topic, where you might consider another mechanism for the piecewise function than the unevaluated call to the unknown function(s).

Your procedure Basenwechsel itself uses the name Basenwechsel in two different ways.

Firstly, it assigns to the name Basenwechsel. as if to use it as a local variable. But secondly, it calls Basenwechsel in a function call (perhaps an attempt at a recursive call to itself).

Perhaps you can instead make Basenwechsel act recursively by using the procname syntax instead . See the attachment below.

Also, you have calls to with inside your procedures. That won't work properly. You could utilize the uses syntax within the procedures, or even more move them to the top level.

I suggest that you explicitly declare all the intended locals of your procedures, so that you know what they are doing. Don't rely on impliciat local declarations. And don't try and use the same name in two different ways.

Check whether this works as you hoped: Basenwechsel_ac1.mw

Did you mean that you wanted to shade the curve itself, or the area between y=0 and the curve, or something else?

If you just want to shade the curve with a single color then pass the color option, eg, color="Blue", etc.

  plot(x*ln(x), x=0..1, color="Blue");

If you want to shade the region between y=0 and y=x*ln(x) then pass the filled option.

If you want to shade the curve itself in a varying manner then you can pass an appropriate colorscheme option.

For example,

plot(x*ln(x), x=0..1, filled);

plot(x*ln(x), x=0..1,
     thickness=3,
     colorscheme=["ygradient", ["Blue", "Red"]]);

plot(x*ln(x), x=0..1,
     thickness=3,
     colorscheme=["xgradient", ["Blue", "Red"]]);

 

Download 2D_curve_shade.mw

There are other variations of coloring, etc.

First 120 121 122 123 124 125 126 Last Page 122 of 336