acer

32687 Reputation

29 Badges

20 years, 75 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

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.

For your first example, try,

   fsolve(f(x)=g(x))

For your second example, try,

   plot( [ Re(f(x)), Im(f(x)) ] )

f:=x->(x^2)-6*x+p+3: g:=x->(4*x^2)-(p-8)*x+7:

sol:=solve({ f(xf)=g(xg), D(f)(xf)=0, D(g)(xg)=0,
             (D@@2)(f)(xf)>0, (D@@2)(g)(xg)>0 });

     /                      -5\    /                     1\ 
    { p = -12, xf = 3, xg = -- }, { p = 12, xf = 3, xg = - }
     \                      2 /    \                     2/ 

eval({f(xf),g(xg)},sol[1])[];

            -18

eval({f(xf),g(xg)},sol[2])[];

              6

Maple's model of functional evaluation is inside-to-outside, and if you want to avoid some potential evaluation issues then I suggest reducing the inert operators from the inside out.

Here's an example, (based in part on this old code's idea). The inert=false option merely allows the output to render in the usual way, as opposed to the gray glyphs.

restart;

R := module() local f, T, S, ModuleApply;
  T := And(function,
           ':-satisfies'(f->evalb(convert(op(0,f),string)[1]="%")));
  S := t -> convert(convert(op(0,t),string)[2..],name);
  f := X -> subsindets(X,And(T,satisfies(e->hastype([op(e)],T)=false)),
                       t->S(t)(op(t)));
  ModuleApply:=proc(X, {inert::truefalse:=true})
    local res,old,temp;
    old := X;
    do print(InertForm:-Display(old,':-inert'=inert));
      temp := f(old);
      if temp=old then break;
      else old := temp; end if;
    end do;
    return temp;
  end proc;
end module:

 

expr := 12 %/ (1 %- %abs(2%^2 %- (3 %- 1 %- 1%^2)%^2))
        %+ %abs(-7) %/ %abs((x %- x) %- 2%^2)%^2:

InertForm:-Display(expr);

0, "%1 is not a command in the %2 package", _Hold, Typesetting

value(expr);

-89/16

R(expr):

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

-89/16

R(expr, inert=false):

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

0, "%1 is not a command in the %2 package", _Hold, Typesetting

-89/16

 

Download inert_value_recur_outwards1.mw

If you really want you can get the behaviour from the outside in, but something general has to be given up. You won't be able to use the inert form of every command (eg. fsolve), while retaining evaluation at each step. But if you're willing to allow inert forms of, say, just arithmetic operators and some simple things (that can return unevaluated) then something could be accomplished with recursion & state (operand list for position, and running expression) & subsop.

Note that the construction of 2^(2/3)/2 from input 2^(-1/3) happens as a consequence of automatic simplification.

As such it cannot be prevented by delaying evaluation, eg. by use of uneval quotes, etc.

You may be able to use the inert operators such as %^, etc, to construct something that can be displayed as you want.

'2^(-1/3)';

(1/2)*2^(2/3)

ee := 2%^(-1/3):

InertForm:-Display(ee, 'inert'=false);

0, "%1 is not a command in the %2 package", _Hold, Typesetting

Typesetting:-Typeset(Typesetting:-EV(ee));

0, "%1 is not a command in the %2 package", _Hold, Typesetting

Download inert_ex.mw

At this point you may care to inform us of how the expression is first formed, ie. do you want to type it in, or is it a result of a computation.

If I understand the question properly, here are some alternatives you might consider.

The first one changes only how it gets normally pretty-printed. The second actually strips off the outer call.

You only have to define the procedure once per session, and you don't have to do some extra step each time you want to create or print an inert expression.

restart;

`print/%+` := proc()
  if nargs=1 then args[1];
  else '`%+`'(args); end if;
end proc:

 

expr := `%+`(floor(5 %/ (2 %* 3 %* 5)));

`%+`(floor(`%/`(5, `%*`(`%*`(2, 3), 5))))

expr;

`%+`(floor(`%/`(5, `%*`(`%*`(2, 3), 5))))

InertForm:-Display(expr);

0, "%1 is not a command in the %2 package", _Hold, Typesetting

lprint(expr);

`%+`(floor(5 %/ ((2 %* 3) %* 5)))

`%+`(a,b,c);

`%+`(a, b, c)

lprint(%);

`%+`(a,b,c)

restart;

`%+` := proc()
  if nargs=1 then args[1];
  else 'procname'(args); end if;
end proc:

 

expr := `%+`(floor(5 %/ (2 %* 3 %* 5)));

floor(`%/`(5, `%*`(`%*`(2, 3), 5)))

expr;

floor(`%/`(5, `%*`(`%*`(2, 3), 5)))

InertForm:-Display(expr);

floor(Typesetting:-_Hold([`%/`(5, `%*`(`%*`(2, 3), 5))]))

lprint(expr);

floor(5 %/ ((2 %* 3) %* 5))

`%+`(a,b,c);

`%+`(a, b, c)

lprint(%);

`%+`(a,b,c)

 

Download inert_plus_single.mw

You might also do something similar for `%*`.

The integervariables option of the LPSolve command allows you to specify (as a list) the names of the variables which must be integer-valued.

Eg,

with(Optimization):

obj := -4*x-5*y:

cons := {x+3/2*y<=6, 5*x+4*y<=20, x>=0, y>=0}:

LPSolve(obj, cons,integervariables=[x]);

   [-20.666666666666668, [x = 1, y = 3.3333333333333335]]


LPSolve(obj, cons, integervariables=[y]);

          [-21.0, [x = 1.4999999999999998, y = 3]]

LPSolve(obj, cons, integervariables=[x,y]);

                 [-20, [x = 0, y = 4]]

Your original attachment called implicitplot for first argument M (which implies M=0), and it called contourplot on first argument M with option contours=[1] (which implies M=1). That's a mismatch in the values/heights of the contours/level-curves, which makes the comparison invalid, and which I've corrected below.

Below are plots for M=1 and M=0, each done with both those commands for comparison.

I used a larger initial grid option size, for implicitplot, and bumped down the gridrefine option's value.

The results basically match, between implicitplot and contourplot, except the latter's curves are coarser. The former is much faster and smoother. And the latter produces a coarser result even with a large grid value, that consists of a very large plotting structure that places considerable burden on the GUI.

restart; with(plots)

beta[0] := ((cos(u)+sin(u)-1)*exp(2*u)-cos(u)+1+(-2*exp(u)+1)*sin(u))/(u*(exp(2*u)*cos(u)+cos(u)-2*exp(u))):

beta[1] := ((cos(u)+sin(u)-1)*exp(2*u)-cos(u)+1+(-2*exp(u)+1)*sin(u))/(u*(exp(2*u)*cos(u)+cos(u)-2*exp(u))):

delta[1] := ((-sin(u)+1)*exp(2*u)-2*exp(u)*cos(u)+sin(u)+1)/(u^2*(exp(2*u)*cos(u)+cos(u)-2*exp(u))):

delta[0] := ((sin(u)-1)*exp(2*u)+2*exp(u)*cos(u)-sin(u)-1)/(u^2*(exp(2*u)*cos(u)+cos(u)-2*exp(u))):

M := simplify((z^2*delta[0]+z*beta[0]+1)/(-z^2*delta[1]-z*beta[1]+1)):

 

Firstly, let's consider M=1.

 

i*mplicitplot(M = 1, z = -15 .. 15, u = -15 .. 15, filled = true, grid = [75, 75], gridrefine = 3, labels = [z, u], coloring = [blue, gray], axes = boxed)

contourplot(M, z = -15 .. 15, u = -15 .. 15, filled = true, grid = [150, 150], contours = [1], labels = [z, u], coloring = [blue, grey], axes = boxed)

NULL

And now for M=0

 

implicitplot(M, z = -15 .. 15, u = -15 .. 15, filled = true, grid = [75, 75], gridrefine = 3, labels = [z, u], coloring = [blue, gray], axes = boxed)

contourplot(M, z = -15 .. 15, u = -15 .. 15, filled = true, grid = [150, 150], contours = [0], labels = [z, u], coloring = [blue, grey], axes = boxed)

``

Here is a revision, done in Maple2016.2,

SDFFM_STAB_ac.mw

With your original grid=[5,5], gridrefine=8 some features/regions get missed. (Missed, I suspect, during initial analysis at the unfortunately-coarse initial [5,5], and hence subsequently also missed for refinement.)

In Maple 2021.1, by the way, the implicitplot command has some trouble with the very large (+/-) values of M, or with the severe slope, I suspect. That can be accomodated by an adjustment, to pass it, say,
    max(min(M,2),-2) = 1
instead of just M=1. And similarly for M=0.

SDFFM_STAB_ac_2021.1.mw

These first two will not work directly in Maple 2015.2, but I'm going to mention them anyway since that version is getting quite out of date and some people might be interested in more current versions's behavior.

restart;

kernelopts(version);

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

expr := -.27059805007310*sin(.12+epsilon)
        +.27059805007310*sqrt(1.-cos(.12+epsilon)^2);

-.27059805007310*sin(.12+epsilon)+.27059805007310*(1.-cos(.12+epsilon)^2)^(1/2)

kernelopts(floatPi=true):

simplify(convert(expr,rational)) assuming epsilon < Pi-12/100, epsilon > -12/100;

0

kernelopts(floatPi=false):

simplify(expr) assuming epsilon < Pi-0.12, epsilon > -0.12;

0.

Download simplify_floatPi.mw

[edit] Maple 2015 suffered from an additional weakness of needing a kick to get the trig identity applied. Here are two ways to do that kick, for each of the two approaches floatPi=true alongside rationals, and floatPi=false.

The approach below using freeze & thaw is an automation of a process to replace the sin & cos arguments temporarily with a symbol, which allows the trig identity simplification to succeed here. That's analogous to automating the steps subs(0.12 + epsilon=t, expr) and (potentially necessary) final replacement of t, in Kitonum's second approach.

For the applyrule apporach, note that the latter step involves simplify(...,trig) which succeeds, while simplify(...) without the option does not succeed in Maple 2015.2.

restart;

kernelopts(version);

`Maple 2015.2, X86 64 LINUX, Dec 20 2015, Build ID 1097895`

expr := -.27059805007310*sin(.12+epsilon)
        +.27059805007310*sqrt(1.-cos(.12+epsilon)^2);

-.27059805007310*sin(.12+epsilon)+.27059805007310*(1.-cos(.12+epsilon)^2)^(1/2)

kernelopts(floatPi=true):

thaw(simplify(subsindets(convert(expr,rational),specfunc({sin,cos}),
                         u->op(0,u)(freeze(op(u))))));

(21732/80311)*sin(3/25+epsilon)*(-1+csgn(sin(3/25+epsilon)))

simplify(%) assuming epsilon < Pi-12/100, epsilon > -12/100;

0

applyrule(1-cos(p::anything)^2=sin(p)^2, convert(expr,rational));

-(21732/80311)*sin(3/25+epsilon)+(21732/80311)*(sin(3/25+epsilon)^2)^(1/2)

simplify(%, trig) assuming epsilon < Pi-12/100, epsilon > -12/100;

0

kernelopts(floatPi=false):

thaw(simplify(subsindets(expr,specfunc({sin,cos}),
                         u->op(0,u)(freeze(op(u))))));

-.2705980501*sin(.12+epsilon)+.2705980501*csgn(sin(.12+epsilon))*sin(.12+epsilon)

simplify(%) assuming epsilon < Pi-0.12, epsilon > -0.12;

0.

applyrule(1-cos(p::anything)^2=sin(p)^2, expr);

-.27059805007310*sin(.12+epsilon)+.27059805007310*(sin(.12+epsilon)^2)^(1/2)

simplify(%, trig) assuming epsilon < Pi-0.12, epsilon > -0.12;

0.

Download simplify_Pyth_floatPi_2015.mw

Lastly, a note on why floatPi matters here. Consider the following effect.

restart;

kernelopts(floatPi=true):

epsilon < Pi - 0.12;

epsilon < 3.021592654

kernelopts(floatPi=false):

epsilon < Pi - 0.12;

epsilon < Pi-.12

Download floatPi_consequence.mw

So, when floatPi=true (default) the inequality gets significantly altered. And in consequence some mixed floating-point & symbolic expressions can just be too much for the simplifier to recognize simplifications under mismatches due to roundoff error.

I used the particular formulation  epsilon<Pi-0.12  in above assumptions only because you had that in your Question. If you accept the formulation as  epsilon+0.12<Pi  and you replace that with a symbol then floatPi may not be relevant. Programatically picking off all arguments to sin&cos calls and freezing them may also get you those replacements. Earlier I used subsindets above on sin&cos calls, but indets can also work, also helping in programmatically generating assumptions.

So, as a more general and programmatic revision of one of my earlier four methods for Maple 2015,

restart;

kernelopts(version);

`Maple 2015.2, X86 64 LINUX, Dec 20 2015, Build ID 1097895`

expr := -.27059805007310*sin(.12+epsilon)
        +.27059805007310*sqrt(1.-cos(.12+epsilon)^2);

-.27059805007310*sin(.12+epsilon)+.27059805007310*(1.-cos(.12+epsilon)^2)^(1/2)

fcns := op~(indets(expr,specfunc({sin,cos}))):
conds := map(u->(u>0,u<Pi),fcns)[]:
R := fcns=~(freeze~(fcns)):
thaw(simplify(eval(expr,R))) assuming eval(conds,R);

0.

Download simplify_trig_float_2015.mw

In the case of multiple trig calls with differing operands you could handle contradictory generated assumptions, say by catching the relevent error thrown by assuming.

First 84 85 86 87 88 89 90 Last Page 86 of 340