LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices



Reply
 
Search this Thread
Old 04-17-2006, 09:51 PM   #1
Four
Member
 
Registered: Aug 2005
Posts: 298

Rep: Reputation: 30
math program that I can enter math functions ...


Whats language (I know c++, and some others) (I prefer interpreted and free for speed of "seeing") or program that I can enter functions in it, and have compositions of functions, and able to call a function like
F(3)
and it would tell me the value there.

Thanks!
 
Old 04-17-2006, 10:00 PM   #2
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 197Reputation: 197
You want octave

this is a math script language similar to mathematica and matlab only it is GPL.

It is available from repositories if you run a debian or rpm based distribution. (Please edit your profile to show your location and distribution, thanks.)
 
Old 04-19-2006, 03:42 AM   #3
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
Try bc(1). The manual:
http://www.gnu.org/software/bc/manual/bc.html
 
Old 04-19-2006, 09:31 AM   #4
Leha208
LQ Newbie
 
Registered: Apr 2006
Posts: 1

Rep: Reputation: 0
Hi!
I am new to here. My friend show me this useful website. I hope anyone here could help me out. Ive tried to learn MATLAB. When i test it with my lecturer's file, i didnt score full mark. Please guide me through.
build-in function-functask2=sinh(x)-x.^2+x+1, xvalues=[1x50 double].
1) i need to compute the function at these xvalues and store in yvalues.
2) find best fit,quadratic n cubic to these values. Store the polynomial coefficient in linecoef, quadcoef and cubiccoef.
3) find new vector of x values,xnew,where there are 5 equispaced points betw each of the values in xvalues.
4) evaluate the polynomials and the function at xnew, store in yline, yquad, ycubic and yfunc.
5) do a cubic spline interpolation betw xvalues, yvalues, to find output values ynew at xnew.
6) overlay all 5 curves in a single plot.

my file is:
function out2=task2(in2)

%%% Compute what is originally in the workspace for task2.
out2=in2;

%%% Let x be a cell array containings the xvalues.
%%% Evaluate the function at x and compute them
%%% in yvalues.
x=in2.xvalues;
out2.yvalues=eval(in2.functask2);

%%% Compute the best fit straightline,
%%% quadractic and cubic to those yvalues.
%%%
out2.linecoef= polyfit(x,out2.yvalues, 1);
out2.quadcoef=polyfit(x,out2.yvalues,2);
out2.cubiccoef=polyfit(x,out2.yvalues,3);
r=numel(x);
xnew=linspace(x(1),x(end),6*(r-1)+ 1);
out2.xnew=xnew;
out2.yline=polyval(out2.linecoef,xnew);
out2.yquad=polyval(out2.quadcoef,xnew);
out2.ycubic=polyval(out2.cubiccoef,xnew);
x = xnew;
out2.yfunc=eval(in2.functask2,xnew);
ynew=spline(in2.xvalues, out2.yvalues, x);
out2.ynew=ynew;
figure(2); clf reset;
plot(xnew,ynew,'b', xnew,out2.yline, 'g',...
xnew,out2.yquad, 'y', xnew, out2.ycubic, 'k',...
xnew, out2.yfunc, 'm');
title( in2.functask2);
legend('vector', 'best fit line', 'quadratic',...
'cubic', 'function');


My up-2-date file is:
function out2=task2(in2)
out2=in2;
x=in2.xvalues;
out2.yvalues=eval(in2.functask2);

% To find the best fit straightline, quadratic
% and cubic at yvalues.
% Store them as polynomial coefficients in linecoef,
% quadcoef and cubiccoef respectively.
out2.linecoef= polyfit(x,out2.yvalues, 1);
out2.quadcoef=polyfit(x,out2.yvalues,2);
out2.cubiccoef=polyfit(x,out2.yvalues,3);

% To find a new vector, xnew.
% xnew contains values in x.
% xnew has 5 equispaced points between
% each of the values in x.
[x_val,y_val]= size(x);
% x_val the number of rows and y_val the number
% of columns in x.
aa=cell(1,(y_val-1));
% creates a 1-by-(y_val-1) cell array of empty matrices.
for i=1y_val-1)
if i==1
aa{i}=linspace(x(i),x(i+1),7);
else % if i is not equal to 1
xx=linspace(x(i),x(i+1),7);
xxx=xx(2:end);
aa{i}=xxx;
end
end
xnew=[aa{1:end}];
out2.xnew=xnew;
% To evaluate the polynomials and functask2 at xnew.
% store them in yline, yquad, ycubic and yfunc
% respectively.
out2.yline=polyval(out2.linecoef,xnew);
out2.yquad=polyval(out2.quadcoef,xnew);
out2.ycubic=polyval(out2.cubiccoef,xnew);
x = xnew;
out2.yfunc=eval(in2.functask2,xnew);

% To perform cubic spline interpolation between
% xvalues and yvalues.
% computes the values at xnew and store them at ynew.
ynew=spline(in2.xvalues, out2.yvalues, xnew);
out2.ynew=ynew;
% To plot a graph on figure(2) showing the 5 curves.
figure(2); clf reset;
plot(xnew,out2.ynew,'b', xnew,out2.yline, 'g',...
xnew,out2.yquad, 'y', xnew, out2.ycubic, 'k',...
xnew, out2.yfunc, 'm');
title(in2.functask2);
legend('vector', 'best fit line', 'quadratic',...
'cubic', 'function');
cheers!! please help me out.

ZUs.

Last edited by Leha208; 04-19-2006 at 09:32 AM.
 
Old 04-19-2006, 01:34 PM   #5
truthfatal
Member
 
Registered: Mar 2005
Location: Winnipeg, MB
Distribution: Raspbian, Debian, Slackware, OS X
Posts: 443
Blog Entries: 9

Rep: Reputation: 32
Maple is my favorite Math Program.

I don't know about languages though -- to me saying math language is the same as saying Math. you learn that in grade two
 
Old 04-19-2006, 09:02 PM   #6
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 197Reputation: 197
Leha208: we are not here to do your homework for you. Why don't you post to me privately, and show me how you tried to do this. Then, maybe I can give you some pointers.

Otherwise, there are plenty of matlab tutorials online.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
c and math functions davidleroux1 Programming 8 09-14-2006 10:47 PM
functions in math.h philgar Slackware 3 03-27-2005 06:08 PM
error while accessing math functions in kernel modules dypgrp Programming 0 01-19-2005 10:12 AM
Math Program evian Linux - Software 4 09-09-2004 11:41 AM
c compiler won't recognize math functions dreamgoat Red Hat 2 08-16-2004 06:45 PM


All times are GMT -5. The time now is 02:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration