23.3.7

8 views
Skip to first unread message

kenny

unread,
Oct 28, 2010, 11:15:19 PM10/28/10
to Study-HTDP
I am having trouble with this exercise, any help would mean a lot. I
haven't spent long on it yet, and will continue to keep working on it.
The book says the sequence for a logarithm is:
2 *[(expt(/(- x 1)(+ x 1))1)+(/ 1 3)*(expt(/(- x 1)(+ x 1))3)....]
Now from this I am thinking that 2 represents the index of 0 in this
sequence so (expt(/(- x 1)(+ x 1))1) would be 1, (/ 1 3)* would be 2
and so on.
I have managed to produces a function which gives me an answer of some
sort, but no where close to the output of log.
I believe that (/ 1 3) can be evaluated to (/ 1(add1 i)) in scheme,
the pattern seems to be 1/3, 1/5, 1/7 and 1/3 is i=2, 1/5 is i=4, 1/7
is i=6.
The other part seems to simply add an exponent of i.
The function I was able to produce is below:

(define(even a-nat-num)
(local((define(odd an)
(cond
[(zero? an)false]
[else(even(sub1 an))]))
(define(even an)
(cond
[(zero? an)true]
[else(odd(sub1 an))])))
(even a-nat-num)))

(define(ln x)
(local((define(ln-taylor i)
(cond
[(= i 0)(* 2 1)]
[(not(even i))
(+(expt(/(- x 1)
(+ x 1))i)
(ln-taylor(sub1 i)))]
[(even i)
(*(/ 1(add1 i))
(ln-taylor(sub1 i)))])))
(exact->inexact(series 3 ln-taylor))))

I am sorry if this isn't entirely clear, still trying to get my head
around how this problem works and I tried explaining it as well as I
can. Please help me find where I went wrong.

kenny

unread,
Oct 29, 2010, 3:14:37 PM10/29/10
to Study-HTDP
Just to update how my progress is, still no luck. None of these
mathematical series exercises are clicking for me. I was able to do
the basic geometric and arithmetic series, but everything else is just
not working. I've tried many things to get an answer and nothing comes
close. The closest I can get is an answer where the higher the index
goes the larger or smaller the number gets.
I tried making a program which would compute what term is at position
i. So, i=0 would be 2, i=1 would be(expt(/(- x 1)(+ x 1))1) and i=2
would be (/ 1(add1 i)) which was successful, the program works as
expected. I am having trouble with figuring out how to find the series
when it alternates between multiplication and addittion. My play was
to use the working locator function and create a new series function
which would multiply for i=odd, and add for i=even but it still
doesn't produce near what is expected.

Im getting pretty frustrated with this and help would be appreciated,
again, I can clear this up if it sounds too confusing. Just let me
know.

Grant Rettke

unread,
Oct 29, 2010, 3:36:25 PM10/29/10
to study...@googlegroups.com
On Fri, Oct 29, 2010 at 2:14 PM, kenny <heg...@yahoo.com> wrote:
> Im getting pretty frustrated with this and help would be appreciated,
> again, I can clear this up if it sounds too confusing. Just let me
> know.

Hey Kennie,

You should post this on the Racket-users mailing list here:

http://lists.racket-lang.org/users/

Best wishes,

Grant Rettke

Dave

unread,
Oct 30, 2010, 11:11:54 PM10/30/10
to Study-HTDP
Hey Kenny --

Let me try to help you with this.

First, as Grant mentioned, you can always post questions to the Racket
users mailing list. Some very knowledgeable people, including the
primary author of HtDP, receive posts from that list, and are very
generous with their time when it comes to helping students work
through difficult exercises.

That being said, you won't get very far with them unless you've
demonstrated that you've followed the design recipe to a "T." What
does that mean? It means beginning each function with a contract,
purpose statement, template, and examples. I can't see that you've
satisfied any of those steps.

So my first suggestion is to fill out the design recipe steps and
repost. If that doesn't produce the "clicking" sound you've been
waiting for, let me know and I'll help guide you to the solution.

Best of luck!

Dave Yrueta

kenny

unread,
Oct 31, 2010, 2:23:52 AM10/31/10
to Study-HTDP
Thanks for the mailing list advice, as far as the problems with the
taylor series stuff, I did finally manage to figure them all out. My
big problem was that I was over complicating how to compute
everything. I also do have contracts, templates, and examples, just I
didn't post them here, sorry, I will remember that for any help I need
later.

Dave

unread,
Oct 31, 2010, 10:05:50 AM10/31/10
to Study-HTDP
Well done!
Reply all
Reply to author
Forward
0 new messages