acer

32490 Reputation

29 Badges

20 years, 7 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@tomleslie Cutting and pasting your example in as 2D Input, it works as the body of an operator.

restart

f := proc (x) options operator, arrow; if x = 0 then 1 elif x = 1 then 2 elif x = 3 then 7 else 10 end if end proc

proc (x) options operator, arrow; if x = 0 then 1 elif x = 1 then 2 elif x = 3 then 7 else 10 end if end proc

map(f, [0, 1, 3, 4])

[1, 2, 7, 10]

``

Download 2dmath_elif_operator.mw

I only tried Maple 2019.0, Maple 2018.2, and Maple 2016.2.

I also works if I type it all on a single line.

@tomleslie I have no idea what you're trying to state, sorry.

You made a claim about operators and requiring `if`(...) form which is not correct.

Also, you made it sound very much like the OP's problem was because he was not using `if`(..) form, and that is not true.

@abecke12 Many users of Maple make these two changes as global preferences in the GUI:

1. File->New shows a new Worksheet rather than a Document.

2. Input notation is 1D Maple Notation (plaintext), rather 2D Input.

Both can be set and saved globally for all future sessions under Tools->Options.

Output still gets marked up and displays in 2D Math.  But the input code is WYSIWYG. And Worksheet editing and navigation are much, much better than for Document.

And the parsing has much, much fewer irritations, issues, and bugs.

@abecke12 Using that much 2D Input can really slow down the parsing of the worksheet, especially (but not restricted to cases) when it thinks there's an issue.

I'm amazed whenever I see anyone willing to wait for several seconds or even longer for parsing that is almost immediate in 1D Maple Notation.

@tomleslie Your claim about operator definitions requiring the form `if`(...) is incorrect. Not even for 2D Math.

It just happens to fix this particular example (as Carl had noted) because some weird bug is occuring with the 2D Input parsing of the wider procedure that encompasses the operator. The GUI displays a red boxed message that wrongly indicates a problem point.

@abecke12 If I just delete some lines from near the bottom of the procedure defn (almost at random) then it parses without that error. So it's possible that it's a 2D Math parsing bug.

It seems to work for me, even in 2D Input in a Document and without encapsulating brackets around the procedure body.

Perhaps you could upload a Document that reproduces the problem.

restart

kernelopts(version)

`Maple 2018.2, X86 64 LINUX, Nov 16 2018, Build ID 1362973`

q1 := proc (n1, n2) options operator, arrow; if n1 < 0 then 0 elif n2 < 0 then 0 elif abs(n1-n2) = 1 then sqrt((1/2)*max(n1, n2)) else 0 end if end proc

q1(7, 6)

(1/2)*14^(1/2)

`if`(n1 = n2, 1, 0); q1 := proc (n1, n2) options operator, arrow; if n1 < 0 then 0 elif n2 < 0 then 0 elif abs(n1-n2) = 1 then sqrt((1/2)*max(n1, n2)) else 0 end if end proc

0

q1(7, 6)

(1/2)*14^(1/2)

``

Download if_operator_2dmath.mw

@dharr And he's also used the name I in a way that may have him confused.

Perhaps best for him would be to use some other name such as II instead. That's might make it more clear if the imaginary unit I appears in the result. (There are alternatives. But as it is the code looks confusing.)

@Bart Yes, using a value of 0.1 for the thickness makes the result from my suggestion to use subsindets look even better than the OP's suggestion to use value 0 does. I have edited my Answer accordingly, with attribution.

I have submitted various bug reports, on commands where thickness=0.1 is not allowed (but ought to be), and that the THICKNESS value 0.1 renders a thinner line that value 0 does. This kind of thing --- where Maple has the power but it's hidden -- needs to be fixed.

@rstellian The stylesheet option was introduced in Maple 2017, so it's not available in Maple 2016.

@wanderson 

It may be enough to change inert Diff to active diff here (or perhaps use value(pde) ).

restart;

kernelopts(version);

`Maple 13.00, X86 64 LINUX, Apr 13 2009, Build ID 397624`

(1)

The equation of heat condition in a medium of
variable conductivity k(x) is
"(&PartialD; u)/(&PartialD; t)=(&PartialD;)/(&PartialD; x)(k(x) (&PartialD; u)/(&PartialD; x))."

In your case the conductivity is a piecewise constant
function which jumps from k__1 to k__2 at the interval's

midpoint. In principle we should be able to take

"k(x) = `k__1`+(`k__2`-`k__1`) Heaviside(x-L),"

or equivalently

"k(x)=`k__1`+(`k__2`-`k__1`) piecewise(x<L, `k__1`, `k__2`)."

I am unable to make either of these representations
work with Maple's numeric solver, so I do the next
best thing which is to approximate the Heaviside function
with a smooth function such as

myHeaviside := x -> (1+erf(4*x))/2;

proc (x) options operator, arrow; 1/2+(1/2)*erf(4*x) end proc

(2)

Let's compare myHeaviside with the real thing:

plot([Heaviside(x), myHeaviside(x)], x=-10..10,
  color=[red,blue], axes=frame, gridlines=false,
  legend=[Heavisie, myHeaviside]);

 

OK, then, let's start:

pde := diff(u(x,t),t) = diff(k(x)*diff(u(x,t),x), x);

diff(u(x, t), t) = (diff(k(x), x))*(diff(u(x, t), x))+k(x)*(diff(diff(u(x, t), x), x))

(3)

ibc := u(x,0)=0, u(0,t)=v1,  u(2*L,t)=v2;

u(x, 0) = 0, u(0, t) = v1, u(2*L, t) = v2

(4)

k := x -> k1 + (k2-k1)*myHeaviside(x-L);

proc (x) options operator, arrow; k1+(k2-k1)*myHeaviside(x-L) end proc

(5)

L := 10: v1 := 20: v2 := 10: k1 := 10: k2 := 20:

To handle the sharp change in conductivity, we refine the spacestep size from

its default value of 2*L/20 by dividing it by 5.

pdsol := pdsolve(pde, {ibc}, numeric, spacestep=(2*L/20)/5);

module () local INFO; export plot, plot3d, animate, value, settings; option `Copyright (c) 2001 by Waterloo Maple Inc. All rights reserved.`; end module

(6)

pdsol:-animate(t=15, frames=50, labels=[x,u(x,t)],
  title="time = %f", gridlines=false);

 

 

Download pde_m13.mw

@Christopher2222 I would never alter someone else's vote even if I could (and I cannot.)

I submitted a bug report, when I first noticed this.

For one thing it is a backwards incompatibility in GUI usage. And it wasn't broken or inconvenient before, so the change didn't fix anything. So it's an unnecessary backwards usage incompatibility.

More importantly, it now looks as if it is a computational effect -- given the menu-item under which it now appears. And that is bad, because it makes it look like it's undoing any actual computation/assignment in kernel space. And of course it isn't.  Mathematica has such a feature and Maple does not.

It's an editing-undo, not an evaluation-undo. It should be moved back, asap in the next point release.

If Carl Love doesn't find it then imagine the havoc for non-experts.

A mistake on multiple levels

Except your idea doesn't always work, in part because it turns names into globals.

I can't imagine why anyone would give this an up-vote.

@reza gugheri I have updated your Question to mark it as version Maple 13.

First 217 218 219 220 221 222 223 Last Page 219 of 594