Question regarding logistic function and the TI-Nspire CAS

831 views
Skip to first unread message

JB

unread,
Dec 7, 2010, 1:41:30 PM12/7/10
to tinspire
Hello all,

Today, we were using the nspire CAS to solve an AP question out of our
book. It was a data problem that has the following data:

Year Sales
0 12
1 114
2 348
3 792
4 1110
5 1520
6 1900

Year 0 was 1992 and the sales were in millions of dollars. The
problem wanted us to use the logistic regression to get a model and
then use it to find where the rate of increase of sales begins to
decrease (2nd deriv. = 0). When we did the derivatives “by hand” and
allowed the calculator to solve it = 0, we got x = 3.8667 (correct
from our book). However, I also tried to get them to just use the
calculators by writing on paper y’’=0 and using the nspire to do the
symbolism
Solve (d^2/dx^2(f1(x)=0,x) where f1 had stored the logistic regression
(d equal to 0) and the calcualtors froze as well as the computer!!

We then tried (after resetting our calculators!) the same thing, but
using d not equal to 0 and it gave 4.05771. I am wondering if anyone
knew what would cause this to freeze and why the other one gave a
different answer?

Jessica Kachur

unread,
Dec 8, 2010, 7:58:34 PM12/8/10
to tins...@googlegroups.com
I was doing this today also, but I got a domain error.  When I started at 1, it solved the problem (I just added a year to every year).
 
Jess Kachur
Mathematics Teacher
Springfield High School, Springfield, Illinois
T3 Regional Instructor
Muka, CGC, TDI, Retired, CL2, CL3-F, CL3-S, CL3-H, TN-O, WV-N
and
Jibay, Sandy Acres lil' Phantom, CGC, CL4, CL4-F, CL4-S, CL4-H



From: JB <arcs...@cinci.rr.com>
To: tinspire <tins...@googlegroups.com>
Sent: Tue, December 7, 2010 12:41:30 PM
Subject: [tinspire] Question regarding logistic function and the TI-Nspire CAS
--
To post to this group, send email to tins...@googlegroups.com
To unsubscribe send email to tinspire+unsub...@googlegroups.com
For more options, visit this group at
http://groups.google.com.au/group/tinspire?hl=en-GB?hl=en-GB
The tns documents shared by group members are archived at
http://lafacroft.com/archive/nspire.php

Nelson Sousa

unread,
Dec 8, 2010, 8:39:41 PM12/8/10
to tins...@googlegroups.com
The logistic regression doesn't allow x=0.

Note that the formula is of the type A/(1+B*exp(C*x))+D so when x=0
the coefficient C disappears.

As for determining the inflection point of the regression equation:
solve will try all sorts of manipulations in order to get an exact
solution before resorting to numerical methods. In complex and
transcendental equations (things with trigonometric functions,
exponentials, logarithms in some sort of non trivial combination) and
especially with decimal numbers, which is the case, solve can take a
very long period of time and still fail to return a solution. In such
cases press ON on the handheld or Pause/Break on the computer (PC) to
interrupt the calculation (what's the key on Mac?)

Instead of using solve, which is not, by far, the correct tool for the
job, use nsolve(equation, var [=value] )

In this case and if your equation is stored as f1,
nSolve(d^2(f1(x))/dx^2=0,x) will give you the correct answer
(x=4.86806, given that we had to increase all x-values by 1 unit)
almost immediately.

As a general rule of thumb: If an exact symbolic solution isn't
expected OR the equation is highly complex and, of course, has only
one unknown, use nsolve instead of solve. Solve should be used in
equations where, in principle, a human being could do the same job
(only doesn't because it's long/tedious/hard/requires too many
techniques/all of the above)

About nsolve: it searches for ONE solution numerically. In case your
equation has more than one solution, nsolve will find only one. And
(and this is a sad but universal and unavoidable truth), in some cases
a solution cannot be found. nsolve employs a variety of numerical
algorithms to try to find a solution (bissection, newton, fixed point,
some combination of these?) and while in most cases (meaning, most
cases we're usually interested in) the algorithms are powerful enough
and converge quickly, in others they fail to converge quickly enough,
to attain the desired precision or to find a specific solution. If a
warning message is displayed (namely, questionable accuracy), check
your solution by replacing it in the equation.

It helps a lot to provide an initial guess if the solution isn't good
enough or the algorithms fail to converge to the solution you're
interested in. For example, by entering nSolve(d^2(f1(x))/dx^2=0,x=4)
will make nsolve use x=4 as initial value of the iterative algorithm.
A good initial value can increase dramatically the speed of the
calculation and "guide" the algorithm to converge to a specific
solution. What I usually do (if I'm dealing with a particularly nasty
equation) is plot the function graphically, then try to estimate a
zero of the function and use two initial values, one above and another
below that estimate, to determine its exact value. In most cases the
algorithms will converge to the nearest solution (there are others,
however, where a specific solution is an "unstable" point and no
matter how close to it is our initial guess, the algorithms will
always drift away from it.

Finally, beware that different numerical algorithms have different
error margins, but they all have error margins; one shouldn't expect,
just because an answer is displayed using 12 digits, to have a
precision of the magnitude of 10^-12. For the most part I think we can
say with some confidence that the returned value should be around
10^-5 or 10^-6 from the exact solution. Hoping for more is a bit
optimistic.

Attached file: the way I did it (I used the Nspire CAS but in order to
use nsolve you don't need it, it can be done on the numeric Nspire).


Nelson

> To unsubscribe send email to tinspire+u...@googlegroups.com


> For more options, visit this group at
> http://groups.google.com.au/group/tinspire?hl=en-GB?hl=en-GB
> The tns documents shared by group members are archived at
> http://lafacroft.com/archive/nspire.php
>

> --
> To post to this group, send email to tins...@googlegroups.com

> To unsubscribe send email to tinspire+u...@googlegroups.com

logistic.tns

sinz54

unread,
Dec 9, 2010, 1:44:03 PM12/9/10
to tinspire


On Dec 8, 7:58 pm, Jessica Kachur <jessicakac...@yahoo.com> wrote:
> I was doing this today also, but I got a domain error.  When I started at 1, it
> solved the problem (I just added a year to every year).
>  Jess Kachur
> Mathematics Teacher
> Springfield High School, Springfield, Illinois
> T3 Regional Instructor
> Muka, CGC, TDI, Retired, CL2, CL3-F, CL3-S, CL3-H, TN-O, WV-N
> and
> Jibay, Sandy Acres lil' Phantom, CGC, CL4, CL4-F, CL4-S, CL4-H
>
> ________________________________
> From: JB <arcsec...@cinci.rr.com>
Even before you try to solve the equation with solve or nsolve,
just trying to symbolically evaluate the second derivative of f1(x)
will blow up on the Nspire CAS.

Evidently on a Spreadsheet page, f1(x) is expressed in a complicated
form

(2161.45 * (2.36954)^x)/(2.36954^x + 28.1336)

which is NOT the same way it's expressed if you calculated the
logistic regression on a Graph page.

But if you first simplify f1(x) into the usual logistic equation form,
by calling
expand (f1(x))

the calculator can figure out the symbolic second derivative of this.

So calling
solve(d^2/dx^2(expand(f1(x))=0,x)

will work and produce
x=3.86806

Michael Houston

unread,
Dec 9, 2010, 3:37:12 PM12/9/10
to tins...@googlegroups.com
Hi everyone-
 
I'm looking to offer a FREE user group meeting via WebEx.  The idea is this: once a month I will host a meeting online where we will discuss Nspireish things such as: best practice sharing in the classroom, awesome activities, and capabilities of the nspire (such as, how do I......).
 
All you need is a computer with a internet connection!  I'm designing this group for the beginner user.  Once things begin to grow then I'll consider running a more intermediate group as well.
 
If you are interested in participating in such a group, then please fill out this short 5 question survey.  Follow the link below.
 
http://www.surveymonkey.com/s/YPD8MHG
 
Thanks, and please let me know if you have any questions!
 
 
Thanks-
 
Mike Houston
Riverside High School
Ellwood City, PA
Reply all
Reply to author
Forward
0 new messages