Carl Love

Carl Love

28160 Reputation

25 Badges

14 years, 9 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

Here is a procedure to return the dependent variables from a PDE, ODE, or a set or list thereof:

depvars:= (pde::{algebraic, `=`(algebraic), {set,list}(algebraic, `=`(algebraic))})-> 
   indets(
      indets(convert(pde, diff), specfunc(diff)), 
      And(typefunc(name, name), Not(typefunc({mathfunc, identical(diff)})))
   )
:

And here is an implementation of is_solution_trivial:

is_solution_trivial:= (pde, sol::{`=`, set(`=`)})-> 
   evalb(eval(`if`(sol::set, sol, {sol}), depvars(pde)=~ 0) = {0=0}) 
:

 

I would guess that the following is a fundamental principle of engineering. I've never formally studied engineering, so I don't know whether it is. To me, it is just intuition (something that is obvious), having taking apart and rebuilt machines and other systems my entire conscious life. (I'd appreciate it if someone who knows would tell me whether it is indeed formally a fundamental principle of engineering.)

Let's say that you have two closely related systems, which I'll call W (for working) and N (for not working). They could be machines, programs, scientific theories, literary essays, biological systems, etc. So, W is working (i.e., it does what it was designed to do), but it needs to be modified so that it can do something else, or something additional. On the other hand, N has been designed and built based on W and it incorporates the needed changes, but it doesn't work.

My principle is 

  1. Junk N. Discard it. It may be disassembled and small parts re-used. Otherwise, it should be forgotten, regardless of how much effort went into it.
  2. Proceed by making small changes to W. Test after every small change to make sure that it's still working. Do not make any further changes until the current version works! This may require hundreds of small changes if you're working alone, and perhaps much more if you're working as a team.
  3. (Optional step) Ocasionally remove from W parts that are no longer needed. The smaller size will make the work proceed faster.

Now, you may protest, "But a lot of effort and/or expense went into N!" That doesn't matter; it's more efficient and/or economical to work on W. Accountants refer to this as "sunk costs"; investment experts say "Don't throw good money after bad"; professors of creative writing say "Kill you darlings". If my principle were not true, then life on Earth would likely have started independently many times. Yet all evidence suggests that it hasn't.

So, in this thread, it seems clear that you have a W program and an N program. You've been trying to correct the N program. Stop that. Work on your W program.

{k = 1, n=1} satisfy your stated conditions. Other than that, I checked for n up to 54177 and found no other solution.

Like this:

convert(evalc(Im(D1C1)), exp)

I think that if you just view the indices by doing seq(nops(L)-i, i= 1..nops(L)), then you'll understand the reason that your second version doesn't work. If not, let me know, and I'll explain further.

By the way, you're finding the reverse of the list, not the inverse. The inverse is something else.

There's currently no predefined way to do that with the legend option. However, it wouldn't be difficult to simply overlay your plot with a legend (exactly as you show above) constructed with the plot and textplot commands. The overlaying is done with the display command. This requires knowing the approximate x and y coordinates of the placement of the legend, preferably the upper left and lower left corners. If you have foreknowledge of the full extent of the x and y axes, this is easy. If you don't have foreknowledge, it's possible to determine the axis extents of an existing plot programmatically.

Yes, it can be done with if ... then. The key is that all the code must be in a single execution group (in other words, a single command prompt). While typing code, to get a new line within the same execution group, use Shift-Enter instead of Enter (or carriage return). Example:

#There's no limit to the complexity of conditions that can be made with
#logical connectives such as `or`, `and`, etc.

if x > 0 then 
   y:= sin(x); #code line 1 to skip
   z:= cos(x)  #code line 2 to skip
   #... more code lines
fi; #or use "end if"

#Or, there can be alternative branches:

if x < 0 and a > 0 then
   y:= sin(x);
   z:= cos(x)
else
   y:= cos(x);
   z:= sin(x)
fi;

#If statements can be nested arbitrarily, and 
#"if ... then ... else if ... then ... fi fi" can 
#be contracted to "if ... then ... elif ... then ... fi".

The above are simplistic examples to get you started. There's actually easier ways to do each.

Here's a procedure that does it:

CheckProperty:= proc(n::And(odd, posint, Not(1), Not(prime)))
local nm1:= n-1;
   ormap(p-> irem(nm1, p[1]-1)=0, ifactors(n)[2])
end proc: 

Both numtheory:-factorset and NumberTheory:-PrimeFactors will do essentially the same job as ifactors here, but they do it by calling ifactors, which could be problematic for some very large  n (say n > 2^200).

The part that you want to extract is op([2,1], sol).

How about

plots:-textplot([0,0,typeset(Sigma)], font= [Times, 300], axes= none);

All that you need is

plot([seq([[k,0], [k, 3*k+2]], k= 1..6)]);

Making a plot rotate is quite simple. Like this (this code picks up immediately where your worksheet left off):

P:= %: #Save the static plot
Frames:= 20:
plots:-animate(
   plottools:-rotate, [P, theta], 
   theta= 0..2*Pi/5*(1-1/Frames), frames= Frames, paraminfo= false
);

The rotation doesn't need to be around the origin. It'd be trivial to rotate around any point.

The integrals have as their third argument the option AllSolutions, which latex can't handle. And what would you have it print for those anyway? So, you can workaround by doing

latex(subs(AllSolutions= (), sol))

The int in `latex/int` refers to the int and Int functions, not to "internal".

The following procedure computes the sequence. However, I don't get the values that you propose. For example, how do you get 2, not 4, as the second entry?

A:= proc(n::posint)
option remember;
local A0; #A(n-1)
   if n=1 then return 1 fi;
   A0:= thisproc(n-1);
   `if`(A0::even, `if`((A0+1)::prime, A0+1, n+2), A0+3)
end proc
:
seq(A(n), n= 1..20);
1, 4, 5, 8, 10, 11, 14, 16, 17, 20, 22, 23, 26, 28, 29, 32, 34, 36, 37, 40

 

The name Zeta is already defined in Maple (for the Riemann-Hurwitz zeta function), so it's dangerous to use it as a variable. You should replace it with zeta, which'll prettyprint identically to Zeta as the lowercase.

Once you make that change, then all you need to do is

evalc(%)

The evalc automatically assumes that all variables are real, thus avoiding some of the complexity of the other Answers. But it won't assume that Zeta is real because that's already defined and is thus not a free variable.
 

If you'd prefer to continue using Zeta, you could do

local Zeta;

and it'll now be a totally free variable. If perchance you'd still like to use the Riemann-Hurwitz zeta function, you can call it with :-Zeta(...), and now the names Zeta and :-Zeta will not have any link to one another.

 

First 142 143 144 145 146 147 148 Last Page 144 of 396