
Evaluate symbolic nthroot and return its symbolic expression to plot
    11 views (last 30 days)
  
       Show older comments
    
    Abhilash Sukumari
 on 2 May 2018
  
    
    
    
    
    Edited: John D'Errico
      
      
 on 3 May 2018
            syms x;
f(x) = ((1 + x)^(1/3));
Ln = functionLinear(f, 2);
disp(LN);
Define the function that will return the tangent line 'res' symbolically. This way I can plot both the actual function and the tangent evaluated at point 'a'. The below function is what I coded, and I am not able to get the symbolic expression back.
function[res] = functionLinear(func, a)
syms x;
g(x) = diff(func);
res = g(a)*(x-a) + func(a);
end
0 Comments
Accepted Answer
  John D'Errico
      
      
 on 2 May 2018
        
      Edited: John D'Errico
      
      
 on 3 May 2018
  
      What is wrong with it? Did you forget to use vpa? For example, with...
a = 1.3;
I get this from your code:
res =
(10^(2/3)*23^(1/3))/10 + (10^(2/3)*23^(1/3)*(x - 13/10))/69
vpa(res)
ans =
0.19130523504288585473789120739135*x + 1.0713093162401607865321907613916
It looks pretty good to me.
ezplot(f,[0,2])
hold on
ezplot(res,[0,2])
grid on

Which as far as I can see, looks like a tangent line to that function at a==1.3. Yes, it suggests that a simple Newton's method on this function will probably get in trouble. But that is not the question here.
solve(res)
ans =
-28/5
It may explain why you were asked to try to solve this problem using Newton's method, probably as homework.
0 Comments
More Answers (0)
See Also
Categories
				Find more on Symbolic Math Toolbox in Help Center and File Exchange
			
	Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
