Error using symengine, Too many input arguments, x= xf; fx = funfcn(x,varargin{:});
12 views (last 30 days)
Show older comments
Viktor Puchý
on 6 May 2022
Commented: Walter Roberson
on 7 May 2022
Hi,
could anyone help me with this problem?
I have this code:
a = 1;
b = 1;
c = 1;
d = 1;
e = 1;
f = 1;
func = @(x)(a.*x.^2 + b.*x + c)./(d.*x.^2 + e.*x + f);
syms y;
f_sym = (a.*y.^2 + b.*y + c) ./ (d.*y.^2 + e.*y + f);
df(y) = diff(f_sym, 2);
formulation = matlabFunction(formula(df));
minbnd = fminbnd(formulation, 0, 3);
And I get this error:
Error using symengine>@()0.0
Too many input arguments.
---
Error in fminbnd (line 232)
x= xf; fx = funfcn(x,varargin{:});
---
Error in Project (line 128)
minbnd = fminbnd(formulation, 0, 3);
Thanks for your help :)
0 Comments
Accepted Answer
Walter Roberson
on 6 May 2022
with those constants, f_sym is (y*y + y + 1)/(y*y+y+1) which is 1 except at 0. derivative of 1 is 0... with no symbolic variables.
When you matlabFunction a constant expression and do not use the 'vars' option then it looks and sees no symbolic variables, and builds a function that accepts no parameters.
You should use 'vars', y for matlabFunction to get @(y)0.0 generated. That will not have an interesting minimum but it will not crash.
2 Comments
Walter Roberson
on 7 May 2022
formulation = matlabFunction(df, 'vars', y);
Remember that in context this is going to create a function that accepts a parameter and ignores it and returns a scalar 0.
More Answers (0)
See Also
Categories
Find more on Number Theory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!