Looks at above two equation,I multiply 0.5 to each element of second equation,which means when plotting, each point x,y will become 2x,2y.I use this method to enlarge plotting object .
enter image description hereenter image description here
But as to complex equation like y^4+2y^2*x-3xy+7x^3==176.984 or r==Sqrt[Sin[2 θ]],I want to ask how to use mathematica built in function to make it easy?

  • $\begingroup$ Take a look at Scale $\endgroup$
    – Kuba
    Mar 8, 2018 at 12:24
  • $\begingroup$ @Kuba,I want to make data changed,not the scale. $\endgroup$
    – kittygirl
    Mar 8, 2018 at 12:55
  • $\begingroup$ Scale does not change the scale; it scales the data, although it scales the output, not the input, data. The change you are looking for is called scaling, but you seem to want to transform the input, not the output. $\endgroup$
    – Michael E2
    Mar 8, 2018 at 13:20
  • 1
    $\begingroup$ Can you please include your expected output for scaling r==Sqrt[Sin[2 θ]]? $\endgroup$
    – jjc385
    Mar 8, 2018 at 14:37
  • 1
    $\begingroup$ I am getting the sense that you are not immediately realizing that you can use the stuff in the answers to some of your previous problems to solve this particular problem. For instance, you've been told that parametric equations can be easily scaled by multiplying the components by the scale factor. Since polar coordinates easily convert to parametric equations, this also implies that multiplying a polar equation by the scale factor will also do the scaling you want. $\endgroup$ Mar 8, 2018 at 18:09

4 Answers 4


Given an equation $F(x,y)=0$ and a transformation $t(x,y)$ that, say, scales points by $2$, then to scale the graph of $F=0$, one applies the inverse transformation and plots $F(t^{-1}(x,y))=0$.

transformEQ[t_, vars_, eq_] :=
  Function[vars, eq] @@ InverseFunction[t]@vars;

equation = y^4 + 2 y^2*x - 3 x y + 7 x^3 == 176.984;
transformEQ[ScalingTransform[{2, 2}], {x, y}, equation]
(*  (7 x^3)/8 - (3 x y)/4 + (x y^2)/4 + y^4/16 == 176.984  *)

In polar coordinates, or in another coordinate system, one either converts the coordinates or the transformation $t$. Since transformations in cartesian coordinates are built into Mathematica, the first point of view seems convenient.

transformEQ[t_, vars_, eq_, "Polar"] :=
  Function[vars, eq] @@ Simplify[       (* simplifying is optional *)
    {First@vars > 0, -Pi < Last@vars < Pi}]; (* match the branch cuts of ArcTan[x, y] *)

polar = r == Sqrt[Sin[2 θ]];
transformEQ[ScalingTransform[{2, 2}], {r, θ}, polar, "Polar"]
(*  r/2 == Sqrt[Sin[2 θ]]  *)

Note: The assumption on the angle generally produces the correct formula, sometimes even when the condition is not met. If a transformed equation seems incorrect, then I would check this first.

This could be extended to other coordinate systems with CoordinateTransformData.


You can use ReplaceAll (/.) to replace each instance of x with .5 x and so on:

equation = y^4 + 2 y^2*x - 3 x y + 7 x^3 < 176.984;
scaled = equation /. {x -> 0.5 x, y -> 0.5 y}

0.875 x^3 - 0.75 x y + 0.25 x y^2 + 0.0625 y^4 == 176.984

RegionPlot[{equation, scaled}, {x, -10, 10}, {y, -10, 10}, 
 PlotLegends -> {"equation", "scaled"}]

enter image description here

Alternatively, if you have many variables and you don't want to write a rule for each one, you can use Alternatives (|) to match a set of symbols in one rule:

equation /. var : (x | y | z | r) :> 0.5 var
  • $\begingroup$ Probably the OP's xy was meant to be separate factors x y. $\endgroup$
    – Michael E2
    Mar 8, 2018 at 12:38
  • $\begingroup$ This method can be used in Cartesian coordinate system,but not Angular coordinates liker==Sqrt[Sin[2\[Theta]] $\endgroup$
    – kittygirl
    Mar 8, 2018 at 12:53
  • $\begingroup$ @kittygirl I highly suggest you edit the question to explicitly state that you're interested in such cases. I entirely ignored that subtlety. (Actually, it would be very useful if you'd give your expected output from scaling the equation r==Sqrt[Sin[2 θ]].) $\endgroup$
    – jjc385
    Mar 8, 2018 at 13:07
  • 1
    $\begingroup$ @kittygirl there's not much sense in scaling angular coodrdinate. $\endgroup$ Mar 8, 2018 at 16:32
  • 1
    $\begingroup$ @kittygirl Regarding the ContourPlot issue, scaled is an inequality, whereas ContourPlot is expecting an expression to evaluate. You can instead do ContourPlot[Evaluate@First@scaled, ...]. $\endgroup$
    – jjc385
    Mar 8, 2018 at 17:05

Change your variables: ./{x->0.5x,y->0.5y}


Edit: I entirely ignored the subtlety of what should happen in polar coordinates. See OP's comment.

A version of what others have suggested that find the variables for you.

(There's a lot of machinery in this answer -- tbh, writing it was largely an exercise in using such machinery for me. As such, please do ask me about anything that's too much to absorb with a quick look at the docs.)


Options[scaleLHS] = {"variables" -> Automatic};

scaleLHS[a_ == b_, scaleFactor_, OptionsPattern[] ] :=
    Module[{vars = OptionValue@"variables"},
        vars = Switch[vars
            , Automatic, Variables@a
            , _Symbol, {vars}
            , _Function, vars[a]
            , _, vars
        (a /. Thread[vars -> scaleFactor*vars]) == b

(* thread over lists of equations *)
scaleLHS[eqList_List, args__] := scaleLHS[#, args] & /@ eqList

(* operator form, because these can be incredibly useful *)
scaleLHS[scaleFactor : (_Symbol | _?NumericQ), args___?(MatchQ[_Rule | {___Rule}])][eq_] := 
    scaleLHS[eq, scaleFactor, args]


The variables can often be discovered for you automatically. This works whenever Variables returns the right variables:

scaleLHS[c] @ {x^2/3 + y^2/9 == 1, y^4 + 2 y^2*x - 3 x y + 7 x^3 == 176.984}
{(c^2 x^2)/3 + (c^2 y^2)/9 == 1, 7 c^3 x^3 - 3 c^2 x y + 2 c^3 x y^2 + c^4 y^4 == 176.984}

Variables treats the entire trig function as a variable, so you need to manually specify θ :

scaleLHS[Sqrt[Sin[2 θ]] == r, c, "vars" -> θ]
Sqrt[Sin[2 c θ]] == r

Possible improvements

  • Define an analagous function scaleRHS
    • Until then, just do Reverse@scaleLHS[Reverse@equation, scaleFactor]
  • Allow different variables to be scaled differently
  • Deal with e.g. polar coordinates in the way OP would like
    • Probably looks like adding an additional option (e.g., "coordinates" -> "Polar"), and some extra work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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