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 6908443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:33:50+00:00 2026-05-27T08:33:50+00:00

Experts; Given f = (#1^#2) & Is there a way to define ‘f’ above

  • 0

Experts;

Given

f = (#1^#2) &

Is there a way to define ‘f’ above such that if #1 and #2 are both zero, then the value of the pure function ‘f’ should be 1 ?

so that when I write

f[0,0]

it will return 1 and not Indeterminate?

btw, I know I can write

f = (If[#1 == 0 && #2 == 0, 1, #1^#2]) &

But I wanted a general rule or pattern, so I do not have to write these checks, as the pure function can be more complicated (many # in it ) and I do not want to do many of these ‘if then else’ checks for each possible 0^0 that might show up.

thanks

Update:

May be I should clarify more why I am doing this.
I have a user selects a function from a menu. The function is

a x^n0 + b y^n1 + c x^n2 y^n3

Where in the above, the parameters ‘n0’, ‘n1’, ‘n2’ and ‘n3’ also can be selected from sliders, and these can be zero.

Now, ‘x’ and ‘y’ are coordinates, and these can be zero also.

Therefore, it is possible that 0^0 can be encountered when evaluating the above function.

There are many cases to check for, when doing it myself. For example ‘y^n3’ can be 0^0 and not the other, y^n1 can be 0^0 and not the other, x^n2 y^n3 can be both 0^0 and not the others, etc.., and so I have to define many different cases. (16 possible cases I think).

And I am trying to avoid this. If I can tell Mathematica to replace 0^0 by 1 at a lower level, then life will be simpler.

Update 12/7/11
Thanks for everyone’s answers and comments, all are very useful and solve my problem and I learned from them.

I selected Leonid answer as it allowed me to solve my problem with least amount of additional coding.

Here is an small example

Manipulate[Row[{format[x, n], "=", eval[x, n]}],
 {{x, 0.0, "x="}, 0, 1, .1, Appearance -> "Labeled"},
 {{n, 0.0, "n="}, 0, 1, .1, Appearance -> "Labeled"},
 Initialization :>
  (
   format[x_, n_] := HoldForm["(" x ")"^n];
   eval = Unevaluated[#1^#2] /. HoldPattern[0.0^0.0] :> 0.0 &
   )
 ]

I use real numbers everywhere in my code (it is a numerical pde solver), so that is why I used 0.0 in the above and not 0^0 to fit with what I am doing.

enter image description here

  • 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-27T08:33:51+00:00Added an answer on May 27, 2026 at 8:33 am

    I agree with the answer of @Deep Yellow, but if you insist on a pure function, here is one way:

    f = Unevaluated[#1^#2] /. HoldPattern[0^0] :> 1 &
    

    EDIT

    Staying within the realm of pure functions, the situation you described in your edit can be addressed in the same way as my solution to your specific original example. You can automate this with a tiny bit of metaprogramming, defining the following function transformer:

    z2zProtect[Function[body_]] := 
       Function[Unevaluated[body] /. HoldPattern[0^0] :> 1]
    

    Then, my previous code can be rewritten as:

     f = z2zProtect[#1^#2 &]
    

    But you can is this more generally, for example:

    ff = z2zProtect[#1^#2 + 2 #2^#3 + 3 #3^#4 &]
    
    In[26]:= ff[0,0,0,0]
    Out[26]= 6
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Silverlight experts out there, I need some help. I used Deep Zoom Composer to
I'm very keen to learn Iphone apps development. Can you experts give me some
Possible Duplicate: mysql_fetch_array() expects parameter 1 to be resource, boolean given in select This
Here is my error: Warning: mysql_query() expects parameter 2 to be resource, null given...
experts,i wonder the intel x86 machineCode/assemblyCode conversion is singleSide or bothSide? means: assemblyCode --->
Experts - I need some advice in the following scenario. I have a configuration
Hi experts I want to know in which scenario I have more Performance(Time to
PHP experts, I've been working on this problem for about a day and a
java experts can you please help me write detached queries as a part of
Dear experts, I am quite new to javascript and I often see coders use

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.