How Can I Fix My DSolve Output to Work as a Function?

  • Context: Mathematica 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Function Output
Click For Summary
SUMMARY

The discussion centers on resolving an issue with the DSolve function in Mathematica, specifically in defining a solution as a proper function. The user initially defined the solution, uEven, incorrectly as a symbol rather than a function, which hindered differentiation and integration. The correct syntax for defining uEven is provided: uEven[x_, b_, l_, \[Alpha]_, L_] := ..., ensuring it can adapt to varying input constants. This adjustment allows for proper mathematical operations on the output of the ordinary differential equation (ODE).

PREREQUISITES
  • Understanding of ordinary differential equations (ODEs)
  • Familiarity with Mathematica syntax and functions
  • Knowledge of function definitions in Mathematica
  • Basic concepts of mathematical differentiation and integration
NEXT STEPS
  • Learn proper function definitions in Mathematica
  • Explore advanced features of DSolve in Mathematica
  • Study the application of boundary conditions in ODEs
  • Investigate the use of symbolic computation for mathematical modeling
USEFUL FOR

Mathematica users, mathematicians, and engineers working with ordinary differential equations and seeking to automate differentiation and integration processes in their models.

member 428835
Hi PF!

The following is a simple ODE I'm solving via DSolve. However, the solution, which I call uEven, does not work as a typical function. Note the last two lines are different. Does anyone know how to fix this, so that I can differentiate and integrate the output of this ODE without copy-pasting?

Ideally I'd like the solution to adapt to different input constants shown at the top. Any help much appreciated!

Code:
L = 0.005;  (* HALF CHANNEL LENGTH  (m)       *)
\[Sigma] = 0.07;    (* \
SURFACE TENSION      (N / m)   *)
\[Rho] = 1000; (* LIQUID \
DENSITY       (kg / m^3) *)
g = 9.8;     (* GRAVITY ACCELERATION (m / \
s^2)  *)
\[Alpha] = 
 70 \[Pi]/180; (* STATIC CONTACT ANGLE (rad)     *)
l = \
Sqrt[\[Sigma]/(\[Rho] g)]; (* CAPILLARY LENGTH SCALE (m) *)
b = (\
\[Rho] g l^2)/\[Sigma]; (* BOND NUMBER *)
\[CapitalGamma][x_, 
  l_, \[Alpha]_, L_] := 
 l Cot[\[Alpha]] Exp[L ( x - 1)/l](* EQUILIBRIUM HEIGHT (m) *)

uEven[x, b, l, \[Alpha], L] = 
  y[x] /. First@
    DSolve[{-y''[
          x] + (b Cos[\[Alpha]] - \[CapitalGamma][x, l, \[Alpha], 
            L]^2) y[x] == 0, y'[0] == 0}, y, x];
uEven[x, b, l, \[Alpha], L]
uEven[y, b, l, \[Alpha], L]
 
Physics news on Phys.org
You are not defining uEven as a function, you are just defining it as a single symbol. You want to use the following syntax instead:

uEven[x_, b_, l_, \[Alpha]_, L_] := ...
 
  • Like
Likes   Reactions: member 428835
Dale said:
You are not defining uEven as a function, you are just defining it as a single symbol. You want to use the following syntax instead:

uEven[x_, b_, l_, \[Alpha]_, L_] := ...
Must've been real late, can't believe I missed this. Thanks!
 
  • Like
Likes   Reactions: Dale

Similar threads

  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 6 ·
Replies
6
Views
7K