Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3623134
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:20:45+00:00 2026-05-18T23:20:45+00:00

Still early days with Mathematica so please forgive what is probably a very obvious

  • 0

Still early days with Mathematica so please forgive what is probably a very obvious question. I am trying to generate some parametric plots. I have:

ParametricPlot[{
    (a + b) Cos[t] - h Cos[(a + b)/b t],
    (a + b) Sin[t] - h Sin[(a + b)/b t]},
    {t, 0, 2 \[Pi]}, PlotRange -> All] /. {a -> 2, b -> 1, h -> 1}

No joy: the replacement rules are not applied and a, b and h remain undefined.

If I instead do:

Hold@ParametricPlot[{
    (a + b) Cos[t] - h Cos[(a + b)/b t],
    (a + b) Sin[t] - h Sin[(a + b)/b t]},
    {t, 0, 2 \[Pi]}, PlotRange -> All] /. {a -> 2, b -> 1, h -> 1}

it looks like the rules ARE working, as confirmed by the output:

Hold[ParametricPlot[{(2 + 1) Cos[t] - 
1 Cos[(2 + 1) t], (2 + 1) Sin[t] - 1 Sin[(2 + 1) t]}, {t, 0, 
2 \[Pi]}, PlotRange -> All]]

Which is what I’d expect. Take the Hold off, though, and the ParametricPlot doesn’t work. There’s nothing wrong with the equations or the ParametricPlot itself, though, because I tried setting values for a, b and h in a separate expression (a=2; b=1; h=1) and I get my pretty double cardoid out as expected.

So, what am I doing wrong with ReplaceAll and why are the transformation rules not working? This is another fundamentally important aspect of MMA that my OOP-ruined brain isn’t understanding.

I tried reading up on ReplaceAll and ParametricPlot and the closest clue I found was that “ParametricPlot has attribute HoldAll and evaluates f only after assigning specific numerical values to variables” which didn’t help much or I wouldn’t be here.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T23:20:46+00:00Added an answer on May 18, 2026 at 11:20 pm

    Mathematica evaluates each head without holding attributes by first evaluating head of each subexpression. Since ReplaceAll doesn’t have holding attributes, ParametricPlot becomes Graphics before replacement

    To see the expression tree, do

    ParametricPlot[{(a + b) Cos[t] - h Cos[(a + b)/b t], (a + b) Sin[t] - 
          h Sin[(a + b)/b t]}, {t, 0, 2 \[Pi]}, 
        PlotRange -> All] /. {a -> 2, b -> 1, h -> 1} // Hold // TreeForm
    

    From that tree you can see that your command is the same as doing

    temp1=ParametricPlot[{(a + b) Cos[t] - h Cos[(a + b)/b t], (a + b) Sin[t] - 
              h Sin[(a + b)/b t]}, {t, 0, 2 \[Pi]}, 
            PlotRange -> All]
    temp2={a -> 2, b -> 1, h -> 1} 
    temp1/.temp2
    

    Look at FullForm[temp1] to confirm that there’s no a or b in that expression.

    If you set ReplaceAll to HoldFirst, that prevents ParametricPlot from being evaluated before ReplaceAll, and result is what you expected. In this case, ReplaceAll evaluates to expression with head ParametricPlot, and only at that point ParametricPlot is evaluated. Make sure to reset the attributes back because changing behavior of built-in commands can have unexpected side-effects.

    SetAttributes[ReplaceAll, HoldFirst]; 
    ParametricPlot[{(a + b) Cos[t] - h Cos[(a + b)/b t], (a + b) Sin[t] - 
        h Sin[(a + b)/b t]}, {t, 0, 2 \[Pi]}, 
      PlotRange -> All] /. {a -> 2, b -> 1, h -> 1}
    ClearAttributes[ReplaceAll, HoldFirst]
    

    A useful trick when needing to evaluate arguments passed to function with HoldAll is to do operations on an expression with List head, and substitute ParametricPlot in the end, for instance

    ParametricPlot @@ ({{(a + b) Cos[t] - 
          h Cos[(a + b)/b t], (a + b) Sin[t] - h Sin[(a + b)/b t]}, {t, 0,
          2 \[Pi]}, PlotRange -> All} /. {a -> 2, b -> 1, h -> 1})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

still a bit of a n00b on SharpSVN, I'm looking to get some simple
Still having issues with this problem. Please help if you can. So I am
Still an iphone dev starter but trying. I would like to have the user
Still in the early stages of learning Java and I saw the following in
I now its still early but I also know you guys are on top
In the early days of .NET, I believe there was an attribute you could
In the early days of C++ when it was bolted on top of C,
In my early coding days, I would tend to group classes that functioned in
I'm still early on in learning XML schema, so hopefully this isn't too easy
I'm new to SSIS, my project is still in the early stages, with only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.