Mathematica Help: Plotting y=k-x/k for All -10<k<10

  • Context: Mathematica 
  • Thread starter Thread starter hang2010wang
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary

Discussion Overview

The discussion revolves around using Mathematica to plot the function y=k-x/k for values of k in the range -10 to 10, while addressing the issue of k being undefined at 0. Participants explore different methods to avoid this singularity in their plots.

Discussion Character

  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant asks for help on how to plot the function while excluding k=0, suggesting a specific code snippet.
  • Another participant shares an alternative approach by plotting the function for k values from 1 to 10, effectively avoiding k=0.
  • A third participant proposes a method that splits the range of k into two parts, plotting separately for positive and negative values of k, and then combining the results.
  • A later reply suggests a more efficient way to exclude k=0 using the Cases function in Mathematica.

Areas of Agreement / Disagreement

Participants present multiple approaches to the problem, indicating that there is no single agreed-upon method for plotting the function while avoiding k=0. The discussion remains unresolved regarding the best approach.

Contextual Notes

Some methods proposed rely on specific intervals and may not address all potential issues with the function's definition across the entire range of k. The effectiveness of each method may depend on the user's familiarity with Mathematica's syntax and functions.

Who May Find This Useful

This discussion may be useful for Mathematica users looking to plot functions with singularities or undefined points, particularly in the context of mathematical modeling or analysis.

hang2010wang
Messages
2
Reaction score
0
Hi, Guys
Can someone help me about this question?
I am trying to use Mathematica to plot all the functions: y=k-x/k for all -10<k<10 with interval of 0.1
what I wrote is like this:
Plot[Table[k-x/k,{k,-10,10,0.1}],{x,-10,10}]

However, because the function doesn't have meaning when k=0.

So how can I type the comment to eliminate k=0
 
Physics news on Phys.org
I cheated and tried this: Plot[Table[{k - x/k, -k + x/k}, {k, 1, 10, 1}], {x, -10, 10}]
 
You could also try this:
s1=Plot[Table[k-x/k,{k,0.1,10,0.1}],{x,-10,10}]
s2=Plot[Table[k-x/k,{k,-10,-0.1,0.1}],{x,-10,10}]
Show[s1,s2]
Enjoy!
 
HAHA,many thanks for all
I have just discovered that it's even better if type in:
Plot[Table[-x/k+k,Cases[{k,-10,10,0.1},Except[0]]],{x,-10,10}]
 

Similar threads

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