acer

29759 Reputation

29 Badges

19 years, 317 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

lprint(indets(sys, name));

   {x, c[0], c[1], c[2], c[3], eqq[0], eqq[3]}

Your last loop only assigns to eqq[1] and eqq[2]. Your code has that loop as,

for i to n-1 do
  eq[i] := RHS_weak_form(i);
end do

Perhaps you intended something more like the following (I am guessing):

for i from 0 to n do
  eqq[i] := evalf(eq[i]-RHS(i));
end do;

But if that is the case then your system would have five unknowns: {x, c[0], c[1], c[2], c[3]}, but x is a dummy name of integration. By informing fsolve that the variables are only {c[0], c[1], c[2], c[3]}, I get the following,

SOL := fsolve(sys, {c[0], c[1], c[2], c[3]});

    {c[0] = 1.000000000, c[1] = -13.06296523,
     c[2] = -11.79236213, c[3] = 2.718281828}

Revised worksheet:

restart

n := 3:

for i from 0 to n do L[i] := Typesetting:-delayDotProduct(product((x-t[j])/(t[i]-t[j]), j = 0 .. i-1), product((x-t[k])/(t[i]-t[k]), k = i+1 .. n)); phi[i] := unapply(%, x) end do:

unassign('u', 'v');

u_g := unapply(add(c[i]*phi[i](x), i = 0 .. n), x);

proc (x) options operator, arrow; c[0]*(-3*x+1)*(-(3/2)*x+1)*(-x+1)+3*c[1]*(x.((-3*x+2)*(-(3/2)*x+3/2)))+(3/2)*c[2]*(x*(3*x-1).(-3*x+3))+c[3]*x*((3/2)*x-1/2)*(3*x-2) end proc

(1)

RHS_weak_form := proc (i) options operator, arrow; a(u_g, phi[i])+L(u_g^2, phi[i]) end proc;

proc (i) options operator, arrow; a(u_g, phi[i])+L(u_g^2, phi[i]) end proc

(2)

for i to n-1 do eq[i] := RHS_weak_form(i) end do:

f := proc (t) options operator, arrow; exp(t)+exp(2*t) end proc:

RHS := proc (i) options operator, arrow; evalf(L(f, phi[i])) end proc:

eq[0] := u_g(0) = 1:

sys := [seq(eqq[j], j = 0 .. n)]:

SOL := fsolve(sys, {c[0], c[1], c[2], c[3]});

{c[0] = 1.000000000, c[1] = -13.06296523, c[2] = -11.79236213, c[3] = 2.718281828}

(3)

NULL

Download problem_solve_system_ac.mw

Either rationalize or evalc can get that task done. And then you might further adjust as you wish.

restart;

Zin := Rin + omega*L*I + (omega*L)^2/(RL + omega*L*I);

Rin+I*omega*L+omega^2*L^2/(RL+I*omega*L)

rationalize(Zin);

-(I*L*RL*omega+I*L*Rin*omega+RL*Rin)*(I*omega*L-RL)/(L^2*omega^2+RL^2)

simplify(expand(rationalize(Zin)));

(L^2*(RL+Rin)*omega^2+I*L*RL^2*omega+RL^2*Rin)/(L^2*omega^2+RL^2)

simplify(evalc(Zin));

(L^2*(RL+Rin)*omega^2+I*L*RL^2*omega+RL^2*Rin)/(L^2*omega^2+RL^2)

Download simpex.mw

note: You used rationalize to similar effect in a previous Question.

Here is another way, with a single call to solve.

Its result fortuitously contains the pair of solutions with calls to 2-argument arctan, as you wanted.

Each also happens to contain the beta(t) solution, but if needed then it's trivial to sieve that out -- as shown in the last line below.

restart

kernelopts(version)

`Maple 2022.0, X86 64 LINUX, Mar 8 2022, Build ID 1599809`

(1)

Vector(3, {(1) = (l+s(t))*cos(beta(t))+xo+s(t)-x(t), (2) = sin(beta(t))*(l+s(t))*sin(alpha(t))-y(t), (3) = -sin(beta(t))*(l+s(t))*cos(alpha(t))-z(t)})

Vector[column](%id = 36893628144889207972)

(2)

"solve([?[2],?[3]],[alpha(t),beta(t)],explicit);"

[[alpha(t) = arctan(y(t)/(z(t)^2+y(t)^2)^(1/2), -z(t)/(z(t)^2+y(t)^2)^(1/2)), beta(t) = arcsin((z(t)^2+y(t)^2)^(1/2)/(l+s(t)))], [alpha(t) = arctan(-y(t)/(z(t)^2+y(t)^2)^(1/2), z(t)/(z(t)^2+y(t)^2)^(1/2)), beta(t) = -arcsin((z(t)^2+y(t)^2)^(1/2)/(l+s(t)))]]

(3)

map(proc (u) options operator, arrow; alpha(t) = eval(alpha(t), u) end proc, %)

[alpha(t) = arctan(y(t)/(z(t)^2+y(t)^2)^(1/2), -z(t)/(z(t)^2+y(t)^2)^(1/2)), alpha(t) = arctan(-y(t)/(z(t)^2+y(t)^2)^(1/2), z(t)/(z(t)^2+y(t)^2)^(1/2))]

(4)

NULL

Download Arctan_ac.mw

You're original example happened to get the intermediate solution (for beta(t)) unsimplified, because subs does not induce a final evaluation.

Your undesired example was not due to automatic simplification, which has a very specific meaning. It was due to the usual full evaluation that happens to arguments of procedure calls, eg. calls to solve. You can also pass the intermediate result from subs -- referenced as its own separate result -- in an argument of a call to solve, while avoiding the usual full evaluation by means forced 1-level eval.  Arctan_ex.mw

But this is all quite problem-specific. I don't see how you can reasonably expect always to be able to get semi-generic solutions that just happen to cover (explicitly, separately) only a pair of branches.

There are a variety of coding problems in the assembly procedure.

For example,
  - The statement that appears to assign to S is just an equation,
     and not an assignment, ie.  = instead of :=

  - The code seems aimed at creating S as a list. But that doesn't
    work later on with the products of S and some Vectors. Why not
    make S (and dS in consequence) a Vector as well?

  - The diff and int command are apparently going to get applied to
     some Vectors, which is no good. Did you intend on mapping
     those commands across the Vectors, instead? (If so you could
     utilize map, or elementwise diff~ or int~.

   - I didn't check whether all the various Vector/Matrix products are
     correct, especially w.r.t orientation. (None of them are dot-products
     that are intended to produce scalars, is that right?) You should check.

I see a Matrix in the results for both (Equation Labels) 19 and 20, not tables.

Why do you say that they are tables?

Have you considered using evalf(exp(1)) instead of exact exp(1), in eq[4]? Or applying evalf at some earlier stage?

Alternatively, have you considered applying evalf to both those mentioned results?

restart;

factor(R^100+598*R^50+67497);

(R^50+447)*(R^50+151)

eval(subsindets([op(%)],`^`,u->`%^`(op(u))),R=10);

[`%^`(10, 50)+447, `%^`(10, 50)+151]

value(%);

[100000000000000000000000000000000000000000000000447, 100000000000000000000000000000000000000000000000151]

isprime~(%);

[true, true]

Download HO.mw

The call to subsindets above is not necessary -- I put it in so that the inert power could be more neatly visualized.

Using the result to check the other equation is straightforward substitution.

You could show how far you got on your own, for these questions.

Judging by this (and another recent posting by you) it reads as if there is something wrong with your output.

It appears as if you are getting the prettyprint=1 kind of output.

I suggest that you check what is returned by,
   interface(prettyprint);
The result ought to be 3, and cetainly not 1 (unless you did that deliberately, in which case you've caused the problem).

You can also check that as a GUI setting, in the main menubar as,
     Tools -> Options -> Display -> Output display
which is normally set to "2-D Math Notation".

If you instead have that set to "Maple Notation" (or prettyprint=1 under the interface command) then you will get poor results from series and taylor as you've indicated. The output would appear as if it were being passed through lprint and line-printed.

That mis-setting would also mess up your plot output (showing a mess of a large expression, just as if you'd lprint'd the plot). That might explain you previous Question, and shown why you'd been looking into other (inferior) plot-devices than the default of inline.

There have been rare reports from users of older versions, whose output setting has apparently been spontaneouly changed. In such case it has (AFAIK) always been adequate for them to switch it back manually -- and save Globally if in GUI Options. Hopefully you are in that boat. If the problem is fixable in that manner, or spontaneously reappears later then you might try a fresh reinstall/redownload.

Use your mouse-pointer to left-click on the plot window that appears in your worksheet. Ie, put the mouse focus in the plot subwindow.

Then in Maple's menubar you should see controls to play/pause the animation. The play button looks like a blue triangle or arrow-head.

Such instructions are stated immediately below the example in the Description section of the Help page for the plots:-animate command. It reads like so: 

To run the animation using the worksheet interface:

1. 

Click the plot. The plot toolbar is displayed.

2. 

In the toolbar, click the Play button.

  

Alternatively, right-click (Control-click, on Mac) the plot to display the context menu.  Select Animation > Play.

The very first frame of your particular example animation is just the line y=0, so you might not have noticed that since it lies right on the x-axis. That makes the first frame look quite similar to an empty plot.

When you inline a worksheet in this forum such animations play automatically.

You can tackle such questions using operators -- as Kitonum did for part of question a) -- or you can use expressions as I show inlined below.

It's not clear to me how much you have to explain and justify your methodology, according to what you've learned in lectures.

It seems reasonable that your instructor would want you to establish the minima/maxima using a 2nd (or higher) derivative test, rather than trying to pass off a mere plot as proof. Plots may indeed be useful to you as a visual check, but I'd guess that you're supposed to show the key aspects programatically/mathematically.

restart;

f := x^3+a*x^2+b*x;

a*x^2+x^3+b*x

This is the 1st derivative of f with respect to x.

df := diff(f,x);

2*a*x+3*x^2+b

This is the 2nd derivative of f with respect to x.

ddf := diff(f,x,x);

2*a+6*x

Part A.
Find candidate values of a and b such that the
1st derivative of f is zero for both x=1 and x=3.

candA := solve({eval(df,x=-1)=0, eval(df,x=3)=0});

{a = -3, b = -9}

Test whether the second derivative of f is negative at x=-1,
ie. a local maximum
 
eval(eval(ddf,x=-1),candA);

-12

Test whether the second derivative of f is positive at x=3,
ie. a local minimum.

eval(eval(ddf,x=3),candA);

12

Part B.
Find candidate values of a and b such that the
1st derivative of f is zero for x=4 and the 2nd derivative
of f is zero at x=1.

candB := solve({eval(df,x=4)=0, eval(ddf,x=1)=0}, allsolutions);

{a = -3, b = -24}

Test whether the second derivative of f is positive at x=4,
ie. a local minimum.

eval(eval(ddf,x=4),candB);

18

We found that (at x=1) the second derivative of f is zero
only at a=-3.
Since it's continuous we only need to show further that the
2nd derivative of f changes sign there. And we can show that
using a value of a less than -3 and a value of a greater than -3.
One of these next results is negative and one of them is positive.

eval(eval(ddf,x=1),a=-3.5), eval(eval(ddf,x=1),a=-2.5);

-1.0, 1.0

Since the 2nd derivative of f (at x=1) changes from negative to
positive at a=-3 then we have shown that to be an inflection point.

Download calcex.mw

You can notice that for f as an expression you can use diff to differentiate and eval to evaluate at (substitute) values.

And here is most of the above, done with f as an operator rather than an expression. For f as an operator you can use D to differentiate. calc_ex.mw

Double check everything yourself.

Tasks are stored in some Help database (.help file, in modern Maple like version 2022.0). The individual Help Topics can be removed from a writable Help database file, and this includes tasks.

First select the following from Maple's menubar,

    Tools -> Help Database -> Remove Topic...

which should open a popop dialogue, with a box in which to enter the location of the Help database that contains your task(s).

In my Maple 2022.0 for Linux the drop-menu in that popup did not already contain the default location to which I'd saved a task earlier in the session. But on Linux that default for tasks is:
     /home/$USER/.maple/2022/tasks.help
If you're on MS-Windows then you could check whether you have such a file as, say,
     C:/Users/<User ID>/AppData/Roaming/Maple/2022/tasks.help
I use forward slashes, but you could also try escaped (double) backslashes.

Once I'd entered the Help database file location I was able to get to the individual task name (Topic) in the lower drop-menu, and remove it.

The "Tasks" palette still showed the task, unitl I fully closed/relaunched Maple's GUI. But the task became inactive as soon as I removed it as described above.

 

ps. On Linux I can create that location string programmatically by issuing,
    cat(kernelopts(':-homedir'),"/.maple/2022/tasks.help");
and you might be able to get it for Windows as, say,
    cat(kernelopts(':-homedir'),"/AppData/Roaming/Maple/2022/tasks.help");

As a workaround you could utilize the is command.

restart;

kernelopts(version);

`Maple 2022.0, X86 64 LINUX, Mar 8 2022, Build ID 1599809`

with(Units:-Simple):

alpha := 45*Unit(arcdeg);

45*Units:-Unit(arcdeg)

if is( alpha > 0 ) then ok; else other; end if;

ok

Download unitsineq_is.mw

Here is another way to accomplish the same results, using eval instead of assign.

# Bernard W. Taylor, Quantitative Analysis for Management, 13th edition

# Chapter 6, transportation example 1

restart;

with(Optimization):

X:=Matrix(1..3,1..3,symbol=x);

Matrix(3, 3, {(1, 1) = x[1, 1], (1, 2) = x[1, 2], (1, 3) = x[1, 3], (2, 1) = x[2, 1], (2, 2) = x[2, 2], (2, 3) = x[2, 3], (3, 1) = x[3, 1], (3, 2) = x[3, 2], (3, 3) = x[3, 3]})

Cost:=Matrix(3,3,[6,8,10,7,11,11,4,5,12]);

Matrix(3, 3, {(1, 1) = 6, (1, 2) = 8, (1, 3) = 10, (2, 1) = 7, (2, 2) = 11, (2, 3) = 11, (3, 1) = 4, (3, 2) = 5, (3, 3) = 12})

TotalCost:=add(add(Cost[i,j]*x[i,j],i=1..3),j=1..3);

6*x[1, 1]+7*x[2, 1]+4*x[3, 1]+8*x[1, 2]+11*x[2, 2]+5*x[3, 2]+10*x[1, 3]+11*x[2, 3]+12*x[3, 3]

Demand :=<200,100,300>;

Vector(3, {(1) = 200, (2) = 100, (3) = 300})

DemandGuidelines:= seq(add(x[i,j],i=1..3) =Demand[j], j=1..3);

x[1, 1]+x[2, 1]+x[3, 1] = 200, x[1, 2]+x[2, 2]+x[3, 2] = 100, x[1, 3]+x[2, 3]+x[3, 3] = 300

Production :=<150,175,275>;

Vector(3, {(1) = 150, (2) = 175, (3) = 275})

ProductionGuidelines:= seq(add(x[i,j],j=1..3) = Production[i], i=1..3);

x[1, 1]+x[1, 2]+x[1, 3] = 150, x[2, 1]+x[2, 2]+x[2, 3] = 175, x[3, 1]+x[3, 2]+x[3, 3] = 275

Ans := LPSolve(TotalCost, [DemandGuidelines,ProductionGuidelines], assume={nonnegative, integer});

[4525, [x[1, 1] = 0, x[1, 2] = 0, x[1, 3] = 150, x[2, 1] = 25, x[2, 2] = 0, x[2, 3] = 150, x[3, 1] = 175, x[3, 2] = 100, x[3, 3] = 0]]

eval(X,Ans[2]);

Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 150, (2, 1) = 25, (2, 2) = 0, (2, 3) = 150, (3, 1) = 175, (3, 2) = 100, (3, 3) = 0})

Ans[1],eval(TotalCost,Ans[2]);

4525, 4525

 

Download Q20220416_ac.mw

It is quite often a better way, IMO, especially if you need to continue to use the unassigned names x[i] (or those Cost/TotatCost formulas, etc) symbolically in further computations.

In the above I used a Matrix instead of the deprecated lowercase array structure. If you really insist on using that deprecated array data structure then you can still accomplish the goals using eval instead of assign.  Q20220416_acm.mw

restart;

kernelopts(version)

`Maple 2022.0, X86 64 LINUX, Mar 8 2022, Build ID 1599809`

with(LinearAlgebra):

w := (2*Pi)/14;

(1/7)*Pi

v := Vector([1, sin(w*t), cos(w*t)]);

Vector(3, {(1) = 1, (2) = sin((1/7)*Pi*t), (3) = cos((1/7)*Pi*t)})

ee := simplify(sum(v . (Transpose(v)), t = k .. k + 13));

Matrix(3, 3, {(1, 1) = 14, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 7-cos((2/7)*Pi*k)-cos((2/7)*Pi*(1+k))+sin((1/14)*Pi*(4*k+1))+sin((1/14)*Pi*(4*k+5))+cos((1/7)*Pi*(2*k+1))+cos((1/7)*Pi*(2*k+3))-sin((1/14)*Pi*(4*k+3)), (2, 3) = sin((2/7)*Pi*k)-sin((1/7)*Pi*(2*k+1))+cos((1/14)*Pi*(4*k+5))-cos((1/14)*Pi*(4*k+3))+sin((2/7)*Pi*(1+k))+cos((1/14)*Pi*(4*k+1))-sin((1/7)*Pi*(2*k+3)), (3, 1) = 0, (3, 2) = sin((2/7)*Pi*k)-sin((1/7)*Pi*(2*k+1))+cos((1/14)*Pi*(4*k+5))-cos((1/14)*Pi*(4*k+3))+sin((2/7)*Pi*(1+k))+cos((1/14)*Pi*(4*k+1))-sin((1/7)*Pi*(2*k+3)), (3, 3) = cos((2/7)*Pi*k)+7+cos((2/7)*Pi*(1+k))-sin((1/14)*Pi*(4*k+1))-sin((1/14)*Pi*(4*k+5))-cos((1/7)*Pi*(2*k+1))-cos((1/7)*Pi*(2*k+3))+sin((1/14)*Pi*(4*k+3))})

evala(expand~(convert~(ee,exp)));

Matrix(3, 3, {(1, 1) = 14, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 7, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 7})

Download simp_ex.mw

I will submit a bug report (SCR), that the simplify command itself does not attain this simplification.

Hardware floating-point precision real and complex linear-algebra is mainly accomplished using the Intel MKL, with parallelized BLAS and LAPACK.

That affects many packages, including LinearAlgebra as well as some commands in other packages (ArrayTools, Statistics, Optimization, etc).

You can disable this parallelization with the follow setting of this environment variable in the shell (Operating System shell) in which Maple is launched:

    OMP_NUM_THREADS=1

Similarly, you can restrict that paralellization, eg. setting 8 as its value.

The first example below is to address the OP's requirement, "I want them to appear as vectors when I type them". That is, the over-arrow appears on the input as well as output.

The point of the 2nd example is that the symbol is bold in both input and output.

The 2nd and 3rd examples look more bold in the actual Maple GUI than they do with the worksheet inlined in this forum.

 

For this first example I used the item having Right arrow over as its tooltip, in the Accents palette.

 

`#mover(mi("A"),mo("&rarr;"))`

`#mover(mi("A"),mo("&rarr;"))`

 

For this next example I used the main menubar to make the input bold. Then I selected the character with the mouse-pointer, and then I used the context action from the right-click menu:
    2-D Math -> Convert To -> Atomic Variable

 

`#mi("G",fontweight = "bold")`

`#mi("G",fontweight = "bold")`

 

For this next example I combined both methods above

 

`#mover(mi("H",fontweight = "bold"),mo("&rarr;",fontweight = "bold"))`

`#mover(mi("H",fontweight = "bold"),mo("&rarr;",fontweight = "bold"))`

Download accents_bold_atomic_var.mw

First 42 43 44 45 46 47 48 Last Page 44 of 309