Carl Love

Carl Love

28070 Reputation

25 Badges

13 years, 35 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@baharm31 

I don't see any uploaded worksheet.

I wasn't saying that you'd necessarily be able to solve the equation by using solve and eval together. I can't know that without having the worksheet. What I'm saying is that you should use eval instead of assuming, in any command, when you want to set the parameters to specific values. 

@nm Please see my addendum about using with inside procedures. That is why you need to execute twice.

@baharm31 You asked:

[I]s it correct to say:

solve(function, x) assuming A=..., B=..., C=...?

No, that's not correct, unfortunately. It's certainly understandable why you might think that that's correct, but it's not. Assumptions of equality are very often ignored, and they're certainly ignored by solve. Use eval instead:

solve(eval(function, [A= ..., B= ......]), x);

Regarding the implicitplot, surely numpoints= 10^8 is a ridiculously large and impossible-to-achieve value. It means that your rectangular region of the xy-plane is subdivided into 100 million subrectangles and every one of these is searched for points that satisfy the equation. There are many subtle options to implicitplot worth exploring. One mentioned already is gridrefine. Try also crossingrefine and rational.

Please post a worksheet.

 

Your model equation doesn't account for the fact that there's a vertical shift in your data. The horizontal asymptote isn't the expected 0 but rather 0.0712.... Any attempt to fit the data to the model equation will be thwarted by this.

@shzan 

Please post a worksheet showing your original code not working so that I can figure out what's going wrong.

@Bendesarts 

2*Pi isn't found because the x-values of the graph do not reach 2*Pi. The last x-value used is about 2*Pi - 1e-13. This is an anomaly of how plot chooses the x-values.

@Bendesarts 

Determing the "zero-crossing values" of an existing plot of a curve is trivial. Here's a procedure for it.

ZeroCrossings:= proc(A::Matrix)
# Input: An Nx2 Matrix extracted from a plot, representing a curve
# Output: A list of x-values of the linearly interpolated zero crossings of the curve
local Z:= table(),k;
     for k to op([1,1], A)-1 do
          if A[k,2]*A[k+1,2] <= 0 then
               Z[k]:= (A[k,1]*A[k+1,2] - A[k+1,1]*A[k,2])/(A[k+1,2]-A[k,2])
          end if
     end do;
     convert(Z, list)
end proc:

P:= plot(sin(x)+sin(2*x), x= 0..2*Pi):
A:= op([1,1], P);

ZeroCrossings(A);

     [0., 2.09456897293401, 3.14159268039291, 4.18860222947577]

@farahnaz 

Okay, I guess that's a reasonable reason to use ApproximateInt. But if you use ApproximateInt, it's up to you to adjust the parameters to control the error.

Do you have some theoretical reason to believe that the answer should change with f? If you just leave f symbolic (i.e., never assign it a value) you'll see that the final polynomial does contain f. But it contains it (apparently) in a way such that the smallest positive root doesn't depend on it.

What do you mean by "trepan"? In English, it means to drill a hole into the skull for surgical reasons. It has no other meaning, metaphorical or idiomatic.

@Bendesarts 

I think that you may be confused by Preben's imprudent use of t as the parameter. Maple doesn't care if you reuse t in this way. Perhaps you'd understand better if you replace Preben's

[Pz[i],t,t=-0.1..0.1]

with

[Pz[i],y,y=-0.1..0.1].

If you accept the easily proved fact that f(n) < < n for n > 999, it follows that h(N) = h({1..999}). Maple can easily show that h({1..999}) = {1, 2, 4}, as I'm sure you're aware.

@Rouben Rostamian  

If you're interested, here's some shortenings of your code, each procedure becoming a one-liner.

 

Happy numbers

See http://www.mapleprimes.com/questions/208360-The-Happy-Ages-Problem

 

Rouben Rostamian, 2016-01-12

restart:

Returns the sum of squares of the decimal digits of an integer:

f:= (n::posint)-> `+`((convert(n, base, 10)^~2)[]):

Example:

f(123);

14

It can be shown that starting with any positive integer n, the sequence of iterates of f, that is , n, f(n), f(f(n)), ..., will ultimately hit either 1 or 4.  (See https://en.wikipedia.org/wiki/Happy_number for proof.)

 

The following function returns the list [n, f(n), f(f(n)), ... ], where the final term is either 1 or 4.

(h,h(1),h(4)):= (((n::posint)-> [n, h(f(n))[]]), [1], [4]):

Examples

h(7);

[7, 49, 97, 130, 10, 1]

h(88);

[88, 128, 69, 117, 51, 26, 40, 16, 37, 58, 89, 145, 42, 20, 4]

If the list returned by h(n) ends in 1, then n is called a happy number.  This function lists all happy numbers from 1 to n:

happy_numbers:= (n::posint)-> select(n-> h(n)[-1]=1, [$1..n]):

Example:

happy_numbers(100);

[1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100]

 

 

Download happy-numbers_mod.mw

@farahnaz 

My comments weren't intended to be a fix for your problem. They were intended to make tracking down the problem easier.

Why do you use evalf(ApproximateInt(...)) rather than the more normal evalf(Int(...))? The latter will return a much more accurate result. The former doesn't respect the accuracy specified by Digits.

You mentioned dsolve, but I can't find any dsolve in your code. If it's there, please highlight it with a comment.

@Kitonum RREF stands for reduced row-echelon form.

It'd be nice if you'd use comments to indicate in your lengthy worksheet where the reader can find f or D5. Also see my Reply in this other recent thread (indeed, it looks like you may be working on the same problem as that poster): "error in calculate Determinant of matrix". My point 4 in that Reply doesn't apply to you, but the others do.

Your worksheet is difficult to read and to debug for several reasons:

  1. First and foremost, separate the commands into separate execution groups.
  2. Use a lower value of Digits until the bugs are worked out.
  3. End commands with semicolons rather than colons so that you can see their output. The infinity must occur before you take the determinant. If you can see the output of the commands, then you'll see where it occurs.
  4. Do not make assignment statements of the form f(x):= y in 2D input. If you're defining a function, use f:= x-> y. On the off chance that you're making a remember table assignment, I advise switching to 1D input. It's not fair to ask the readers of your worksheet to decide between the two, and there's no way to set a default answer to the question.

If you make these changes, I'll be happy to take another look at your worksheet.

First 440 441 442 443 444 445 446 Last Page 442 of 709