The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
cas-function: locuscurve
02-20-2018, 10:34 AM (This post was last modified: 02-22-2018 02:54 PM by Arno K.)
Post: #1
cas-function: locuscurve
This small program provides on input of a set of function f(x,k) and an additional parameter p a list containing the equations (as strings to be easily usable in plots) of extreme points (p=1) or turning points (p=2). As I did not want to bother about used variables x and k must be used. f may also be an expression.
Code:
locuscurve(x*e^(-k*x^2),1)
provides the output:
Code:
{"y:=x^2/(abs(x)*e^(1/2))","y:=-x^2/(abs(x)*e^(1/2))"}
Here you must clearly see for yourself that the first part is for max-points and the second one is for mins, putting this together to only "y:=x*e^(-1/2)" would have caused a lot of different cases to be taken care of, so I omitted that.
Code:
// calculates the curve through locuspoints of a parametric function which must be dependent from x and k
// p=1: extreme points, p=2: turning points
// f can be function or symbolic 
#cas
locuscurve(f,p):=
BEGIN
LOCAL g,x,k,z;
LOCAL l1,l2,j;
purge(x);
purge(k);
IF type(f)≠DOM_FUNC THEN
f(x,k):=f;//transform to function
END;

g:=diff(f(x,k),x,p);
l1:=zeros(g);//x-vals
l2:=apply(z→f(z,k),l1);//y-vals
l1:=x.-l1;
l1:=apply(z→solve(z=0,k),l1);
FOR j FROM 1 TO size(l1) DO
l1[j]:=l1[j][1];
l2[j]:="f"+j+"(x):="+simplify(subst(l2[j],k=l1[j]));//string for convenience
END;


  return convert(l2,23);// convert matrix to list
END;
#end
Arno
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
cas-function: locuscurve - Arno K - 02-20-2018 10:34 AM
RE: cas-function: locuscurve - Arno K - 02-27-2018, 11:32 PM



User(s) browsing this thread: 1 Guest(s)