Hi
I have the function f(x) = x^2/(1+sqrt(x)) and I am trying to calulate the value of the invrese function at 2 i.e. F^-1(2)
I am trying to use 'finverse' but and have succefulle extracted the inverse function and seperatley calculating the value but nor during the same attempt.
this is the latest attempt
sym x
x = 2;
g = finverse(x.^2./(1+sqrt(x)),x);
f = @(x) g;
disp(f(2))

 채택된 답변

VBBV
VBBV 2022년 10월 17일

0 개 추천

syms x
g = finverse(x.^2./(1+sqrt(x)),x);
% x = 2;
f = @(x) g;
disp(f(2))

댓글 수: 1

syms x
g = finverse(x.^2./(1+sqrt(x)),x);
% x = 2;
f = @(x) g;
double(subs(g,x,2))
ans = 2.2336

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sam Chak
Sam Chak 2022년 10월 17일

1 개 추천

How about this?
syms x
f(x) = (x^2)/(1 + sqrt(x));
g = finverse(f)
g(x) = 
double(g(2))
ans = 2.2336

댓글 수: 6

Johan Ahlberg
Johan Ahlberg 2022년 10월 17일
You are getting the answer I am looking for but for some reason I am getting the following error
Error using sym/subsindex
Invalid indexing or function definition. Indexing must follow MATLAB
indexing. Function arguments must be symbolic variables, and function
body must be sym expression.
Error in A_3_1_31 (line 3)
f(x) = (x^2)/(1 + sqrt(x));
It thinks you used symbolic variable "x" as indices
syms x
x = 2; % <--- because of this line
f(x) = (x^2)/(1 + sqrt(x));
g = finverse(f)
You can comment out it.
Johan Ahlberg
Johan Ahlberg 2022년 10월 17일
Copied your code directly and got that error
clear
check the workspace variables if it has x value assigned to 2, use clear and try again
Sam Chak
Sam Chak 2022년 10월 17일
Hmm... This is strange. No error on mine.
Perhaps try clearing the variables from your Workspace. Then test the code again.
Have you tried @VBBV's code on your MATLAB?
Johan Ahlberg
Johan Ahlberg 2022년 10월 17일
Clearing the workspace worked, my bad.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Calendar에 대해 자세히 알아보기

제품

릴리스

R2022a

태그

질문:

2022년 10월 17일

댓글:

2022년 10월 17일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by