Plotting Mathematica f[r_][x_]: Solving Derivatives & Plotting Lines

  • Context: Mathematica 
  • Thread starter Thread starter Dustinsfl
  • Start date Start date
  • Tags Tags
    Mathematica Plotting
Click For Summary
SUMMARY

The discussion focuses on plotting the function f[r][x] = 1 + r*x + x^2 in Mathematica, specifically addressing how to visualize its derivatives. Users aim to differentiate the plot lines based on the sign of the derivative, using solid lines for negative derivatives and dashed lines for positive derivatives. The solution involves defining the critical points cps[r_] and using the Manipulate function to dynamically adjust the plot. The final implementation includes plotting the derived functions y[r_] and t[r_] with specific styles to indicate their derivative characteristics.

PREREQUISITES
  • Mathematica programming knowledge
  • Understanding of derivatives and their graphical representation
  • Familiarity with the Plot and Manipulate functions in Mathematica
  • Basic algebraic manipulation and solving equations in Mathematica
NEXT STEPS
  • Learn how to use the Derivative function in Mathematica for automatic differentiation
  • Explore advanced plotting techniques in Mathematica, including custom styles
  • Investigate the use of conditional formatting in plots based on function properties
  • Study the implications of critical points in function analysis and their graphical representations
USEFUL FOR

Mathematica users, mathematicians, educators, and students interested in visualizing mathematical functions and their derivatives effectively.

Dustinsfl
Messages
2,217
Reaction score
5
Code:
f[r_][x_] := 1 + r*x + x^2;
A = Table[
   cps[r_] = x /. Quiet[Solve[f[r][x] == 0, x], Solve::ratnz], {r, -5,
     5, 0.01}];

I want to then tell mathematica to check the derivative of f with each value from the table, plot the values, but make the lines where there derivative in less than 0 solid and dashed for greater than 0.

Any ideas on how to finish this?
 
Physics news on Phys.org
dwsmith said:
Code:
f[r_][x_] := 1 + r*x + x^2;
   cps[r_] = x /. Quiet[Solve[f[r][x] == 0, x], Solve::ratnz]

I want to then tell mathematica to check the derivative of f with each value from the table, plot the values, but make the lines where there derivative in less than 0 solid and dashed for greater than 0.

Any ideas on how to finish this?

So I got rid of the table.
Code:
f[r_][x_] := 1 + r*x + x^2;
cps[r_] = x /. Quiet[Solve[f[r][x] == 0, x], Solve::ratnz];
g[r_] = x /. Quiet[Solve[f[r][x] == 0, x], Solve::ratnz]
Plot[g[r], {r, -5, 5}, PlotStyle -> {Red, Thick}]
{1/2 (-r - Sqrt[-4 + r^2]), 1/2 (-r + Sqrt[-4 + r^2])}
Manipulate[Plot[f[r][x], {x, -4, 4}], {r, -10, 10}]

y[r_] = 1/2 (-r - Sqrt[-4 + r^2]);
t[r_] = 1/2 (-r + Sqrt[-4 + r^2]);
Plot[{y[r], t[r]}, {r, -5, 5}, 
 PlotStyle -> {{Dashing[{Medium}], Red}, {Thick, Red}}]

I can create what I want be defining the g[r] output but is there a way to have the g[r] output automatically defined as functions without doing it by hand?
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
8
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K