acer

32373 Reputation

29 Badges

19 years, 334 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

This is just an idea I saw elsewhere; I'll have to wait and see if it makes a difference.

I have toggled off "Enable MapleCloud connection" in the popup dialogue,
     Tools -> Options - Network

Elementwise mapping of DrawGraph works fine for me, over CubicVT a table of graphs. The result will, naturally, also be a table.

tablemap_ac.mw

I elected to convert that resulting table to a list, after which there are several easy ways to plot them together.

Your attachment seems to have unevaluated Graph calls in it, making it suspicious whether GraphTheory really was loaded before such construction attempted. (Orphaned output, and a lack of restart, are additional small hints of a possible lack of care about programmatic flow...)

If I were to do it programmatically then I might start with something more like the following, which I think is a little less opaque,

restart;

 

shiftsum := proc(S, s)
  local p2 := op(2,S), v := lhs(p2);
  op(0,S)(eval(op(1,S), v=v+s),
          v = map(`-`, rhs(p2), s),
          op(3..,S));
end proc:

 

S0 := sum(a[k]*(k + r)*(k + r - 1)*x^(k + r - 1), k = 0 .. infinity);

sum(a[k]*(k+r)*(k+r-1)*x^(k+r-1), k = 0 .. infinity)

shiftsum(S0, 1);

sum(a[k+1]*(k+1+r)*(k+r)*x^(k+r), k = -1 .. infinity)

shiftsum(Sum(f(r), r = a .. b), u);

Sum(f(r+u), r = a-u .. b-u)

Download shiftsum.mw

Of course, one could also add type-checks, eg. ensuring that S is of type {Sum,sum}, that op(2,S) is of type name=range, etc.

You are passing a flat sequence of eight arguments, after s.

It doesn't magically read your mind and know that you intended it to take successive pairs from that flat sequence of eight things. You could see that by changing SubstituteAll to a dummy name like, say, SA.

How about using four lists (of pairs), and having a custom iterator take the operands from its second argument, before it calls SubstituteAll.

  foldl( (a, b)->SubstituteAll( a, b[] ), s, seq( [L1[i], L2[i]], i=1..4 ) );

Eg,

s:="[ (0, 1), (1, 2), (1, 10), (2, 3), (3, 4), (4, 5),
(4, 9), (5, 6), (6, 7), (7, 8),(8, 9), (10, 11), (11, 12),
(11, 16), (12, 13), (13, 14), (14, 15), (15, 16)]":

with(StringTools):

L1:= "()[]": L2:= "{}{}":

foldl((a,b)->SubstituteAll(a,b[]),s,seq([L1[i],L2[i]],i=1..length(L1)));

"{ {0, 1}, {1, 2}, {1, 10}, {2, 3}, {3, 4}, {4, 5},
{4, 9}, {5, 6}, {6, 7}, {7, 8},{8, 9}, {10, 11}, {11, 12},
{11, 16}, {12, 13}, {13, 14}, {14, 15}, {15, 16}}"

Download foldl_ex.mw

ps. I find that much more legible than a mixture of extra unevaluation quotes and eval calls.

How's this?

Mat_1_-_Noter_adc.mw

I don't know how to prevent it with any guarantee. It seems to be related to entering typeset Vectors/Matrices in 2D Input mode (via the Matrix palette?).

In the distant past there were hints that older issues were related to inlining images into Documents.

I gave this Question the "units" tag late last night, but didn't have time to answer.

(In my Maple 2022.2 it is not necessary to put a lowercase typeset call around the axis labels, with default settings.)

With units the kg/m^3 is rendered in upright Roman instead of italics, by default. (As Tom showed.) But it's not mecessary to load the Units package in order to do that.

A short re-usable procedure is one relatively easy way to make other non-unit names get rendered in upright Roman in a plot's axis labels.

restart:

 

plot(x, x=0..1,
     labels=[ foo*Unit(kg/m^3), bar*Unit(m) ] );

 

Roman := proc(e) uses Typesetting;
  subs(mi=mo,Typeset(e)); end proc:

 

plot(x, x=0..1,
     labels=[ Roman(foo)*Unit(kg/m^3), Roman(bar)*Unit(m) ] );

Download roman_label_ex.mw

Did you set numeric formatting for that Document Block? If so, you could try right-clicking in that border element and clearing any formatting.

Or, if you wish to retain the formatting but not see any markers, then from the GUI's main menubar, uncheck the "Markers" box under the "View" item. 

See Help topic worksheet/reference/markers .

As a tip for future queries,

> MmaTranslator:-FromMma("Hypergeometric0F1Regularized[a, z]");

        hypergeom([], [a], z)
        ---------------------
              GAMMA(a)

> lprint(%);

hypergeom([],[a],z)/GAMMA(a)

You have used Maple 2021, and 2D Input.

In that case you can use the prefix form of the inert `%.` operator.

Also, to get it to display in infix notation as output, you'd need to utilize the extended typesetting level. (In that case the "dot" appears in gray.)

You can use InertForm:-Display to show the "dot" in black, instead of gray.

And you can use the value command to make the inert call active.

restart

kernelopts(version)

`Maple 2021.2, X86 64 LINUX, Nov 23 2021, Build ID 1576349`

interface(typesetting = extended)

with(LinearAlgebra)

U := `<,>`(u1, u2)

Vector[column](%id = 36893628195279574668)

K := Matrix(2, 2, symbol = k)

Matrix(%id = 36893628195279567316)

NULL

Q := `%.`(K, U)

`%.`(Matrix(%id = 36893628195279567316), Vector[column](%id = 36893628195279574668))

InertForm:-Display(Q, 'inert' = false)

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

value(Q)

Vector[column](%id = 36893628195279541660)

NULL

Download inert_matrix_products_M2021.mw

@abert Preben's procedure returns the name of its local z. That is sometimes called an escaped local.

restart;

f := proc()
 local z;
 z := 2;
 return 'z';
end proc:

Q := f();

z

eval(Q,1), Q;

z, 2

type(eval(Q,1), `local`);

true

addressof(eval(Q,1));

36893628155892795900

# in contrast to the global z
addressof(:-z);

36893628155892795612

Download escaped_local.mw

As Christian mentioned, the means by which your procedure f evaluates that name z is the same means as for your procedure h, ie. because in both cases the unevaluated name was passed in as the argument.

You mentioned "lexical scope".  Consider the following contrasting example, in which procedure g gets a value for z via lexical scoping. Perhaps you were thinking of something like this, when you wrote of your procedure g, "After all, its definition is within the lexical scope of z."

restart;

f := proc()
  local z, g;
  g := proc()
    printf("g says: z evaluates to %a.\n", z);
  end proc;
  z := 2;
  g();
  return 'z', [op(7,eval(g))], ToInert(eval(g))
end proc:

R := f();

g says: z evaluates to 2.

z, [z, z], _Inert_PROC(_Inert_PARAMSEQ(), _Inert_LOCALSEQ(), _Inert_OPTIONSEQ(), _Inert_EXPSEQ(), _Inert_STATSEQ(_Inert_FUNCTION(_Inert_ASSIGNEDNAME("printf", "PROC", _Inert_ATTRIBUTE(_Inert_EXPSEQ(_Inert_NAME("protected", _Inert_ATTRIBUTE(_Inert_NAME("protected"))), _Inert_NAME("_syslib")))), _Inert_EXPSEQ(_Inert_STRING("g says: z evaluates to %a.
"), _Inert_LEXICAL_LOCAL(1)))), _Inert_DESCRIPTIONSEQ(), _Inert_GLOBALSEQ(), _Inert_LEXICALSEQ(_Inert_LEXICALPAIR(_Inert_NAME("z"), _Inert_ASSIGNEDLOCALNAME("z", "INTPOS", 36893628209820994140))), _Inert_EOP(_Inert_EXPSEQ()))

eval(R,1)[1];

z

addressof(eval(R,1)[1]);

36893628209820994140

addressof(:-z);

36893628209820993756

Download lexical_ex.mw

Note. op(7,eval(g)) is the lexical table of the procedure assigned to g, as mentioned on the Help page for topic proc.

Your original example's procedure g, however, has an empty lexical table, and does not get a value for z via lexical scoping. It gets it because the reference was actually passed.

Fwiw, illustrating six free variables, and all integer solutions:

[k[6] = 22*k[1]-3*k[2]-k[3]-4*k[4]+4*k[5]+3*k[10],
 k[7] = -5*k[1]+k[2]+2*k[3]+10*k[4]-k[5]-k[10],
 k[8] = -14*k[1]+k[2]-k[3]-3*k[4]-3*k[5]+k[10],
 k[9] = -4*k[1]-k[3]-4*k[4]-k[5]-4*k[10]]

That can be had by,

simplify(combine(solve(evalc(convert(eqs,radical)),
                {k[6],k[7],k[8],k[9]}))):

You wrote the k[1]..k[6] are the "unknowns". The following produces a rational solution. This is similar to what Kitonum showed, but without requiring the unguaranteed steps of evalf & identify.

simplify(combine(solve(evalc(convert(eqs,radical)),
                       {k[7],k[8],k[9],k[10]})));

Naturally, you can scale (here, by 3) to get purely integer solutions.

The following would remove spurious imaginary components (eg. small imaginary artefacts due to floating-point roundoff error).

It will also remove remaining complex (ie. non-real) results, so that max can succeed.

temp := [solve(f=0,x)]:

max(select(type,
           simplify(fnormal(evalf(temp)),
                    ':-zero'),
           realcons));

Why haven't you shown us your actual equations, or uploaded and attached a worksheet that produces them? That would make it easier for people to help you.

The simplest way to get the result is to use the solve command.

The way in which the optional second argument is passed to solve controls the form in which the result is returned (ie. as y=value, or just the value).

restart;

eq := (3*y - 2)/3 + (2*y + 3)/3 = (y + 7)/6;

(5/3)*y+1/3 = (1/6)*y+7/6

solve(eq, {y});

{y = 5/9}

solve(eq, y);

5/9

solve(eq);

5/9

Download solve_lin.mw

You could also get a so-called step-by-step solution shown for this class of linear problem.

This is a verbose illustration of how one could solve it by hand. (Maple's solve command has its own methodology, and I'm not sure whether you are actually asking how that works, internally.)

restart;

eq:=(3*y - 2)/3 + (2*y + 3)/3 = (y + 7)/6;

(5/3)*y+1/3 = (1/6)*y+7/6

Student:-Basics:-LinearSolveSteps(eq, y);

"[[`%+`(`%*`(`%/`(5,3),y),`%/`(1,3))=`%+`(`%/`(y,6),`%/`(7,6))],[`%+`(`%*`(`%/`(5,3),y),`%/`(1,3),-`%/`(1,3)-`%/`(y,6))=`%+`(`%/`(y,6),`%/`(7,6),-`%/`(1,3)-`%/`(y,6)),("Subtract" (1)/(3)+(y)/(6) "from both sides")],[`%+`(`%*`(`%/`(5,3),y),`%/`(-y,6))=`%+`(`%/`(7,6),`%/`(-1,3)),("Simplify")],[`%+`(`%/`(5 y,3),`%/`(-y,6))=`%+`(`%/`(7,6),`%/`(-1,3)),("Multiply fraction")],[(3 y)/2=`%+`(`%/`(7,6),`%/`(-1,3)),("Add terms")],[(3 y)/2=5/6,("Add terms")],[`%*`(3/2 y,2)=`%*`(2,5/6),("Multiply rhs by denominator of lhs")],[3 y=5/3,("Simplify")],[`%/`(`%*`(3,y),3)=`%/`(5/3,3),("Divide both sides by" 3)],[y=5/9,("Simplify")]]"

Download SBLSS.mw

restart;

expr:= sqrt(alpha^2+k^2)*(-sqrt(alpha^2+k^2)*exp(k*z0)+k*exp(sqrt(alpha^2+k^2)*z0))
       /((-alpha^2-k^2)*exp(k*z0)+exp(sqrt(alpha^2+k^2)*z0)*sqrt(alpha^2+k^2)*k);

(alpha^2+k^2)^(1/2)*(-(alpha^2+k^2)^(1/2)*exp(k*z0)+k*exp((alpha^2+k^2)^(1/2)*z0))/((-alpha^2-k^2)*exp(k*z0)+exp((alpha^2+k^2)^(1/2)*z0)*(alpha^2+k^2)^(1/2)*k)

radnormal(expr);

1

Download simpl_ex.mw

I will submit a bug report against simplify.

First 50 51 52 53 54 55 56 Last Page 52 of 336