I am to draw a 3D function, using PSTricks' \parametricplotThreeD. Coordinate Z in two parameters is so awkward, in terms of controlling boundary values and formulation that I decided to break it into the affordable functions.

For the mathematical function (as an example),

f(t, u) = (1-u)cos(t) + uSin(t/3),

I used some of the tex.stackexchange questions and defined my function as, e.g.,




\usepackage[nomessages]{fp}% http://ctan.org/pkg/fp


{\FPeval\result{(1-#2)(cos(#1)) + (#2)(sin((#1)/3))}\result}.

\parametricplotThreeD[algebraic, xPlotpoints=20,
linewidth=0.5pt,plotstyle=curve](0, 1)(0, 1){%


I get alot af errors.

I would like to know if defining a function in two variables is possible and how it can be utilised. If I moved, then, additionally I like to define another function, say,

g(t, u) = 2 + sqrt (f(g, u)),

and use it in place of Z.

Edit 1: My goal in this question is not drawing. I like to know if it is possible to define a custom mathematical function in two variables. We already know how to define a custom f(x). I like to define a custom f(x,y).

  • I assume your last expression should be g(t,u) = 2 + sqrt(f(t,u)). Do you have a graphic of what the function should look like? – Werner Jan 12 '16 at 20:10
  • Never use the minimal class, see Why should the minimal class be avoided? – egreg Jan 13 '16 at 21:58
  • @egreg: for PSTricks it makes offen sense to use the minimal class! – user2478 Jan 13 '16 at 22:01
  • @Herbert I don't think so. – egreg Jan 13 '16 at 22:02
  • My class, actually, is \documentclass[makeidx]{amsbook}. I meant to give a minimal example here. – Peter Jones Jan 14 '16 at 11:38

I do not see how g(t,u) = 2 + sqrt(f(t,u)) should work with 0..1. f(t,u) can be negative. However, no need for the parametric function:


\psset{viewpoint=30 -50 30 rtp2xyz,Decran=50,lightsrc=viewpoint}
\psSolid[object=grille,base=0 3 0 3,action=draw]
\psSurface[ngrid=.1 .1,incolor=yellow,axesboxed,Zmin=-2,Zmax=4,
    algebraic,hue=0 1](0,0)(3,3){(1-y)*cos(x)+y*sin(x/3)}


enter image description here

or with a defined function:

\psset{viewpoint=30 -50 30 rtp2xyz,Decran=50,lightsrc=viewpoint}
    \psSolid[object=grille,base=0 3 0 3,action=draw]
    \psSurface[ngrid=.1 .1,incolor=yellow,axesboxed,Zmin=-2,Zmax=4,
    algebraic,hue=0 1](0,0)(3,3){\myFunction(x,y)}
  • I am honoured getting answer directly from Herbert. Nevertheless my question is to put a function myFunction(x,y) defined at the top and then plugged into as (0,0)(3,3){myFunction(x,y)} instead of explicit expression (0,0)(3,3){(1-y)*cos(x)+y*sin(x/3)}. – Peter Jones Jan 14 '16 at 11:33
  • 1
    \def\myFunction(#1,#2){(1-#2)*cos(#1)+#2*sin(#1/3)} See edited answer – user2478 Jan 14 '16 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.