all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jay Belanger <jay.p.belanger@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to use calc functions in own lisp program?
Date: Mon, 01 Jun 2009 17:06:28 -0500	[thread overview]
Message-ID: <87vdnftxqz.fsf@vh213601.truman.edu> (raw)
In-Reply-To: h0063e$4jm$1@news.onet.pl



Marc Tfardy <no@email.com> writes:
> Jay Belanger schrieb:
..
>> calc-curve-fit is designed to be used as an interactive Calc function,
>> so it assumes it is being used from the Calc buffer and interacts with
>> the stack,
>
> When this is true, why provide calc-curve-fit all needed data as call
> arguments?

I don't know. :(

> This is what I looking for! VERY VERY BIG THANKS!

You're welcome. :)

> The polynomial fit ist the first step. Now I must to compute
> values on this curve at certain points. In Calc it is very easy.
> I put the value for 'x' on the stack and press 'sl', Calc ask for
> variable, I type 'x RET' and get a polynom value for my 'x'. But how can
> I do in my lisp code?

You could use `subst', which takes the form "subst(expr,var,value)".
(Actually, instead of a variable any expression can be substituted for.)
So, if you want the best fit curve evaluated at x=2, for example,
you could use
 (calc-eval
     "simplify(subst(fit(a*x^2+b*x+c,[x],[a,b,c],[[1,2,3,4],[1.1,4.2,9.2,15.8]]),x,2))")
or even
  (string-to-number ...above...)

(Of course, depending on what else you want Calc to do, it might be more
efficient to write a lisp program that will do the curve fitting.)

Jay



  reply	other threads:[~2009-06-01 22:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-29 17:29 How to use calc functions in own lisp program? Marc Tfardy
2009-05-29 19:39 ` Andreas Röhler
2009-06-01  9:18   ` Marc Tfardy
2009-05-30  1:34 ` Jay Belanger
2009-06-01  9:13   ` Marc Tfardy
2009-06-01 22:06     ` Jay Belanger [this message]
2009-06-02  9:01       ` Marc Tfardy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vdnftxqz.fsf@vh213601.truman.edu \
    --to=jay.p.belanger@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.