how to plot f(x)=ax^2+bx+c with 5-point and line in the same fig
Subject: how to plot f(x)=ax^2+bx+c with 5-point and line in the same fig
From: 黃 裕雄
Date: Sat, 10 Oct 2009 21:58:44 +0800
I try to plot the f(x)=ax^2+bx+c with a program
that is my code.
I assign the 5-point to matrix m ,but I don't know how to plot these points and f(x) curve in the same fig
============================================================
f(a,b,c):=a*x^2+b*x+c;
[a,b,c]:[2,4,5];
f(a,b,c);
F(x):=a*x^2+b*x+c;
F(x);
i:-b/(2*a); /* vertex pt of x=-b/(2a)*/
for i:1 thru 5 do (m[1,i]:[0,0]); /*initial matrix m=0*/
for j: i-2 thru i+2 do (print(j,F(j)),m[1,i]:[j,F(j)],print(m[1,i])); /* assign (j,F(j)) to matrix m*/
plot2d([discrete,m],[x,-10,10],[style,[points,4,2,2],[lines,3,3]]); /* plot2d by 5-point ( from matrix m), F(x) */;
(%o161) f(a,b,c):=a*x^2+b*x+c
(%o162) [2,4,5]
(%o163) 2*x^2+4*x+5
(%o164) F(x):=a*x^2+b*x+c
(%o165) 2*x^2+4*x+5
(%o166) -1
(%o167) done
-311
[-3,11]
-25
[-2,5]
-13
[-1,3]
05
[0,5]
111
[1,11]
(%o168) done
Incorrect syntax: No subscripts given
m[]
^
=====================================================
> From: maxima-request at math.utexas.edu
> Subject: Maxima Digest, Vol 39, Issue 26
> To: maxima at math.utexas.edu
> Date: Fri, 9 Oct 2009 07:25:37 -0500
>
> Send Maxima mailing list submissions to
> maxima at math.utexas.edu
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://www.math.utexas.edu/mailman/listinfo/maxima
> or, via email, send a message with subject or body 'help' to
> maxima-request at math.utexas.edu
>
> You can reach the person managing the list at
> maxima-owner at math.utexas.edu
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Maxima digest..."
>
>
> Today's Topics:
>
> 1. Using maxima for vector calculus in spherical (Edwin Woollett)
> 2. Re: Using maxima for vector calculus in spherical coordinates
> (Mario Rodriguez)
> 3. Another silly question: is sqrt(3) an integer (Robert Marik)
> 4. plotting a parametric integral (Stanislav Maslovski)
> 5. Re: trigonometric equations (Barton Willis)
> 6. Re: trigonometric equations (Richard Fateman)
> 7. Re: plotting a parametric integral (Mario Rodriguez)
> 8. Re: plotting a parametric integral (Jaime Villate)
> 9. Re: plotting a parametric integral (Leo Butler)
> 10. linux journal (Leo Butler)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 8 Oct 2009 12:26:30 -0700
> From: "Edwin Woollett" <woollett at charter.net>
> Subject: Using maxima for vector calculus in spherical
> To: <pamarca at gmail.com>
> Cc: maxima mailing list <maxima at math.utexas.edu>
> Message-ID: <957AC33E480243C6A874144550B860EA at edwinc367e16bd>
> Content-Type: text/plain; format=flowed; charset="iso-8859-1";
> reply-type=original
>
> On Oct. 7, 2009, Pablo Marchant wrote:
> ----------------
> I'm trying to find a way to work with vector calculus in spherical
> coordinates. I know the typical operators are contained in the vect package,
> but I haven't found a way to make them work with coordinates other that
> cartesian.
> -----------------------------
> You might have a look at chapter 6, Maxima by Example, Differential
> Calculus,
> sections 6.8, 6.9, and 6.10, which does vector calculus calculations in
> several
> coordinate systems using my package vcalc.mac, all available free of
> charge at http://www.csulb.edu/~woollett/
>
> Best Wishes,
> Ted Woollett
>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 08 Oct 2009 21:35:17 +0200
> From: Mario Rodriguez <biomates at telefonica.net>
> Subject: Re: [Maxima] Using maxima for vector calculus in spherical
> coordinates
> To: Pablo Marchant <pamarca at gmail.com>
> Cc: maxima at math.utexas.edu
> Message-ID: <1255030517.7635.2.camel at pc>
> Content-Type: text/plain; charset=utf-8
>
> El mi?, 07-10-2009 a las 16:26 -0400, Pablo Marchant escribi?:
> > Hi. I'm trying to find a way to work with vector calculus in spherical
> > coordinates. I know the typical operators are contained in the vect
> > package, but I haven't found a way to make them work with coordinates
> > other that cartesian.
>
>
> I have never used it, but I think that package 'vector3d', which is not
> documented, is the response.
>
> Some demos in share/contrib/vector3d
>
>
> --
> Mario
>
>
>
> ------------------------------
>
> Message: 3
> Date: Thu, 8 Oct 2009 21:10:37 +0000 (UTC)
> From: Robert Marik <marik at mendelu.cz>
> Subject: Another silly question: is sqrt(3) an integer
> To: maxima at math.utexas.edu
> Message-ID: <loom.20091008T230841-802 at post.gmane.org>
> Content-Type: text/plain; charset=us-ascii
>
> Hello is this known problem?
>
> load('contrib_ode);
> contrib_ode('diff(y,x,2)*x^2+'diff(y,x)*x+(x^2-3)*y=0,y,x);
>
> asks if sqrt(3) is integer
>
> Thanks
> Robert Marik
>
>
>
> ------------------------------
>
> Message: 4
> Date: Fri, 9 Oct 2009 02:10:19 +0400
> From: Stanislav Maslovski <stanislav.maslovski at gmail.com>
> Subject: plotting a parametric integral
> To: maxima at math.utexas.edu
> Message-ID: <20091008221019.GA12603 at kaiba.homelan>
> Content-Type: text/plain; charset=us-ascii
>
> Hello,
>
> I am trying to plot this simple Fourier integral in Maxima 5.17.1:
>
> (%i1) display2d : false$
>
> (%i2) f(k):=integrate(exp(%i*k*x)*sin(x)/x,x,minf,inf)$
>
> (%i3) [f(0), f(1), f(3/2)];
>
> (%o3) [%pi,%pi,0]
>
> So far so good.
>
> (%i4) plot2d(f,[x,-3,3]);
>
> (%o4)
> (%i5) Warning: empty y range [0:0], adjusting to [-1:1]
>
> Theoretically, f(k) must be equal to %pi for k in [-1;1] and 0
> outside. The plot does not show anything in [-1;1].
>
> Moreover, if I try this plotting command
>
> plot2d(f(k),[k,-3,3]);
>
> I get a stupid question about the sign of k-1.
>
> Can anyone explain what is wrong here?
>
> --
> Stanislav
>
>
> ------------------------------
>
> Message: 5
> Date: Thu, 8 Oct 2009 18:43:17 -0500
> From: Barton Willis <willisb at unk.edu>
> Subject: Re: [Maxima] trigonometric equations
> To: "Jos Simons" <simons17 at xs4all.nl>
> Cc: maxima at math.utexas.edu
> Message-ID:
> <OF77708A64.A3A81822-ON86257649.00824E90-86257649.00824E91 at unk.edu>
> Content-Type: text/plain; charset=US-ASCII
>
> If algsys (or maybe solve) solved the cyclotomic polynomials using
> trigonometric functions instead of radicals, the to_poly_solver would
> give a simpler solution for cos(2*x) = 1/2 - sin(x), I think.
>
> We're too much in love with messy solutions in radicals when a
> simple trigonometric function would do the job.
>
> Barton
>
>
>
> ------------------------------
>
> Message: 6
> Date: Thu, 08 Oct 2009 17:19:12 -0700
> From: Richard Fateman <fateman at cs.berkeley.edu>
> Subject: Re: [Maxima] trigonometric equations
> To: Jos Simons <simons17 at xs4all.nl>
> Cc: maxima at math.utexas.edu
> Message-ID: <4ACE8180.3030400 at cs.berkeley.edu>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Jos Simons wrote:
> > L.S.,
> >
> > How can I solve with Maxima the equation
> >
> > cos(2*x) =1/2 - sin(x)
> >
> > in such a way that I get the exact solutions
> > 3/10 pi, 7/10 pi, 11/10 pi, 19/10 pi, etc.
> >
>
> trigexpand(%);
> subst(1-sin(x)^2,cos(x)^2,%);
> solve(%,x);
>
> gets
> [x=-asin(sqrt(5)/4-1/4),x=asin(sqrt(5)/4+1/4)]
>
> you can also take the original equation and do
> %,exponentialize;
> solve(%,x)
>
> and get answers in terms of logs and radicals.
>
> -------------- next part --------------
> URL: http://www.math.utexas.edu/pipermail/maxima/attachments/20091008/6348a8aa/attachment-0001.htm
>
> ------------------------------
>
> Message: 7
> Date: Fri, 09 Oct 2009 07:56:10 +0200
> From: Mario Rodriguez <biomates at telefonica.net>
> Subject: Re: [Maxima] plotting a parametric integral
> To: Stanislav Maslovski <stanislav.maslovski at gmail.com>
> Cc: maxima at math.utexas.edu
> Message-ID: <1255067770.6186.31.camel at pc>
> Content-Type: text/plain; charset=utf-8
>
> El vie, 09-10-2009 a las 02:10 +0400, Stanislav Maslovski escribi?:
> > Hello,
> >
> > I am trying to plot this simple Fourier integral in Maxima 5.17.1:
> >
> > (%i1) display2d : false$
> >
> > (%i2) f(k):=integrate(exp(%i*k*x)*sin(x)/x,x,minf,inf)$
> >
> > (%i3) [f(0), f(1), f(3/2)];
> >
> > (%o3) [%pi,%pi,0]
> >
> > So far so good.
> >
> > (%i4) plot2d(f,[x,-3,3]);
> >
> > (%o4)
> > (%i5) Warning: empty y range [0:0], adjusting to [-1:1]
> >
> > Theoretically, f(k) must be equal to %pi for k in [-1;1] and 0
> > outside. The plot does not show anything in [-1;1].
> >
>
> Hello,
>
> The draw package has a similar problem. When the function returned by
> coerce-float-fun is applied to x values in the range [-1,1] to get the
> corresponding ordinate, it returns $%pi, instead of a float. An extra
> call to $float fixes this problem.
>
> Perhaps a better solution is to modify coerce-float-fun, if possible, so
> that both plot and draw work as expected. The alternative is to add some
> extra calls to Maxima's float function in several places.
>
>
>
>
>
>
> Stanislav, I have commited a new version of draw with this quick fix:
>
> http://maxima.cvs.sourceforge.net/viewvc/*checkout*/maxima/maxima/share/draw/draw.lisp
>
>
> draw2d(explicit(f,x,-1.5,1.5));
>
> should now work, but it takes a lot of time to be plotted due to the
> adaptive algorithm. This version is faster:
>
> draw2d(adapt_depth=1, explicit(f,x,-1.5,1.5));
>
>
>
> > Moreover, if I try this plotting command
> >
> > plot2d(f(k),[k,-3,3]);
> >
> > I get a stupid question about the sign of k-1.
> >
> > Can anyone explain what is wrong here?
> >
>
> Maxima tries to evaluate the general expression f(k) before the
> generation of the list of pairs.
>
>
>
>
>
> --
> Mario
>
>
>
> ------------------------------
>
> Message: 8
> Date: Fri, 09 Oct 2009 08:59:01 +0100
> From: Jaime Villate <villate at fe.up.pt>
> Subject: Re: [Maxima] plotting a parametric integral
> To: Stanislav Maslovski <stanislav.maslovski at gmail.com>
> Cc: maxima at math.utexas.edu
> Message-ID: <1255075141.4169.11.camel at bethe>
> Content-Type: text/plain
>
> On Sex, 2009-10-09 at 02:10 +0400, Stanislav Maslovski wrote:
>
> > I am trying to plot this simple Fourier integral in Maxima 5.17.1:
>
> > (%i2) f(k):=integrate(exp(%i*k*x)*sin(x)/x,x,minf,inf)$
>
> > (%i4) plot2d(f,[x,-3,3]);
>
> Hi,
> as Mario has already pointed out, the problem is that plot2d is passing
> a symbol %pi to the plotting program, where it should pass a
> floating-point approximation to %pi. Try the following:
>
> (%i2) f(k):=float(integrate(exp(%i*k*x)*sin(x)/x,x,minf,inf))$
>
> (%i4) plot2d(f,[x,-3,3],[y,-1,4]);
>
> (if you don't use the "y" option, part of your plot will be covered by
> the plot box.)
>
> Regards,
> Jaime Villate
>
>
>
>
> ------------------------------
>
> Message: 9
> Date: Fri, 9 Oct 2009 09:03:42 +0100 (BST)
> From: Leo Butler <l.butler at ed.ac.uk>
> Subject: Re: [Maxima] plotting a parametric integral
> To: Stanislav Maslovski <stanislav.maslovski at gmail.com>
> Cc: maxima at math.utexas.edu
> Message-ID:
> <alpine.LRH.1.10.0910090822410.12794 at erdelyi.maths.ed.ac.uk>
> Content-Type: TEXT/PLAIN; charset=US-ASCII
>
>
>
> On Fri, 9 Oct 2009, Stanislav Maslovski wrote:
>
> < Hello,
> <
> < I am trying to plot this simple Fourier integral in Maxima 5.17.1:
> <
> < (%i1) display2d : false$
> <
> < (%i2) f(k):=integrate(exp(%i*k*x)*sin(x)/x,x,minf,inf)$
> <
> < (%i3) [f(0), f(1), f(3/2)];
> <
> < (%o3) [%pi,%pi,0]
> <
> < So far so good.
> <
> < (%i4) plot2d(f,[x,-3,3]);
> <
> < (%o4)
> < (%i5) Warning: empty y range [0:0], adjusting to [-1:1]
> <
> < Theoretically, f(k) must be equal to %pi for k in [-1;1] and 0
> < outside. The plot does not show anything in [-1;1].
> <
> < Moreover, if I try this plotting command
> <
> < plot2d(f(k),[k,-3,3]);
> <
> < I get a stupid question about the sign of k-1.
> <
> < Can anyone explain what is wrong here?
>
> There are a few things. The integral, f(k), is a piece-wise constant
> function. At the moment, Maxima lacks the ability to return an answer in
> this form. Work is being done to correct this.
>
> I would suggest that you try the following definition:
>
> (%i2) f(t) ::= buildq([k:t],
> integrate(exp(%i*k*x)*sin(x)/x,x,minf,inf));
> (%o2) f(t)::=buildq([k:t],integrate(exp(%i*k*x)*sin(x)/x,x,minf,inf))
>
> This will avoid any calls to 'asksign' (which is asking about the sign
> of k) when t is a constant. I have also set ratprint to false to avoid
> the annoying warnings about floats being converted to rationals.
>
> (%i3) l : makelist(i/10,i,-20,20)$
> (%i4) fl : float(map(f,l));
> (%o4) [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,3.141592653589793,
> 3.141592653589793,3.141592653589793,3.141592653589793,
> 3.141592653589793,3.141592653589793,3.141592653589793,
> 3.141592653589793,3.141592653589793,3.141592653589793,
> 3.141592653589793,3.141592653589793,3.141592653589793,
> 3.141592653589793,3.141592653589793,3.141592653589793,
> 3.141592653589793,3.141592653589793,3.141592653589793,
> 3.141592653589793,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
> (%i5) plot2d([discrete,l,fl]);
> This plots what you want.
>
> Incidentally, you will find that this is very slow. The problem is that
> the integral is being recomputed each time f is evaluated. What you
> would really want to do is to compute the integral once, as a symbolic
> facility is under development.
>
> Note that you can also use 'assume':
>
> (%i35) [ (map(forget,facts()), assume(k<-1),f(k)) , (forget(k<-1),
> assume(k>1),f(k)) , (forget(k>1), assume(k>-1,k<1),f(k)), f(-1), f(1) ];
> (%o35) [0,0,%pi,0,%pi]
>
> Leo
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
>
>
> ------------------------------
>
> Message: 10
> Date: Fri, 9 Oct 2009 13:24:30 +0100 (BST)
> From: Leo Butler <l.butler at ed.ac.uk>
> Subject: linux journal
> To: "'Maxima List'" <maxima at math.utexas.edu>
> Cc: mdiehl at diehlnet.com
> Message-ID:
> <alpine.LRH.1.10.0910091307170.12794 at erdelyi.maths.ed.ac.uk>
> Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII
>
> I'm not sure how I missed this article, but I just found it:
>
> http://www.linuxjournal.com/content/exploring-advanced-math-maxima
>
> I thought about adding the link to the maxima wiki, but I don't see an
> obvious spot. Suggestions?
>
> Leo
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
>
>
> ------------------------------
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>
> End of Maxima Digest, Vol 39, Issue 26
> **************************************
_________________________________________________________________
???P???? ?V ?Q?? Windows Live ????????????
http://download.live.com/toolbar