acer

32385 Reputation

29 Badges

19 years, 334 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Firstly, try not to use the word "function" if you find yourself in a muddle with expressions (that depend on name t) versus operators (whose formal parameter dummy name just happens to be t). Otherwise you might be using the word ambiguously.

restart;


Here f is an expression that depends on t. There
are no operators in play here.

f := sin(x(t));

sin(x(t))

diff(f, t);

(diff(x(t), t))*cos(x(t))

restart;


Here f is an operator. It is not an expression that
depends on t.

f := t -> sin(x(t));

proc (t) options operator, arrow; sin(x(t)) end proc


But f(t) is an expression that depends on t, after
applying the operator f to t.

f(t);

sin(x(t))

diff(f(t), t);

(diff(x(t), t))*cos(x(t))


If you really want you could construct a new
operator from that.

unapply(%, t);

proc (t) options operator, arrow; (diff(x(t), t))*cos(x(t)) end proc


Alternatively we can directly construct a new
operator which returns the derivative (wrt t) of
what f returns.

D(f);

proc (t) options operator, arrow; (D(x))(t)*cos(x(t)) end proc


We can also apply that new operator to t. This
produces an expression that depends on t.

D(f)(t);

(D(x))(t)*cos(x(t))


We could now also convert that expression
from D form to active diff form.

convert(%, diff);

(diff(x(t), t))*cos(x(t))

 

Download differentiation_expr_vs_operator.mw

Also, note that Diff is an inert version of active diff. Your goal is to actively differentiate, so using inert Diff would just add more muddle here.

Here are a few ways. I used the second (red code) in the plot on the right.

I moved the angle textplot a little to the left, and reduced the font size to 14.

restart


These first two examples look ok.

 

nprintf(`#mn("%a°");`,100);

`#mn("100°");`

Typesetting:-mn("100°");

"100°"


In this next example the spacing between the number
and the degree symbol is a little too wide.

 

100*`°`;

100*`°`


In the next example the 100 is in italic font,
which doesn't look as good.

 

cat(100, `°`);

`100°`

NULL

NULL

g[1] := plot([[0, 0], [1, 0], [-1, 2], [0, 0]], style = line, color = black, axes = none)

g[2] := plots[textplot]({[-.7, 1.6, typeset(beta), 'font' = ["times", 16]], [-.6, 1, typeset(b), 'font' = ["times", 16]], [0.5e-1, .13, typeset(alpha), 'font' = ["times", 16]], [.1, 1, typeset(c), 'font' = ["times", 16]], [.5, -.1, typeset(a), 'font' = ["times", 16]], [.8, .11, typeset(psi), 'font' = ["times", 16]]})

plots[display]([g[1], g[2]], caption = ["Triangle 1", font = [TIMES, BOLD, 16]], size = [300, 300])

NULL

g[1] := plot([[0, 0], [1, 0], [2, 2], [0, 0]], style = line, color = black, axes = none)

 

Below I typed in Typesetting:-mn("100°") and the
input was immediate marked up with the degree symbol

 

g[2] := plots[textplot]({[.22, .1, typeset(omega), 'font' = ["times", 16]], [.5, -.1*(1/2), typeset(p), 'font' = ["times", 16]], [.8, 1, typeset(x), 'font' = ["times", 16]], [.89, .1, Typesetting:-mn("100°"), 'font' = ["times", 14]], [1.6, 1, typeset(m), 'font' = ["times", 16]], [1.75, 1.65, typeset(gamma), 'font' = ["times", 16]]})

plots[display]([g[1], g[2]], caption = ["Triangle 2", font = [TIMES, BOLD, 16]], size = [300, 300])

 

Download QuestionTypeset_ac.mw

You seem to be mistakenly conflating this GetEquations functionality with this older (deprecated) GetEquations functionality that has a different usage and syntax.

The names "foo" and "bar" are convenient short names, where the general idea is that people may recognize them as being offhand, disposable, example names.

See foobar and FUBAR, which respectively give the letter "r" as standing for "repair" and "recognition". I am more familiar with the latter.

You have to supply the initial voltage, if they don't provide it for you. Otherwise your function U(t) will not output values that are numeric. You need numeric values for plotting. That should not be surprising.

[edit] I'll note that part a) says to plot the graph of y=U(t).

You wrote, U(t)=cos(2t)*U*e^t/10, but that's not what the text image shows! The text uses a "U" with subscript "0" on the right-hand side. That's a common way to represent the initial value (constant), and is intended to be a distinct name and not the same as the "U" on the lhs.

The initial voltage should not be assigned to a name that depends on the same name U as used for the procedure. So, in Maple, U0 or U__0 would be ok, but U[0] is asking for trouble.

Note that U__0 (double underscore) prettyprints with a subscript. (See also here for shortcuts).

In this attachment I typed the keystrokes U__0 to get the subscripted name in 2D Input.

restart

U := proc (t) options operator, arrow; U__0*exp(-(1/10)*t)*cos(2*t) end proc

proc (t) options operator, arrow; U__0*exp(-(1/10)*t)*cos(2*t) end proc

U__0 := 20

20

plot(U, 0 .. 10, size = [500, 200])

Download initial_U.mw

restart;

 

 

bracket:=proc(ee::{list,set},
              {left::{truefalse,identical("{","[","(")}:=true,
               right::{truefalse,identical("}","]",")")}:=true})
  local i; uses Typesetting;
  mrow(piecewise(member(left,{true,"{"}),mo("{"),
                 left="[",mo("["),left="(",mo("("),mo("")),
       mtable(seq(mtr(mtd(Typeset(EV(ee[i])))),i=1..nops(ee))),
       piecewise(member(right,{true,"}"}), mo("}"),
                 right="]",mo("]"),right=")",mo(")"),mo("")));
end proc:

 

 

sys:=[x+y-z = 3, x-y-z = 5, -x-y-z = 7];

[x+y-z = 3, x-y-z = 5, -x-y-z = 7]

bracket(sys);

"{[[x+y-z=3],[x-y-z=5],[-x-y-z=7]]}"

bracket(sys, left=false);

"[[x+y-z=3],[x-y-z=5],[-x-y-z=7]]}"

bracket(sys, right=false);

"{[[x+y-z=3],[x-y-z=5],[-x-y-z=7]]"

bracket(sys, left="[", right="]");

Vector(3, {(1) = x+y-z = 3, (2) = x-y-z = 5, (3) = -x-y-z = 7})

bracket(sys, left=false, right="]");

"[[x+y-z=3],[x-y-z=5],[-x-y-z=7]]]"

bracket(sys, left="[", right=false);

"[[[x+y-z=3],[x-y-z=5],[-x-y-z=7]]"

bracket(sys, left="(", right=")");

Vector(3, {(1) = x+y-z = 3, (2) = x-y-z = 5, (3) = -x-y-z = 7})

bracket(sys, left=false, right=")");

"[[x+y-z=3],[x-y-z=5],[-x-y-z=7]])"

bracket(sys, left="(", right=false);

"([[x+y-z=3],[x-y-z=5],[-x-y-z=7]]"

bracket(sys, right="]");

"{[[x+y-z=3],[x-y-z=5],[-x-y-z=7]]]"

Download fencing.mw

Here are various ways (since you explicitly asked about select, and a loop).

restart;

r:=rand(0...5.):

y:=[seq(r(), n=1..10)]:

#
# Kitonum's good suggestion.
#
[seq(`if`(y[n]>0 and y[n]<1,[n,y[n]],NULL), n=1..nops(y))];

[[1, .2499109628], [4, .3475034102], [10, 0.8823971507e-2]]

#
# This is slightly less efficient since it creates list [$nops(y)]
#
map(i->`if`(y[i]>0 and y[i]<1,[i,y[i]],NULL), [$nops(y)]);

[[1, .2499109628], [4, .3475034102], [10, 0.8823971507e-2]]

#
# This inefficiently creates all [i,y[i]] even if not needed.
# It also creates list [$nops(y)]
#
select(u->u[2]>0 and u[2]<1, map(i->[i,y[i]], [$nops(y)]));

[[1, .2499109628], [4, .3475034102], [10, 0.8823971507e-2]]

#
# Using a loop, which is not awful but more to code.
#
L:='L': # L will become a table
for i from 1 to nops(y) do
  if y[i]>0 and y[i]<1 then
    L[i] := [i,y[i]];
  end if;
end do:
convert(L, list);

[[1, .2499109628], [4, .3475034102], [10, 0.8823971507e-2]]

#
# This is a bad way to do it, by repeatedly
# augmenting the list.
#
L:=[]:
for i from 1 to nops(y) do
  if y[i]>0 and y[i]<1 then
    L := [op(L), [i,y[i]]];
  end if;
end do:
L;

[[1, .2499109628], [4, .3475034102], [10, 0.8823971507e-2]]

 

Now some timings, with a larger example of 10^5 elements.

Each is done after its own restart, for a fair comparison.

 

restart;

r:=rand(0...5.):

y:=[seq(r(), n=1..10^5)]:

str:=time[real]():

[seq(`if`(y[n]>0 and y[n]<1,[n,y[n]],NULL), n=1..nops(y))]:

(time[real]()-str)*'seconds';
nops(%%);

.293*seconds

20166

restart;

r:=rand(0...5.):

y:=[seq(r(), n=1..10^5)]:

#
# This is slightly less efficient since it creates list [$nops(y)]
#
str:=time[real]():

map(i->`if`(y[i]>0 and y[i]<1,[i,y[i]],NULL), [$nops(y)]):

(time[real]()-str)*'seconds';
nops(%%);

.329*seconds

20166

restart;

r:=rand(0...5.):

y:=[seq(r(), n=1..10^5)]:

#
# This inefficiently creates all [i,y[i]] even if not needed.
# It also creates list [$nops(y)]
#
str:=time[real]():

select(u->u[2]>0 and u[2]<1, map(i->[i,y[i]], [$nops(y)])):

(time[real]()-str)*'seconds';
nops(%%);

.479*seconds

20166

restart;

r:=rand(0...5.):

y:=[seq(r(), n=1..10^5)]:

str:=time[real]():

L:='L': # L will become a table
for i from 1 to nops(y) do
  if y[i]>0 and y[i]<1 then
    L[i] := [i,y[i]];
  end if;
end do:
convert(L, list):

(time[real]()-str)*'seconds';
nops(%%);

.363*seconds

20166

restart;

r:=rand(0...5.):

y:=[seq(r(), n=1..10^5)]:

#
# This is a bad way to do it, by repeatedly
# augmenting the list.
#
str:=time[real]():

L:=[]:
for i from 1 to nops(y) do
  if y[i]>0 and y[i]<1 then
    L := [op(L), [i,y[i]]];
  end if;
end do:
L:

(time[real]()-str)*'seconds';
nops(%%);

15.413*seconds

20166

 

Download list_selection.mw

[edit] If you only want the first element that satifies the condition (or if you know that your list has at most one such element) then there are approaches that can be faster. It can be beneficial to break out of the search as soone as one element is found. For example, comparing with the original seq approach,

restart;

r:=rand(1.0..5.0):

y:=[seq(r(), n=1..10^5)]:
y:=[y[1..floor(nops(y)/3)][],0.4,y[floor(nops(y)/3)+1..-1][]]:

str:=time[real]():

[seq(`if`(y[n]>0 and y[n]<1,[n,y[n]],NULL), n=1..nops(y))];

(time[real]()-str)*'seconds';

[[33334, .4]]

.230*seconds

restart;

r:=rand(1.0..5.0):

y:=[seq(r(), n=1..10^5)]:
y:=[y[1..floor(nops(y)/3)][],0.4,y[floor(nops(y)/3)+1..-1][]]:

str:=time[real]():

L:='L': # L will become a table
for i from 1 to nops(y) do
  if y[i]>0 and y[i]<1 then
    L[i] := [i,y[i]];
    break;
  end if;
end do:
convert(L, list);

(time[real]()-str)*'seconds';

[[33334, .4]]

0.83e-1*seconds

restart;

r:=rand(1.0..5.0):

y:=[seq(r(), n=1..10^5)]:
y:=[y[1..floor(nops(y)/3)][],0.4,y[floor(nops(y)/3)+1..-1][]]:

#
# If we only want the first successful element then
# the table is not necessary.
#
str:=time[real]():

for i from 1 to nops(y) do
  if y[i]>0 and y[i]<1 then
    ans := [i,y[i]];
    break;
  end if;
end do:
ans;

(time[real]()-str)*'seconds';

[33334, .4]

0.84e-1*seconds

 

restart;

r:=rand(1.0..5.0):

y:=[seq(r(), n=1..10^5)]:
y:=[y[1..floor(nops(y)/3)][],0.4,y[floor(nops(y)/3)+1..-1][]]:

str:=time[real]():

(e->[e,y[e]])(ListTools:-SelectFirst(e->e>0 and e<1, y, 'output'=':-indices'));

(time[real]()-str)*'seconds';

[33334, .4]

.112*seconds

 

Download list_selection_singleton.mw

The procedure shown as IPP:-Convolution is a local member of the IPP submodule of the SignalProcessing module (package).

Here are two ways that you can inspect its (initial) form.

restart;
showstat((SignalProcessing::IPP)::Convolution);

Convolution := proc()
   1   passign(procname,defun(convert("Convolution",'string'),"msp",(':-mtsafe
         ') = true));
   2   procname(_passed)
end proc
restart;
kernelopts(opaquemodules=false):
eval(SignalProcessing:-IPP:-Convolution);
kernelopts(opaquemodules=true):

proc()
   option THREAD_SAFE;
   passign(procname, defun(convert("Convolution", 'string'), "msp", ':-mtsafe' = true)); procname(args)
end proc

That somewhat obscure-looking code serves the purpose of rewriting the procedure's own body the first time it gets called.

SignalProcessing:-Convolution(Array([5,7]),Array([-2,6,10])):

kernelopts(opaquemodules=false):
eval(SignalProcessing:-IPP:-Convolution);
kernelopts(opaquemodules=true):

proc()
   options call_external,
           define_external(mspConvolution, MAPLE, LIB = "libmsp.so", THREAD_SAFE);
   call_external(0, 140184961382080, true, true, args)
end proc

The first time it gets called it sets itself up and replaces itself with a so-called external-call, ie. a call out to a precompiled external dynamic library. In this case it is an external-call to a bridging function, and the module name IPP suggests that the bridge is to a suitable function from the Intel IPP Library (Integrated Performance Primitives), containing highly optimized functionality that includes signal processing.

Your attachment doesn't provide your own method for shading under the curve, even for any fixed T value. You said you knew how to combine that with the curve using plots:-display, but didn't provide any example of just what you meant. So I'll supply something crude for that part of the task.

Here are a few ways. One of them calls densityplot dynamically, for each new "explored" value. The other computes a sole densityplot up front, and then transforms that to fit under your curve.

Also the first uses WavelengthToColor from the ColorTools package, while the second uses a linear hue gradient (which is of course not quite right). You may have your own wavelength->hue method. I am not satisfied with the values from WavelengthToColor, but I am having trouble finding my own version written many years ago...

You can experiment with various combinations, to see which gets you the smoothest action under a continuous movement of the Slider. If the code is too slow to compute each frame (for each T value) then continuously moving the Slider will produce a computational backlog and make the action appear jilted. In such a case you could toggle off continuous-updating of the Slider, having it only compute once, after the Slider is finished its move. But a continuous update is more visually impressive, if the frame computations are fast enough to allow it.

You could mix and match the apporaches: transformation of a single precomputed densityplot, or dynamically generated densityplots -- either of those using any wavelength->hue scheme mentioned above, or your own.

You could also call Explore directly on some of the plots:-display calls, without need for name procedures (foo, blah). I prefer such custom procedures because then I can test them by calling them outside of Explore.

Download Planck_curve_ac.mw

It is also possible to use the full qualities of the colors, ie. also use their intensity and saturation, and not only their hue (with maximal intensity and saturation). Perhaps its prudent to wait for complete details of what you want to accomplish, and what you want the colors to represent in terms of power or perception.

My Maple GUI sometimes gets into this state.

If I shutdown the GUI (either using the menu, or the corner Close icon) then it (almost always) prompts me whether I want to save the open worksheet. If the worksheet was not yet saved as a filename then usually it prompts me for a filename at that point.

If that works then I can Relaunch the GUI and then Reopen the saved worksheet.

A rare scenario is that it gets into the problem state but doesn't allow me to save. Hopefully that is not your case.

Here are various ways.

Obtaining floating-point approximations is relatively easy, and two direct ways are shown, ie. straight calls to a single command. The fsolve example relies on guessing an overestimate of the number of roots. The Calculus1:-Roots example doesn't require such as guess.

Obtaining all the roots in 0..2*Pi, in exact form, is also shown, in a few ways that have varying success and complexity. These kinds of computation can involve using fortuitous simplifications -- sometimes both before and after substitution. (Discovering a sufficient simplification is one aspect that can make this tough, for both the user and Maple's own symbolic solvers.)

restart;

kernelopts(version);

`Maple 2021.1, X86 64 LINUX, May 19 2021, Build ID 1539851`

expr := sin(x)-cos(4*x - 1/6*Pi);

sin(x)-sin(4*x+(1/3)*Pi)

 

The following uses the undocumented option `maxsols`.

 

ans1 := [fsolve(expr, x=0..2*Pi, maxsols=10)];

[.4188790204, 1.675516081, 1.745329251, 2.932153143, 3.839724354, 4.188790204, 5.445427266, 5.934119456]

nops(ans1);

8

ans2a := Student:-Calculus1:-Roots(expr, x=0..2*Pi, numeric);

[.4188790205, 1.675516082, 1.745329252, 2.932153143, 3.839724354, 4.188790205, 5.445427266, 5.934119457]

nops(ans2a);

8

 

The following finds some (but not all) of the roots exactly. Some are not best simplified.

 

ans2b := Student:-Calculus1:-Roots(expr, x=0..2*Pi);

Warning, some roots are returned as numeric approximations

[.4188790227, 1.675516082, (5/9)*Pi, 2.932153134, -(1/2)*arctan(sin((4/9)*Pi)/(3^(1/2)*sin((4/9)*Pi)-2*cos((1/9)*Pi)))+Pi, (4/3)*Pi, 5.445427266, (17/9)*Pi]

simplify(combine(convert(ans2b,expln)));

[.4188790227, 1.675516082, (5/9)*Pi, 2.932153134, (11/9)*Pi, (4/3)*Pi, 5.445427266, (17/9)*Pi]

identify(%);

[.4188790227, (8/15)*Pi, (5/9)*Pi, 2.932153134, (11/9)*Pi, (4/3)*Pi, (26/15)*Pi, (17/9)*Pi]

evalf(%);

[.4188790227, 1.675516082, 1.745329252, 2.932153134, 3.839724354, 4.188790204, 5.445427266, 5.934119458]

nops(%);

8

 

The following does better at finding exact representations, but misses some.

 

ans3 := sort(simplify(eval~(x,[solve({expr, x>=0, x<=2*Pi}, x, explicit)])));

[(2/15)*Pi, (5/9)*Pi, (8/15)*Pi, (14/15)*Pi]

evalf(ans3); # `solve` missed the solutions between Pi and 2*Pi

[.4188790204, 1.745329252, 1.675516082, 2.932153144]

nops(%);

4

 

These are exact roots.

 

exroots := sort([2*Pi/15, 8/15*Pi, 5/9*Pi, 14*Pi/15, 11/9*Pi, 4/3*Pi, 26/15*Pi, 17/9*Pi]);

[(2/15)*Pi, (4/3)*Pi, (5/9)*Pi, (8/15)*Pi, (11/9)*Pi, (14/15)*Pi, (17/9)*Pi, (26/15)*Pi]

seq(expr, x=exroots);

0, 0, 0, 0, 0, 0, 0, 0

nops(exroots);

8

 

We can find the following exact representations. We could subsequently
substitute the unspecified integer constants _Z?? with generated values
and select only those which fell within the 0..2*Pi range. Below I get
lucky in the choice of -5..5 as candidate values for those unknowns.

 

[solve({expr}, x, explicit, allsolutions)]:
raw4 := simplify(evala(convert(eval~(x,%),expln)));

[-(2/3)*Pi+2*Pi*_Z4, -(1/9)*Pi+2*Pi*_Z5, -(7/9)*Pi+2*Pi*_Z5, (5/9)*Pi+2*Pi*_Z5, (2/15)*Pi+2*Pi*_Z6, (8/15)*Pi+2*Pi*_Z6, -(4/15)*Pi+2*Pi*_Z6, (14/15)*Pi+2*Pi*_Z6]

unkns := indets(raw4, suffixed(_Z));

{_Z4, _Z5, _Z6}

ans4 := sort(select(v->v::realcons and is(v>=0) and is(v<=2*Pi),
                    [seq(seq(eval(raw4,u=uu)[], uu=-5..5)[], u=unkns)[]]));

[(2/15)*Pi, (4/3)*Pi, (5/9)*Pi, (8/15)*Pi, (11/9)*Pi, (14/15)*Pi, (17/9)*Pi, (26/15)*Pi]

seq(expr, x=ans4);

0, 0, 0, 0, 0, 0, 0, 0

nops(ans4);

8

 

Download solve_trig_ex.mw

[edit] The above was done in Maple 2021.1. In my older Maple 2019.2 getting the nicer exact form of (some of) the results from the second calls to Calculus1:-Roots required a slightly different simplifying concoction, eg.
    simplify(evala(simplify(convert(ans2b,expln))))
solve_trig_ex_2019.2.mw

I will submit some of these weaknesses in simplify as bug reports.

The Units:-UseUnit command allows you to set the units to which something (of the matching dimension) will simplify. But I don't see that as also providing the given choice via the right-click units-formatting menu, in my Maple 2021.1.

But I do get that choice -- via the right-click menu -- if I use an older mechanism involving two commands, Units:-AddSystem and Units:-UseSystem.

In the attached worksheet I utilized the right-click units-formatting on the last line's output, and selected the desired choice from the drop-menu. Only that last output has right-click units-formatting.

restart

Units:-AddSystem(NewSI, Units:-GetSystem('SI'), J/(K*mol))

Units:-UseSystem(NewSI)

expr := (3/2*8.3144621)*Unit(J/(K*mol))

12.47169315*Units:-Unit(J/(K*mol))

simplify(expr)

12.47169315*Units:-Unit(J/(K*mol))

expr2 := (3/2*8.3144621)*Unit(m^2*kg/(s^2*K*mol))

12.47169315*Units:-Unit(m^2*kg/(s^2*K*mol))

simplify(expr2)

12.47169315*Units:-Unit(J/(K*mol))

expr2

12.47169315*Units:-Unit(m^2*kg/(s^2*K*mol))

expr2

12.47169315*Units:-Unit(J/(K*mol))

 

Download UseSystem_units_formatting.mw

Already in Maple 2016.0.

kernelopts(version);
              Maple 2016.0, X86 64 LINUX, Feb 16 2016, Build ID 1113130

f := x*y:                                           

JH := int(Heaviside(f-1/2), x=0..1, y=0..1);        

         JH := 1/2 - 1/2 ln(2)

JP := int(piecewise(x*y>1/2, 1, 0), x=0..1, y=0..1);

         JP := 1/2 - 1/2 ln(2)

Your example of 1.0*e7 is rather simple, and there are many trivial ways to render 10e6 based on 1.0e7 as input. Something more general could be useful.

I looked around some old worksheets and found the following for engineering notation of floats.

(The finesse of stripping trailing zeros -- one of several options below -- is based on a revision on some old code by Axel Vogt.)

In custom axis-tickmarks of the second and third plots below I show some additional formatting choices (which you could also use in formatting other float values for the legend).

restart;
EN := module() local ModuleApply, Strip;
  ModuleApply := proc(t::numeric,
                      {displayonly::truefalse:=true,
                       enotation::{truefalse,
                                   identical(lowercase)}:=false,
                       showzeroexponent::truefalse:=true,
                       stripzeroes::truefalse:=true})
    local m,mant,sgn,strip; uses InertForm;
    strip := `if`(stripzeroes,Strip,x->x);
    if t=0.0 then (m,mant,sgn) := 0,Strip(t),1;
    else m := iquo(ilog10(t),3);
      (mant,sgn) := Strip(10^(-3*m)*t),signum(t);
    end if;
    if showzeroexponent=false and m=0 then Strip(t);
    elif displayonly then
      if member(enotation,[true,':-lowercase']) then
        nprintf("#mrow(mn(%a),mn(%s),mn(%a));",
                `if`(mant=0.,"0.",
                     sprintf(sprintf("%s.%af","%",
                             length(op(1,mant/sgn))-ilog10(mant/sgn)-1),
                             mant)),
                `if`(enotation=true,"E","e"),3*m);
      else sgn*Display(mant/sgn%*10%^(3*m),':-inert'=false);
      end if;
    else mant*10%^(3*m);
    end if;  
  end proc:
  Strip:=proc(x)
    local M,E,sM,smu,res; uses StringTools;
    if x=0 then return x;
    elif not type(x,float) then return x;
    elif x < 0 then return -procname(-x) end if;
    (M,E) := SFloatMantissa(x),SFloatExponent(x);
    sM := convert(M,string);
    smu := SubstituteAll(TrimRight(SubstituteAll(sM,"0"," "))," ","0");
    res := SFloat(parse(smu),E+length(sM)-length(smu));
    if res=trunc(res) then trunc(res) else res; end if;
  end proc;
end module:

Lres := 1/((2*Pi*freq)^2*Cres):
ftest := 10e6:

plot(eval(Lres, freq = ftest), Cres = 0.0 .. 1e-9,
     labels = [Cres, 'Lres'],
     legend = EN(ftest),
     color = red,
     title = 'Inductance*Value*as*a*Function*of*Resonant*Capacitance',
     axis = [gridlines = [default]], size=[600,300]);

plot(eval(Lres, freq = ftest), Cres = 0.0 .. 1e-9,
     labels = [Cres, 'Lres'],
     legend = EN(ftest),
     color = red,
     title = 'Inductance*Value*as*a*Function*of*Resonant*Capacitance',
     xtickmarks = map(x->x=EN(x,enotation=lowercase),[seq(0.0..1e-9, 2e-10)]),
     axis = [gridlines = [default]], size=[600,300]);

plot(eval(Lres, freq = ftest), Cres = 0.0 .. 1e-9,
     labels = [Cres, 'Lres'],
     legend = EN(ftest),
     color = red,
     title = 'Inductance*Value*as*a*Function*of*Resonant*Capacitance',
     xtickmarks = map(x->x=EN(x,enotation=lowercase,showzeroexponent=false),[seq(0.0..1e-9, 2e-10)]),
     ytickmarks = map(x->x=EN(x,enotation=lowercase,showzeroexponent=false),[seq(0.0..1e-5, 1e-6)]),
     axis = [gridlines = [default]], size=[600,300]);

engineering_notation.mw

The attached worksheet contains a few more corner cases (testing), and a column-by-column table for visually easier comparision of optional effects.

There is room for improvement. When stripzeroes=false is specified then additional trailing zeroes appear -- so at present it can't be used to denote the concept of precision or extra significant-figures.

There are several pitfalls, where the regular typesetting mechanisms can interfere and undo part of some crafted solutions. But at least all this doesn't involve the poor mechanism of applying ``(...) and the ensuing italic font and unnecessary brackets.

You might play around with the colorscheme used in a densityplot of the complex argument of the function.

restart;

f := x -> x^3 + 3^x:

plots:-densityplot(argument(f(a+b*I)),
                   a=-17..23,b=-35..35,
                   grid=[401,401],style=surface,
                   colorscheme=["zgradient",[white,red,blue]],
                   labels=[Re(x),Im(x)],
                   size=[700,400],axes=boxed);

plots:-densityplot(argument(f(a+b*I)),
                   a=-17..23,b=-35..35,
                   grid=[401,401],style=surface,
                   colorstyle=HUE,
                   labels=[Re(x),Im(x)],
                   size=[700,400],axes=boxed);

 

Download cplx_plot_colorscheme.mw

Another way to obtain the color image of that second example (the full hue range) is to rip the color substructure out of the complexplot3d result. This allow you to display it as an image instead of as a high resolution density plot, and so place much less burden on the GUI interface. (You may find that the GUI becomes slugglish when scrolling or saving, for the other approaches in this Answer which render plots.) Eg,

restart;
f := x -> x^3 + 3^x:
H:=op([1,4,2],plots:-complexplot3d(f,-17-35*I..23+35*I,grid=[700,400])):
hsv:=Array(1..700,1..400,1..3,1.0,datatype=float[8]):
hsv[..,..,1]:=360*H:
img:=ImageTools:-Rotate(ImageTools:-HSVtoRGB(hsv),90,':-degrees'):
plot(view=[-17..23,-35..35],background=img,
     labels=[Re(x),Im(x)],
     size=[700,400]);
ImageTools:-Embed(img);

note: The background option to the plotting command is a little buggy (offset) in (only, so far) release Maple 2021.1.

Yet another way to do it as a density plot is to transform the complexplot3d result from 3D to 2D. This is an easy way to avoid some of the artefacts (due to undefined, say) in the earlier full hue densityplot result. Eg,

restart;
f := x -> x^3 + 3^x:
Q:=plots:-complexplot3d(f,-17-35*I..23+35*I,grid=[700,400],
                        style=surface,size=[700,400]):
plottools:-transform((x,y,z)->[x,y])(Q);

[edit] Your Question's title contains the wording, "...2D line type separating the real and imaginary parts". But I have considered reproducing the kind of plot colorings that you showed in your Question. If you really want to show only some curves/areas where the complex argument takes on only some finite number of values (or within epsilon of such) -- such as when the result is purely real -- then please respond and be very clear and explicit about the goal.

First 80 81 82 83 84 85 86 Last Page 82 of 336