Post Reply 
RPN-duino
10-01-2016, 01:18 PM
Post: #41
RE: RPN-duino
The instability problem is now resolved.

I added a couple of lines to my code that would report free RAM when shift and enter were pressed together on the Texas RPN-duino. It was clear that a major heap crunch was going on whenever trig. functions were invoked from the keyboard. I had based sine, cosine and tangent on an example sine routine that comes with the Arduino BigNumber library:


Code:

// calculate sine of x with 'precision' iterations
BigNumber sine (const BigNumber x, BigNumber precision)
{
  BigNumber val = 1;
  const BigNumber one = 1, two = 2;
  while (precision > 0)
  {
    val = one - val * x * x / (two * precision) / (two * precision + one);
    precision--;
  }
  val = x * val;
  return val;
} // end of function sine


I never work out quite how it delivered sine but went ahead and used it anyway. It looks harmless enough and certainly converges rapidly on the right answer. Also, it doesn't seem to have any of that disappear-up-your-own-tail-pipe recursion that some programmers love to use, and which I can never get my head around. However, it seems to be very hard on heap memory when called. I replaced it with a brutishly direct implementation of the Maclaurin series to 12 terms and the stability problem disappeared. The calculator is now running happily on a luxurious 25 digits of BigNumber.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RPN-duino - Chasfield - 10-16-2015, 03:55 PM
RE: RPN-duino - eried - 10-16-2015, 07:03 PM
RE: RPN-duino - David Hayden - 10-16-2015, 07:22 PM
RE: RPN-duino - Chasfield - 10-16-2015, 07:23 PM
RE: RPN-duino - Dwight Sturrock - 10-16-2015, 11:40 PM
RE: RPN-duino - eried - 10-16-2015, 08:50 PM
RE: RPN-duino - rprosperi - 10-16-2015, 09:23 PM
RE: RPN-duino - Chasfield - 10-17-2015, 04:38 AM
RE: RPN-duino - Thomas Klemm - 10-17-2015, 07:48 AM
RE: RPN-duino - rprosperi - 10-17-2015, 12:56 PM
RE: RPN-duino - Dwight Sturrock - 10-17-2015, 04:41 PM
RE: RPN-duino - Dave Frederickson - 10-17-2015, 05:02 PM
RE: RPN-duino - Vtile - 11-14-2015, 08:25 PM
RE: RPN-duino - walter b - 11-14-2015, 09:11 PM
RE: RPN-duino - Chasfield - 10-24-2015, 10:45 AM
RE: RPN-duino - ggauny@live.fr - 10-29-2015, 08:26 AM
RE: RPN-duino - vido - 09-18-2016, 06:50 PM
RE: RPN-duino - Chasfield - 11-14-2015, 05:27 PM
RE: RPN-duino - Thomas Klemm - 11-14-2015, 05:48 PM
RE: RPN-duino - Chasfield - 11-15-2015, 10:28 AM
RE: RPN-duino - compsystems - 11-17-2015, 07:51 PM
RE: RPN-duino - Chasfield - 11-18-2015, 05:14 PM
RE: RPN-duino - Chasfield - 11-18-2015, 07:25 PM
RE: RPN-duino - Chasfield - 11-22-2015, 10:21 AM
RE: RPN-duino - Chasfield - 02-13-2016, 12:28 PM
RE: RPN-duino - Chasfield - 08-24-2016, 01:23 PM
RE: RPN-duino - Chasfield - 09-17-2016, 02:49 PM
RE: RPN-duino - larthurl - 04-06-2018, 02:29 PM
RE: RPN-duino - Luigi Vampa - 09-17-2016, 03:33 PM
RE: RPN-duino - Nigel (UK) - 09-17-2016, 06:57 PM
RE: RPN-duino - Chasfield - 09-18-2016, 01:52 PM
RE: RPN-duino - Nigel (UK) - 09-19-2016, 08:48 AM
RE: RPN-duino - Maximilian Hohmann - 09-19-2016, 09:44 AM
RE: RPN-duino - Chasfield - 09-19-2016, 02:35 PM
RE: RPN-duino - Luigi Vampa - 09-19-2016, 04:05 PM
RE: RPN-duino - jch - 09-19-2016, 07:08 PM
RE: RPN-duino - Chasfield - 09-28-2016, 03:24 PM
RE: RPN-duino - Chasfield - 09-28-2016, 05:01 PM
RE: RPN-duino - Luigi Vampa - 09-28-2016, 07:23 PM
RE: RPN-duino - Chasfield - 09-29-2016, 06:51 AM
RE: RPN-duino - Chasfield - 09-30-2016, 06:50 PM
RE: RPN-duino - Chasfield - 10-01-2016 01:18 PM
RE: RPN-duino - Luigi Vampa - 10-01-2016, 03:20 PM
RE: RPN-duino - Chasfield - 10-01-2016, 03:31 PM
RE: RPN-duino - Chasfield - 10-01-2016, 05:39 PM
RE: RPN-duino - Luigi Vampa - 10-01-2016, 06:38 PM
RE: RPN-duino - Chasfield - 10-01-2016, 07:00 PM
RE: RPN-duino - Luigi Vampa - 10-02-2016, 09:14 AM
RE: RPN-duino - Luigi Vampa - 10-02-2016, 12:43 PM
RE: RPN-duino - Chasfield - 10-02-2016, 01:54 PM
RE: RPN-duino - Chasfield - 10-16-2016, 03:41 PM
RE: RPN-duino - Luigi Vampa - 10-16-2016, 07:49 PM
RE: RPN-duino - larthurl - 04-06-2018, 02:38 PM
RE: RPN-duino - Chasfield - 10-17-2016, 05:31 AM
RE: RPN-duino - Chasfield - 10-27-2016, 02:13 PM
RE: RPN-duino - Luigi Vampa - 10-27-2016, 08:27 PM
RE: RPN-duino - Chasfield - 10-28-2016, 01:20 PM
RE: RPN-duino - Chasfield - 03-25-2017, 03:02 PM
RE: RPN-duino - Luigi Vampa - 03-25-2017, 09:52 PM
RE: RPN-duino - Chasfield - 03-26-2017, 08:32 AM
RE: RPN-duino - Chasfield - 03-27-2017, 03:19 PM
RE: RPN-duino - Maximilian Hohmann - 03-27-2017, 03:58 PM
RE: RPN-duino - BobVA - 03-27-2017, 05:00 PM
RE: RPN-duino - Chasfield - 03-27-2017, 04:42 PM
RE: RPN-duino - Chasfield - 07-19-2017, 04:51 PM
RE: RPN-duino - Luigi Vampa - 07-19-2017, 05:26 PM
RE: RPN-duino - EugeneNine - 07-19-2017, 06:12 PM
RE: RPN-duino - Chasfield - 07-24-2017, 01:50 PM
RE: RPN-duino - Dan - 07-27-2017, 03:44 AM
RE: RPN-duino - larthurl - 11-28-2017, 09:11 PM
RE: RPN-duino - Luigi Vampa - 11-28-2017, 09:40 PM
RE: RPN-duino - Chasfield - 04-05-2018, 04:41 PM
RE: RPN-duino - Luigi Vampa - 04-05-2018, 04:44 PM
RE: RPN-duino - Luigi Vampa - 04-06-2018, 02:41 PM
RE: RPN-duino - Chasfield - 04-06-2018, 06:14 PM
RE: RPN-duino - Chasfield - 04-08-2018, 10:34 AM



User(s) browsing this thread: 25 Guest(s)