ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 04 Feb 2011 06:20:26 +0100Plot the level sets of a functionhttps://ask.sagemath.org/question/7919/plot-the-level-sets-of-a-function/I'm trying to draw level set of a function f:R^2->R, that is the set of solutions of
f(x,y)=h for a given h.
For that purpose I wrote the following
#! /usr/bin/sage -python
# -*- coding: utf8 -*-
from sage.all import *
def level_curve(f,h):
solutions_list = solve(f==h,y)
return [sol.rhs() for sol in solutions_list]
var('x,y')
f=x+y+2
for g in level_curve(f,3):
print g
print "-----"
f=x**2+y**2
for g in level_curve(f,3):
print g
This works, but I'm not satisfied principally because I got the level sets under the form of a list of functions. Moreover it will not work if the level set is vertical.
Thus I would prefer to get the solution under the form of a parametric curve.
Does Sage provides something for that ?
Laurent ClaessensFri, 04 Feb 2011 06:20:26 +0100https://ask.sagemath.org/question/7919/